18 package org.turro.dossier.dossier;
20 import java.util.ArrayList;
21 import java.util.Date;
22 import java.util.EnumSet;
23 import java.util.List;
24 import org.turro.string.Strings;
25 import org.turro.action.Contacts;
26 import org.turro.auth.Authentication;
27 import org.turro.dossier.db.DossierPU;
28 import org.turro.dossier.dw.DossierDWReport;
29 import org.turro.dossier.entity.DescriptorDefinition;
30 import org.turro.dossier.entity.DescriptorValue;
31 import org.turro.dossier.entity.Dossier;
32 import org.turro.dossier.entity.DossierType;
33 import org.turro.dossier.entity.IDossierParticipant;
34 import org.turro.dossier.entity.IssueParticipantRole;
35 import org.turro.dossier.entity.Participant;
36 import org.turro.dossier.entity.ParticipantRole;
37 import org.turro.dossier.entity.Project;
38 import org.turro.dossier.issue.IssueWrapper;
39 import org.turro.dossier.search.CategoryResults;
40 import org.turro.dossier.search.IssueResults;
41 import org.turro.elephant.context.Application;
42 import org.turro.elephant.db.WhereClause;
43 import org.turro.i18n.I_;
44 import org.turro.jpa.Dao;
45 import org.turro.jpa.entity.DaoEntity;
46 import org.turro.jpa.entity.EntityCollections;
47 import org.turro.jpa.entity.EntityWebUrls;
48 import org.turro.plugin.contacts.IContact;
49 import org.turro.related.RelatedItem;
50 import org.turro.related.Relateds;
51 import org.turro.util.CompareUtil;
52 import org.turro.util.PhraseBuilder;
61 private List<ParticipantRole> role;
62 private List<IssueWrapper> issueAlarms;
63 private String issueParticipant;
78 if(
entity.getCreation() ==
null) {
79 entity.setCreation(
new Date());
81 if(
entity.getType() ==
null) {
86 p.setRole(p.getRole());
96 entity.setProject(project);
99 PhraseBuilder pb =
new PhraseBuilder();
101 pb.addPendingSeparator(
" - ");
104 entity.setDescription(pb.toString());
116 if(
entity.getId() !=
null) {
117 String url = Strings.unpunctuateKeepPath(
entity.getCategory().getPath()).toLowerCase() +
119 "/" + Strings.unpunctuate(
entity.getDescription()).toLowerCase();
126 public boolean delete() {
129 return super.delete();
143 return I_.
get(
"Project");
145 return I_.
get(
"Dossier");
151 return entity.getFullDescription();
152 }
catch(Exception ex) {
158 this.contact = contact;
162 if(
entity ==
null)
return false;
163 return getRole() !=
null && !getRole().isEmpty();
167 if(
entity ==
null)
return false;
172 if(
entity ==
null)
return false;
177 if(
entity ==
null)
return false;
182 if(
entity ==
null)
return false;
189 if(p.getIdContact().equals(contact.
getId()) && p.isShowParticipants()) {
198 if(
entity ==
null)
return false;
203 if(p.getIdContact().equals(contact.
getId()) && p.isShowAllAttachments()) {
212 if(
entity ==
null)
return false;
217 if(p.getIdContact().equals(contact.
getId()) && p.isShowAllIssues()) {
229 if(p.getIdContact().equals(contact.
getId()) && p.isReceiveAllEmails()) {
246 return issueParticipant;
250 this.issueParticipant = issueParticipant;
254 if(issueAlarms ==
null) createIssueAlarms();
264 if(issueParticipant !=
null) {
284 wc.
addClause(
"select distinct participant.idContact");
285 wc.
addClause(
"from IssueParticipant as participant");
286 wc.
addClause(
"where participant.issue.dossier = :dossier");
287 wc.
addClause(
"and participant.role = :role");
288 wc.
addClause(
"order by participant.name");
291 List<DossierWrapper> l =
new ArrayList<>();
292 for(String s : (List<String>) dao.getResultList(wc)) {
303 wc.
addClause(
"select count(issue) from Issue as issue");
304 wc.
addClause(
"where dossier = :dossier");
312 wc.
addClause(
"select max(issue.modification)");
314 wc.
addClause(
"where dossier = :dossier");
319 private void createIssueAlarms() {
320 issueAlarms =
new ArrayList<>();
322 if(wissue.getIssue().getStatus().isFinished())
continue;
323 if(wissue.hasAlarm()) {
324 issueAlarms.add(wissue);
329 private List<ParticipantRole> getRole() {
330 if(role ==
null &&
getEntity() !=
null) {
331 role =
new ArrayList<>();
332 for(IDossierParticipant p :
getEntity().getFullParticipants()) {
333 if(p.getIdContact() !=
null && p.getIdContact().equals(contact.
getId())) {
334 role.add(p.getRole());
343 if(
"all".
equals(grouping) || CompareUtil.compare(grouping, dd.getGrouping()) == 0) {
345 if(required && dd.isRequired() && (dv ==
null || dv.
isEmpty())) {
static IContact getIContact()
static String getObjectPath(Object object)
boolean getCanShowAllIssues()
String getIssueParticipantName()
Date getIssueLastModification()
IssueResults getIssueSearch()
boolean isEmptyDescriptors(String grouping, boolean required)
List< DossierWrapper > getResponsibles()
void setContact(IContact contact)
boolean getReceiveAllEmails()
void setIssueParticipant(String issueParticipant)
boolean getCanShowAllAttachments()
DossierWrapper(Dossier entity)
DossierDWReport getReport()
boolean getCanShowParticipants()
String getIssueParticipant()
void setReportValues(Dossier dossier)
void setProjectTitle(String projectTitle)
void setDossier(Dossier dossier)
static void normalizeUniquePaths()
void setIssueValue(String issueValue)
void setDossierId(Long dossierId)
void setCkOthers(boolean ckOthers)
void setByParticipantId(String id)
void setRoles(Set< IssueParticipantRole > roles)
boolean isInRole(String role)
static Application getApplication()
void addClause(String clause)
void addNamedValue(String name, Object value)
static String get(String msg)
Object getSingleResult(WhereClause wc)
boolean equals(Object obj)
static EntityCollections entities(Collection values)
static EntityWebUrl addWebUrl(String entityPath, String url)