BrightSide Workbench Full Report + Source Code
PortfolioItem.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 java.util.Collection;
21 import org.turro.financials.entity.Document;
22 import org.turro.financials.entity.DocumentWorkflow;
23 import org.turro.util.CompareUtil;
24 
29 public class PortfolioItem implements Comparable<PortfolioItem> {
30 
31  private Document document;
32  private WorkflowSet forward, backward;
33 
34  public PortfolioItem(Document document) {
35  this.document = document;
36  forward = new WorkflowSet();
37  backward = new WorkflowSet();
38  }
39 
40  public void addForward(DocumentWorkflow dw) {
41  forward.add(new WorkflowItem(dw));
42  }
43 
44  public void addBackward(DocumentWorkflow dw) {
45  backward.add(new WorkflowItem(dw));
46  }
47 
48  public Collection<WorkflowItem> getBackward() {
49  return backward;
50  }
51 
52  public Document getDocument() {
53  return document;
54  }
55 
56  public void setDocument(Document document) {
57  this.document = document;
58  }
59 
60  public Collection<WorkflowItem> getForward() {
61  return forward;
62  }
63 
64  @Override
65  public int compareTo(PortfolioItem o) {
66  int result = CompareUtil.compare(document.getContract().getId(), o.document.getContract().getId());
67  if(result == 0) {
68  result = CompareUtil.compare(document.getDocumentDefinition().getId(), o.document.getDocumentDefinition().getId());
69  }
70  if(result == 0) {
71  result = document.getDocumentDate().compareTo(o.document.getDocumentDate());
72  }
73  if(result == 0) {
74  result = CompareUtil.compare(document.getId(), o.document.getId());
75  }
76  return result;
77  }
78 
79 }
DocumentDefinition getDocumentDefinition()
Definition: Document.java:167
Collection< WorkflowItem > getBackward()
Collection< WorkflowItem > getForward()