19 package org.turro.dossier.www;
21 import java.io.IOException;
22 import java.io.PrintWriter;
23 import javax.servlet.ServletException;
24 import org.turro.string.ObjectString;
25 import org.turro.string.Strings;
26 import org.turro.auth.Authentication;
27 import org.turro.collections.KeyValueMap;
28 import org.turro.dossier.db.DossierPU;
29 import org.turro.dossier.entity.Dossier;
30 import org.turro.dossier.entity.Issue;
31 import org.turro.dossier.entity.IssueResolution;
32 import org.turro.dossier.entity.IssueStatus;
33 import org.turro.dossier.entity.IssueType;
34 import org.turro.dossier.issue.IssueWrapper;
35 import org.turro.dossier.workload.WorkloadItem;
36 import org.turro.dossier.workload.WorkloadQuery;
37 import org.turro.dossier.workload.WorkloadSet;
38 import org.turro.dossier.zul.issue.IssueStage;
39 import org.turro.elephant.context.Application;
40 import org.turro.elephant.context.ElephantContext;
41 import org.turro.elephant.context.IElement;
42 import org.turro.elephant.impl.abstracts.AbstractElement;
43 import org.turro.elephant.layout.IManageable;
44 import org.turro.elephant.layout.IRenderable;
45 import org.turro.elephant.security.IDefendable;
46 import org.turro.entities.Entities;
47 import org.turro.file.util.FileAttach;
48 import org.turro.i18n.I_;
49 import org.turro.jpa.search.DaoHtmlSearch;
50 import org.turro.jpa.search.DaoSearchKey;
51 import org.turro.marker.ElephantMarker;
52 import org.turro.marker.MarkerHelper;
53 import org.turro.plugin.contacts.ContactList;
54 import org.turro.plugin.contacts.IContact;
55 import org.turro.www.describeit.DescribeItCtrl;
56 import org.turro.www.starit.StarItCtrl;
57 import org.turro.www.voteit.VoteItCtrl;
65 protected String
sclass, fullTemplate, summaryTemplate, dossierPath;
67 protected boolean allowInterest, allowComments, allowVotes, showDescriptions, showSubject, showAttachments, showFiles;
73 public void loadData() throws ServletException, IOException {
77 allowVotes =
getAttributes().getAttributeBooleanValue(
"attrib:allowVotes",
true);
78 showDescriptions =
getAttributes().getAttributeBooleanValue(
"attrib:showDescriptions",
true);
79 showFiles =
getAttributes().getAttributeBooleanValue(
"attrib:showFiles",
true);
80 showSubject =
getAttributes().getAttributeBooleanValue(
"attrib:showSubject",
true);
81 fullTemplate =
getAttributes().getAttributeValue(
"attrib:fullTemplate",
"");
82 summaryTemplate =
getAttributes().getAttributeValue(
"attrib:summaryTemplate",
"");
83 dossierPath =
getAttributes().getAttributeValue(
"attrib:dossierPath",
null);
86 if(kvm !=
null && !kvm.isEmpty() && kvm.containsKey(
"item")) {
87 item = kvm.get(Long.class,
"item");
112 if(!Strings.isBlank(dossierPath)) {
116 prepareValues(marker,
issue, 0);
120 marker.
put(
"stage",
I_.
byKey(stage.toString()));
121 marker.
put(
"wrapper", iw);
124 marker.
process(
"issue", getFullTemplate());
132 String searchValue =
null;
141 wq.
setSearchValue(Strings.isBlank(searchValue) ?
"*" : searchValue);
147 marker.
put(
"divider", index > 0);
148 marker.
put(
"header", index == 0);
149 marker.
put(
"footer", index == ws.size() - 1);
151 if(!(current.equals(stage))) {
153 marker.
put(
"newStage",
true);
155 marker.
put(
"newStage",
false);
157 prepareValues(marker, iw.
getIssue(), 0);
158 marker.
put(
"stage",
I_.
byKey(current.toString()));
159 marker.
put(
"wrapper", iw);
161 marker.
process(
"issue", getSummaryTemplate());
200 out.write(
"<h3>" +
I_.
get(
"Empty list") +
"</h3>");
210 return "<div class='" +
sclass +
"dossier-web'>";
223 String link = getItemLink(
issue, page);
225 marker.
put(
"path", link);
226 marker.
put(
"all", getPageLink(page));
228 marker.
put(
"readall", getItemLink(
issue, page));
229 marker.
put(
"issueClass", getIssueClass(
issue));
233 if(dossier.getType().isVotes()) {
235 vic.setEntityPath(DossierPU.getObjectPath(
issue));
237 if(dossier.getType().isSecret()) {
239 vic.setAllowed((ContactList) dossier.getFullParticipants().getVoteIParticipants());
241 marker.
put(
"vic", vic);
246 sic.setEntityPath(DossierPU.getObjectPath(
issue));
247 marker.
put(
"sic", sic);
249 if(showDescriptions) {
251 dic.setEntityPath(DossierPU.getObjectPath(
issue));
252 marker.
put(
"dic", dic);
256 marker.
put(
"files",
new FileAttach(DossierPU.getObjectPath(
issue)));
260 private String getItemLink(Issue
issue,
int page) {
264 private String getPageLink(
int page) {
268 private String getIssueClass(Issue
issue) {
270 (
issue.
getStatus().equals(IssueStatus.STATUS_NEW) ?
" new" :
"") +
271 (
issue.
getStatus().equals(IssueStatus.STATUS_STARTED) ?
" started" :
"") +
272 (
issue.
getStatus().equals(IssueStatus.STATUS_INCOMPLETE) ?
" incomplete" :
"") +
273 (
issue.
getStatus().equals(IssueStatus.STATUS_REOPENED) ?
" reopened" :
"") +
274 (
issue.
getStatus().equals(IssueStatus.STATUS_REUNION) ?
" reunion" :
"") +
275 (
issue.
getStatus().equals(IssueStatus.STATUS_FROZEN) ?
" frozen" :
"") +
276 (
issue.
getStatus().equals(IssueStatus.STATUS_RESOLVED) ?
" resolved" :
"") +
277 (
issue.
getStatus().equals(IssueStatus.STATUS_VERIFIED) ?
" verified" :
"") +
278 (
issue.
getStatus().equals(IssueStatus.STATUS_CLOSED) ?
" closed" :
"") +
280 (
issue.
getType().equals(IssueType.TYPE_DEFECT) ?
" defect" :
"") +
281 (
issue.
getType().equals(IssueType.TYPE_ENHANCEMENT) ?
" enhancement" :
"") +
282 (
issue.
getType().equals(IssueType.TYPE_FEATURE) ?
" feature" :
"") +
283 (
issue.
getType().equals(IssueType.TYPE_NONCONFORMITY) ?
" nonconformity" :
"") +
284 (
issue.
getType().equals(IssueType.TYPE_PATCH) ?
" patch" :
"") +
285 (
issue.
getType().equals(IssueType.TYPE_PREVENTION) ?
" prevention" :
"") +
286 (
issue.
getType().equals(IssueType.TYPE_QUESTION) ?
" question" :
"") +
287 (
issue.
getType().equals(IssueType.TYPE_TASK) ?
" task" :
"") +
288 (
issue.
getType().equals(IssueType.TYPE_DOCUMENT) ?
" document" :
"") +
289 (
issue.
getType().equals(IssueType.TYPE_BESTPRACTICE) ?
" bestpractice" :
"") +
290 (
issue.
getType().equals(IssueType.TYPE_PROCESS) ?
" process" :
"") +
291 (
issue.
getType().equals(IssueType.TYPE_PROPOSITION) ?
" proposition" :
"") +
293 (
issue.
getResolution().equals(IssueResolution.RESOLUTION_DUPLICATED) ?
" duplicated" :
"") +
295 (
issue.
getResolution().equals(IssueResolution.RESOLUTION_INVALID) ?
" invalid" :
"") +
298 (
issue.
getResolution().equals(IssueResolution.RESOLUTION_WONTFIX) ?
" wontfix" :
"") +
299 (
issue.
getResolution().equals(IssueResolution.RESOLUTION_WORKSFORME) ?
" worksforme" :
"");
302 private String getSummaryTemplate() {
303 return Strings.isBlank(summaryTemplate) ?
"mySummary" : summaryTemplate;
306 private String getFullTemplate() {
307 return Strings.isBlank(fullTemplate) ?
"myFull" : fullTemplate;
310 private IssueStage getStage(IssueWrapper wissue) {
312 if(wissue.isUnrelated()) {
313 return IssueStage.ISSUE_STAGE_UNRELATED;
316 if(wissue.hasPassedNow()) {
317 return IssueStage.ISSUE_STAGE_DATE_SURPASSED;
320 if(!wissue.hasPassedStartDate() || !wissue.canStartBySources()) {
321 return IssueStage.ISSUE_STAGE_TO_COME;
324 int stage = wissue.getRelevanceOrderByContact();
327 case 1:
return IssueStage.ISSUE_STAGE_TO_DO;
328 case 2:
return IssueStage.ISSUE_STAGE_REUNION;
329 case 5:
return IssueStage.ISSUE_STAGE_FROZEN;
332 return IssueStage.ISSUE_STAGE_TO_MONITOR;
static IContact getIContact()
IssueResolution getResolution()
boolean isFullParticipant()
void setSearchValue(String searchValue)
static IssueStage getStage(WorkloadItem item)
boolean isInRole(String role)
static Application getApplication()
static String getRootWebPath()
static String getContextVariable(IConstructor constructor)
AttributeSupport getAttributes()
static IElephantEntity getController(String path)
static String byKey(String key)
static String get(String msg)
String render(IConstructor constructor)
static DaoHtmlSearch getInstance(IConstructor constructor, String context)
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)
static KeyValueMap getObfuscatedParameters()
String getParameter(String param)
void setTitle(String title)
IConstructor getConstructor()