From d4c713eb3c1e5c45ccb1fe7b1ea1cb74be17a6af Mon Sep 17 00:00:00 2001 From: Miguel Martin Rojas Date: Wed, 13 Mar 2019 10:31:15 +0100 Subject: [PATCH] feature/810 Add querying by planned date for workbasket monitor reports --- .../impl/CategoryReportBuilderImpl.java | 6 + .../impl/ClassificationReportBuilderImpl.java | 22 +- .../CustomFieldValueReportBuilderImpl.java | 7 + .../impl/TaskStatusReportBuilderImpl.java | 9 + .../impl/WorkbasketReportBuilderImpl.java | 19 + .../taskana/impl/report/structure/Report.java | 1 + .../taskana/mappings/TaskMonitorMapper.java | 709 ++++++++++-------- .../pro/taskana/report/WorkbasketReport.java | 6 + .../ProvideWorkbasketReportAccTest.java | 30 +- .../impl/WorkbasketReportBuilderImplTest.java | 55 +- .../resources/sql/monitor-sample-data.sql | 6 +- lib/taskana-spring/pom.xml | 2 + .../pro/taskana/rest/MonitorController.java | 59 +- web/src/app/app.component.html | 3 +- .../restConnector/rest-connector.service.ts | 2 +- 15 files changed, 578 insertions(+), 358 deletions(-) diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/CategoryReportBuilderImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/CategoryReportBuilderImpl.java index 5b29511e2..8f00aae74 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/CategoryReportBuilderImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/CategoryReportBuilderImpl.java @@ -12,6 +12,7 @@ import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.impl.report.header.TimeIntervalColumnHeader; import pro.taskana.impl.report.item.MonitorQueryItem; import pro.taskana.impl.report.preprocessor.DaysToWorkingDaysPreProcessor; +import pro.taskana.impl.report.structure.Report; import pro.taskana.mappings.TaskMonitorMapper; import pro.taskana.report.CategoryReport; @@ -58,4 +59,9 @@ public class CategoryReportBuilderImpl } } + @Override + public Report buildPlannedDateBasedReport() + throws NotAuthorizedException, InvalidArgumentException { + throw new java.lang.UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationReportBuilderImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationReportBuilderImpl.java index bbb37ed15..d2f77acef 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationReportBuilderImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationReportBuilderImpl.java @@ -1,10 +1,7 @@ package pro.taskana.impl; -import java.util.List; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaRole; import pro.taskana.exceptions.InvalidArgumentException; @@ -16,6 +13,9 @@ import pro.taskana.impl.report.preprocessor.DaysToWorkingDaysPreProcessor; import pro.taskana.mappings.TaskMonitorMapper; import pro.taskana.report.ClassificationReport; import pro.taskana.report.ClassificationReport.DetailedClassificationReport; +import pro.taskana.report.Report; + +import java.util.List; /** * The implementation of ClassificationReportBuilder. @@ -48,10 +48,10 @@ public class ClassificationReportBuilderImpl this.taskanaEngine.openConnection(); ClassificationReport report = new ClassificationReport(this.columnHeaders); List monitorQueryItems = this.taskMonitorMapper.getTaskCountOfClassifications( - this.workbasketIds, this.states, this.categories, this.domains, this.classificationIds, - this.excludedClassificationIds, this.customAttributeFilter); + this.workbasketIds, this.states, this.categories, this.domains, this.classificationIds, + this.excludedClassificationIds, this.customAttributeFilter); report.addItems(monitorQueryItems, - new DaysToWorkingDaysPreProcessor<>(this.columnHeaders, this.inWorkingDays)); + new DaysToWorkingDaysPreProcessor<>(this.columnHeaders, this.inWorkingDays)); return report; } finally { this.taskanaEngine.returnConnection(); @@ -67,11 +67,11 @@ public class ClassificationReportBuilderImpl this.taskanaEngine.openConnection(); DetailedClassificationReport report = new DetailedClassificationReport(this.columnHeaders); List detailedMonitorQueryItems = this.taskMonitorMapper - .getTaskCountOfDetailedClassifications(this.workbasketIds, this.states, this.categories, this.domains, - this.classificationIds, this.excludedClassificationIds, this.customAttributeFilter); + .getTaskCountOfDetailedClassifications(this.workbasketIds, this.states, this.categories, this.domains, + this.classificationIds, this.excludedClassificationIds, this.customAttributeFilter); report.addItems(detailedMonitorQueryItems, - new DaysToWorkingDaysPreProcessor<>(this.columnHeaders, this.inWorkingDays)); + new DaysToWorkingDaysPreProcessor<>(this.columnHeaders, this.inWorkingDays)); return report; } finally { @@ -80,4 +80,8 @@ public class ClassificationReportBuilderImpl } } + @Override + public Report buildPlannedDateBasedReport() throws NotAuthorizedException, InvalidArgumentException { + throw new java.lang.UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/CustomFieldValueReportBuilderImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/CustomFieldValueReportBuilderImpl.java index db50d9c5b..855f20f58 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/CustomFieldValueReportBuilderImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/CustomFieldValueReportBuilderImpl.java @@ -13,6 +13,7 @@ import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.impl.report.header.TimeIntervalColumnHeader; import pro.taskana.impl.report.item.MonitorQueryItem; import pro.taskana.impl.report.preprocessor.DaysToWorkingDaysPreProcessor; +import pro.taskana.impl.report.structure.Report; import pro.taskana.mappings.TaskMonitorMapper; import pro.taskana.report.CustomFieldValueReport; @@ -66,4 +67,10 @@ public class CustomFieldValueReportBuilderImpl } } + @Override + public Report buildPlannedDateBasedReport() + throws NotAuthorizedException, InvalidArgumentException { + throw new java.lang.UnsupportedOperationException("Not supported yet."); + } + } diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskStatusReportBuilderImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskStatusReportBuilderImpl.java index fd2ce7893..595de6d44 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskStatusReportBuilderImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskStatusReportBuilderImpl.java @@ -8,8 +8,11 @@ import org.slf4j.LoggerFactory; import pro.taskana.TaskState; import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaRole; +import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.NotAuthorizedException; +import pro.taskana.impl.report.header.TaskStatusColumnHeader; import pro.taskana.impl.report.item.TaskQueryItem; +import pro.taskana.impl.report.structure.Report; import pro.taskana.mappings.TaskMonitorMapper; import pro.taskana.report.TaskStatusReport; @@ -57,4 +60,10 @@ public class TaskStatusReportBuilderImpl implements TaskStatusReport.Builder { } } + @Override + public Report buildPlannedDateBasedReport() + throws NotAuthorizedException, InvalidArgumentException { + throw new java.lang.UnsupportedOperationException("Not supported yet."); + } + } diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketReportBuilderImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketReportBuilderImpl.java index d4c4139a4..2de498f7d 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketReportBuilderImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketReportBuilderImpl.java @@ -59,6 +59,25 @@ public class WorkbasketReportBuilderImpl } } + @Override + public WorkbasketReport buildPlannedDateBasedReport() throws NotAuthorizedException, InvalidArgumentException { + LOGGER.debug("entry to buildPlannedDateReport(), this = {}", this); + this.taskanaEngine.checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN); + try { + this.taskanaEngine.openConnection(); + WorkbasketReport report = new WorkbasketReport(this.columnHeaders); + List monitorQueryItems = this.taskMonitorMapper.getTaskCountOfWorkbasketsBasedOnPlannedDate( + this.workbasketIds, this.states, this.categories, this.domains, this.classificationIds, + this.excludedClassificationIds, this.customAttributeFilter, this.combinedClassificationFilter); + report.addItems(monitorQueryItems, + new DaysToWorkingDaysPreProcessor<>(this.columnHeaders, this.inWorkingDays)); + return report; + } finally { + this.taskanaEngine.returnConnection(); + LOGGER.debug("exit from buildPlannedDateReport()."); + } + } + @Override public WorkbasketReport.Builder combinedClassificationFilterIn( List combinedClassificationFilter) { diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/report/structure/Report.java b/lib/taskana-core/src/main/java/pro/taskana/impl/report/structure/Report.java index 9bcc12d34..fdfb7aaa5 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/report/structure/Report.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/report/structure/Report.java @@ -105,5 +105,6 @@ public abstract class Report> { Report buildReport() throws NotAuthorizedException, InvalidArgumentException; + Report buildPlannedDateBasedReport() throws NotAuthorizedException, InvalidArgumentException; } } diff --git a/lib/taskana-core/src/main/java/pro/taskana/mappings/TaskMonitorMapper.java b/lib/taskana-core/src/main/java/pro/taskana/mappings/TaskMonitorMapper.java index 66b1f8685..2ba9f2991 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/mappings/TaskMonitorMapper.java +++ b/lib/taskana-core/src/main/java/pro/taskana/mappings/TaskMonitorMapper.java @@ -24,362 +24,417 @@ import pro.taskana.impl.report.item.TaskQueryItem; public interface TaskMonitorMapper { @Select("") + + "SELECT T.WORKBASKET_KEY, (DAYS(T.DUE) - DAYS(CURRENT_TIMESTAMP)) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "SELECT T.WORKBASKET_KEY, DATEDIFF('DAY', CURRENT_TIMESTAMP, T.DUE) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "SELECT T.WORKBASKET_KEY, DATE_PART('DAY', T.DUE - CURRENT_TIMESTAMP) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "FROM TASK AS T LEFT JOIN ATTACHMENT AS A ON T.ID = A.TASK_ID " + + "" + + "" + + "T.WORKBASKET_ID IN (#{workbasketId}) " + + "" + + "" + + "AND T.STATE IN (#{state}) " + + "" + + "" + + "AND T.CLASSIFICATION_CATEGORY IN (#{category}) " + + "" + + "" + + "AND T.DOMAIN IN (#{domain}) " + + "" + + "" + + "AND CLASSIFICATION_ID IN (#{classificationId}) " + + "" + + "" + + "AND CLASSIFICATION_ID NOT IN (#{excludedClassificationId}) " + + "" + + "" + + "AND ((${key} = '${customAttributeFilter.get(key)}')) " + + "" + + "" + + "AND " + + "T.CLASSIFICATION_ID = #{item.taskClassificationId}" + + "" + + "AND A.CLASSIFICATION_ID = #{item.attachmentClassificationId}" + + "" + + "" + + "" + + "AND T.DUE IS NOT NULL " + + "" + + "GROUP BY T.WORKBASKET_KEY, (DAYS(T.DUE) - DAYS(CURRENT_TIMESTAMP)) " + + "GROUP BY T.WORKBASKET_KEY, DATEDIFF('DAY', CURRENT_TIMESTAMP, T.DUE) " + + "GROUP BY T.WORKBASKET_KEY, DATE_PART('DAY', T.DUE - CURRENT_TIMESTAMP) " + + "with UR " + + "") @Results({ - @Result(column = "WORKBASKET_KEY", property = "key"), - @Result(column = "AGE_IN_DAYS", property = "ageInDays"), - @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")}) + @Result(column = "WORKBASKET_KEY", property = "key"), + @Result(column = "AGE_IN_DAYS", property = "ageInDays"), + @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")}) List getTaskCountOfWorkbaskets(@Param("workbasketIds") List workbasketIds, - @Param("states") List states, - @Param("categories") List categories, - @Param("domains") List domains, - @Param("classificationIds") List classificationIds, - @Param("excludedClassificationIds") List excludedClassificationIds, - @Param("customAttributeFilter") Map customAttributeFilter, - @Param("combinedClassificationFilter") List combinedClassificationFilter); + @Param("states") List states, + @Param("categories") List categories, + @Param("domains") List domains, + @Param("classificationIds") List classificationIds, + @Param("excludedClassificationIds") List excludedClassificationIds, + @Param("customAttributeFilter") Map customAttributeFilter, + @Param("combinedClassificationFilter") List combinedClassificationFilter); @Select("") + + "SELECT T.WORKBASKET_KEY, (DAYS(T.PLANNED) - DAYS(CURRENT_TIMESTAMP)) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "SELECT T.WORKBASKET_KEY, DATEDIFF('DAY', CURRENT_TIMESTAMP, T.PLANNED) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "SELECT T.WORKBASKET_KEY, DATE_PART('DAY', T.PLANNED - CURRENT_TIMESTAMP) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "FROM TASK AS T LEFT JOIN ATTACHMENT AS A ON T.ID = A.TASK_ID " + + "" + + "" + + "T.WORKBASKET_ID IN (#{workbasketId}) " + + "" + + "" + + "AND T.STATE IN (#{state}) " + + "" + + "" + + "AND T.CLASSIFICATION_CATEGORY IN (#{category}) " + + "" + + "" + + "AND T.DOMAIN IN (#{domain}) " + + "" + + "" + + "AND CLASSIFICATION_ID IN (#{classificationId}) " + + "" + + "" + + "AND CLASSIFICATION_ID NOT IN (#{excludedClassificationId}) " + + "" + + "" + + "AND ((${key} = '${customAttributeFilter.get(key)}')) " + + "" + + "" + + "AND " + + "T.CLASSIFICATION_ID = #{item.taskClassificationId}" + + "" + + "AND A.CLASSIFICATION_ID = #{item.attachmentClassificationId}" + + "" + + "" + + "" + + "AND T.PLANNED IS NOT NULL " + + "" + + "GROUP BY T.WORKBASKET_KEY, (DAYS(T.PLANNED) - DAYS(CURRENT_TIMESTAMP)) " + + "GROUP BY T.WORKBASKET_KEY, DATEDIFF('DAY', CURRENT_TIMESTAMP, T.PLANNED) " + + "GROUP BY T.WORKBASKET_KEY, DATE_PART('DAY', T.PLANNED - CURRENT_TIMESTAMP) " + + "with UR " + + "") @Results({ - @Result(column = "CLASSIFICATION_CATEGORY", property = "key"), - @Result(column = "AGE_IN_DAYS", property = "ageInDays"), - @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")}) + @Result(column = "WORKBASKET_KEY", property = "key"), + @Result(column = "AGE_IN_DAYS", property = "ageInDays"), + @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")}) + List getTaskCountOfWorkbasketsBasedOnPlannedDate(@Param("workbasketIds") List workbasketIds, + @Param("states") List states, + @Param("categories") List categories, + @Param("domains") List domains, + @Param("classificationIds") List classificationIds, + @Param("excludedClassificationIds") List excludedClassificationIds, + @Param("customAttributeFilter") Map customAttributeFilter, + @Param("combinedClassificationFilter") List combinedClassificationFilter); + + @Select("") + @Results({ + @Result(column = "CLASSIFICATION_CATEGORY", property = "key"), + @Result(column = "AGE_IN_DAYS", property = "ageInDays"), + @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")}) List getTaskCountOfCategories(@Param("workbasketIds") List workbasketIds, - @Param("states") List states, - @Param("categories") List categories, - @Param("domains") List domains, - @Param("classificationIds") List classificationIds, - @Param("excludedClassificationIds") List excludedClassificationIds, - @Param("customAttributeFilter") Map customAttributeFilter); + @Param("states") List states, + @Param("categories") List categories, + @Param("domains") List domains, + @Param("classificationIds") List classificationIds, + @Param("excludedClassificationIds") List excludedClassificationIds, + @Param("customAttributeFilter") Map customAttributeFilter); @Select("") + + "SELECT CLASSIFICATION_KEY, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "SELECT CLASSIFICATION_KEY, DATEDIFF('DAY', CURRENT_TIMESTAMP, DUE) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "SELECT CLASSIFICATION_KEY, DATE_PART('DAY', DUE - CURRENT_TIMESTAMP) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "FROM TASK " + + "" + + "" + + "WORKBASKET_ID IN (#{workbasketId}) " + + "" + + "" + + "AND STATE IN (#{state}) " + + "" + + "" + + "AND CLASSIFICATION_CATEGORY IN (#{category}) " + + "" + + "" + + "AND DOMAIN IN (#{domain}) " + + "" + + "" + + "AND CLASSIFICATION_ID IN (#{classificationId}) " + + "" + + "" + + "AND CLASSIFICATION_ID NOT IN (#{excludedClassificationId}) " + + "" + + "" + + "AND ((${key} = '${customAttributeFilter.get(key)}')) " + + "" + + "AND DUE IS NOT NULL " + + "" + + "GROUP BY CLASSIFICATION_KEY, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) " + + "GROUP BY CLASSIFICATION_KEY, DATEDIFF('DAY', CURRENT_TIMESTAMP, DUE) " + + "GROUP BY CLASSIFICATION_KEY, DATE_PART('DAY', DUE - CURRENT_TIMESTAMP) " + + "with UR " + + "") @Results({ - @Result(column = "CLASSIFICATION_KEY", property = "key"), - @Result(column = "AGE_IN_DAYS", property = "ageInDays"), - @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")}) + @Result(column = "CLASSIFICATION_KEY", property = "key"), + @Result(column = "AGE_IN_DAYS", property = "ageInDays"), + @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")}) List getTaskCountOfClassifications(@Param("workbasketIds") List workbasketIds, - @Param("states") List states, - @Param("categories") List categories, - @Param("domains") List domains, - @Param("classificationIds") List classificationIds, - @Param("excludedClassificationIds") List excludedClassificationIds, - @Param("customAttributeFilter") Map customAttributeFilter); + @Param("states") List states, + @Param("categories") List categories, + @Param("domains") List domains, + @Param("classificationIds") List classificationIds, + @Param("excludedClassificationIds") List excludedClassificationIds, + @Param("customAttributeFilter") Map customAttributeFilter); @Select("") + + "SELECT T.CLASSIFICATION_KEY as TASK_CLASSIFICATION_KEY, A.CLASSIFICATION_KEY as ATTACHMENT_CLASSIFICATION_KEY, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "SELECT T.CLASSIFICATION_KEY as TASK_CLASSIFICATION_KEY, A.CLASSIFICATION_KEY as ATTACHMENT_CLASSIFICATION_KEY, DATEDIFF('DAY', CURRENT_TIMESTAMP, DUE) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "SELECT T.CLASSIFICATION_KEY as TASK_CLASSIFICATION_KEY, A.CLASSIFICATION_KEY as ATTACHMENT_CLASSIFICATION_KEY, DATE_PART('DAY', DUE - CURRENT_TIMESTAMP) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "FROM TASK AS T LEFT JOIN ATTACHMENT AS A ON T.ID = A.TASK_ID " + + "" + + "" + + "T.WORKBASKET_ID IN (#{workbasketId}) " + + "" + + "" + + "AND STATE IN (#{state}) " + + "" + + "" + + "AND CLASSIFICATION_CATEGORY IN (#{category}) " + + "" + + "" + + "AND DOMAIN IN (#{domain}) " + + "" + + "" + + "AND CLASSIFICATION_ID IN (#{classificationId}) " + + "" + + "" + + "AND CLASSIFICATION_ID NOT IN (#{excludedClassificationId}) " + + "" + + "" + + "AND ((${key} = '${customAttributeFilter.get(key)}')) " + + "" + + "AND DUE IS NOT NULL " + + "" + + "GROUP BY T.CLASSIFICATION_KEY, A.CLASSIFICATION_KEY, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) " + + "GROUP BY T.CLASSIFICATION_KEY, A.CLASSIFICATION_KEY, DATEDIFF('DAY', CURRENT_TIMESTAMP, DUE) " + + "GROUP BY T.CLASSIFICATION_KEY, A.CLASSIFICATION_KEY, DATE_PART('DAY', DUE - CURRENT_TIMESTAMP) " + + "with UR " + + "") @Results({ - @Result(column = "TASK_CLASSIFICATION_KEY", property = "key"), - @Result(column = "ATTACHMENT_CLASSIFICATION_KEY", property = "attachmentKey"), - @Result(column = "AGE_IN_DAYS", property = "ageInDays"), - @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")}) + @Result(column = "TASK_CLASSIFICATION_KEY", property = "key"), + @Result(column = "ATTACHMENT_CLASSIFICATION_KEY", property = "attachmentKey"), + @Result(column = "AGE_IN_DAYS", property = "ageInDays"), + @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")}) List getTaskCountOfDetailedClassifications( - @Param("workbasketIds") List workbasketIds, - @Param("states") List states, - @Param("categories") List categories, - @Param("domains") List domains, - @Param("classificationIds") List classificationIds, - @Param("excludedClassificationIds") List excludedClassificationIds, - @Param("customAttributeFilter") Map customAttributeFilter); + @Param("workbasketIds") List workbasketIds, + @Param("states") List states, + @Param("categories") List categories, + @Param("domains") List domains, + @Param("classificationIds") List classificationIds, + @Param("excludedClassificationIds") List excludedClassificationIds, + @Param("customAttributeFilter") Map customAttributeFilter); @Select("") + + "SELECT ${customField} as CUSTOM_FIELD, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "SELECT ${customField} as CUSTOM_FIELD, DATEDIFF('DAY', CURRENT_TIMESTAMP, DUE) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "SELECT ${customField} as CUSTOM_FIELD, DATE_PART('DAY', DUE - CURRENT_TIMESTAMP) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS " + + "FROM TASK " + + "" + + "" + + "WORKBASKET_ID IN (#{workbasketId}) " + + "" + + "" + + "AND STATE IN (#{state}) " + + "" + + "" + + "AND CLASSIFICATION_CATEGORY IN (#{category}) " + + "" + + "" + + "AND DOMAIN IN (#{domain}) " + + "" + + "" + + "AND CLASSIFICATION_ID IN (#{classificationId}) " + + "" + + "" + + "AND CLASSIFICATION_ID NOT IN (#{excludedClassificationId}) " + + "" + + "" + + "AND ((${key} = '${customAttributeFilter.get(key)}')) " + + "" + + "AND DUE IS NOT NULL " + + "" + + "GROUP BY ${customField}, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) " + + "GROUP BY ${customField}, DATEDIFF('DAY', CURRENT_TIMESTAMP, DUE) " + + "GROUP BY ${customField}, DATE_PART('DAY', DUE - CURRENT_TIMESTAMP) " + + "with UR " + + "") @Results({ - @Result(column = "CUSTOM_FIELD", property = "key"), - @Result(column = "AGE_IN_DAYS", property = "ageInDays"), - @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")}) + @Result(column = "CUSTOM_FIELD", property = "key"), + @Result(column = "AGE_IN_DAYS", property = "ageInDays"), + @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")}) List getTaskCountOfCustomFieldValues( - @Param("customField") CustomField customField, - @Param("workbasketIds") List workbasketIds, - @Param("states") List states, - @Param("categories") List categories, - @Param("domains") List domains, - @Param("classificationIds") List classificationIds, - @Param("excludedClassificationIds") List excludedClassificationIds, - @Param("customAttributeFilter") Map customAttributeFilter); + @Param("customField") CustomField customField, + @Param("workbasketIds") List workbasketIds, + @Param("states") List states, + @Param("categories") List categories, + @Param("domains") List domains, + @Param("classificationIds") List classificationIds, + @Param("excludedClassificationIds") List excludedClassificationIds, + @Param("customAttributeFilter") Map customAttributeFilter); @Select("") + + "SELECT T.ID FROM TASK T " + + "" + + "LEFT JOIN ATTACHMENT A ON T.ID = A.TASK_ID " + + "" + + "" + + "" + + "T.WORKBASKET_ID IN (#{workbasketId}) " + + "" + + "" + + "AND T.STATE IN (#{state}) " + + "" + + "" + + "AND T.CLASSIFICATION_CATEGORY IN (#{category}) " + + "" + + "" + + "AND DOMAIN IN (#{domain}) " + + "" + + "" + + "AND T.CLASSIFICATION_ID IN (#{classificationId}) " + + "" + + "" + + "AND T.CLASSIFICATION_ID NOT IN (#{excludedClassificationId}) " + + "" + + "" + + "AND ((${key} = '${customAttributeFilter.get(key)}')) " + + "" + + "AND T.DUE IS NOT NULL AND ( " + + "" + + "#{selectedItem.key} = T.${groupedBy} AND " + + "" + + "A.CLASSIFICATION_KEY = #{selectedItem.subKey} AND " + + "" + + "" + + "#{selectedItem.upperAgeLimit} >= (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) AND " + + "#{selectedItem.lowerAgeLimit} <= (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) " + + " " + + "" + + "#{selectedItem.upperAgeLimit} >= DATEDIFF('DAY', CURRENT_TIMESTAMP, DUE) AND " + + "#{selectedItem.lowerAgeLimit} <= DATEDIFF('DAY', CURRENT_TIMESTAMP, DUE) " + + " " + + "" + + "#{selectedItem.upperAgeLimit} >= DATE_PART('day', DUE - CURRENT_TIMESTAMP ) AND " + + "#{selectedItem.lowerAgeLimit} <= DATE_PART('day', DUE - CURRENT_TIMESTAMP ) " + + " " + + ") " + + "" + + "with UR " + + "") List getTaskIdsForSelectedItems(@Param("workbasketIds") List workbasketIds, - @Param("states") List states, - @Param("categories") List categories, - @Param("domains") List domains, - @Param("classificationIds") List classificationIds, - @Param("excludedClassificationIds") List excludedClassificationIds, - @Param("customAttributeFilter") Map customAttributeFilter, - @Param("groupedBy") String groupedBy, @Param("selectedItems") List selectedItems, - @Param("joinWithAttachments") boolean joinWithAttachments); + @Param("states") List states, + @Param("categories") List categories, + @Param("domains") List domains, + @Param("classificationIds") List classificationIds, + @Param("excludedClassificationIds") List excludedClassificationIds, + @Param("customAttributeFilter") Map customAttributeFilter, + @Param("groupedBy") String groupedBy, @Param("selectedItems") List selectedItems, + @Param("joinWithAttachments") boolean joinWithAttachments); @Select("") + + "SELECT DOMAIN, STATE, COUNT(STATE) as COUNT " + + "FROM TASK " + + "" + + "" + + "DOMAIN IN (#{domain}) " + + "" + + "" + + "AND STATE IN (#{state}) " + + "" + + "" + + "GROUP BY DOMAIN, STATE" + + "") @Results({ - @Result(column = "DOMAIN", property = "domain"), - @Result(column = "STATE", property = "state"), - @Result(column = "COUNT", property = "count"), + @Result(column = "DOMAIN", property = "domain"), + @Result(column = "STATE", property = "state"), + @Result(column = "COUNT", property = "count"), }) List getTasksCountByState(@Param("domains") List domains, - @Param("states") List states); + @Param("states") List states); @Select("") + + "SELECT DISTINCT ${customField} " + + "FROM TASK " + + "" + + "" + + "WORKBASKET_ID IN (#{workbasketId}) " + + "" + + "" + + "AND STATE IN (#{state}) " + + "" + + "" + + "AND CLASSIFICATION_CATEGORY IN (#{category}) " + + "" + + "" + + "AND DOMAIN IN (#{domain}) " + + "" + + "" + + "AND CLASSIFICATION_ID IN (#{classificationId}) " + + "" + + "" + + "AND CLASSIFICATION_ID NOT IN (#{excludedClassificationId}) " + + "" + + "" + + "AND ((${key} = '${customAttributeFilter.get(key)}')) " + + "" + + "" + + "") List getCustomAttributeValuesForReport(@Param("workbasketIds") List workbasketIds, - @Param("states") List states, - @Param("categories") List categories, @Param("domains") List domains, - @Param("classificationIds") List classificationIds, - @Param("excludedClassificationIds") List excludedClassificationIds, - @Param("customAttributeFilter") Map customAttributeFilter, - @Param("customField") CustomField customField); + @Param("states") List states, + @Param("categories") List categories, @Param("domains") List domains, + @Param("classificationIds") List classificationIds, + @Param("excludedClassificationIds") List excludedClassificationIds, + @Param("customAttributeFilter") Map customAttributeFilter, + @Param("customField") CustomField customField); @Select("