TSK-265: Added support for getting task ids for classification report.
This commit is contained in:
parent
2a6fe0ef77
commit
7b31734e24
|
@ -13,5 +13,11 @@ public enum CustomField {
|
|||
CUSTOM_7,
|
||||
CUSTOM_8,
|
||||
CUSTOM_9,
|
||||
CUSTOM_10
|
||||
CUSTOM_10,
|
||||
CUSTOM_11,
|
||||
CUSTOM_12,
|
||||
CUSTOM_13,
|
||||
CUSTOM_14,
|
||||
CUSTOM_15,
|
||||
CUSTOM_16
|
||||
}
|
||||
|
|
|
@ -18,6 +18,10 @@ import pro.taskana.impl.report.impl.WorkbasketLevelReport;
|
|||
*/
|
||||
public interface TaskMonitorService {
|
||||
|
||||
String DIMENSION_CLASSIFICATION_CATEGORY = "CLASSIFICATION_CATEGORY";
|
||||
String DIMENSION_CLASSIFICATION_KEY = "CLASSIFICATION_KEY";
|
||||
String DIMENSION_WORKBASKET_KEY = "WORKBASKET_KEY";
|
||||
|
||||
/**
|
||||
* Returns a {@link WorkbasketLevelReport} grouped by workbaskets. The report contains the total numbers of tasks of
|
||||
* the respective workbasket as well as the total number of all tasks. If no filter is required, the respective
|
||||
|
@ -128,46 +132,6 @@ public interface TaskMonitorService {
|
|||
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays)
|
||||
throws InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a list of all task ids in the selected items of a {@link pro.taskana.impl.report.Report}. By default the
|
||||
* age of the tasks is counted in working days. The tasks of the report are filtered by workbaskets, states,
|
||||
* categories, domains and values of a custom field. If no filter is required, the respective parameter should be
|
||||
* null. Tasks with Timestamp DUE = null are not considered.
|
||||
*
|
||||
* @param workbasketIds
|
||||
* a list of workbasket ids objects to filter by workbaskets. To omit this filter, use null for this
|
||||
* parameter
|
||||
* @param states
|
||||
* a list of states objects to filter by states. To omit this filter, use null for this parameter
|
||||
* @param categories
|
||||
* a list of categories to filter by categories. To omit this filter, use null for this parameter
|
||||
* @param domains
|
||||
* a list of domains to filter by domains. To omit this filter, use null for this parameter
|
||||
* @param customField
|
||||
* a custom field to filter by the values of the custom field. To omit this filter, use null for this
|
||||
* parameter
|
||||
* @param customFieldValues
|
||||
* a list of custom field values to filter by the values of the custom field. To omit this filter, use
|
||||
* null for this parameter
|
||||
* @param columnHeaders
|
||||
* a list of columnHeaders 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 columnHeaders should not
|
||||
* overlap and should not have gaps. If the ReportLineDefinition should represent a single day,
|
||||
* lowerLimit and upperLimit have to be equal. The outer cluster of a report should have open ends. These
|
||||
* open ends are represented with Integer.MIN_VALUE and Integer.MAX_VALUE.
|
||||
* @param inWorkingDays
|
||||
* a boolean parameter that specifies whether the age of the tasks should be counted in days or in
|
||||
* working days
|
||||
* @return the report
|
||||
* @throws InvalidArgumentException
|
||||
* thrown if DaysToWorkingDaysConverter is initialized with null
|
||||
*/
|
||||
List<String> getTaskIdsOfWorkbasketLevelReportLineItems(List<String> workbasketIds, List<TaskState> states,
|
||||
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
|
||||
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays, List<SelectedItem> selectedItems)
|
||||
throws InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a {@link CategoryReport} grouped by categories. The report contains the total numbers of tasks of the
|
||||
* respective category as well as the total number of all tasks. The tasks of the report are filtered by
|
||||
|
@ -623,45 +587,10 @@ public interface TaskMonitorService {
|
|||
* a list of categories to filter by categories. To omit this filter, use null for this parameter
|
||||
* @param domains
|
||||
* a list of domains to filter by domains. To omit this filter, use null for this parameter
|
||||
* @param customField
|
||||
* a custom field to filter by the values of the custom field. To omit this filter, use null for this
|
||||
* parameter
|
||||
* @param customFieldValues
|
||||
* a list of custom field values to filter by the values of the custom field. To omit this filter, use
|
||||
* null for this parameter
|
||||
* @param columnHeaders
|
||||
* a list of columnHeaders 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 columnHeaders should not
|
||||
* overlap and should not have gaps. If the ReportLineDefinition should represent a single day,
|
||||
* lowerLimit and upperLimit have to be equal. The outer cluster of a report should have open ends. These
|
||||
* open ends are represented with Integer.MIN_VALUE and Integer.MAX_VALUE.
|
||||
* @param selectedItems
|
||||
* a list of {@link SelectedItem}s that are selected from the report whose task ids should be determined.
|
||||
* @return the list of task ids
|
||||
* @throws InvalidArgumentException
|
||||
* thrown if columnHeaders is null or if selectedItems is empty or null
|
||||
*/
|
||||
List<String> getTaskIdsOfCategoryReportLineItems(List<String> workbasketIds, List<TaskState> states,
|
||||
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
|
||||
List<TimeIntervalColumnHeader> columnHeaders, List<SelectedItem> selectedItems)
|
||||
throws InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a list of all task ids in the selected items of a {@link pro.taskana.impl.report.Report}. By default the
|
||||
* age of the tasks is counted in working days. The tasks of the report are filtered by workbaskets, states,
|
||||
* categories, domains and values of a custom field. If no filter is required, the respective parameter should be
|
||||
* null. Tasks with Timestamp DUE = null are not considered.
|
||||
*
|
||||
* @param workbasketIds
|
||||
* a list of workbasket ids objects to filter by workbaskets. To omit this filter, use null for this
|
||||
* parameter
|
||||
* @param states
|
||||
* a list of states objects to filter by states. To omit this filter, use null for this parameter
|
||||
* @param categories
|
||||
* a list of categories to filter by categories. To omit this filter, use null for this parameter
|
||||
* @param domains
|
||||
* a list of domains to filter by domains. To omit this filter, use null for this parameter
|
||||
* @param classificationKeys
|
||||
* a list of task classification key to filter. To omit this filter, use null for this parameter
|
||||
* @param excludedClassificationKeys
|
||||
* a list of task classification key to exclude. To omit this filter, use null for this parameter
|
||||
* @param customField
|
||||
* a custom field to filter by the values of the custom field. To omit this filter, use null for this
|
||||
* parameter
|
||||
|
@ -680,14 +609,18 @@ public interface TaskMonitorService {
|
|||
* working days
|
||||
* @param selectedItems
|
||||
* a list of {@link SelectedItem}s that are selected from the report whose task ids should be determined.
|
||||
* @param dimension
|
||||
* defines the meaning of the key in the {@link SelectedItem}s.
|
||||
* @return the list of task ids
|
||||
* @throws InvalidArgumentException
|
||||
* thrown if columnHeaders is null or if selectedItems is empty or null
|
||||
*/
|
||||
List<String> getTaskIdsOfCategoryReportLineItems(List<String> workbasketIds, List<TaskState> states,
|
||||
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
|
||||
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays,
|
||||
List<SelectedItem> selectedItems) throws InvalidArgumentException;
|
||||
List<String> getTaskIdsForSelectedItems(List<String> workbasketIds, List<TaskState> states, List<String> categories,
|
||||
List<String> domains, List<String> classificationKeys,
|
||||
List<String> excludedClassificationKeys, CustomField customField, List<String> customFieldValues,
|
||||
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays, List<SelectedItem> selectedItems,
|
||||
String dimension)
|
||||
throws InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Returns a list of distinct custom attribute values for the selection from the entire task pool.
|
||||
|
|
|
@ -7,6 +7,7 @@ package pro.taskana.impl;
|
|||
public class SelectedItem {
|
||||
|
||||
private String key;
|
||||
private String subKey;
|
||||
private int upperAgeLimit;
|
||||
private int lowerAgeLimit;
|
||||
|
||||
|
@ -18,6 +19,14 @@ public class SelectedItem {
|
|||
this.key = key;
|
||||
}
|
||||
|
||||
public String getSubKey() {
|
||||
return subKey;
|
||||
}
|
||||
|
||||
public void setSubKey(String subKey) {
|
||||
this.subKey = subKey;
|
||||
}
|
||||
|
||||
public int getUpperAgeLimit() {
|
||||
return upperAgeLimit;
|
||||
}
|
||||
|
@ -36,7 +45,8 @@ public class SelectedItem {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Key: " + this.key + ", Limits: (" + this.lowerAgeLimit + "," + this.getUpperAgeLimit() + ")";
|
||||
return "Key: " + this.key + ", SubKey: " + this.subKey + ", Limits: (" + this.lowerAgeLimit + ","
|
||||
+ this.getUpperAgeLimit() + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -288,60 +288,6 @@ public class TaskMonitorServiceImpl implements TaskMonitorService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTaskIdsOfCategoryReportLineItems(List<String> workbasketIds, List<TaskState> states,
|
||||
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
|
||||
List<TimeIntervalColumnHeader> columnHeaders, List<SelectedItem> selectedItems)
|
||||
throws InvalidArgumentException {
|
||||
return getTaskIdsOfCategoryReportLineItems(workbasketIds, states, categories, domains, customField,
|
||||
customFieldValues, columnHeaders, true, selectedItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTaskIdsOfCategoryReportLineItems(List<String> workbasketIds, List<TaskState> states,
|
||||
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
|
||||
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays,
|
||||
List<SelectedItem> selectedItems) throws InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("entry to getTaskIdsOfCategoryReportLineItems(workbasketIds = {}, states = {}, "
|
||||
+ "categories = {}, domains = {}, customField = {}, customFieldValues = {}, "
|
||||
+ "columnHeaders = {}, inWorkingDays = {}, selectedItems = {})",
|
||||
LoggerUtils.listToString(workbasketIds), LoggerUtils.listToString(states),
|
||||
LoggerUtils.listToString(categories), LoggerUtils.listToString(domains), customField,
|
||||
LoggerUtils.listToString(customFieldValues), LoggerUtils.listToString(columnHeaders),
|
||||
inWorkingDays, LoggerUtils.listToString(selectedItems));
|
||||
}
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
|
||||
if (columnHeaders == null) {
|
||||
throw new InvalidArgumentException("ReportLineItemDefinitions can´t be used as NULL-Parameter");
|
||||
}
|
||||
if (selectedItems == null || selectedItems.size() == 0) {
|
||||
throw new InvalidArgumentException(
|
||||
"SelectedItems can´t be used as NULL-Parameter and should not be empty");
|
||||
}
|
||||
|
||||
configureDaysToWorkingDaysConverter();
|
||||
|
||||
if (inWorkingDays) {
|
||||
selectedItems = convertWorkingDaysToDays(selectedItems, columnHeaders);
|
||||
}
|
||||
|
||||
// List<String> taskIds = taskMonitorMapper.getTaskIdsOfCategoriesBySelectedItems(workbasketIds, states,
|
||||
// categories, domains, customField, customFieldValues, selectedItems);
|
||||
|
||||
List<String> taskIds = taskMonitorMapper.getTaskIdsForSelectedItems(workbasketIds, states,
|
||||
categories, domains, customField, customFieldValues, "CLASSIFICATION_CATEGORY", selectedItems);
|
||||
|
||||
return taskIds;
|
||||
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
LOGGER.debug("exit from getTaskIdsOfCategoryReportLineItems().");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCustomAttributeValuesForReport(List<String> workbasketIds, List<TaskState> states,
|
||||
List<String> categories, List<String> domains, List<String> classificationIds,
|
||||
|
@ -376,27 +322,34 @@ public class TaskMonitorServiceImpl implements TaskMonitorService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTaskIdsOfWorkbasketLevelReportLineItems(List<String> workbasketIds, List<TaskState> states,
|
||||
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
|
||||
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays, List<SelectedItem> selectedItems)
|
||||
throws InvalidArgumentException {
|
||||
public List<String> getTaskIdsForSelectedItems(List<String> workbasketIds, List<TaskState> states,
|
||||
List<String> categories, List<String> domains, List<String> classificationIds,
|
||||
List<String> excludedClassificationIds, CustomField customField, List<String> customFieldValues,
|
||||
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays,
|
||||
List<SelectedItem> selectedItems, String dimension) throws InvalidArgumentException {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("entry to getTaskIdsOfWorkbasketLevelReportLineItems(workbasketIds = {}, states = {}, "
|
||||
LOGGER.debug("entry to getTaskIdsForSelectedItems(workbasketIds = {}, states = {}, "
|
||||
+ "categories = {}, domains = {}, customField = {}, customFieldValues = {}, "
|
||||
+ "columnHeaders = {}, inWorkingDays = {}, selectedItems = {})",
|
||||
+ "columnHeaders = {}, inWorkingDays = {}, selectedItems = {}, dimension = {})",
|
||||
LoggerUtils.listToString(workbasketIds), LoggerUtils.listToString(states),
|
||||
LoggerUtils.listToString(categories), LoggerUtils.listToString(domains), customField,
|
||||
LoggerUtils.listToString(categories), LoggerUtils.listToString(domains),
|
||||
LoggerUtils.listToString(classificationIds), LoggerUtils.listToString(excludedClassificationIds),
|
||||
customField,
|
||||
LoggerUtils.listToString(customFieldValues), LoggerUtils.listToString(columnHeaders),
|
||||
inWorkingDays, LoggerUtils.listToString(selectedItems));
|
||||
inWorkingDays, LoggerUtils.listToString(selectedItems), dimension);
|
||||
}
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
if (columnHeaders == null) {
|
||||
throw new InvalidArgumentException("ReportLineItemDefinitions can´t be used as NULL-Parameter");
|
||||
throw new InvalidArgumentException("ColumnHeader must not be null.");
|
||||
}
|
||||
if (selectedItems == null || selectedItems.size() == 0) {
|
||||
throw new InvalidArgumentException(
|
||||
"SelectedItems can´t be used as NULL-Parameter and should not be empty");
|
||||
"SelectedItems must not be null or empty.");
|
||||
}
|
||||
boolean joinWithAttachments = subKeyIsSet(selectedItems);
|
||||
if (joinWithAttachments && !TaskMonitorService.DIMENSION_CLASSIFICATION_KEY.equals(dimension)) {
|
||||
throw new InvalidArgumentException("SubKeys are supported for dimension CLASSIFICATION_KEY only.");
|
||||
}
|
||||
|
||||
configureDaysToWorkingDaysConverter();
|
||||
|
@ -405,18 +358,15 @@ public class TaskMonitorServiceImpl implements TaskMonitorService {
|
|||
selectedItems = convertWorkingDaysToDays(selectedItems, columnHeaders);
|
||||
}
|
||||
|
||||
// List<String> taskIds = taskMonitorMapper.getTaskIdsOfWorkbasketLevelBySelectedItems(workbasketIds,
|
||||
// states,
|
||||
// categories, domains, customField, customFieldValues, selectedItems);
|
||||
|
||||
List<String> taskIds = taskMonitorMapper.getTaskIdsForSelectedItems(workbasketIds, states,
|
||||
categories, domains, customField, customFieldValues, "WORKBASKET_KEY", selectedItems);
|
||||
categories, domains, classificationIds, excludedClassificationIds, customField, customFieldValues,
|
||||
dimension, selectedItems, joinWithAttachments);
|
||||
|
||||
return taskIds;
|
||||
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
LOGGER.debug("exit from getTaskIdsOfWorkbasketLevelReportLineItems().");
|
||||
LOGGER.debug("exit from getTaskIdsForSelectedItems().");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,4 +414,13 @@ public class TaskMonitorServiceImpl implements TaskMonitorService {
|
|||
this.taskanaEngineImpl.getConfiguration().isGermanPublicHolidaysEnabled());
|
||||
}
|
||||
|
||||
private boolean subKeyIsSet(List<SelectedItem> selectedItems) {
|
||||
for (SelectedItem selectedItem : selectedItems) {
|
||||
if (selectedItem.getSubKey() != null && !selectedItem.getSubKey().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -208,26 +208,38 @@ public interface TaskMonitorMapper {
|
|||
@Param("customFieldValues") List<String> customFieldValues);
|
||||
|
||||
@Select("<script>"
|
||||
+ "SELECT ID FROM TASKANA.TASK "
|
||||
+ "SELECT TASK.ID FROM TASKANA.TASK "
|
||||
+ "<if test=\"joinWithAttachments\">"
|
||||
+ "LEFT JOIN TASKANA.ATTACHMENT ON TASK.ID = ATTACHMENT.TASK_ID "
|
||||
+ "</if>"
|
||||
+ "<where>"
|
||||
+ "<if test=\"workbasketIds != null\">"
|
||||
+ "WORKBASKET_ID IN (<foreach collection='workbasketIds' item='workbasketId' separator=','>#{workbasketId}</foreach>) "
|
||||
+ "TASK.WORKBASKET_ID IN (<foreach collection='workbasketIds' item='workbasketId' separator=','>#{workbasketId}</foreach>) "
|
||||
+ "</if>"
|
||||
+ "<if test=\"states != null\">"
|
||||
+ "AND STATE IN (<foreach collection='states' item='state' separator=','>#{state}</foreach>) "
|
||||
+ "AND TASK.STATE IN (<foreach collection='states' item='state' separator=','>#{state}</foreach>) "
|
||||
+ "</if>"
|
||||
+ "<if test=\"categories != null\">"
|
||||
+ "AND CLASSIFICATION_CATEGORY IN (<foreach collection='categories' item='category' separator=','>#{category}</foreach>) "
|
||||
+ "AND TASK.CLASSIFICATION_CATEGORY IN (<foreach collection='categories' item='category' separator=','>#{category}</foreach>) "
|
||||
+ "</if>"
|
||||
+ "<if test=\"domains != null\">"
|
||||
+ "AND DOMAIN IN (<foreach collection='domains' item='domain' separator=','>#{domain}</foreach>) "
|
||||
+ "</if>"
|
||||
+ "<if test=\"customField != null and customFieldValues != null\">"
|
||||
+ "AND ${customField} IN (<foreach collection='customFieldValues' item='customFieldValue' separator=','>#{customFieldValue}</foreach>) "
|
||||
+ "<if test='classificationIds != null'>"
|
||||
+ "AND TASK.CLASSIFICATION_ID IN (<foreach collection='classificationIds' item='classificationId' separator=','>#{classificationId}</foreach>) "
|
||||
+ "</if>"
|
||||
+ "AND DUE IS NOT NULL AND ( "
|
||||
+ "<if test='excludedClassificationIds != null'>"
|
||||
+ "AND TASK.CLASSIFICATION_ID NOT IN (<foreach collection='excludedClassificationIds' item='excludedClassificationId' separator=','>#{excludedClassificationId}</foreach>) "
|
||||
+ "</if>"
|
||||
+ "<if test=\"customField != null and customFieldValues != null\">"
|
||||
+ "AND TASK.${customField} IN (<foreach collection='customFieldValues' item='customFieldValue' separator=','>#{customFieldValue}</foreach>) "
|
||||
+ "</if>"
|
||||
+ "AND TASK.DUE IS NOT NULL AND ( "
|
||||
+ "<foreach collection='selectedItems' item='selectedItem' separator=' OR '>"
|
||||
+ "#{selectedItem.key} = ${groupedBy} AND "
|
||||
+ "#{selectedItem.key} = TASK.${groupedBy} AND "
|
||||
+ "<if test=\"joinWithAttachments\">"
|
||||
+ "ATTACHMENT.CLASSIFICATION_KEY = #{selectedItem.subKey} AND "
|
||||
+ "</if>"
|
||||
+ "<if test=\"_databaseId == 'db2'\">"
|
||||
+ "#{selectedItem.upperAgeLimit} >= (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) AND "
|
||||
+ "#{selectedItem.lowerAgeLimit} <= (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) "
|
||||
|
@ -243,8 +255,11 @@ public interface TaskMonitorMapper {
|
|||
List<String> getTaskIdsForSelectedItems(@Param("workbasketIds") List<String> workbasketIds,
|
||||
@Param("states") List<TaskState> states,
|
||||
@Param("categories") List<String> categories, @Param("domains") List<String> domains,
|
||||
@Param("classificationIds") List<String> classificationIds,
|
||||
@Param("excludedClassificationIds") List<String> excludedClassificationIds,
|
||||
@Param("customField") CustomField customField, @Param("customFieldValues") List<String> customFieldValues,
|
||||
@Param("groupedBy") String groupedBy, @Param("selectedItems") List<SelectedItem> selectedItems);
|
||||
@Param("groupedBy") String groupedBy, @Param("selectedItems") List<SelectedItem> selectedItems,
|
||||
@Param("joinWithAttachments") boolean joinWithAttachments);
|
||||
|
||||
@Select("<script>"
|
||||
+ "SELECT DOMAIN, STATE, COUNT(STATE) as COUNT "
|
||||
|
|
|
@ -82,8 +82,9 @@ public class GetTaskIdsOfCategoryReportAccTest {
|
|||
s3.setUpperAgeLimit(0);
|
||||
selectedItems.add(s3);
|
||||
|
||||
List<String> ids = taskMonitorService.getTaskIdsOfCategoryReportLineItems(null, null, null, null, null, null,
|
||||
columnHeaders, selectedItems);
|
||||
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null,
|
||||
null, null, null,
|
||||
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY);
|
||||
|
||||
assertEquals(11, ids.size());
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
|
||||
|
@ -126,8 +127,9 @@ public class GetTaskIdsOfCategoryReportAccTest {
|
|||
s3.setUpperAgeLimit(0);
|
||||
selectedItems.add(s3);
|
||||
|
||||
List<String> ids = taskMonitorService.getTaskIdsOfCategoryReportLineItems(workbasketIds, null, null, null, null,
|
||||
null, columnHeaders, selectedItems);
|
||||
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(workbasketIds, null, null, null, null,
|
||||
null, null, null,
|
||||
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY);
|
||||
|
||||
assertEquals(4, ids.size());
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
|
||||
|
@ -163,8 +165,9 @@ public class GetTaskIdsOfCategoryReportAccTest {
|
|||
s3.setUpperAgeLimit(0);
|
||||
selectedItems.add(s3);
|
||||
|
||||
List<String> ids = taskMonitorService.getTaskIdsOfCategoryReportLineItems(null, states, null, null, null, null,
|
||||
columnHeaders, selectedItems);
|
||||
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, states, null, null, null,
|
||||
null, null, null,
|
||||
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY);
|
||||
|
||||
assertEquals(11, ids.size());
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
|
||||
|
@ -201,8 +204,9 @@ public class GetTaskIdsOfCategoryReportAccTest {
|
|||
s2.setUpperAgeLimit(0);
|
||||
selectedItems.add(s2);
|
||||
|
||||
List<String> ids = taskMonitorService.getTaskIdsOfCategoryReportLineItems(null, null, categories, null, null,
|
||||
null, columnHeaders, selectedItems);
|
||||
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, categories, null, null,
|
||||
null, null, null,
|
||||
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY);
|
||||
|
||||
assertEquals(3, ids.size());
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
|
||||
|
@ -237,8 +241,9 @@ public class GetTaskIdsOfCategoryReportAccTest {
|
|||
s3.setUpperAgeLimit(0);
|
||||
selectedItems.add(s3);
|
||||
|
||||
List<String> ids = taskMonitorService.getTaskIdsOfCategoryReportLineItems(null, null, null, domains, null, null,
|
||||
columnHeaders, selectedItems);
|
||||
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, domains, null,
|
||||
null, null, null,
|
||||
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY);
|
||||
|
||||
assertEquals(4, ids.size());
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000020"));
|
||||
|
@ -275,8 +280,10 @@ public class GetTaskIdsOfCategoryReportAccTest {
|
|||
s3.setUpperAgeLimit(0);
|
||||
selectedItems.add(s3);
|
||||
|
||||
List<String> ids = taskMonitorService.getTaskIdsOfCategoryReportLineItems(null, null, null, null, customField,
|
||||
customFieldValues, columnHeaders, selectedItems);
|
||||
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null, null,
|
||||
customField,
|
||||
customFieldValues,
|
||||
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY);
|
||||
|
||||
assertEquals(5, ids.size());
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000020"));
|
||||
|
@ -286,6 +293,26 @@ public class GetTaskIdsOfCategoryReportAccTest {
|
|||
assertTrue(ids.contains("TKI:000000000000000000000000000000000032"));
|
||||
}
|
||||
|
||||
@Test(expected = InvalidArgumentException.class)
|
||||
public void testThrowsExceptionIfSubKeysAreUsed() throws InvalidArgumentException {
|
||||
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
|
||||
|
||||
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
|
||||
|
||||
List<SelectedItem> selectedItems = new ArrayList<>();
|
||||
|
||||
SelectedItem s1 = new SelectedItem();
|
||||
s1.setKey("EXTERN");
|
||||
s1.setSubKey("INVALID");
|
||||
s1.setLowerAgeLimit(-5);
|
||||
s1.setUpperAgeLimit(-2);
|
||||
selectedItems.add(s1);
|
||||
|
||||
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null,
|
||||
null, null, null,
|
||||
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY);
|
||||
}
|
||||
|
||||
private List<TimeIntervalColumnHeader> getListOfColumnHeaders() {
|
||||
List<TimeIntervalColumnHeader> columnHeaders = new ArrayList<>();
|
||||
columnHeaders.add(new TimeIntervalColumnHeader(Integer.MIN_VALUE, -11));
|
||||
|
|
|
@ -0,0 +1,185 @@
|
|||
package acceptance.monitoring;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import pro.taskana.TaskMonitorService;
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.database.TestDataGenerator;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.impl.SelectedItem;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
import pro.taskana.impl.configuration.DBCleaner;
|
||||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
|
||||
|
||||
/**
|
||||
* Acceptance test for all "get task ids of classification report" scenarios.
|
||||
*/
|
||||
public class GetTaskIdsOfClassificationReportAccTest {
|
||||
|
||||
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
protected static TaskanaEngine taskanaEngine;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupTest() throws Exception {
|
||||
resetDb();
|
||||
}
|
||||
|
||||
public static void resetDb() throws SQLException, IOException {
|
||||
DataSource dataSource = TaskanaEngineConfigurationTest.getDataSource();
|
||||
DBCleaner cleaner = new DBCleaner();
|
||||
cleaner.clearDb(dataSource, true);
|
||||
dataSource = TaskanaEngineConfigurationTest.getDataSource();
|
||||
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
|
||||
taskanaEngineConfiguration.setGermanPublicHolidaysEnabled(false);
|
||||
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
((TaskanaEngineImpl) taskanaEngine).setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
|
||||
cleaner.clearDb(dataSource, false);
|
||||
TestDataGenerator testDataGenerator = new TestDataGenerator();
|
||||
testDataGenerator.generateMonitoringTestData(dataSource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskIdsOfClassificationReport() throws InvalidArgumentException {
|
||||
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
|
||||
|
||||
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
|
||||
|
||||
List<SelectedItem> selectedItems = new ArrayList<>();
|
||||
|
||||
SelectedItem s1 = new SelectedItem();
|
||||
s1.setKey("L10000");
|
||||
s1.setLowerAgeLimit(0);
|
||||
s1.setUpperAgeLimit(0);
|
||||
selectedItems.add(s1);
|
||||
|
||||
SelectedItem s2 = new SelectedItem();
|
||||
s2.setKey("L10000");
|
||||
s2.setLowerAgeLimit(Integer.MIN_VALUE);
|
||||
s2.setUpperAgeLimit(-11);
|
||||
selectedItems.add(s2);
|
||||
|
||||
SelectedItem s3 = new SelectedItem();
|
||||
s3.setKey("L30000");
|
||||
s3.setLowerAgeLimit(Integer.MIN_VALUE);
|
||||
s3.setUpperAgeLimit(-11);
|
||||
selectedItems.add(s3);
|
||||
|
||||
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null,
|
||||
null, null, null,
|
||||
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_KEY);
|
||||
|
||||
assertEquals(6, ids.size());
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000001"));
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000004"));
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000007"));
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000010"));
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000033"));
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskIdsOfClassificationReportWithAttachments() throws InvalidArgumentException {
|
||||
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
|
||||
|
||||
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
|
||||
|
||||
List<SelectedItem> selectedItems = new ArrayList<>();
|
||||
|
||||
SelectedItem s1 = new SelectedItem();
|
||||
s1.setKey("L10000");
|
||||
s1.setSubKey("L11000");
|
||||
s1.setLowerAgeLimit(0);
|
||||
s1.setUpperAgeLimit(0);
|
||||
selectedItems.add(s1);
|
||||
|
||||
SelectedItem s2 = new SelectedItem();
|
||||
s2.setKey("L10000");
|
||||
s2.setSubKey("L11000");
|
||||
s2.setLowerAgeLimit(Integer.MIN_VALUE);
|
||||
s2.setUpperAgeLimit(-11);
|
||||
selectedItems.add(s2);
|
||||
|
||||
SelectedItem s3 = new SelectedItem();
|
||||
s3.setKey("L30000");
|
||||
s3.setLowerAgeLimit(Integer.MIN_VALUE);
|
||||
s3.setUpperAgeLimit(-11);
|
||||
selectedItems.add(s3);
|
||||
|
||||
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null,
|
||||
null, null, null,
|
||||
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_KEY);
|
||||
|
||||
assertEquals(2, ids.size());
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000001"));
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000033"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskIdsOfClassificationReportWithDomainFilter() throws InvalidArgumentException {
|
||||
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
|
||||
|
||||
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
|
||||
|
||||
List<SelectedItem> selectedItems = new ArrayList<>();
|
||||
|
||||
SelectedItem s1 = new SelectedItem();
|
||||
s1.setKey("L10000");
|
||||
s1.setLowerAgeLimit(0);
|
||||
s1.setUpperAgeLimit(0);
|
||||
selectedItems.add(s1);
|
||||
|
||||
SelectedItem s2 = new SelectedItem();
|
||||
s2.setKey("L10000");
|
||||
s2.setLowerAgeLimit(Integer.MIN_VALUE);
|
||||
s2.setUpperAgeLimit(-11);
|
||||
selectedItems.add(s2);
|
||||
|
||||
SelectedItem s3 = new SelectedItem();
|
||||
s3.setKey("L30000");
|
||||
s3.setLowerAgeLimit(Integer.MIN_VALUE);
|
||||
s3.setUpperAgeLimit(-11);
|
||||
selectedItems.add(s3);
|
||||
|
||||
List<String> domains = new ArrayList<>();
|
||||
domains.add("DOMAIN_B");
|
||||
domains.add("DOMAIN_C");
|
||||
|
||||
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, domains, null,
|
||||
null, null, null,
|
||||
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_KEY);
|
||||
|
||||
assertEquals(3, ids.size());
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000001"));
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000004"));
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
|
||||
}
|
||||
|
||||
private List<TimeIntervalColumnHeader> getListOfColumnHeaders() {
|
||||
List<TimeIntervalColumnHeader> columnHeaders = new ArrayList<>();
|
||||
columnHeaders.add(new TimeIntervalColumnHeader(Integer.MIN_VALUE, -11));
|
||||
columnHeaders.add(new TimeIntervalColumnHeader(-10, -6));
|
||||
columnHeaders.add(new TimeIntervalColumnHeader(-5, -2));
|
||||
columnHeaders.add(new TimeIntervalColumnHeader(-1));
|
||||
columnHeaders.add(new TimeIntervalColumnHeader(0));
|
||||
columnHeaders.add(new TimeIntervalColumnHeader(1));
|
||||
columnHeaders.add(new TimeIntervalColumnHeader(2, 5));
|
||||
columnHeaders.add(new TimeIntervalColumnHeader(6, 10));
|
||||
columnHeaders.add(new TimeIntervalColumnHeader(11, Integer.MAX_VALUE));
|
||||
return columnHeaders;
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
@ -78,9 +79,9 @@ public class GetTaskIdsOfWorkbasketReportAccTest {
|
|||
s3.setUpperAgeLimit(Integer.MAX_VALUE);
|
||||
selectedItems.add(s3);
|
||||
|
||||
List<String> ids = taskMonitorService.getTaskIdsOfWorkbasketLevelReportLineItems(null, null, null, null, null,
|
||||
null,
|
||||
columnHeaders, true, selectedItems);
|
||||
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null,
|
||||
null, null, null,
|
||||
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_WORKBASKET_KEY);
|
||||
|
||||
assertEquals(7, ids.size());
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000001"));
|
||||
|
@ -92,6 +93,43 @@ public class GetTaskIdsOfWorkbasketReportAccTest {
|
|||
assertTrue(ids.contains("TKI:000000000000000000000000000000000050"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskIdsOfWorkbasketReportWithExcludedClassifications() throws InvalidArgumentException {
|
||||
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
|
||||
|
||||
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
|
||||
|
||||
List<SelectedItem> selectedItems = new ArrayList<>();
|
||||
|
||||
SelectedItem s1 = new SelectedItem();
|
||||
s1.setKey("USER_1_1");
|
||||
s1.setLowerAgeLimit(0);
|
||||
s1.setUpperAgeLimit(0);
|
||||
selectedItems.add(s1);
|
||||
|
||||
SelectedItem s2 = new SelectedItem();
|
||||
s2.setKey("USER_1_1");
|
||||
s2.setLowerAgeLimit(Integer.MIN_VALUE);
|
||||
s2.setUpperAgeLimit(-11);
|
||||
selectedItems.add(s2);
|
||||
|
||||
SelectedItem s3 = new SelectedItem();
|
||||
s3.setKey("USER_1_2");
|
||||
s3.setLowerAgeLimit(1000);
|
||||
s3.setUpperAgeLimit(Integer.MAX_VALUE);
|
||||
selectedItems.add(s3);
|
||||
|
||||
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null,
|
||||
Collections.singletonList("CLI:000000000000000000000000000000000001"), null, null,
|
||||
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_WORKBASKET_KEY);
|
||||
|
||||
assertEquals(4, ids.size());
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000009"));
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000031"));
|
||||
assertTrue(ids.contains("TKI:000000000000000000000000000000000050"));
|
||||
}
|
||||
|
||||
private List<TimeIntervalColumnHeader> getListOfColumnHeaders() {
|
||||
List<TimeIntervalColumnHeader> columnHeaders = new ArrayList<>();
|
||||
columnHeaders.add(new TimeIntervalColumnHeader(Integer.MIN_VALUE, -11));
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.mockito.MockitoAnnotations;
|
|||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import pro.taskana.CustomField;
|
||||
import pro.taskana.TaskMonitorService;
|
||||
import pro.taskana.TaskState;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
|
@ -443,11 +444,13 @@ public class TaskMonitorServiceImplTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetTaskIdsOfCategoryReportLineItems() throws InvalidArgumentException {
|
||||
public void testGetTaskIdsForSelectedItems() throws InvalidArgumentException {
|
||||
List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
|
||||
List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY);
|
||||
List<String> categories = Collections.singletonList("EXTERN");
|
||||
List<String> domains = Collections.singletonList("DOMAIN_A");
|
||||
List<String> classificationIds = Collections.singletonList("L10000");
|
||||
List<String> excludedClassificationIds = Collections.singletonList("L20000");
|
||||
CustomField customField = CustomField.CUSTOM_1;
|
||||
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
|
||||
List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(
|
||||
|
@ -460,18 +463,22 @@ public class TaskMonitorServiceImplTest {
|
|||
List<SelectedItem> selectedItems = Collections.singletonList(selectedItem);
|
||||
|
||||
List<String> expectedResult = Collections.singletonList("TKI:000000000000000000000000000000000001");
|
||||
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskIdsForSelectedItems(workbasketIds,
|
||||
states, categories, domains, customField, customFieldValues, "CLASSIFICATION_CATEGORY", selectedItems);
|
||||
when(taskMonitorMapperMock.getTaskIdsForSelectedItems(workbasketIds,
|
||||
states, categories, domains, classificationIds, excludedClassificationIds, customField, customFieldValues,
|
||||
"CLASSIFICATION_CATEGORY", selectedItems, false)).thenReturn(expectedResult);
|
||||
|
||||
List<String> actualResult = cut.getTaskIdsOfCategoryReportLineItems(workbasketIds, states, categories, domains,
|
||||
customField, customFieldValues, reportLineItemDefinitions, selectedItems);
|
||||
List<String> actualResult = cut.getTaskIdsForSelectedItems(workbasketIds, states, categories, domains,
|
||||
classificationIds, excludedClassificationIds,
|
||||
customField, customFieldValues, reportLineItemDefinitions, true, selectedItems,
|
||||
TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY);
|
||||
|
||||
verify(taskanaEngineImplMock, times(1)).openConnection();
|
||||
verify(taskanaEngineImplMock, times(2)).getConfiguration();
|
||||
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
|
||||
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
|
||||
verify(taskMonitorMapperMock, times(1))
|
||||
.getTaskIdsForSelectedItems(any(), any(), any(), any(), any(), any(), any(), any());
|
||||
.getTaskIdsForSelectedItems(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(),
|
||||
eq(false));
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
|
||||
|
||||
|
|
Loading…
Reference in New Issue