19 package org.turro.financials.content;
21 import java.io.Writer;
22 import java.util.ArrayList;
23 import java.util.Arrays;
24 import java.util.Collection;
25 import org.turro.string.Strings;
26 import org.turro.attach.www.AttachCtrl;
27 import org.turro.elephant.context.ElephantContext;
28 import org.turro.elephant.context.IConstructor;
29 import org.turro.elephant.db.WhereClause;
30 import org.turro.elephant.impl.repository.Repository;
31 import org.turro.elephant.impl.repository.RepositoryFile;
32 import org.turro.elephant.web.SocialImageMap;
33 import org.turro.elephant.web.SocialNet;
34 import org.turro.entities.Entities;
35 import org.turro.file.util.FileAttach;
36 import org.turro.financials.command.ContractPortfolio;
37 import org.turro.financials.db.FinancialsPU;
38 import org.turro.financials.entity.Contract;
39 import org.turro.financials.entity.ContractInterventionType;
40 import org.turro.jpa.content.EntityDaoContentIterator;
41 import org.turro.jpa.search.DaoHtmlSearch;
42 import org.turro.jpa.search.DaoSearchKey;
43 import org.turro.marker.ElephantMarker;
44 import org.turro.plugin.contacts.IContact;
45 import org.turro.www.commentit.CommentItCtrl;
46 import org.turro.www.describeit.DescribeItCtrl;
54 private boolean publicOnly, checkParticipation;
55 private int type, status;
59 this.checkParticipation =
true;
71 return checkParticipation;
75 this.checkParticipation = checkParticipation;
90 public Collection<Contract>
items() {
97 wc.
addClause(
"select distinct ctc from Contract ctc");
98 if(checkParticipation) {
99 wc.
addClause(
"left join ctc.participants par");
109 wc.
addClause(
"select count(distinct ctc) from Contract ctc");
110 if(checkParticipation) {
111 wc.
addClause(
"left join ctc.participants par");
121 prepareValues(e, page);
129 prepareValues(e, page);
161 }
else if(status == 2) {
164 if(checkParticipation) {
166 wc.
addClause(
"and (ctc.contractor = :contractor");
168 for(ContractInterventionType cit : ContractInterventionType.values()) {
169 if(cit.isShowDocuments()) {
170 wc.
addClause(
"or (par.interventionType = :cit" + cit.toString());
172 wc.
addClause(
"and par.idContact = :con" + cit.toString() +
")");
179 wc.
addClause(
"and ctc.contractDefinition.id = :ctcdef");
184 private void prepareValues(Contract contract,
int page) {
188 (contract.isActive() ?
" active" :
"") +
189 (contract.isStock() ?
" store" :
""));
190 marker.
put(
"portfolio",
new ContractPortfolio(contract));
200 ArrayList<RepositoryFile> files =
new ArrayList<>();
214 return isMail() ?
"content/newsletter/sections/contracts" :
"contract";
219 throw new UnsupportedOperationException(
"Not supported yet.");
224 throw new UnsupportedOperationException(
"Not supported yet.");
253 throw new UnsupportedOperationException(
"Not supported yet.");
264 if(Strings.isBlank(path)) {
272 return "/user/contracts";
static String getContextVariable(IConstructor constructor)
void addClause(String clause)
void addNamedValue(String name, Object value)
Set< RepositoryFile > getRepositoryFiles(String pattern)
static boolean hasImage(String url)
List< String > getMetas()
static IElephantEntity getController(String path)
Repository getPublishableRepository(IConstructor constructor)
Collection< Contract > items()
ContractContentIterator(IConstructor constructor, Writer writer, IContact contact, boolean mail, String pubPath)
String getRestrictedLink()
Object doVotesCtrl(Contract e)
Object getPortfolioCtrl(Contract e)
void renderItem(ElephantMarker marker, Contract e, int page)
boolean isValid(Contract e)
Contract entity(Long value)
void renderSummary(ElephantMarker marker, Contract e, int page)
Object doAttachmentsCtrl(Contract e)
void setCheckParticipation(boolean checkParticipation)
void setStatus(int status)
Object doFilesCtrl(Contract e)
WhereClause getCountClause()
WhereClause getWhereClause()
boolean isCheckParticipation()
Object doCommentsCtrl(Contract e)
Object doInterestCtrl(Contract e)
Object doDescriptionsCtrl(Contract e)
String getItemLink(Contract e)
Collection< String > metas(Contract e)
Object doPollsCtrl(Contract e)
static String getObjectPath(Object object)
Collection< IContact > getIParticipants()
String getFullDescription()
void prepareControls(E entity, int page)
String doItemLink(E entity, ID id, boolean obfuscated)
String getSummaryTemplate()
List< E > getTotalItems()
static DaoHtmlSearch getInstance(IConstructor constructor, String context)
boolean applyToQuery(WhereClause wc, List< String > fields, boolean withSynonyms)
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)
Object configureCtrl(Object ctrl, IContact contact)