BrightSide Workbench Full Report + Source Code
PortfolioOptions.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 java.util.Date;
22 import org.turro.financials.contract.logic.ContractWrapper;
23 import org.turro.financials.document.logic.DocumentDefinitionWrapper;
24 import org.turro.financials.entity.Contract;
25 import org.turro.financials.entity.DocumentDefinition;
26 import org.turro.financials.model.contract.ContractSortedSet;
27 import org.turro.i18n.I_;
28 import org.turro.zul.frame.Framework;
29 
34 public class PortfolioOptions {
35 
36  private boolean accumulated = false, autosave = false,
37  stopOnContract = true, conciliateRegister = false;
38  private int storeMode = 0;
39  private Contract store;
40  private int dateMode = 0;
41  private Date date;
42  private DocumentDefinition documentDefinition;
43  private Contract contract;
44 
45  public PortfolioOptions(DocumentDefinition documentDefinition, Contract contract) {
46  this.documentDefinition = documentDefinition;
47  this.contract = contract;
48  date = (Date) Framework.getAttribute(this, "date");
49  dateMode = (Integer) Framework.getAttribute(this, "dateMode", Integer.valueOf(0));
50  store = (Contract) Framework.getAttribute(this, "store");
51  storeMode = (Integer) Framework.getAttribute(this, "storeMode", Integer.valueOf(0));
52  accumulated = (Boolean) Framework.getAttribute(this, "accumulated", Boolean.FALSE);
53  autosave = (Boolean) Framework.getAttribute(this, "autosave", Boolean.FALSE);
54  stopOnContract = (Boolean) Framework.getAttribute(this, "stopOnContract", Boolean.TRUE);
55  conciliateRegister = (Boolean) Framework.getAttribute(this, "conciliateRegister", Boolean.FALSE);
56  }
57 
58  public boolean isAccumulated() {
59  return accumulated;
60  }
61 
62  public void setAccumulated(boolean accumulated) {
63  this.accumulated = accumulated;
64  Framework.setAttribute(this, "accumulated", accumulated);
65  }
66 
67  public String getAccumulatedString() {
68  return I_.format("Accumulate in a single %s", documentDefinition.getName());
69  }
70 
71  public boolean isAutosave() {
72  return autosave;
73  }
74 
75  public void setAutosave(boolean autosave) {
76  this.autosave = autosave;
77  Framework.setAttribute(this, "autosave", autosave);
78  }
79 
80  public String getContractString() {
81  return contract.getFullDescription();
82  }
83 
84  public Date getDate() {
85  return date;
86  }
87 
88  public void setDate(Date date) {
89  this.date = date;
90  Framework.setAttribute(this, "date", date);
91  }
92 
93  public int getDateMode() {
94  return dateMode;
95  }
96 
97  public void setDateMode(int dateMode) {
98  this.dateMode = dateMode;
99  Framework.setAttribute(this, "dateMode", dateMode);
100  }
101 
102  public boolean isStopOnContract() {
103  return stopOnContract;
104  }
105 
106  public void setStopOnContract(boolean stopOnContract) {
107  this.stopOnContract = stopOnContract;
108  Framework.setAttribute(this, "stopOnContract", stopOnContract);
109  }
110 
111  public Contract getStore() {
112  return store;
113  }
114 
115  public void setStore(Contract store) {
116  this.store = store;
117  Framework.setAttribute(this, "store", store);
118  }
119 
120  public int getStoreMode() {
121  return storeMode;
122  }
123 
124  public void setStoreMode(int storeMode) {
125  this.storeMode = storeMode;
126  Framework.setAttribute(this, "storeMode", storeMode);
127  }
128 
129  public boolean isConciliateRegister() {
130  return conciliateRegister;
131  }
132 
133  public void setConciliateRegister(boolean conciliateRegister) {
134  this.conciliateRegister = conciliateRegister;
135  Framework.setAttribute(this, "conciliateRegister", conciliateRegister);
136  }
137 
138  public Collection getStores() {
139  Collection<Contract> stores;
140  stores = new DocumentDefinitionWrapper(documentDefinition)
141  .getRelatedStores(contract);
142  if(stores.isEmpty()) {
143  stores = new DocumentDefinitionWrapper(documentDefinition)
144  .getRelatedStores();
145  }
147  return new ContractSortedSet(stores, false);
148  }
149 
150 }
PortfolioOptions(DocumentDefinition documentDefinition, Contract contract)
void setConciliateRegister(boolean conciliateRegister)
static String format(String msg, Object... arguments)
Definition: I_.java:49
static Object getAttribute(Object object, String key)
Definition: Framework.java:207
static void setAttribute(Object object, String key, Object value)
Definition: Framework.java:216