19 package org.turro.dossier.content;
21 import java.io.Writer;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.List;
25 import org.turro.string.Strings;
26 import org.turro.attach.www.AttachCtrl;
27 import org.turro.dossier.db.DossierPU;
28 import org.turro.dossier.entity.Category;
29 import org.turro.dossier.entity.Dossier;
30 import org.turro.dossier.entity.DossierStatus;
31 import org.turro.dossier.entity.Issue;
32 import org.turro.dossier.entity.IssueResolution;
33 import org.turro.dossier.entity.IssueStatus;
34 import org.turro.dossier.entity.IssueType;
35 import org.turro.dossier.issue.IssueWrapper;
36 import org.turro.dossier.www.IssueOrdering;
37 import org.turro.elephant.context.IConstructor;
38 import org.turro.elephant.db.WhereClause;
39 import org.turro.elephant.impl.repository.Repository;
40 import org.turro.elephant.impl.repository.RepositoryFile;
41 import org.turro.elephant.web.SocialImageMap;
42 import org.turro.elephant.web.SocialNet;
43 import org.turro.entities.Entities;
44 import org.turro.file.util.FileAttach;
45 import org.turro.jpa.content.EntityDaoContentIterator;
46 import org.turro.marker.ElephantMarker;
47 import org.turro.plugin.contacts.IContact;
48 import org.turro.www.commentit.CommentItCtrl;
49 import org.turro.www.describeit.DescribeItCtrl;
50 import org.turro.www.starit.StarItCtrl;
51 import org.turro.www.voteit.VoteItCtrl;
59 private long categoryId, dossierId, lastDosierId = -1, lastCategoryId = -1;
60 private List<String> issueTypes, issueStatus, dossierStatus;
61 private boolean showSubject, all;
70 this.categoryId = categoryId;
74 this.dossierId = dossierId;
78 this.dossierStatus = dossierStatus;
82 this.issueTypes = issueTypes;
86 this.issueStatus = issueStatus;
94 this.showSubject = showSubject;
102 this.orderBy = orderBy;
108 wc.
addClause(
"select distinct i from Issue as i");
109 wc.
addClause(
"join i.participants as p");
118 wc.
addClause(
"select count(distinct i) from Issue as i");
119 wc.
addClause(
"join i.participants as p");
132 prepareValues(e, page);
141 prepareValues(e, page);
154 wc.
addClause(
"select distinct i from Issue as i");
155 wc.
addClause(
"join i.participants as p");
163 wc.
addClause(
"where i.publishable = TRUE");
165 wc.
addClause(
"and i.dossier.category.id in (" + getCategories(categoryId) +
")");
166 }
else if(dossierId > 0) {
167 wc.
addClause(
"and i.dossier.id = " + dossierId);
169 if(dossierStatus !=
null && dossierStatus.size() > 0) {
172 for(String s : dossierStatus) {
173 DossierStatus ds = DossierStatus.valueOf(s);
176 wc.
addClause(sep +
"i.dossier.status = :" + par);
183 if(issueStatus !=
null && issueStatus.size() > 0) {
186 for(String s : issueStatus) {
187 IssueStatus is = IssueStatus.valueOf(s);
190 wc.
addClause(sep +
"i.status = :" + par);
197 if(issueTypes !=
null && issueTypes.size() > 0) {
200 for(String s : issueTypes) {
201 IssueType it = IssueType.valueOf(s);
218 return super.isValid(e);
222 private String getCategories(
long categoryId) {
223 String result =
null;
225 return addCategory(category, result);
228 private String addCategory(Category category, String result) {
229 if(category !=
null) {
230 result = (String) (((result ==
null) ?
"" : result +
",") + category.getId());
231 for(Category c : category.getChildren()) {
232 result = addCategory(c, result);
238 private void prepareValues(Issue issue,
int page) {
241 marker.
put(
"issueClass", getIssueClass(issue));
242 Dossier dossier = issue.getDossier();
244 (dossier.getStatus().equals(DossierStatus.DOSSIER_OPENED) ?
" openned" :
"") +
245 (dossier.getStatus().equals(DossierStatus.DOSSIER_CLOSED) ?
" closed" :
"") +
246 (dossier.getStatus().equals(DossierStatus.DOSSIER_FROZEN) ?
" frozen" :
""));
250 private String getIssueClass(Issue issue) {
252 (issue.getStatus().equals(IssueStatus.STATUS_NEW) ?
" new" :
"") +
253 (issue.getStatus().equals(IssueStatus.STATUS_STARTED) ?
" started" :
"") +
254 (issue.getStatus().equals(IssueStatus.STATUS_INCOMPLETE) ?
" incomplete" :
"") +
255 (issue.getStatus().equals(IssueStatus.STATUS_REOPENED) ?
" reopened" :
"") +
256 (issue.getStatus().equals(IssueStatus.STATUS_REUNION) ?
" reunion" :
"") +
257 (issue.getStatus().equals(IssueStatus.STATUS_FROZEN) ?
" frozen" :
"") +
258 (issue.getStatus().equals(IssueStatus.STATUS_RESOLVED) ?
" resolved" :
"") +
259 (issue.getStatus().equals(IssueStatus.STATUS_VERIFIED) ?
" verified" :
"") +
260 (issue.getStatus().equals(IssueStatus.STATUS_CLOSED) ?
" closed" :
"") +
262 (issue.getType().equals(IssueType.TYPE_DEFECT) ?
" defect" :
"") +
263 (issue.getType().equals(IssueType.TYPE_ENHANCEMENT) ?
" enhancement" :
"") +
264 (issue.getType().equals(IssueType.TYPE_FEATURE) ?
" feature" :
"") +
265 (issue.getType().equals(IssueType.TYPE_NONCONFORMITY) ?
" nonconformity" :
"") +
266 (issue.getType().equals(IssueType.TYPE_PATCH) ?
" patch" :
"") +
267 (issue.getType().equals(IssueType.TYPE_PREVENTION) ?
" prevention" :
"") +
268 (issue.getType().equals(IssueType.TYPE_QUESTION) ?
" question" :
"") +
269 (issue.getType().equals(IssueType.TYPE_TASK) ?
" task" :
"") +
270 (issue.getType().equals(IssueType.TYPE_DOCUMENT) ?
" document" :
"") +
271 (issue.getType().equals(IssueType.TYPE_BESTPRACTICE) ?
" bestpractice" :
"") +
272 (issue.getType().equals(IssueType.TYPE_PROCESS) ?
" process" :
"") +
273 (issue.getType().equals(IssueType.TYPE_PROPOSITION) ?
" proposition" :
"") +
275 (issue.getResolution().equals(IssueResolution.RESOLUTION_DUPLICATED) ?
" duplicated" :
"") +
276 (issue.getResolution().equals(IssueResolution.RESOLUTION_FIXED) ?
" fixed" :
"") +
277 (issue.getResolution().equals(IssueResolution.RESOLUTION_INVALID) ?
" invalid" :
"") +
278 (issue.getResolution().equals(IssueResolution.RESOLUTION_MOVED) ?
" moved" :
"") +
279 (issue.getResolution().equals(IssueResolution.RESOLUTION_NONE) ?
" none" :
"") +
280 (issue.getResolution().equals(IssueResolution.RESOLUTION_WONTFIX) ?
" wontfix" :
"") +
281 (issue.getResolution().equals(IssueResolution.RESOLUTION_WORKSFORME) ?
" worksforme" :
"");
294 ArrayList<RepositoryFile> files =
new ArrayList<>();
308 return isMail() ?
"content/newsletter/sections/issues" :
"issue";
349 throw new UnsupportedOperationException(
"Not supported yet.");
360 if(Strings.isBlank(path)) {
368 return "/user/myissues";
void setShowSubject(boolean showSubject)
Object doFilesCtrl(Issue e)
void setDossierId(long dossierId)
Object doInterestCtrl(Issue e)
WhereClause getWhereClause()
Object doCommentsCtrl(Issue e)
void setIssueStatus(List< String > issueStatus)
void setIssueTypes(List< String > issueTypes)
void setDossierStatus(List< String > dossierStatus)
void renderItem(ElephantMarker marker, Issue e, int page)
Object doDescriptionsCtrl(Issue e)
void setOrderBy(IssueOrdering orderBy)
void setCategoryId(long categoryId)
Object doPollsCtrl(Issue e)
String getItemLink(Issue e)
Object doAttachmentsCtrl(Issue e)
IssueOrdering getOrderBy()
Collection< String > metas(Issue e)
String getRestrictedLink()
Object doVotesCtrl(Issue e)
IssueContentIterator(IConstructor constructor, Writer writer, IContact contact, boolean mail, String pubPath)
WhereClause getCountClause()
void renderSummary(ElephantMarker marker, Issue e, int page)
static String getObjectPath(Object object)
String getFullDescription()
boolean isFullParticipant()
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)
Object getSingleResultOrNull(SqlClause sc)
void prepareControls(E entity, int page)
String doItemLink(E entity, ID id, boolean obfuscated)
String getSummaryTemplate()
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)
boolean isInRole(String role)
ORDER_BY_CATEGORY_DOSSIER_ISSUE
Object configureCtrl(Object ctrl, IContact contact)