18 package org.turro.financials.contract;
20 import java.util.Collection;
21 import java.util.List;
22 import org.turro.contacts.Contact;
23 import org.turro.elephant.db.WhereClause;
24 import org.turro.financials.db.FinancialsPU;
25 import org.turro.financials.entity.Contract;
26 import org.turro.financials.entity.ContractDefinition;
27 import org.turro.financials.model.contract.ContractWrapper;
28 import org.turro.jpa.Dao;
29 import org.turro.plugin.filter.IFilterValue;
30 import org.turro.zkoss.grid.GroupExtended;
31 import org.zkoss.zul.Grid;
32 import org.zkoss.zul.Group;
40 private String mainOrderField, mode =
"all", searchText =
"";
44 private long lastId = 0;
45 private String lastContact =
null;
55 this.contact = contact;
59 return contractDefinition;
63 this.contractDefinition = contractDefinition;
79 this.searchText = searchText;
82 public Collection<Contract>
getContracts(List<IFilterValue> values) {
87 Collection<Contract> list = dao.getResultList(wc);
88 if(
"active".equals(mode)) {
90 }
else if(
"inactive".equals(mode)) {
97 if(
"ctc.contractDefinition.id".equals(mainOrderField)) {
102 grid.getRows().appendChild(group);
104 }
else if(
"ctc.contractor".equals(mainOrderField)) {
105 if(lastContact ==
null || !lastContact.equals(contract.
getContractor())) {
109 grid.getRows().appendChild(group);
114 private WhereClause createCriteria(List<IFilterValue> values) {
115 mainOrderField =
"ctc.contractDefinition.id";
117 wc.
addClause(
"select ctc from Contract as ctc");
120 if(v.hasValue() &&
"Contract model".equals(v.getLabel())) {
121 mainOrderField =
"ctc.contractor";
122 }
else if(v.hasValue() &&
"Contact".equals(v.getLabel())) {
123 mainOrderField =
"ctc.contractDefinition.id";
127 wc.
addClause(
"order by " + mainOrderField +
", ctc.id");
void addClause(String clause)
void setContractDefinition(ContractDefinition contractDefinition)
void setContact(Contact contact)
Collection< Contract > getContracts(List< IFilterValue > values)
void setSearchText(String searchText)
void checkGroup(Grid grid, Contract contract, boolean open)
void setMode(String mode)
ContractDefinition getContractDefinition()
ContractDefinition getContractDefinition()
IContact getIContractor()
static void clearActives(Collection< Contract > contracts)
static void clearInactives(Collection< Contract > contracts)