19 package org.turro.dossier.dw;
21 import java.util.Collection;
22 import java.util.Date;
23 import java.util.List;
24 import org.turro.action.Contacts;
25 import org.turro.dossier.db.DossierPU;
26 import org.turro.dossier.entity.IssueParticipantRole;
27 import org.turro.dossier.entity.IssuePriority;
28 import org.turro.dossier.entity.IssueResolution;
29 import org.turro.dossier.entity.IssueStatus;
30 import org.turro.dossier.entity.IssueType;
31 import org.turro.dossier.entity.ParticipantRole;
32 import org.turro.elephant.db.WhereClause;
33 import org.turro.jpa.Dao;
34 import org.turro.plugin.contacts.IContact;
35 import org.zkoss.lang.Strings;
44 private String participantId, categoryPath;
45 private Long dossierId, versionId;
46 private Date startDate, endDate;
55 wc.
addClause(
"select count(distinct issueId)");
64 wc.
addClause(
"select count(distinct issueId)");
74 wc.
addClause(
"select count(participantId)");
92 wc.
addClause(
"select type, count(distinct issueId)");
97 return getDao().getResultList(wc);
102 wc.
addClause(
"select status, count(distinct issueId)");
107 return getDao().getResultList(wc);
112 wc.
addClause(
"select resolution, count(distinct issueId)");
117 return getDao().getResultList(wc);
122 wc.
addClause(
"select distinct dossierId");
125 return getDao().getResultList(wc);
130 wc.
addClause(
"select distinct participantId, count(distinct issueId)");
131 wc.
addClause(
",(select count(distinct i2.issueId) from DWIssue i2 where i2.participantId = i.participantId and i2.status <> :status2 and i2.participantRole = :participantRole2)");
135 wc.
addClause(
"where participantRole = :participantRole");
137 addCriteriaParticipantExists(wc);
140 return getDao().getResultList(wc);
145 wc.
addClause(
"select distinct participantId, count(distinct issueId)");
146 wc.
addClause(
",(select count(distinct i2.issueId) from DWIssue i2 where i2.participantId = i.participantId and i2.status <> :status2 and i2.participantRole = :participantRole2)");
150 wc.
addClause(
"where participantRole = :participantRole");
152 addCriteriaParticipantExists(wc);
155 return getDao().getResultList(wc);
160 wc.
addClause(
"select distinct participantId, count(distinct issueId)");
161 wc.
addClause(
",(select count(distinct i2.issueId) from DWIssue i2 where i2.participantId = i.participantId and i2.status <> :status2 and i2.participantRole = :participantRole2)");
165 wc.
addClause(
"where participantRole = :participantRole");
167 addCriteriaParticipantExists(wc);
170 return getDao().getResultList(wc);
175 wc.
addClause(
"select distinct participantId, count(distinct issueId)");
176 wc.
addClause(
",(select count(distinct i2.issueId) from DWIssue i2 where i2.participantId = i.participantId and i2.status <> :status2 and i2.participantRole = :participantRole2)");
180 wc.
addClause(
"where participantRole = :participantRole");
182 addCriteriaParticipantExists(wc);
185 return getDao().getResultList(wc);
195 return getDao().find(
DWDossier.class, dossierId);
200 return getDao().find(
DWIssue.class, issueId);
204 return participantId;
208 this.participantId = participantId;
217 this.categoryPath = categoryPath;
225 this.dossierId = dossierId;
233 this.versionId = versionId;
241 this.startDate = startDate;
249 this.endDate = endDate;
253 return participantRole;
257 this.participantRole = participantRole;
273 this.priority = priority;
281 this.status = status;
289 this.resolution = resolution;
296 private Dao getDao() {
304 private void addCriteria(WhereClause wc) {
305 if(!Strings.isBlank(participantId)) {
306 wc.addClause(
"and participantId = :participantId");
307 wc.addNamedValue(
"participantId", participantId);
308 if(participantRole !=
null) {
309 wc.addClause(
"and participantRole = :participantRole");
310 wc.addNamedValue(
"participantRole", participantRole);
313 if(!Strings.isBlank(categoryPath)) {
314 wc.addClause(
"and categoryPath = :categoryPath");
315 wc.addNamedValue(
"categoryPath", categoryPath);
317 if(dossierId !=
null && dossierId > 0) {
318 wc.addClause(
"and dossierId = :dossierId");
319 wc.addNamedValue(
"dossierId", dossierId);
321 if(versionId !=
null && versionId > 0) {
322 wc.addClause(
"and versionId = :versionId");
323 wc.addNamedValue(
"versionId", versionId);
327 private void addCriteriaParticipantExists(WhereClause wc) {
328 if(!Strings.isBlank(participantId)) {
329 wc.addClause(
"and exists(");
330 wc.addClause(
"select i2 from DWIssue i2");
331 wc.addClause(
"where i2.issueId = i.issueId");
332 wc.addClause(
"and participantId = :participantId");
333 wc.addNamedValue(
"participantId", participantId);
334 if(participantRole !=
null) {
335 wc.addClause(
"and participantRole = :participantRole");
336 wc.addNamedValue(
"participantRole", participantRole);
340 if(!Strings.isBlank(categoryPath)) {
341 wc.addClause(
"and categoryPath = :categoryPath");
342 wc.addNamedValue(
"categoryPath", categoryPath);
344 if(dossierId !=
null && dossierId > 0) {
345 wc.addClause(
"and dossierId = :dossierId");
346 wc.addNamedValue(
"dossierId", dossierId);
348 if(versionId !=
null && versionId > 0) {
349 wc.addClause(
"and versionId = :versionId");
350 wc.addNamedValue(
"versionId", versionId);
356 private transient IContact _contact;
359 if(_contact ==
null) {
367 participantId = _contact !=
null ? _contact.
getId() :
null;
370 private void resetIContact() {
IssueResolution getResolution()
void setResolution(IssueResolution resolution)
void setIParticipant(IContact contact)
void setDossierId(Long dossierId)
IContact getIParticipant()
void setType(IssueType type)
void setPriority(IssuePriority priority)
void setParticipantId(String participantId)
Long getParticipantsCount()
void setStartDate(Date startDate)
DWIssue getIssue(Long issueId)
void setVersionId(Long versionId)
ParticipantRole getParticipantRole()
void setEndDate(Date endDate)
void setCategoryPath(String categoryPath)
Collection< Long > getDossiersId()
IssuePriority getPriority()
String getParticipantId()
IContact getIContact(String contactId)
void setStatus(IssueStatus status)
void setParticipantRole(ParticipantRole participantRole)
DWDossier getDossier(Long dossierId)
static void generateData()
void addClause(String clause)
void addNamedValue(String name, Object value)
Object getSingleResultOrNull(SqlClause sc)