BrightSide Workbench Full Report + Source Code
PortfolioAction.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.financials.portfolio;
19 
20 import org.turro.financials.entity.Document;
21 import org.turro.financials.entity.DocumentDefinition;
22 import org.turro.financials.entity.DocumentWorkflow;
23 import org.turro.util.CompareUtil;
24 import org.zkoss.zul.Row;
25 
30 public class PortfolioAction implements Comparable<PortfolioAction> {
31 
32  private Document document;
33  private DocumentWorkflow workflow;
34  private boolean forward;
35  private Row row;
36 
37  public PortfolioAction(Document document, DocumentWorkflow workflow, boolean forward, Row row) {
38  this.document = document;
39  this.workflow = workflow;
40  this.forward = forward;
41  this.row = row;
42  }
43 
44  public Document getDocument() {
45  return document;
46  }
47 
48  public boolean isForward() {
49  return forward;
50  }
51 
52  public Row getRow() {
53  return row;
54  }
55 
57  return workflow;
58  }
59 
61  if(forward) {
62  return workflow.getDescendant();
63  } else {
64  return workflow.getAncestor();
65  }
66  }
67 
68  @Override
69  public int compareTo(PortfolioAction o) {
70  int result = CompareUtil.compare(document.getContract().getId(), o.document.getContract().getId());
71  if(result == 0) {
72  result = CompareUtil.compare(forward, o.forward);
73  }
74  if(result == 0) {
75  if(forward) {
76  result = CompareUtil.compare(workflow.getDescendant().getId(), o.workflow.getDescendant().getId());
77  } else {
78  result = CompareUtil.compare(workflow.getAncestor().getId(), o.workflow.getAncestor().getId());
79  }
80  }
81  if(result == 0) {
82  result = CompareUtil.compare(document.getDocumentDefinition().getId(), o.document.getDocumentDefinition().getId());
83  }
84  if(result == 0) {
85  result = document.getDocumentDate().compareTo(o.document.getDocumentDate());
86  }
87  if(result == 0) {
88  result = CompareUtil.compare(document.getId(), o.document.getId());
89  }
90  return result;
91  }
92 
93 }
DocumentDefinition getDocumentDefinition()
Definition: Document.java:167
PortfolioAction(Document document, DocumentWorkflow workflow, boolean forward, Row row)