From b78b3ccb2f0957d8cb9bb17ba06376144ed42494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Kl=C3=A4ger?= Date: Thu, 15 Feb 2018 12:23:32 +0100 Subject: [PATCH] TSK-261: Extend classification report by attachment classifications - Add ClassificationReport - Add DetailedClassificationReport - Add DetailedReportLine - Add DetailedMonitorItem - Implement getDetailedClassificationReport - Move createReport method to the Report class - Add tests and update sample data --- .../java/pro/taskana/TaskMonitorService.java | 108 ++++-- .../taskana/impl/ClassificationReport.java | 12 + .../impl/DetailedClassificationReport.java | 49 +++ .../impl/DetailedMonitorQueryItem.java | 23 ++ .../pro/taskana/impl/DetailedReportLine.java | 58 ++++ .../main/java/pro/taskana/impl/Report.java | 69 +++- .../java/pro/taskana/impl/ReportLine.java | 29 +- .../java/pro/taskana/impl/ReportLineItem.java | 1 + .../taskana/impl/TaskMonitorServiceImpl.java | 120 ++++--- .../taskana/mappings/TaskMonitorMapper.java | 20 ++ .../ProvideCategoryReportAccTest.java | 18 +- .../ProvideClassificationReportAccTest.java | 40 +-- .../ProvideCustomFieldValueReportAccTest.java | 46 +-- ...deDetailedClassificationReportAccTest.java | 311 ++++++++++++++++++ .../ProvideWorkbasketLevelReportAccTest.java | 12 +- .../impl/TaskMonitorServiceImplTest.java | 101 +++++- .../resources/sql/monitor-sample-data.sql | 17 + 17 files changed, 873 insertions(+), 161 deletions(-) create mode 100644 lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationReport.java create mode 100644 lib/taskana-core/src/main/java/pro/taskana/impl/DetailedClassificationReport.java create mode 100644 lib/taskana-core/src/main/java/pro/taskana/impl/DetailedMonitorQueryItem.java create mode 100644 lib/taskana-core/src/main/java/pro/taskana/impl/DetailedReportLine.java create mode 100644 lib/taskana-core/src/test/java/acceptance/monitoring/ProvideDetailedClassificationReportAccTest.java diff --git a/lib/taskana-core/src/main/java/pro/taskana/TaskMonitorService.java b/lib/taskana-core/src/main/java/pro/taskana/TaskMonitorService.java index fb8dd5709..269f45968 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/TaskMonitorService.java +++ b/lib/taskana-core/src/main/java/pro/taskana/TaskMonitorService.java @@ -2,7 +2,9 @@ package pro.taskana; import java.util.List; +import pro.taskana.impl.ClassificationReport; import pro.taskana.impl.CustomField; +import pro.taskana.impl.DetailedClassificationReport; import pro.taskana.impl.Report; import pro.taskana.impl.ReportLineItemDefinition; import pro.taskana.impl.TaskState; @@ -135,26 +137,26 @@ public interface TaskMonitorService { List reportLineItemDefinitions, boolean inWorkingDays); /** - * Returns a {@link Report} grouped by classifications for a given list of {@link Workbasket}s and for a given list - * of {@link TaskState}s. The report only contains the number of all tasks of the respective classification as well - * as the total sum of all tasks. Only tasks with a state in the list of TaskStates are provided. Task with - * Timestamp DUE = null are not considered. + * Returns a {@link ClassificationReport} grouped by classifications for a given list of {@link Workbasket}s and for + * a given list of {@link TaskState}s. The report only contains the number of all tasks of the respective + * classification as well as the total sum of all tasks. Only tasks with a state in the list of TaskStates are + * provided. Task with Timestamp DUE = null are not considered. * * @param workbaskets * a list of {@link Workbasket} objects whose task should be considered in the report * @param states * a list of {@link TaskState} objects that specify the states of the tasks that are provided - * @return a {@link Report} object that only contains the number of all tasks of the respective classification as - * well as the total number of all tasks + * @return a {@link ClassificationReport} object that only contains the number of all tasks of the respective + * classification as well as the total number of all tasks */ - Report getClassificationReport(List workbaskets, List states); + ClassificationReport getClassificationReport(List workbaskets, List states); /** - * Returns a {@link Report} grouped by classifications for a given list of {@link Workbasket}s, a given list of - * {@link TaskState}s and a given list of {@link ReportLineItemDefinition}s. For each classification the report - * contains a list of ReportLineItems that subdivides the report in to different cluster grouped by the due date. By - * default the age of the tasks is counted in working days. Only tasks with a state in the list of TaskStates are - * provided. Tasks with Timestamp DUE = null are not considered. + * Returns a {@link ClassificationReport} grouped by classifications for a given list of {@link Workbasket}s, a + * given list of {@link TaskState}s and a given list of {@link ReportLineItemDefinition}s. For each classification + * the report contains a list of ReportLineItems that subdivides the report in to different cluster grouped by the + * due date. By default the age of the tasks is counted in working days. Only tasks with a state in the list of + * TaskStates are provided. Tasks with Timestamp DUE = null are not considered. * * @param workbaskets * a list of {@link Workbasket} objects whose task should be considered in the report @@ -166,16 +168,81 @@ public interface TaskMonitorService { * as positive values. To avoid tasks are counted multiple times or not be listed in the report, these * reportLineItemDefinitions should not overlap and should not have gaps. If the ReportLineDefinition * should represent a single day, lowerLimit and upperLimit have to be equal. - * @return a {@link Report} object that represents an overview of all tasks of the respective classification + * @return a {@link ClassificationReport} object that represents an overview of all tasks of the respective + * classification */ - Report getClassificationReport(List workbaskets, List states, + ClassificationReport getClassificationReport(List workbaskets, List states, List reportLineItemDefinitions); /** - * Returns a {@link Report} grouped by classifications for a given list of {@link Workbasket}s, a given list of - * {@link TaskState}s and a given list of {@link ReportLineItemDefinition}s. For each classification the report - * contains a list of ReportLineItems that subdivides the report in to different cluster grouped by the due date. - * Only tasks with a state in the list of TaskStates are provided. Tasks with Timestamp DUE = null are not + * Returns a {@link DetailedClassificationReport} grouped by classifications for a given list of + * {@link Workbasket}s, a given list of {@link TaskState}s and a given list of {@link ReportLineItemDefinition}s. + * For each classification the report contains a list of ReportLineItems that subdivides the report in to different + * cluster grouped by the due date. Only tasks with a state in the list of TaskStates are provided. Tasks with + * Timestamp DUE = null are not considered. + * + * @param workbaskets + * a list of {@link Workbasket} objects whose task should be considered in the report + * @param states + * a list of {@link TaskState} objects that specify the states of the tasks that are provided + * @param reportLineItemDefinitions + * a list of {@link ReportLineItemDefinition} objects that specify the subdivision into different cluster + * of due dates. Days in past are represented as negative values and days in the future are represented + * as positive values. To avoid tasks are counted multiple times or not be listed in the report, these + * reportLineItemDefinitions should not overlap and should not have gaps. If the ReportLineDefinition + * should represent a single day, lowerLimit and upperLimit have to be equal. + * @param inWorkingDays + * a boolean parameter that specifies whether the age of the tasks should be counted in days or in + * working days. + * @return a {@link DetailedClassificationReport} object that represents an overview of all tasks of the respective + * classification + */ + DetailedClassificationReport getDetailedClassificationReport(List workbaskets, List states, + List reportLineItemDefinitions, boolean inWorkingDays); + + /** + * Returns a {@link DetailedClassificationReport} grouped by classifications for a given list of {@link Workbasket}s + * and for a given list of {@link TaskState}s. The report only contains the number of all tasks of the respective + * classification as well as the total sum of all tasks. Only tasks with a state in the list of TaskStates are + * provided. Task with Timestamp DUE = null are not considered. + * + * @param workbaskets + * a list of {@link Workbasket} objects whose task should be considered in the report + * @param states + * a list of {@link TaskState} objects that specify the states of the tasks that are provided + * @return a {@link DetailedClassificationReport} object that only contains the number of all tasks of the + * respective classification as well as the total number of all tasks + */ + DetailedClassificationReport getDetailedClassificationReport(List workbaskets, List states); + + /** + * Returns a {@link DetailedClassificationReport} grouped by classifications for a given list of + * {@link Workbasket}s, a given list of {@link TaskState}s and a given list of {@link ReportLineItemDefinition}s. + * For each classification the report contains a list of ReportLineItems that subdivides the report in to different + * cluster grouped by the due date. By default the age of the tasks is counted in working days. Only tasks with a + * state in the list of TaskStates are provided. Tasks with Timestamp DUE = null are not considered. + * + * @param workbaskets + * a list of {@link Workbasket} objects whose task should be considered in the report + * @param states + * a list of {@link TaskState} objects that specify the states of the tasks that are provided + * @param reportLineItemDefinitions + * a list of {@link ReportLineItemDefinition} objects that specify the subdivision into different cluster + * of due dates. Days in past are represented as negative values and days in the future are represented + * as positive values. To avoid tasks are counted multiple times or not be listed in the report, these + * reportLineItemDefinitions should not overlap and should not have gaps. If the ReportLineDefinition + * should represent a single day, lowerLimit and upperLimit have to be equal. + * @return a {@link DetailedClassificationReport} object that represents an overview of all tasks of the respective + * classification + */ + DetailedClassificationReport getDetailedClassificationReport(List workbaskets, List states, + List reportLineItemDefinitions); + + /** + * Returns a {@link ClassificationReport} grouped by classifications for a given list of {@link Workbasket}s, a + * given list of {@link TaskState}s and a given list of {@link ReportLineItemDefinition}s. For each classification + * the report contains a list of ReportLineItems that subdivides the report in to different cluster grouped by the + * due date. Only tasks with a state in the list of TaskStates are provided. Tasks with Timestamp DUE = null are not * considered. * * @param workbaskets @@ -191,9 +258,10 @@ public interface TaskMonitorService { * @param inWorkingDays * a boolean parameter that specifies whether the age of the tasks should be counted in days or in * working days. - * @return a {@link Report} object that represents an overview of all tasks of the respective classification + * @return a {@link ClassificationReport} object that represents an overview of all tasks of the respective + * classification */ - Report getClassificationReport(List workbaskets, List states, + ClassificationReport getClassificationReport(List workbaskets, List states, List reportLineItemDefinitions, boolean inWorkingDays); /** diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationReport.java b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationReport.java new file mode 100644 index 000000000..7eeee3c23 --- /dev/null +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationReport.java @@ -0,0 +1,12 @@ +package pro.taskana.impl; + +/** + * The ClassificationReport extends the Report. + */ +public class ClassificationReport extends Report { + + public ClassificationReport() { + super(); + } + +} diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/DetailedClassificationReport.java b/lib/taskana-core/src/main/java/pro/taskana/impl/DetailedClassificationReport.java new file mode 100644 index 000000000..dea9d36d0 --- /dev/null +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/DetailedClassificationReport.java @@ -0,0 +1,49 @@ +package pro.taskana.impl; + +import java.util.List; + +/** + * The DetailedClassificationReport extends the ClassificationReport. The additional addDetailedMonitoringQueryItems + * method allows to add {@link DetailedMonitorQueryItem}s to the DetailedClassificationReport. + */ +public class DetailedClassificationReport extends ClassificationReport { + + public DetailedClassificationReport() { + super(); + } + + /** + * Adds the information of the {@link DetailedMonitorQueryItem}s to the DetailedClassificationReport. + * + * @param detailedMonitorQueryItems + * a list of {@link DetailedMonitorQueryItem} with the information of the database + * @param reportLineItemDefinitions + * a list of {@link ReportLineItemDefinition}s that is needed to create the {@link ReportLine}s. + * @param inWorkingDays + * a boolean parameter that specifies whether the age of the tasks should be counted in days or in + * working days. + */ + public void addDetailedMonitoringQueryItems(List detailedMonitorQueryItems, + List reportLineItemDefinitions, boolean inWorkingDays) { + + DaysToWorkingDaysConverter instance = null; + if (reportLineItemDefinitions != null && inWorkingDays) { + instance = DaysToWorkingDaysConverter.initialize(reportLineItemDefinitions); + } + + for (DetailedMonitorQueryItem item : detailedMonitorQueryItems) { + if (instance != null) { + item.setAgeInDays(instance.convertDaysToWorkingDays(item.getAgeInDays())); + } + if (!this.reportLines.containsKey(item.getKey())) { + DetailedReportLine detailedReportLine = new DetailedReportLine(); + detailedReportLine.create(reportLineItemDefinitions); + this.reportLines.put(item.getKey(), detailedReportLine); + } + DetailedReportLine detailedReportLine = (DetailedReportLine) this.reportLines.get(item.getKey()); + detailedReportLine.addNumberOfTasks(item, reportLineItemDefinitions); + } + this.sumLine = createSumLine(reportLineItemDefinitions); + } + +} diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/DetailedMonitorQueryItem.java b/lib/taskana-core/src/main/java/pro/taskana/impl/DetailedMonitorQueryItem.java new file mode 100644 index 000000000..4c2d1e34b --- /dev/null +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/DetailedMonitorQueryItem.java @@ -0,0 +1,23 @@ +package pro.taskana.impl; + +/** + * The DetailedMonitorQueryItem extends the MonitorQueryItem. The additional attachment key is used for the detailed + * classification report. + */ +public class DetailedMonitorQueryItem extends MonitorQueryItem { + + private String attachmentKey; + + public DetailedMonitorQueryItem() { + super(); + } + + public String getAttachmentKey() { + return attachmentKey; + } + + public void setAttachmentKey(String attachmentKey) { + this.attachmentKey = attachmentKey; + } + +} diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/DetailedReportLine.java b/lib/taskana-core/src/main/java/pro/taskana/impl/DetailedReportLine.java new file mode 100644 index 000000000..130f9076f --- /dev/null +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/DetailedReportLine.java @@ -0,0 +1,58 @@ +package pro.taskana.impl; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * The DetailedReportLine extends the ReportLine. + */ +public class DetailedReportLine extends ReportLine { + + private Map detailLines; + + public DetailedReportLine() { + super(); + this.detailLines = new LinkedHashMap<>(); + } + + public Map getDetailLines() { + return detailLines; + } + + public void setDetailLines(Map reportLines) { + this.detailLines = reportLines; + } + + /** + * Adds the number of tasks of the {@link DetailedMonitorQueryItem} to the respective {@link ReportLineItem} of this + * {@link DetailedReportLine} and and of the suitable sub line. + * + * @param item + * a {@link DetailedMonitorQueryItem} that contains the number of tasks, the age in days of these tasks + * and the Classification key of the corresponding attachment. + * @param reportLineItemDefinitions + * a list of {@link ReportLineItemDefinition}s that is needed to create a sub line if necessary. + */ + public void addNumberOfTasks(DetailedMonitorQueryItem item, + List reportLineItemDefinitions) { + super.addNumberOfTasks(item); + + if (item.getAttachmentKey() != null) { + if (!this.detailLines.containsKey(item.getAttachmentKey())) { + ReportLine reportLine = new ReportLine(); + reportLine.create(reportLineItemDefinitions); + this.detailLines.put(item.getAttachmentKey(), reportLine); + } + this.detailLines.get(item.getAttachmentKey()).addNumberOfTasks(item); + } else { + if (!this.detailLines.containsKey("N/A")) { + ReportLine reportLine = new ReportLine(); + reportLine.create(reportLineItemDefinitions); + this.detailLines.put("N/A", reportLine); + } + this.detailLines.get("N/A").addNumberOfTasks(item); + } + } + +} diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/Report.java b/lib/taskana-core/src/main/java/pro/taskana/impl/Report.java index 43df31925..e3ba92fdd 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/Report.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/Report.java @@ -2,6 +2,7 @@ package pro.taskana.impl; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; /** @@ -12,20 +13,19 @@ import java.util.Map; */ public class Report { - private Map detailLines; - private ReportLine sumLine; + protected Map reportLines; + protected ReportLine sumLine; public Report() { - this.detailLines = new LinkedHashMap<>(); - this.sumLine = new ReportLine(); + this.reportLines = new LinkedHashMap(); } - public Map getDetailLines() { - return detailLines; + public Map getReportLines() { + return reportLines; } - public void setDetailLines(Map detailLines) { - this.detailLines = detailLines; + public void setReportLines(Map reportLines) { + this.reportLines = reportLines; } public ReportLine getSumLine() { @@ -36,19 +36,62 @@ public class Report { this.sumLine = sumLine; } - public void generateSumLine(ReportLine sumLine) { - this.sumLine = sumLine; + /** + * Adds the information of the {@link MonitorQueryItem}s to the Report. + * + * @param monitorQueryItems + * a list of {@link MonitorQueryItem} with the information of the database + * @param reportLineItemDefinitions + * a list of {@link ReportLineItemDefinition}s that is needed to create the {@link ReportLine}s. + * @param inWorkingDays + * a boolean parameter that specifies whether the age of the tasks should be counted in days or in + * working days. + */ + public void addMonitoringQueryItems(List monitorQueryItems, + List reportLineItemDefinitions, boolean inWorkingDays) { + DaysToWorkingDaysConverter instance = null; + if (reportLineItemDefinitions != null && inWorkingDays) { + instance = DaysToWorkingDaysConverter.initialize(reportLineItemDefinitions); + } + + for (MonitorQueryItem item : monitorQueryItems) { + if (instance != null) { + item.setAgeInDays(instance.convertDaysToWorkingDays(item.getAgeInDays())); + } + if (!this.reportLines.containsKey(item.getKey())) { + ReportLine reportLine = new ReportLine(); + reportLine.create(reportLineItemDefinitions); + this.reportLines.put(item.getKey(), reportLine); + } + this.reportLines.get(item.getKey()).addNumberOfTasks(item); + } + + this.sumLine = createSumLine(reportLineItemDefinitions); + } + + /** + * Creates the sum line of this {@link Report}. + * + * @param reportLineItemDefinitions + * a list of {@link ReportLineItemDefinition}s that specify the subdivision into different cluster of + * ages. + * @return a {@link ReportLine} that contains the sums of the different cluster of this {@link Report}. + */ + protected ReportLine createSumLine(List reportLineItemDefinitions) { + ReportLine sumLine = new ReportLine(); + sumLine.create(reportLineItemDefinitions); int totalNumberOfTasks = 0; - for (ReportLine reportLine : this.getDetailLines().values()) { + for (ReportLine reportLine : this.reportLines.values()) { Iterator reportLineItemIterator = reportLine.getLineItems().iterator(); - Iterator sumLineItemIterator = this.sumLine.getLineItems().iterator(); + Iterator sumLineItemIterator = sumLine.getLineItems().iterator(); while (reportLineItemIterator.hasNext() && sumLineItemIterator.hasNext()) { int numberOfTasks = reportLineItemIterator.next().getNumberOfTasks(); sumLineItemIterator.next().addNumberOfTasks(numberOfTasks); } totalNumberOfTasks += reportLine.getTotalNumberOfTasks(); } - this.sumLine.setTotalNumberOfTasks(totalNumberOfTasks); + sumLine.setTotalNumberOfTasks(totalNumberOfTasks); + return sumLine; } } diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/ReportLine.java b/lib/taskana-core/src/main/java/pro/taskana/impl/ReportLine.java index 1e889c47a..0c6e0fa58 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/ReportLine.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/ReportLine.java @@ -8,8 +8,8 @@ import java.util.List; */ public class ReportLine { - private List lineItems; - private int totalNumberOfTasks; + protected List lineItems; + protected int totalNumberOfTasks; public ReportLine() { this.lineItems = new ArrayList<>(); @@ -32,6 +32,30 @@ public class ReportLine { this.totalNumberOfTasks = totalNumberOfTasks; } + /** + * Creates a list of {@link ReportLineItem}s for this {@link ReportLine} by using the list of + * {@link ReportLineItemDefinition}s. + * + * @param reportLineItemDefinitions + * a list of {@link ReportLineItemDefinition}s that specify the subdivision into different cluster of + * ages. + */ + public void create(List reportLineItemDefinitions) { + if (reportLineItemDefinitions != null) { + for (ReportLineItemDefinition reportLineItemDefinition : reportLineItemDefinitions) { + ReportLineItem reportLineItem = new ReportLineItem(); + reportLineItem.setReportLineItemDefinition(reportLineItemDefinition); + this.getLineItems().add(reportLineItem); + } + } + } + + /** + * Adds the number of tasks of the {@link MonitorQueryItem} to the respective {@link ReportLineItem}. + * + * @param item + * a {@link MonitorQueryItem} that contains the number of tasks and the age in days of these tasks. + */ public void addNumberOfTasks(MonitorQueryItem item) { this.totalNumberOfTasks += item.getNumberOfTasks(); for (ReportLineItem reportLineItem : lineItems) { @@ -43,4 +67,5 @@ public class ReportLine { } } } + } diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/ReportLineItem.java b/lib/taskana-core/src/main/java/pro/taskana/impl/ReportLineItem.java index edcd9ce45..12ee6fc57 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/ReportLineItem.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/ReportLineItem.java @@ -28,6 +28,7 @@ public class ReportLineItem { public void setNumberOfTasks(int numberOfTasks) { this.numberOfTasks = numberOfTasks; } + public void addNumberOfTasks(int numberOfTasks) { this.numberOfTasks += numberOfTasks; } diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskMonitorServiceImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskMonitorServiceImpl.java index 77d47635a..38ba3fc1d 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskMonitorServiceImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskMonitorServiceImpl.java @@ -42,17 +42,19 @@ public class TaskMonitorServiceImpl implements TaskMonitorService { List reportLineItemDefinitions, boolean inWorkingDays) { if (LOGGER.isDebugEnabled()) { LOGGER.debug( - "entry to getWorkbasketLevelReport(workbaskets = {}, states = {}, reportLineItemDefinitions = {})", + "entry to getWorkbasketLevelReport(workbaskets = {}, states = {}, reportLineItemDefinitions = {}," + + " inWorkingDays = {})", LoggerUtils.listToString(workbaskets), LoggerUtils.listToString(states), - LoggerUtils.listToString(reportLineItemDefinitions)); + LoggerUtils.listToString(reportLineItemDefinitions), inWorkingDays); } try { taskanaEngineImpl.openConnection(); + Report report = new Report(); List monitorQueryItems = taskMonitorMapper .getTaskCountOfWorkbasketsByWorkbasketsAndStates(workbaskets, states); - - return createReport(reportLineItemDefinitions, inWorkingDays, monitorQueryItems); + report.addMonitoringQueryItems(monitorQueryItems, reportLineItemDefinitions, inWorkingDays); + return report; } finally { taskanaEngineImpl.returnConnection(); @@ -77,17 +79,19 @@ public class TaskMonitorServiceImpl implements TaskMonitorService { List reportLineItemDefinitions, boolean inWorkingDays) { if (LOGGER.isDebugEnabled()) { LOGGER.debug( - "entry to getCategoryReport(workbaskets = {}, states = {}, reportLineItemDefinitions = {})", + "entry to getCategoryReport(workbaskets = {}, states = {}, reportLineItemDefinitions = {}," + + " inWorkingDays = {})", LoggerUtils.listToString(workbaskets), LoggerUtils.listToString(states), - LoggerUtils.listToString(reportLineItemDefinitions)); + LoggerUtils.listToString(reportLineItemDefinitions), inWorkingDays); } try { taskanaEngineImpl.openConnection(); + Report report = new Report(); List monitorQueryItems = taskMonitorMapper .getTaskCountOfCategoriesByWorkbasketsAndStates(workbaskets, states); - - return createReport(reportLineItemDefinitions, inWorkingDays, monitorQueryItems); + report.addMonitoringQueryItems(monitorQueryItems, reportLineItemDefinitions, inWorkingDays); + return report; } finally { taskanaEngineImpl.returnConnection(); @@ -96,32 +100,34 @@ public class TaskMonitorServiceImpl implements TaskMonitorService { } @Override - public Report getClassificationReport(List workbaskets, List states) { + public ClassificationReport getClassificationReport(List workbaskets, List states) { return getClassificationReport(workbaskets, states, null, false); } @Override - public Report getClassificationReport(List workbaskets, List states, + public ClassificationReport getClassificationReport(List workbaskets, List states, List reportLineItemDefinitions) { return getClassificationReport(workbaskets, states, reportLineItemDefinitions, true); } @Override - public Report getClassificationReport(List workbaskets, List states, + public ClassificationReport getClassificationReport(List workbaskets, List states, List reportLineItemDefinitions, boolean inWorkingDays) { if (LOGGER.isDebugEnabled()) { LOGGER.debug( - "entry to getClassificationReport(workbaskets = {}, states = {}, reportLineItemDefinitions = {})", + "entry to getClassificationReport(workbaskets = {}, states = {}, reportLineItemDefinitions = {}," + + " inWorkingDays = {})", LoggerUtils.listToString(workbaskets), LoggerUtils.listToString(states), - LoggerUtils.listToString(reportLineItemDefinitions)); + LoggerUtils.listToString(reportLineItemDefinitions), inWorkingDays); } try { taskanaEngineImpl.openConnection(); + ClassificationReport report = new ClassificationReport(); List monitorQueryItems = taskMonitorMapper .getTaskCountOfClassificationsByWorkbasketsAndStates(workbaskets, states); - - return createReport(reportLineItemDefinitions, inWorkingDays, monitorQueryItems); + report.addMonitoringQueryItems(monitorQueryItems, reportLineItemDefinitions, inWorkingDays); + return report; } finally { taskanaEngineImpl.returnConnection(); @@ -129,6 +135,45 @@ public class TaskMonitorServiceImpl implements TaskMonitorService { } } + @Override + public DetailedClassificationReport getDetailedClassificationReport(List workbaskets, + List states) { + return getDetailedClassificationReport(workbaskets, states, null, false); + } + + @Override + public DetailedClassificationReport getDetailedClassificationReport(List workbaskets, + List states, List reportLineItemDefinitions) { + return getDetailedClassificationReport(workbaskets, states, reportLineItemDefinitions, true); + } + + @Override + public DetailedClassificationReport getDetailedClassificationReport(List workbaskets, + List states, List reportLineItemDefinitions, boolean inWorkingDays) { + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug( + "entry to getDetailedClassificationReport(workbaskets = {}, states = {}, customField = {}, " + + "reportLineItemDefinitions = {}, inWorkingDays = {})", + LoggerUtils.listToString(workbaskets), LoggerUtils.listToString(states), + LoggerUtils.listToString(reportLineItemDefinitions), inWorkingDays); + } + try { + taskanaEngineImpl.openConnection(); + + DetailedClassificationReport report = new DetailedClassificationReport(); + List detailedMonitorQueryItems = taskMonitorMapper + .getTaskCountOfDetailedClassificationsByWorkbasketsAndStates(workbaskets, states); + report.addDetailedMonitoringQueryItems(detailedMonitorQueryItems, reportLineItemDefinitions, + inWorkingDays); + return report; + + } finally { + taskanaEngineImpl.returnConnection(); + LOGGER.debug("exit from getDetailedClassificationReport()."); + } + } + @Override public Report getCustomFieldValueReport(List workbaskets, List states, CustomField customField) { @@ -146,17 +191,19 @@ public class TaskMonitorServiceImpl implements TaskMonitorService { CustomField customField, List reportLineItemDefinitions, boolean inWorkingDays) { if (LOGGER.isDebugEnabled()) { LOGGER.debug( - "entry to getCustomFieldValueReport(workbaskets = {}, states = {}, customField = {}, reportLineItemDefinitions = {})", + "entry to getCustomFieldValueReport(workbaskets = {}, states = {}, customField = {}, " + + "reportLineItemDefinitions = {}, inWorkingDays = {})", LoggerUtils.listToString(workbaskets), LoggerUtils.listToString(states), customField, - LoggerUtils.listToString(reportLineItemDefinitions)); + LoggerUtils.listToString(reportLineItemDefinitions), inWorkingDays); } try { taskanaEngineImpl.openConnection(); + Report report = new Report(); List monitorQueryItems = taskMonitorMapper .getTaskCountOfCustomFieldValuesByWorkbasketsAndStatesAndCustomField(workbaskets, states, customField); - - return createReport(reportLineItemDefinitions, inWorkingDays, monitorQueryItems); + report.addMonitoringQueryItems(monitorQueryItems, reportLineItemDefinitions, inWorkingDays); + return report; } finally { taskanaEngineImpl.returnConnection(); @@ -164,39 +211,4 @@ public class TaskMonitorServiceImpl implements TaskMonitorService { } } - private Report createReport(List reportLineItemDefinitions, boolean inWorkingDays, - List monitorQueryItems) { - Report report = new Report(); - - DaysToWorkingDaysConverter instance = null; - if (reportLineItemDefinitions != null && inWorkingDays) { - instance = DaysToWorkingDaysConverter.initialize(reportLineItemDefinitions); - } - - for (MonitorQueryItem item : monitorQueryItems) { - if (instance != null) { - item.setAgeInDays(instance.convertDaysToWorkingDays(item.getAgeInDays())); - } - if (!report.getDetailLines().containsKey(item.getKey())) { - report.getDetailLines().put(item.getKey(), createEmptyReportLine(reportLineItemDefinitions)); - } - report.getDetailLines().get(item.getKey()).addNumberOfTasks(item); - } - - report.generateSumLine(createEmptyReportLine(reportLineItemDefinitions)); - return report; - } - - private ReportLine createEmptyReportLine(List reportLineItemDefinitions) { - ReportLine reportLine = new ReportLine(); - if (reportLineItemDefinitions != null) { - for (ReportLineItemDefinition reportLineItemDefinition : reportLineItemDefinitions) { - ReportLineItem reportLineItem = new ReportLineItem(); - reportLineItem.setReportLineItemDefinition(reportLineItemDefinition); - reportLine.getLineItems().add(reportLineItem); - } - } - return reportLine; - } - } 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 93871dfe1..1bbf80d86 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 @@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Select; import pro.taskana.Workbasket; import pro.taskana.impl.CustomField; +import pro.taskana.impl.DetailedMonitorQueryItem; import pro.taskana.impl.MonitorQueryItem; import pro.taskana.impl.TaskState; @@ -71,6 +72,25 @@ public interface TaskMonitorMapper { @Param("workbaskets") List workbaskets, @Param("states") List states); + @Select("") + @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") }) + List getTaskCountOfDetailedClassificationsByWorkbasketsAndStates( + @Param("workbaskets") List workbaskets, + @Param("states") List states); + @Select("