TSK-571: Create a fluent API for the monitoring

- Create report builders that create the reports and list the tasks of
the reports
- Extend getTaskIds by customFieldValueReport
- Rename WorkbasketLevelReport to WorkbasketReport
- Harmonize report filters
This commit is contained in:
Konstantin Kläger 2018-06-12 15:36:59 +02:00 committed by Holger Hagen
parent 13f31c7b93
commit 43d25e0496
34 changed files with 3439 additions and 1977 deletions

View File

@ -0,0 +1,143 @@
package pro.taskana;
import java.util.List;
import java.util.Map;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.SelectedItem;
import pro.taskana.impl.report.impl.CategoryReport;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
/**
* The CategoryReportBuilder is used to build a {@link CategoryReport}, list the taskIds of a CategoryReport and list
* the values of an entered custom field. A CategoryReport contains the total numbers of tasks of the respective
* category as well as the total number of all tasks. The tasks of the report can be filtered by workbaskets, states,
* categories, domains, classifications and values of a custom field. Classifications can also be excluded from the
* report. If the {@link TimeIntervalColumnHeader}s are set, the report contains also the number of tasks of the
* respective cluster. The age of the tasks can be counted in days or in working days. Tasks with Timestamp DUE = null
* are not considered.
*/
public interface CategoryReportBuilder {
/**
* Adds a list {@link TimeIntervalColumnHeader}s to the builder to subdivide the report into clusters.
*
* @param columnHeaders
* the column headers the report should consist of.
* @return the CategoryReportBuilder
*/
CategoryReportBuilder withColumnHeaders(List<TimeIntervalColumnHeader> columnHeaders);
/**
* If this filter is used, the days of the report are counted in working days.
*
* @return the CategoryReportBuilder
*/
CategoryReportBuilder inWorkingDays();
/**
* Adds a list of workbasketIds to the builder. The created report contains only tasks with a workbasketId in this
* list.
*
* @param workbasketIds
* a list of workbasketIds
* @return the CategoryReportBuilder
*/
CategoryReportBuilder workbasketIdIn(List<String> workbasketIds);
/**
* Adds a list of states to the builder. The created report contains only tasks with a state in this list.
*
* @param states
* a list of states
* @return the CategoryReportBuilder
*/
CategoryReportBuilder stateIn(List<TaskState> states);
/**
* Adds a list of categories to the builder. The created report contains only tasks with a category in this list.
*
* @param categories
* a list of categories
* @return the CategoryReportBuilder
*/
CategoryReportBuilder categoryIn(List<String> categories);
/**
* Adds a list of classificationIds to the builder. The created report contains only tasks with a classificationId
* in this list.
*
* @param classificationIds
* a list of classificationIds
* @return the CategoryReportBuilder
*/
CategoryReportBuilder classificationIdIn(List<String> classificationIds);
/**
* Adds a list of excludedClassificationIds to the builder. The created report contains only tasks with a
* classificationId NOT in this list.
*
* @param excludedClassificationIds
* a list of excludedClassificationIds
* @return the CategoryReportBuilder
*/
CategoryReportBuilder excludedClassificationIdIn(List<String> excludedClassificationIds);
/**
* Adds a list of domains to the builder. The created report contains only tasks with a domain in this list.
*
* @param domains
* a list of domains
* @return the CategoryReportBuilder
*/
CategoryReportBuilder domainIn(List<String> domains);
/**
* Adds a map of custom attributes and custom attribute values to the builder. The created report contains only
* tasks with a custom attribute value in this list.
*
* @param customAttributeFilter
* a map of custom attributes and custom attribute value
* @return the CategoryReportBuilder
*/
CategoryReportBuilder customAttributeFilterIn(Map<CustomField, String> customAttributeFilter);
/**
* Returns a {@link CategoryReport} containing all tasks after applying the filters. If the column headers are set
* the report is subdivided into clusters.
*
* @throws InvalidArgumentException
* if the column headers are not initialized
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the CategoryReport
*/
CategoryReport buildReport() throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a list of all taskIds of the report that are in the list of selected items.
*
* @param selectedItems
* a list of selectedItems
* @throws InvalidArgumentException
* if the column headers are not initialized
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the list of all taskIds
*/
List<String> listTaskIdsForSelectedItems(List<SelectedItem> selectedItems)
throws NotAuthorizedException, InvalidArgumentException;
/**
* Returns a list of all values of an entered custom field that are in the report.
*
* @param customField
* the customField whose values should appear in the list
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the list of all custom attribute values
*/
List<String> listCustomAttributeValuesForCustomAttributeName(CustomField customField)
throws NotAuthorizedException;
}

View File

@ -0,0 +1,161 @@
package pro.taskana;
import java.util.List;
import java.util.Map;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.SelectedItem;
import pro.taskana.impl.report.impl.ClassificationReport;
import pro.taskana.impl.report.impl.DetailedClassificationReport;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
/**
* The ClassificationReportBuilder is used to build a {@link ClassificationReport} or a
* {@link DetailedClassificationReport}. Furthermore the taskIds and values of an entered custom field of these reports
* can be listed. A ClassificationReport contains the total numbers of tasks of the respective classification as well as
* the total number of all tasks. A ReportLine of a DetailedClassificationReport contains an additional list of
* ReportLines for the classifications of the attachments of the tasks. The tasks of the report can be filtered by
* workbaskets, states, categories, domains, classifications and values of a custom field. Classifications can also be
* excluded from the report. If the {@link TimeIntervalColumnHeader}s are set, the report contains also the number of
* tasks of the respective cluster. The age of the tasks can be counted in days or in working days. Tasks with Timestamp
* DUE = null are not considered.
*/
public interface ClassificationReportBuilder {
/**
* Adds a list {@link TimeIntervalColumnHeader}s to the builder to subdivide the report into clusters.
*
* @param columnHeaders
* the column headers the report should consist of.
* @return the ClassificationReportBuilder
*/
ClassificationReportBuilder withColumnHeaders(List<TimeIntervalColumnHeader> columnHeaders);
/**
* If this filter is used, the days of the report are counted in working days.
*
* @return the ClassificationReportBuilder
*/
ClassificationReportBuilder inWorkingDays();
/**
* Adds a list of workbasket ids to the builder. The created report contains only tasks with a workbasket id in this
* list.
*
* @param workbasketIds
* a list of workbasket ids
* @return the ClassificationReportBuilder
*/
ClassificationReportBuilder workbasketIdIn(List<String> workbasketIds);
/**
* Adds a list of states to the builder. The created report contains only tasks with a state in this list.
*
* @param states
* a list of states
* @return the ClassificationReportBuilder
*/
ClassificationReportBuilder stateIn(List<TaskState> states);
/**
* Adds a list of categories to the builder. The created report contains only tasks with a category in this list.
*
* @param categories
* a list of categories
* @return the ClassificationReportBuilder
*/
ClassificationReportBuilder categoryIn(List<String> categories);
/**
* Adds a list of classificationIds to the builder. The created report contains only tasks with a classificationId
* in this list.
*
* @param classificationIds
* a list of classificationIds
* @return the ClassificationReportBuilder
*/
ClassificationReportBuilder classificationIdIn(List<String> classificationIds);
/**
* Adds a list of excludedClassificationIds to the builder. The created report contains only tasks with a
* classificationId NOT in this list.
*
* @param excludedClassificationIds
* a list of excludedClassificationIds
* @return the ClassificationReportBuilder
*/
ClassificationReportBuilder excludedClassificationIdIn(List<String> excludedClassificationIds);
/**
* Adds a list of domains to the builder. The created report contains only tasks with a domain in this list.
*
* @param domains
* a list of domains
* @return the ClassificationReportBuilder
*/
ClassificationReportBuilder domainIn(List<String> domains);
/**
* Adds a map of custom attributes and custom attribute values to the builder. The created report contains only
* tasks with a custom attribute value in this list.
*
* @param customAttributeFilter
* a map of custom attributes and custom attribute value
* @return the ClassificationReportBuilder
*/
ClassificationReportBuilder customAttributeFilterIn(Map<CustomField, String> customAttributeFilter);
/**
* Returns a {@link ClassificationReport} containing all tasks after applying the filters. If the column headers are
* set the report is subdivided into clusters.
*
* @throws InvalidArgumentException
* if the column headers are not initialized
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the ClassificationReport
*/
ClassificationReport buildReport() throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link DetailedClassificationReport} containing all tasks after applying the filters. If the column
* headers are set the report is subdivided into clusters. Its
* {@link pro.taskana.impl.report.impl.DetailedReportRow}s contain an additional list of
* {@link pro.taskana.impl.report.ReportRow}s for the classifications of the attachments of the tasks.
*
* @throws InvalidArgumentException
* if the column headers are not initialized
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the DetailedClassificationReport
*/
DetailedClassificationReport buildDetailedReport() throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a list of all taskIds of the report that are in the list of selected items.
*
* @param selectedItems
* a list of selectedItems
* @throws InvalidArgumentException
* if the column headers are not initialized
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the list of all taskIds
*/
List<String> listTaskIdsForSelectedItems(List<SelectedItem> selectedItems)
throws NotAuthorizedException, InvalidArgumentException;
/**
* Returns a list of all values of an entered custom field that are in the report.
*
* @param customField
* the customField whose values should appear in the list
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the list of all custom attribute values
*/
List<String> listCustomAttributeValuesForCustomAttributeName(CustomField customField)
throws NotAuthorizedException;
}

View File

@ -0,0 +1,149 @@
package pro.taskana;
import java.util.List;
import java.util.Map;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.SelectedItem;
import pro.taskana.impl.report.impl.CustomFieldValueReport;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
/**
* The CustomFieldValueReportBuilder is used to build a {@link CustomFieldValueReport} and list the values of a entered
* custom field. A CustomFieldValueReport contains the total numbers of tasks of the respective custom field as well as
* the total number of all tasks. The tasks of the report can be filtered by workbaskets, states, categories, domains,
* classifications and values of a custom field. Classifications can also be excluded from the report. If the
* {@link TimeIntervalColumnHeader}s are set, the report contains also the number of tasks of the respective cluster.
* The age of the tasks can be counted in days or in working days. Tasks with Timestamp DUE = null are not considered.
*/
public interface CustomFieldValueReportBuilder {
/**
* Adds a list {@link TimeIntervalColumnHeader}s to the builder to subdivide the report into clusters.
*
* @param columnHeaders
* the column headers the report should consist of.
* @return the CustomFieldValueReportBuilder
*/
CustomFieldValueReportBuilder withColumnHeaders(List<TimeIntervalColumnHeader> columnHeaders);
/**
* If this filter is used, the days of the report are counted in working days.
*
* @return the CustomFieldValueReportBuilder
*/
CustomFieldValueReportBuilder inWorkingDays();
/**
* Adds a list of workbasket ids to the builder. The created report contains only tasks with a workbasket id in this
* list.
*
* @param workbasketIds
* a list of workbasket ids
* @return the CustomFieldValueReportBuilder
*/
CustomFieldValueReportBuilder workbasketIdIn(List<String> workbasketIds);
/**
* Adds a list of states to the builder. The created report contains only tasks with a state in this list.
*
* @param states
* a list of states
* @return the CustomFieldValueReportBuilder
*/
CustomFieldValueReportBuilder stateIn(List<TaskState> states);
/**
* Adds a list of categories to the builder. The created report contains only tasks with a category in this list.
*
* @param categories
* a list of categories
* @return the CustomFieldValueReportBuilder
*/
CustomFieldValueReportBuilder categoryIn(List<String> categories);
/**
* Adds a list of classificationIds to the builder. The created report contains only tasks with a classificationId
* in this list.
*
* @param classificationIds
* a list of classificationIds
* @return the CustomFieldValueReportBuilder
*/
CustomFieldValueReportBuilder classificationIdIn(List<String> classificationIds);
/**
* Adds a list of excludedClassificationIds to the builder. The created report contains only tasks with a
* classificationId NOT in this list.
*
* @param excludedClassificationIds
* a list of excludedClassificationIds
* @return the CustomFieldValueReportBuilder
*/
CustomFieldValueReportBuilder excludedClassificationIdIn(List<String> excludedClassificationIds);
/**
* Adds a list of domains to the builder. The created report contains only tasks with a domain in this list.
*
* @param domains
* a list of domains
* @return the CustomFieldValueReportBuilder
*/
CustomFieldValueReportBuilder domainIn(List<String> domains);
/**
* Adds a map of custom attributes and custom attribute values to the builder. The created report contains only
* tasks with a custom attribute value in this list.
*
* @param customAttributeFilter
* a map of custom attributes and custom attribute value
* @return the CustomFieldValueReportBuilder
*/
CustomFieldValueReportBuilder customAttributeFilterIn(Map<CustomField, String> customAttributeFilter);
/**
* Returns a {@link CustomFieldValueReportBuilder} containing all tasks after applying the filters. If the column
* headers are set the report is subdivided into clusters.
*
* @throws InvalidArgumentException
* if the column headers are not initialized
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the CustomFieldValueReportBuilder
*/
CustomFieldValueReport buildReport() throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a list of all taskIds of the report that are in the list of selected items.
*
* @param selectedItems
* a list of selectedItems
* @throws InvalidArgumentException
* if the column headers are not initialized
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the list of all taskIds
*/
List<String> listTaskIdsForSelectedItems(List<SelectedItem> selectedItems)
throws NotAuthorizedException, InvalidArgumentException;
/**
* Returns a list of all values of an entered custom field that are in the report.
*
* @param customField
* the customField whose values should appear in the list
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the list of all custom attribute values
*/
List<String> listCustomAttributeValuesForCustomAttributeName(CustomField customField)
throws NotAuthorizedException;
/**
* Gets the customField property of the CustomFieldValueReportBuilder.
*
* @return the customField property
*/
CustomField getCustomField();
}

View File

@ -1,741 +1,53 @@
package pro.taskana; package pro.taskana;
import java.util.List; import pro.taskana.impl.CustomFieldValueReportBuilderImpl;
import java.util.Map; import pro.taskana.impl.TaskStatusReportBuilderImpl;
import pro.taskana.impl.WorkbasketReportBuilderImpl;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.SelectedItem;
import pro.taskana.impl.report.impl.CategoryReport;
import pro.taskana.impl.report.impl.ClassificationReport;
import pro.taskana.impl.report.impl.CombinedClassificationFilter;
import pro.taskana.impl.report.impl.CustomFieldValueReport;
import pro.taskana.impl.report.impl.DetailedClassificationReport;
import pro.taskana.impl.report.impl.TaskStatusReport;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.impl.report.impl.WorkbasketLevelReport;
/** /**
* The Task Monitor Service manages operations on tasks regarding the monitoring. * The Task Monitor Service manages operations on tasks regarding the monitoring.
*/ */
public interface TaskMonitorService { public interface TaskMonitorService {
String DIMENSION_CLASSIFICATION_CATEGORY = "CLASSIFICATION_CATEGORY"; /**
String DIMENSION_CLASSIFICATION_KEY = "CLASSIFICATION_KEY"; * Provides a {@link WorkbasketReportBuilderImpl} for creating a WorkbasketReport, list the task ids of this report
String DIMENSION_WORKBASKET_KEY = "WORKBASKET_KEY"; * and list the values of an entered custom attribute.
*
* @return a {@link WorkbasketReportBuilderImpl}
*/
WorkbasketReportBuilderImpl createWorkbasketReportBuilder();
/** /**
* Returns a {@link WorkbasketLevelReport} grouped by workbaskets. The report contains the total numbers of tasks of * Provides a {@link CategoryReportBuilder} for creating a CategoryReport, list the task ids of this report and list
* the respective workbasket as well as the total number of all tasks. If no filter is required, the respective * the values of an entered custom attribute.
* parameter should be null. The tasks of the report are filtered by workbaskets, states, categories, domains and *
* values of a custom field. Tasks with Timestamp DUE = null are not considered. * @return a {@link CategoryReportBuilder}
*/
CategoryReportBuilder createCategoryReportBuilder();
/**
* Provides a {@link ClassificationReportBuilder} for creating a ClassificationReport or a
* DetailedClassificationReport, list the task ids of these reports and list the values of an entered custom
* attribute.
*
* @return a {@link ClassificationReportBuilder}
*/
ClassificationReportBuilder createClassificationReportBuilder();
/**
* Provides a {@link CustomFieldValueReportBuilderImpl} for creating a CustomFieldValueReport and list the values of
* an entered custom attribute.
* *
* @param workbasketIds
* a list of workbasket ids to filter by workbaskets. To omit this filter, use null for this parameter
* @param states
* a list of states 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 * @param customField
* a custom field to filter by the values of the custom field. To omit this filter, use null for this * the customField whose values should appear in the report
* parameter * @return a {@link CustomFieldValueReportBuilderImpl}
* @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 combinedClassificationFilter
* a list of pairs of a classificationId for a task and a classificationId for the corresponding
* attachment that is used to filter by the classification of the attachment. To filter by the
* classification of the task, the classificationId of the attachment should be null. To omit this
* filter, use null for this parameter
* @return the report
* @throws InvalidArgumentException
* thrown if DaysToWorkingDaysConverter is initialized with null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/ */
WorkbasketLevelReport getWorkbasketLevelReport(List<String> workbasketIds, List<TaskState> states, CustomFieldValueReportBuilderImpl createCustomFieldValueReportBuilder(CustomField customField);
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
List<CombinedClassificationFilter> combinedClassificationFilter)
throws InvalidArgumentException, NotAuthorizedException;
/** /**
* Returns a {@link WorkbasketLevelReport} grouped by workbaskets. For each workbasket the report contains the total * Provides a {@link TaskStatusReportBuilderImpl} for creating a TaskStatusReport.
* number of tasks and the number of tasks of the respective cluster that are specified by the
* {@link TimeIntervalColumnHeader}s. By default the age of the tasks is counted in working days. Furthermore the
* Report contains a sum line that contains the total numbers of the different clusters and the total number of all
* tasks in this report. 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 * @return a {@link TaskStatusReportBuilderImpl}
* 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 combinedClassificationFilter
* a list of pairs of a classificationId for a task and a classificationId for the corresponding
* attachment that is used to filter by the classification of the attachment. To filter by the
* classification of the task, the classificationId of the attachment should be null. 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.
* @return the report
* @throws InvalidArgumentException
* thrown if DaysToWorkingDaysConverter is initialized with null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/ */
WorkbasketLevelReport getWorkbasketLevelReport(List<String> workbasketIds, List<TaskState> states, TaskStatusReportBuilderImpl createTaskStatusReportBuilder();
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
List<CombinedClassificationFilter> combinedClassificationFilter, List<TimeIntervalColumnHeader> columnHeaders)
throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link WorkbasketLevelReport} for specific classifications grouped by workbaskets. For each workbasket
* the report contains the total number of tasks and the number of tasks of the respective cluster that are
* specified by the {@link TimeIntervalColumnHeader}s. It can be specified whether the age of the tasks is counted
* in days or in working days. Furthermore the report contains a sum line that contains the total numbers of the
* different clusters and the total number of all tasks. 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 combinedClassificationFilter
* a list of pairs of a classificationId for a task and a classificationId for the corresponding
* attachment that is used to filter by the classification of the attachment. To filter by the
* classification of the task, the classificationId of the attachment should be null. 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
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
WorkbasketLevelReport getWorkbasketLevelReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
List<CombinedClassificationFilter> combinedClassificationFilter, List<TimeIntervalColumnHeader> columnHeaders,
boolean inWorkingDays) throws InvalidArgumentException, NotAuthorizedException;
/**
* 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
* workbaskets, states, categories, domains and values of a custom field 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 to filter by workbaskets. To omit this filter, use null for this parameter
* @param states
* a list of states 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
* @return the report
* @throws InvalidArgumentException
* thrown if DaysToWorkingDaysConverter is initialized with null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
CategoryReport getCategoryReport(List<String> workbasketIds, List<TaskState> states, List<String> categories,
List<String> domains, CustomField customField, List<String> customFieldValues)
throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link CategoryReport} grouped by categories. For each category the report contains the total number of
* tasks and the number of tasks of the respective cluster that are specified by the
* {@link TimeIntervalColumnHeader}s. By default the age of the tasks is counted in working days. Furthermore the
* Report contains a sum line that contains the total numbers of the different clusters and the total number of all
* tasks in this report. 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.
* @return the report
* @throws InvalidArgumentException
* thrown if DaysToWorkingDaysConverter is initialized with null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
CategoryReport getCategoryReport(List<String> workbasketIds, List<TaskState> states, List<String> categories,
List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders) throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link CategoryReport} grouped by categories. For each category the report contains the total number of
* tasks and the number of tasks of the respective cluster that are specified by the
* {@link TimeIntervalColumnHeader}s. It can be specified whether the age of the tasks is counted in days or in
* working days. Furthermore the report contains a sum line that contains the total numbers of the different
* clusters and the total number of all tasks. 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
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
CategoryReport getCategoryReport(List<String> workbasketIds, List<TaskState> states, List<String> categories,
List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays)
throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link ClassificationReport} grouped by classifications. The report contains the total numbers of tasks
* of the respective classification as well as the total number of all tasks. 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 to filter by workbaskets. To omit this filter, use null for this parameter
* @param states
* a list of states 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
* @return the ClassificationReport
* @throws InvalidArgumentException
* thrown if DaysToWorkingDaysConverter is initialized with null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
ClassificationReport getClassificationReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues)
throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link ClassificationReport} grouped by classifications. For each classification the report contains
* the total number of tasks and the number of tasks of the respective cluster that are specified by the
* {@link TimeIntervalColumnHeader}s. By default the age of the tasks is counted in working days. Furthermore the
* Report contains a sum line that contains the total numbers of the different clusters and the total number of all
* tasks in this report. 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.
* @return the ClassificationReport
* @throws InvalidArgumentException
* thrown if DaysToWorkingDaysConverter is initialized with null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
ClassificationReport getClassificationReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders) throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link ClassificationReport} grouped by classification. For each classification the report contains the
* total number of tasks and the number of tasks of the respective cluster that are specified by the
* {@link TimeIntervalColumnHeader}s. It can be specified whether the age of the tasks is counted in days or in
* working days. Furthermore the report contains a sum line that contains the total numbers of the different
* clusters and the total number of all tasks. 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 ClassificationReport
* @throws InvalidArgumentException
* thrown if DaysToWorkingDaysConverter is initialized with null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
ClassificationReport getClassificationReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays)
throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link DetailedClassificationReport}. The report contains the total numbers of tasks of the respective
* classification as well as the total number of all tasks. Each ReportLine contains an additional list of
* ReportLines for the classifications of the attachments of the tasks. 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 to filter by workbaskets. To omit this filter, use null for this parameter
* @param states
* a list of states 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
* @return the DetailedClassificationReport
* @throws InvalidArgumentException
* thrown if DaysToWorkingDaysConverter is initialized with null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
DetailedClassificationReport getDetailedClassificationReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues)
throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link DetailedClassificationReport}. For each classification the report contains the total number of
* tasks and the number of tasks of the respective cluster that are specified by the
* {@link TimeIntervalColumnHeader}s. By default the age of the tasks is counted in working days. Each ReportLine
* contains an additional list of ReportLines for the classifications of the attachments of the tasks. Furthermore
* the Report contains a sum line that contains the total numbers of the different clusters and the total number of
* all tasks in this report. 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.
* @return the DetailedClassificationReport
* @throws InvalidArgumentException
* thrown if DaysToWorkingDaysConverter is initialized with null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
DetailedClassificationReport getDetailedClassificationReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders) throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link DetailedClassificationReport}. For each classification the report contains the total number of
* tasks and the number of tasks of the respective cluster that are specified by the
* {@link TimeIntervalColumnHeader}s. It can be specified whether the age of the tasks is counted in days or in
* working days. Each ReportLine contains an additional list of ReportLines for the classifications of the
* attachments of the tasks. Furthermore the report contains a sum line that contains the total numbers of the
* different clusters and the total number of all tasks. 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 DetailedClassificationReport
* @throws InvalidArgumentException
* thrown if DaysToWorkingDaysConverter is initialized with null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
DetailedClassificationReport getDetailedClassificationReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays)
throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link CustomFieldValueReport} grouped by the value of a certain {@link CustomField}. The report
* contains the total numbers of tasks of the respective custom field as well as the total number of all tasks. 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 to filter by workbaskets. To omit this filter, use null for this parameter
* @param states
* a list of states 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
* @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
* @return the report
* @throws InvalidArgumentException
* thrown if customField is null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
CustomFieldValueReport getCustomFieldValueReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues)
throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link CustomFieldValueReport} grouped by the value of a certain {@link CustomField}. For each value of
* the custom field the report contains the total number of tasks and the number of tasks of the respective cluster
* that are specified by the {@link TimeIntervalColumnHeader}s. By default the age of the tasks is counted in
* working days. Furthermore the Report contains a sum line that contains the total numbers of the different
* clusters and the total number of all tasks in this report. 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
* @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.
* @return the report
* @throws InvalidArgumentException
* thrown if customField is null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
CustomFieldValueReport getCustomFieldValueReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders) throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a {@link CustomFieldValueReport} grouped by the value of a certain {@link CustomField}. For each value of
* the custom field the report contains the total number of tasks and the number of tasks of the respective cluster
* that are specified by the {@link TimeIntervalColumnHeader}s. It can be specified whether the age of the tasks is
* counted in days or in working days. Furthermore the report contains a sum line that contains the total numbers of
* the different clusters and the total number of all tasks. 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
* @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 customField is null
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
CustomFieldValueReport getCustomFieldValueReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories,
List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays)
throws InvalidArgumentException, NotAuthorizedException;
/**
* 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
* @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
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
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, NotAuthorizedException;
/**
* Returns a list of distinct custom attribute values for the selection from the entire task pool.
*
* @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 classificationIds
* a List of all classification ids to include in the selection.
* @param excludedClassificationIds
* a List of all classification ids to exclude from the selection.
* @param customAttributeFilter
* a Map containing a key value pair for the custom attributes to be applied as a filter criteria
* @param customAttributeName
* the name of the custom attribute to determine the existing values from.
* @return the list of existing values for the custom attribute with name customAttributeName in the filtered task
* pool.
* @throws InvalidArgumentException
* thrown if the customAttributeName is invalid/empty.
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR
*/
List<String> getCustomAttributeValuesForReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, List<String> classificationIds,
List<String> excludedClassificationIds, Map<String, String> customAttributeFilter,
String customAttributeName) throws InvalidArgumentException, NotAuthorizedException;
/**
* Overloaded method for {@link #getTaskStatusReport(List, List)}. This method omits all filters.
*
* @return the {@link TaskStatusReport}
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR or ADMIN
*/
TaskStatusReport getTaskStatusReport() throws NotAuthorizedException;
/**
* Overloaded method for {@link #getTaskStatusReport(List, List)}. This method applies a domain filter and omits the
* state filter.
*
* @param domains
* a list of domains to filter by domains. To omit this filter, use null for this parameter
* @return the {@link TaskStatusReport}
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR or ADMIN
*/
TaskStatusReport getTaskStatusReport(List<String> domains) throws NotAuthorizedException;
/**
* Returns a {@link TaskStatusReport}. For each domain the report contains the total number of tasks, clustered in
* their task status. Furthermore the report contains a sum line that contains the total numbers of the different
* clusters and the total number of all tasks.
*
* @param states
* a list of states objects to filter by states. 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
* @return the {@link TaskStatusReport}
* @throws NotAuthorizedException
* if the current user is not member of role MONITOR or ADMIN
*/
TaskStatusReport getTaskStatusReport(List<String> domains, List<TaskState> states) throws NotAuthorizedException;
} }

View File

@ -0,0 +1,41 @@
package pro.taskana;
import java.util.List;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.impl.TaskStatusReport;
/**
* The TaskStatusReportBuilder is used to build a {@link TaskStatusReport}. A TaskStatusReport contains the total number
* of tasks, clustered in their task status. Furthermore the report contains a sum line that contains the total numbers
* of the different clusters and the total number of all tasks.
*/
public interface TaskStatusReportBuilder {
/**
* Adds a list of states to the builder. The created report contains only tasks with a state in this list.
*
* @param states
* a list of states
* @return the TaskStatusReportBuilder
*/
TaskStatusReportBuilder stateIn(List<TaskState> states);
/**
* Adds a list of domains to the builder. The created report contains only tasks with a domain in this list.
*
* @param domains
* a list of domains
* @return the TaskStatusReportBuilder
*/
TaskStatusReportBuilder domainIn(List<String> domains);
/**
* Returns a {@link TaskStatusReport} containing all tasks after applying the filters.
*
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the TaskStatusReport
*/
TaskStatusReport buildReport() throws NotAuthorizedException;
}

View File

@ -0,0 +1,157 @@
package pro.taskana;
import java.util.List;
import java.util.Map;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.SelectedItem;
import pro.taskana.impl.WorkbasketReportBuilderImpl;
import pro.taskana.impl.report.impl.CombinedClassificationFilter;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.impl.report.impl.WorkbasketReport;
/**
* The WorkbasketReportBuilder is used to build a {@link WorkbasketReport}, list the taskIds of a WorkbasketReport and
* list the values of a entered custom field. A WorkbasketReport contains the total numbers of tasks of the respective
* workbasket as well as the total number of all tasks. The tasks of the report can be filtered by workbaskets, states,
* categories, domains, classifications and values of a custom field. Classifications can also be excluded from the
* report. It is also possible to filter by the classifications of the attachments by using the
* {@link CombinedClassificationFilter}. If the {@link TimeIntervalColumnHeader}s are set, the report contains also the
* number of tasks of the respective cluster. The age of the tasks can be counted in days or in working days. Tasks with
* Timestamp DUE = null are not considered.
*/
public interface WorkbasketReportBuilder {
/**
* Adds a list {@link TimeIntervalColumnHeader}s to the builder to subdivide the report into clusters.
*
* @param columnHeaders
* the column headers the report should consist of.
* @return the WorkbasketReportBuilder
*/
WorkbasketReportBuilder withColumnHeaders(List<TimeIntervalColumnHeader> columnHeaders);
/**
* If this filter is used, the days of the report are counted in working days.
*
* @return the WorkbasketReportBuilder
*/
WorkbasketReportBuilder inWorkingDays();
/**
* Adds a list of workbasket ids to the builder. The created report contains only tasks with a workbasket id in this
* list.
*
* @param workbasketIds
* a list of workbasket ids
* @return the WorkbasketReportBuilder
*/
WorkbasketReportBuilder workbasketIdIn(List<String> workbasketIds);
/**
* Adds a list of states to the builder. The created report contains only tasks with a state in this list.
*
* @param states
* a list of states
* @return the WorkbasketReportBuilder
*/
WorkbasketReportBuilder stateIn(List<TaskState> states);
/**
* Adds a list of categories to the builder. The created report contains only tasks with a category in this list.
*
* @param categories
* a list of categories
* @return the WorkbasketReportBuilder
*/
WorkbasketReportBuilder categoryIn(List<String> categories);
/**
* Adds a list of classificationIds to the builder. The created report contains only tasks with a classificationId
* in this list.
*
* @param classificationIds
* a list of classificationIds
* @return the WorkbasketReportBuilder
*/
WorkbasketReportBuilder classificationIdIn(List<String> classificationIds);
/**
* Adds a list of excludedClassificationIds to the builder. The created report contains only tasks with a
* classificationId NOT in this list.
*
* @param excludedClassificationIds
* a list of excludedClassificationIds
* @return the WorkbasketReportBuilder
*/
WorkbasketReportBuilder excludedClassificationIdIn(List<String> excludedClassificationIds);
/**
* Adds a list of domains to the builder. The created report contains only tasks with a domain in this list.
*
* @param domains
* a list of domains
* @return the WorkbasketReportBuilder
*/
WorkbasketReportBuilder domainIn(List<String> domains);
/**
* Adds a map of custom attributes and custom attribute values to the builder. The created report contains only
* tasks with a custom attribute value in this list.
*
* @param customAttributeFilter
* a map of custom attributes and custom attribute value
* @return the WorkbasketReportBuilder
*/
WorkbasketReportBuilder customAttributeFilterIn(Map<CustomField, String> customAttributeFilter);
/**
* Adds a list of {@link CombinedClassificationFilter} to the builder. The created report contains only tasks with a
* pair of a classificationId for a task and a classificationId for the corresponding attachment in this list.
*
* @param combinedClassificationFilter
* a list of combinedClassificationFilter
* @return the WorkbasketReportBuilder
*/
WorkbasketReportBuilderImpl combinedClassificationFilterIn(
List<CombinedClassificationFilter> combinedClassificationFilter);
/**
* Returns a {@link WorkbasketReport} containing all tasks after applying the filters. If the column headers are set
* the report is subdivided into clusters.
*
* @throws InvalidArgumentException
* if the column headers are not initialized
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the WorkbasketReport
*/
WorkbasketReport buildReport() throws InvalidArgumentException, NotAuthorizedException;
/**
* Returns a list of all taskIds of the report that are in the list of selected items.
*
* @param selectedItems
* a list of selectedItems
* @throws InvalidArgumentException
* if the column headers are not initialized
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the list of all taskIds
*/
List<String> listTaskIdsForSelectedItems(List<SelectedItem> selectedItems)
throws NotAuthorizedException, InvalidArgumentException;
/**
* Returns a list of all values of an entered custom field that are in the report.
*
* @param customField
* the customField whose values should appear in the list
* @throws NotAuthorizedException
* if the user has no rights to access the monitor
* @return the list of all custom attribute values
*/
List<String> listCustomAttributeValuesForCustomAttributeName(CustomField customField)
throws NotAuthorizedException;
}

View File

@ -0,0 +1,107 @@
package pro.taskana.impl;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.CategoryReportBuilder;
import pro.taskana.CustomField;
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.impl.CategoryReport;
import pro.taskana.impl.report.impl.DaysToWorkingDaysPreProcessor;
import pro.taskana.impl.report.impl.MonitorQueryItem;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.mappings.TaskMonitorMapper;
/**
* The implementation of CategoryReportBuilder.
*/
public class CategoryReportBuilderImpl extends ReportBuilder implements CategoryReportBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(CategoryReportBuilder.class);
public CategoryReportBuilderImpl(TaskanaEngine taskanaEngine, TaskMonitorMapper taskMonitorMapper) {
super(taskanaEngine, taskMonitorMapper);
}
@Override
public CategoryReportBuilder withColumnHeaders(List<TimeIntervalColumnHeader> columnHeaders) {
this.columnHeaders = columnHeaders;
return this;
}
@Override
public CategoryReportBuilder inWorkingDays() {
this.inWorkingDays = true;
return this;
}
@Override
public CategoryReportBuilder workbasketIdIn(List<String> workbasketIds) {
this.workbasketIds = workbasketIds;
return this;
}
@Override
public CategoryReportBuilder stateIn(List<TaskState> states) {
this.states = states;
return this;
}
@Override
public CategoryReportBuilder categoryIn(List<String> categories) {
this.categories = categories;
return this;
}
@Override
public CategoryReportBuilder classificationIdIn(List<String> classificationIds) {
this.classificationIds = classificationIds;
return this;
}
@Override
public CategoryReportBuilder excludedClassificationIdIn(List<String> excludedClassificationIds) {
this.excludedClassificationIds = excludedClassificationIds;
return this;
}
@Override
public CategoryReportBuilder domainIn(List<String> domains) {
this.domains = domains;
return this;
}
@Override
public CategoryReportBuilder customAttributeFilterIn(Map<CustomField, String> customAttributeFilter) {
this.customAttributeFilter = customAttributeFilter;
return this;
}
@Override
public CategoryReport buildReport() throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug("entry to buildReport(), this = {}", this);
this.taskanaEngine.checkRoleMembership(TaskanaRole.MONITOR);
try {
this.taskanaEngine.openConnection();
CategoryReport report = new CategoryReport(this.columnHeaders);
List<MonitorQueryItem> monitorQueryItems = this.taskMonitorMapper.getTaskCountOfCategories(
this.workbasketIds,
this.states, this.categories, this.domains, this.classificationIds, this.excludedClassificationIds,
this.customAttributeFilter);
report.addItems(monitorQueryItems,
new DaysToWorkingDaysPreProcessor<>(this.columnHeaders, this.inWorkingDays));
return report;
} finally {
this.taskanaEngine.returnConnection();
LOGGER.debug("exit from buildReport().");
}
}
}

View File

@ -0,0 +1,129 @@
package pro.taskana.impl;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.ClassificationReportBuilder;
import pro.taskana.CustomField;
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.impl.ClassificationReport;
import pro.taskana.impl.report.impl.DaysToWorkingDaysPreProcessor;
import pro.taskana.impl.report.impl.DetailedClassificationReport;
import pro.taskana.impl.report.impl.DetailedMonitorQueryItem;
import pro.taskana.impl.report.impl.MonitorQueryItem;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.mappings.TaskMonitorMapper;
/**
* The implementation of ClassificationReportBuilder.
*/
public class ClassificationReportBuilderImpl extends ReportBuilder implements ClassificationReportBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationReportBuilder.class);
public ClassificationReportBuilderImpl(TaskanaEngine taskanaEngine, TaskMonitorMapper taskMonitorMapper) {
super(taskanaEngine, taskMonitorMapper);
}
@Override
public ClassificationReportBuilder withColumnHeaders(List<TimeIntervalColumnHeader> columnHeaders) {
this.columnHeaders = columnHeaders;
return this;
}
@Override
public ClassificationReportBuilder inWorkingDays() {
this.inWorkingDays = true;
return this;
}
@Override
public ClassificationReportBuilder workbasketIdIn(List<String> workbasketIds) {
this.workbasketIds = workbasketIds;
return this;
}
@Override
public ClassificationReportBuilder stateIn(List<TaskState> states) {
this.states = states;
return this;
}
@Override
public ClassificationReportBuilder categoryIn(List<String> categories) {
this.categories = categories;
return this;
}
@Override
public ClassificationReportBuilder domainIn(List<String> domains) {
this.domains = domains;
return this;
}
@Override
public ClassificationReportBuilder customAttributeFilterIn(Map<CustomField, String> customAttributeFilter) {
this.customAttributeFilter = customAttributeFilter;
return this;
}
@Override
public ClassificationReportBuilder classificationIdIn(List<String> classificationIds) {
this.classificationIds = classificationIds;
return this;
}
@Override
public ClassificationReportBuilder excludedClassificationIdIn(List<String> excludedClassificationIds) {
this.excludedClassificationIds = excludedClassificationIds;
return this;
}
@Override
public ClassificationReport buildReport() throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug("entry to buildReport(), this = {}", this);
this.taskanaEngine.checkRoleMembership(TaskanaRole.MONITOR);
try {
this.taskanaEngine.openConnection();
ClassificationReport report = new ClassificationReport(this.columnHeaders);
List<MonitorQueryItem> monitorQueryItems = this.taskMonitorMapper.getTaskCountOfClassifications(
this.workbasketIds, this.states, this.categories, this.domains, this.classificationIds,
this.excludedClassificationIds, this.customAttributeFilter);
report.addItems(monitorQueryItems,
new DaysToWorkingDaysPreProcessor<>(this.columnHeaders, this.inWorkingDays));
return report;
} finally {
this.taskanaEngine.returnConnection();
LOGGER.debug("exit from buildReport().");
}
}
@Override
public DetailedClassificationReport buildDetailedReport() throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug("entry to buildDetailedReport(), this = {}", this);
this.taskanaEngine.checkRoleMembership(TaskanaRole.MONITOR);
try {
this.taskanaEngine.openConnection();
DetailedClassificationReport report = new DetailedClassificationReport(this.columnHeaders);
List<DetailedMonitorQueryItem> detailedMonitorQueryItems = this.taskMonitorMapper
.getTaskCountOfDetailedClassifications(this.workbasketIds, this.states, this.categories, this.domains,
this.classificationIds, this.excludedClassificationIds, this.customAttributeFilter);
report.addItems(detailedMonitorQueryItems,
new DaysToWorkingDaysPreProcessor<>(this.columnHeaders, this.inWorkingDays));
return report;
} finally {
this.taskanaEngine.returnConnection();
LOGGER.debug("exit from buildDetailedReport().");
}
}
}

View File

@ -0,0 +1,119 @@
package pro.taskana.impl;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.CustomField;
import pro.taskana.CustomFieldValueReportBuilder;
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.impl.CustomFieldValueReport;
import pro.taskana.impl.report.impl.DaysToWorkingDaysPreProcessor;
import pro.taskana.impl.report.impl.MonitorQueryItem;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.mappings.TaskMonitorMapper;
/**
* The implementation of CustomFieldValueReportBuilder.
*/
public class CustomFieldValueReportBuilderImpl extends ReportBuilder implements CustomFieldValueReportBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(CustomFieldValueReportBuilderImpl.class);
public CustomField customField;
public CustomFieldValueReportBuilderImpl(TaskanaEngine taskanaEngine, TaskMonitorMapper taskMonitorMapper,
CustomField customField) {
super(taskanaEngine, taskMonitorMapper);
this.customField = customField;
}
@Override
public CustomFieldValueReportBuilderImpl withColumnHeaders(List<TimeIntervalColumnHeader> columnHeaders) {
this.columnHeaders = columnHeaders;
return this;
}
@Override
public CustomFieldValueReportBuilderImpl inWorkingDays() {
this.inWorkingDays = true;
return this;
}
@Override
public CustomFieldValueReportBuilderImpl workbasketIdIn(List<String> workbasketIds) {
this.workbasketIds = workbasketIds;
return this;
}
@Override
public CustomFieldValueReportBuilderImpl stateIn(List<TaskState> states) {
this.states = states;
return this;
}
@Override
public CustomFieldValueReportBuilderImpl categoryIn(List<String> categories) {
this.categories = categories;
return this;
}
@Override
public CustomFieldValueReportBuilderImpl domainIn(List<String> domains) {
this.domains = domains;
return this;
}
@Override
public CustomFieldValueReportBuilderImpl classificationIdIn(List<String> classificationIds) {
this.classificationIds = classificationIds;
return this;
}
@Override
public CustomFieldValueReportBuilderImpl excludedClassificationIdIn(List<String> excludedClassificationIds) {
this.excludedClassificationIds = excludedClassificationIds;
return this;
}
@Override
public CustomFieldValueReportBuilderImpl customAttributeFilterIn(Map<CustomField, String> customAttributeFilter) {
this.customAttributeFilter = customAttributeFilter;
return this;
}
@Override
public CustomFieldValueReport buildReport()
throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug("entry to buildReport(customField = {}), this = {}", this.customField, this);
this.taskanaEngine.checkRoleMembership(TaskanaRole.MONITOR);
try {
this.taskanaEngine.openConnection();
CustomFieldValueReport report = new CustomFieldValueReport(this.columnHeaders);
List<MonitorQueryItem> monitorQueryItems = this.taskMonitorMapper.getTaskCountOfCustomFieldValues(
this.customField, this.workbasketIds, this.states, this.categories, this.domains,
this.classificationIds,
this.excludedClassificationIds,
this.customAttributeFilter);
report.addItems(monitorQueryItems,
new DaysToWorkingDaysPreProcessor<>(this.columnHeaders, this.inWorkingDays));
return report;
} finally {
this.taskanaEngine.returnConnection();
LOGGER.debug("exit from buildReport().");
}
}
@Override
public CustomField getCustomField() {
return customField;
}
}

View File

@ -0,0 +1,181 @@
package pro.taskana.impl;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.CategoryReportBuilder;
import pro.taskana.ClassificationReportBuilder;
import pro.taskana.CustomField;
import pro.taskana.CustomFieldValueReportBuilder;
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.exceptions.SystemException;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.mappings.TaskMonitorMapper;
/**
* The super class of the different report builders.
*/
public abstract class ReportBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(ReportBuilder.class);
private static final String DIMENSION_CLASSIFICATION_CATEGORY = "CLASSIFICATION_CATEGORY";
private static final String DIMENSION_CLASSIFICATION_KEY = "CLASSIFICATION_KEY";
private static final String DIMENSION_WORKBASKET_KEY = "WORKBASKET_KEY";
protected TaskanaEngineImpl taskanaEngine;
protected TaskMonitorMapper taskMonitorMapper;
protected List<TimeIntervalColumnHeader> columnHeaders;
protected boolean inWorkingDays;
protected List<String> workbasketIds;
protected List<TaskState> states;
protected List<String> categories;
protected List<String> domains;
protected List<String> classificationIds;
protected List<String> excludedClassificationIds;
protected Map<CustomField, String> customAttributeFilter;
public ReportBuilder(TaskanaEngine taskanaEngine, TaskMonitorMapper taskMonitorMapper) {
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
this.taskMonitorMapper = taskMonitorMapper;
this.columnHeaders = Collections.emptyList();
configureDaysToWorkingDaysConverter();
}
public List<TimeIntervalColumnHeader> getColumnHeaders() {
return this.columnHeaders;
}
public boolean isInWorkingDays() {
return this.inWorkingDays;
}
public List<String> getWorkbasketIdIn() {
return this.workbasketIds;
}
public List<TaskState> getStateIn() {
return this.states;
}
public List<String> getCategoryIn() {
return this.categories;
}
public List<String> getDomainIn() {
return this.domains;
}
public List<String> getClassificationIdsIn() {
return this.classificationIds;
}
public List<String> getExcludedClassificationIdsIn() {
return this.excludedClassificationIds;
}
public Map<CustomField, String> getCustomAttributeFilter() {
return this.customAttributeFilter;
}
public List<String> listTaskIdsForSelectedItems(List<SelectedItem> selectedItems)
throws NotAuthorizedException, InvalidArgumentException {
LOGGER.debug("entry to listTaskIdsForSelectedItems(selectedItems = {}), this = {}",
LoggerUtils.listToString(selectedItems), this);
this.taskanaEngine.checkRoleMembership(TaskanaRole.MONITOR);
try {
this.taskanaEngine.openConnection();
if (this.columnHeaders == null) {
throw new InvalidArgumentException("ColumnHeader must not be null.");
}
if (selectedItems == null || selectedItems.size() == 0) {
throw new InvalidArgumentException("SelectedItems must not be null or empty.");
}
boolean joinWithAttachments = subKeyIsSet(selectedItems);
if (!(this instanceof ClassificationReportBuilder) && joinWithAttachments) {
throw new InvalidArgumentException("SubKeys are supported for ClassificationReport only.");
}
String dimension = determineDimension();
if (this.inWorkingDays) {
selectedItems = convertWorkingDaysToDays(selectedItems, this.columnHeaders);
}
List<String> taskIds = this.taskMonitorMapper.getTaskIdsForSelectedItems(this.workbasketIds,
this.states, this.categories, this.domains, this.classificationIds, this.excludedClassificationIds,
this.customAttributeFilter, dimension, selectedItems, joinWithAttachments);
return taskIds;
} finally {
this.taskanaEngine.returnConnection();
LOGGER.debug("exit from listTaskIdsForSelectedItems().");
}
}
private String determineDimension() {
String dimension = null;
if (this instanceof CategoryReportBuilder) {
dimension = DIMENSION_CLASSIFICATION_CATEGORY;
} else if (this instanceof WorkbasketReportBuilderImpl) {
dimension = DIMENSION_WORKBASKET_KEY;
} else if (this instanceof ClassificationReportBuilder) {
dimension = DIMENSION_CLASSIFICATION_KEY;
} else if (this instanceof CustomFieldValueReportBuilder) {
dimension = ((CustomFieldValueReportBuilder) this).getCustomField().toString();
} else {
throw new SystemException("Internal error. listTaskIdsForSelectedItems() does not support " + this);
}
return dimension;
}
public List<String> listCustomAttributeValuesForCustomAttributeName(CustomField customField)
throws NotAuthorizedException {
LOGGER.debug("entry to listCustomAttributeValuesForCustomAttributeName(customField = {}), this = {}",
customField, this);
this.taskanaEngine.checkRoleMembership(TaskanaRole.MONITOR);
try {
this.taskanaEngine.openConnection();
List<String> customAttributeValues = taskMonitorMapper.getCustomAttributeValuesForReport(this.workbasketIds,
this.states, this.categories, this.domains, this.classificationIds, this.excludedClassificationIds,
this.customAttributeFilter, customField);
return customAttributeValues;
} finally {
this.taskanaEngine.returnConnection();
LOGGER.debug("exit from listCustomAttributeValuesForCustomAttributeName().");
}
}
private void configureDaysToWorkingDaysConverter() {
DaysToWorkingDaysConverter.setCustomHolidays(this.taskanaEngine.getConfiguration().getCustomHolidays());
DaysToWorkingDaysConverter.setGermanPublicHolidaysEnabled(
this.taskanaEngine.getConfiguration().isGermanPublicHolidaysEnabled());
}
private List<SelectedItem> convertWorkingDaysToDays(List<SelectedItem> selectedItems,
List<TimeIntervalColumnHeader> columnHeaders) throws InvalidArgumentException {
DaysToWorkingDaysConverter instance = DaysToWorkingDaysConverter.initialize(columnHeaders);
for (SelectedItem selectedItem : selectedItems) {
selectedItem
.setLowerAgeLimit(Collections.min(instance.convertWorkingDaysToDays(selectedItem.getLowerAgeLimit())));
selectedItem
.setUpperAgeLimit(Collections.max(instance.convertWorkingDaysToDays(selectedItem.getUpperAgeLimit())));
}
return selectedItems;
}
protected boolean subKeyIsSet(List<SelectedItem> selectedItems) {
for (SelectedItem selectedItem : selectedItems) {
if (selectedItem.getSubKey() != null && !selectedItem.getSubKey().isEmpty()) {
return true;
}
}
return false;
}
}

View File

@ -1,32 +1,13 @@
package pro.taskana.impl; package pro.taskana.impl;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import pro.taskana.CategoryReportBuilder;
import pro.taskana.ClassificationReportBuilder;
import pro.taskana.CustomField; import pro.taskana.CustomField;
import pro.taskana.TaskMonitorService; import pro.taskana.TaskMonitorService;
import pro.taskana.TaskState;
import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaRole;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.impl.CategoryReport;
import pro.taskana.impl.report.impl.ClassificationReport;
import pro.taskana.impl.report.impl.CombinedClassificationFilter;
import pro.taskana.impl.report.impl.CustomFieldValueReport;
import pro.taskana.impl.report.impl.DaysToWorkingDaysPreProcessor;
import pro.taskana.impl.report.impl.DetailedClassificationReport;
import pro.taskana.impl.report.impl.DetailedMonitorQueryItem;
import pro.taskana.impl.report.impl.MonitorQueryItem;
import pro.taskana.impl.report.impl.TaskQueryItem;
import pro.taskana.impl.report.impl.TaskStatusReport;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.impl.report.impl.WorkbasketLevelReport;
import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.mappings.TaskMonitorMapper; import pro.taskana.mappings.TaskMonitorMapper;
/** /**
@ -45,400 +26,28 @@ public class TaskMonitorServiceImpl implements TaskMonitorService {
} }
@Override @Override
public WorkbasketLevelReport getWorkbasketLevelReport(List<String> workbasketIds, List<TaskState> states, public WorkbasketReportBuilderImpl createWorkbasketReportBuilder() {
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues, return new WorkbasketReportBuilderImpl(taskanaEngineImpl, taskMonitorMapper);
List<CombinedClassificationFilter> combinedClassificationFilter)
throws InvalidArgumentException, NotAuthorizedException {
return getWorkbasketLevelReport(workbasketIds, states, categories, domains, customField, customFieldValues,
combinedClassificationFilter, Collections.emptyList(), false);
} }
@Override @Override
public WorkbasketLevelReport getWorkbasketLevelReport(List<String> workbasketIds, List<TaskState> states, public CategoryReportBuilder createCategoryReportBuilder() {
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues, return new CategoryReportBuilderImpl(taskanaEngineImpl, taskMonitorMapper);
List<CombinedClassificationFilter> combinedClassificationFilter, List<TimeIntervalColumnHeader> columnHeaders)
throws InvalidArgumentException, NotAuthorizedException {
return getWorkbasketLevelReport(workbasketIds, states, categories, domains, customField, customFieldValues,
combinedClassificationFilter, columnHeaders, true);
} }
@Override @Override
public WorkbasketLevelReport getWorkbasketLevelReport(List<String> workbasketIds, List<TaskState> states, public ClassificationReportBuilder createClassificationReportBuilder() {
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues, return new ClassificationReportBuilderImpl(taskanaEngineImpl, taskMonitorMapper);
List<CombinedClassificationFilter> combinedClassificationFilter, List<TimeIntervalColumnHeader> columnHeaders,
boolean inWorkingDays) throws InvalidArgumentException, NotAuthorizedException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("entry to getWorkbasketLevelReport(workbasketIds = {}, states = {}, categories = {}, "
+ "domains = {}, customField = {}, customFieldValues = {}, combinedClassificationFilter = {}, "
+ "columnHeaders = {}, inWorkingDays = {})", LoggerUtils.listToString(workbasketIds),
LoggerUtils.listToString(states), LoggerUtils.listToString(categories),
LoggerUtils.listToString(domains), customField, LoggerUtils.listToString(customFieldValues),
LoggerUtils.listToString(combinedClassificationFilter), LoggerUtils.listToString(columnHeaders),
inWorkingDays);
}
taskanaEngineImpl.checkRoleMembership(TaskanaRole.MONITOR);
try {
taskanaEngineImpl.openConnection();
configureDaysToWorkingDaysConverter();
WorkbasketLevelReport report = new WorkbasketLevelReport(columnHeaders);
List<MonitorQueryItem> monitorQueryItems = taskMonitorMapper.getTaskCountOfWorkbaskets(
workbasketIds, states, categories, domains, customField, customFieldValues,
combinedClassificationFilter);
report.addItems(monitorQueryItems, new DaysToWorkingDaysPreProcessor<>(columnHeaders, inWorkingDays));
return report;
} finally {
taskanaEngineImpl.returnConnection();
LOGGER.debug("exit from getWorkbasketLevelReport().");
}
} }
@Override @Override
public CategoryReport getCategoryReport(List<String> workbasketIds, List<TaskState> states, List<String> categories, public CustomFieldValueReportBuilderImpl createCustomFieldValueReportBuilder(CustomField customField) {
List<String> domains, CustomField customField, List<String> customFieldValues) return new CustomFieldValueReportBuilderImpl(taskanaEngineImpl, taskMonitorMapper, customField);
throws InvalidArgumentException, NotAuthorizedException {
return getCategoryReport(workbasketIds, states, categories, domains, customField, customFieldValues,
Collections.emptyList(),
false);
} }
@Override @Override
public CategoryReport getCategoryReport(List<String> workbasketIds, List<TaskState> states, List<String> categories, public TaskStatusReportBuilderImpl createTaskStatusReportBuilder() {
List<String> domains, CustomField customField, List<String> customFieldValues, return new TaskStatusReportBuilderImpl(taskanaEngineImpl, taskMonitorMapper);
List<TimeIntervalColumnHeader> columnHeaders) throws InvalidArgumentException, NotAuthorizedException {
return getCategoryReport(workbasketIds, states, categories, domains, customField, customFieldValues,
columnHeaders, true);
}
@Override
public CategoryReport getCategoryReport(List<String> workbasketIds, List<TaskState> states, List<String> categories,
List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays)
throws InvalidArgumentException, NotAuthorizedException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("entry to getCategoryReport(workbasketIds = {}, states = {}, categories = {}, "
+ "domains = {}, customField = {}, customFieldValues = {}, reportLineItemDefinitions = {}, "
+ "inWorkingDays = {})", LoggerUtils.listToString(workbasketIds), LoggerUtils.listToString(states),
LoggerUtils.listToString(categories), LoggerUtils.listToString(domains), customField,
LoggerUtils.listToString(customFieldValues), LoggerUtils.listToString(columnHeaders),
inWorkingDays);
}
taskanaEngineImpl.checkRoleMembership(TaskanaRole.MONITOR);
try {
taskanaEngineImpl.openConnection();
configureDaysToWorkingDaysConverter();
CategoryReport report = new CategoryReport(columnHeaders);
List<MonitorQueryItem> monitorQueryItems = taskMonitorMapper.getTaskCountOfCategories(
workbasketIds, states, categories, domains, customField, customFieldValues);
report.addItems(monitorQueryItems, new DaysToWorkingDaysPreProcessor<>(columnHeaders, inWorkingDays));
return report;
} finally {
taskanaEngineImpl.returnConnection();
LOGGER.debug("exit from getCategoryReport().");
}
}
@Override
public ClassificationReport getClassificationReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues)
throws InvalidArgumentException, NotAuthorizedException {
return getClassificationReport(workbasketIds, states, categories, domains, customField, customFieldValues,
Collections.emptyList(), false);
}
@Override
public ClassificationReport getClassificationReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders) throws InvalidArgumentException, NotAuthorizedException {
return getClassificationReport(workbasketIds, states, categories, domains, customField, customFieldValues,
columnHeaders, true);
}
@Override
public ClassificationReport getClassificationReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays)
throws InvalidArgumentException, NotAuthorizedException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("entry to getClassificationReport(workbasketIds = {}, states = {}, categories = {}, "
+ "domains = {}, customField = {}, customFieldValues = {}, columnHeaders = {}, "
+ "inWorkingDays = {})", LoggerUtils.listToString(workbasketIds), LoggerUtils.listToString(states),
LoggerUtils.listToString(categories), LoggerUtils.listToString(domains), customField,
LoggerUtils.listToString(customFieldValues), LoggerUtils.listToString(columnHeaders),
inWorkingDays);
}
taskanaEngineImpl.checkRoleMembership(TaskanaRole.MONITOR);
try {
taskanaEngineImpl.openConnection();
configureDaysToWorkingDaysConverter();
ClassificationReport report = new ClassificationReport(columnHeaders);
List<MonitorQueryItem> monitorQueryItems = taskMonitorMapper.getTaskCountOfClassifications(
workbasketIds, states, categories, domains, customField, customFieldValues);
report.addItems(monitorQueryItems, new DaysToWorkingDaysPreProcessor<>(columnHeaders, inWorkingDays));
return report;
} finally {
taskanaEngineImpl.returnConnection();
LOGGER.debug("exit from getClassificationReport().");
}
}
@Override
public DetailedClassificationReport getDetailedClassificationReport(List<String> workbasketIds,
List<TaskState> states, List<String> categories, List<String> domains, CustomField customField,
List<String> customFieldValues) throws InvalidArgumentException, NotAuthorizedException {
return getDetailedClassificationReport(workbasketIds, states, categories, domains, customField,
customFieldValues, Collections.emptyList(), false);
}
@Override
public DetailedClassificationReport getDetailedClassificationReport(List<String> workbasketIds,
List<TaskState> states, List<String> categories, List<String> domains, CustomField customField,
List<String> customFieldValues, List<TimeIntervalColumnHeader> columnHeaders)
throws InvalidArgumentException, NotAuthorizedException {
return getDetailedClassificationReport(workbasketIds, states, categories, domains, customField,
customFieldValues, columnHeaders, true);
}
@Override
public DetailedClassificationReport getDetailedClassificationReport(List<String> workbasketIds,
List<TaskState> states, List<String> categories, List<String> domains, CustomField customField,
List<String> customFieldValues, List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays)
throws InvalidArgumentException, NotAuthorizedException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("entry to getDetailedClassificationReport(workbasketIds = {}, states = {}, "
+ "categories = {}, domains = {}, customField = {}, customFieldValues = {}, "
+ "columnHeaders = {}, inWorkingDays = {})", LoggerUtils.listToString(workbasketIds),
LoggerUtils.listToString(states), LoggerUtils.listToString(categories),
LoggerUtils.listToString(domains), customField, LoggerUtils.listToString(customFieldValues),
LoggerUtils.listToString(columnHeaders), inWorkingDays);
}
taskanaEngineImpl.checkRoleMembership(TaskanaRole.MONITOR);
try {
taskanaEngineImpl.openConnection();
configureDaysToWorkingDaysConverter();
DetailedClassificationReport report = new DetailedClassificationReport(columnHeaders);
List<DetailedMonitorQueryItem> detailedMonitorQueryItems = taskMonitorMapper
.getTaskCountOfDetailedClassifications(workbasketIds, states, categories, domains, customField,
customFieldValues);
report.addItems(detailedMonitorQueryItems,
new DaysToWorkingDaysPreProcessor<>(columnHeaders, inWorkingDays));
return report;
} finally {
taskanaEngineImpl.returnConnection();
LOGGER.debug("exit from getDetailedClassificationReport().");
}
}
@Override
public CustomFieldValueReport getCustomFieldValueReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues)
throws InvalidArgumentException, NotAuthorizedException {
return getCustomFieldValueReport(workbasketIds, states, categories, domains, customField, customFieldValues,
Collections.emptyList(), false);
}
@Override
public CustomFieldValueReport getCustomFieldValueReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders) throws InvalidArgumentException, NotAuthorizedException {
return getCustomFieldValueReport(workbasketIds, states, categories, domains, customField, customFieldValues,
columnHeaders, true);
}
@Override
public CustomFieldValueReport getCustomFieldValueReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, CustomField customField, List<String> customFieldValues,
List<TimeIntervalColumnHeader> columnHeaders, boolean inWorkingDays)
throws InvalidArgumentException, NotAuthorizedException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("entry to getCustomFieldValueReport(workbasketIds = {}, states = {}, categories = {}, "
+ "domains = {}, customField = {}, customFieldValues = {}, columnHeaders = {}, "
+ "inWorkingDays = {})", LoggerUtils.listToString(workbasketIds), LoggerUtils.listToString(states),
LoggerUtils.listToString(categories), LoggerUtils.listToString(domains), customField,
LoggerUtils.listToString(customFieldValues), LoggerUtils.listToString(columnHeaders),
inWorkingDays);
}
taskanaEngineImpl.checkRoleMembership(TaskanaRole.MONITOR);
try {
taskanaEngineImpl.openConnection();
if (customField == null) {
throw new InvalidArgumentException("CustomField can´t be used as NULL-Parameter");
}
configureDaysToWorkingDaysConverter();
CustomFieldValueReport report = new CustomFieldValueReport(columnHeaders);
List<MonitorQueryItem> monitorQueryItems = taskMonitorMapper.getTaskCountOfCustomFieldValues(
workbasketIds, states, categories, domains, customField, customFieldValues);
report.addItems(monitorQueryItems, new DaysToWorkingDaysPreProcessor<>(columnHeaders, inWorkingDays));
return report;
} finally {
taskanaEngineImpl.returnConnection();
LOGGER.debug("exit from getCustomFieldValueReport().");
}
}
@Override
public List<String> getCustomAttributeValuesForReport(List<String> workbasketIds, List<TaskState> states,
List<String> categories, List<String> domains, List<String> classificationIds,
List<String> excludedClassificationIds, Map<String, String> customAttributeFilter,
String customAttributeName) throws InvalidArgumentException, NotAuthorizedException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("entry to getCustomAttributeValuesForReport(workbasketIds = {}, states = {}, "
+ "categories = {}, domains = {}, classificationIds = {}, excludedClassificationIds = {}, customAttributeName = {})",
LoggerUtils.listToString(workbasketIds), LoggerUtils.listToString(states),
LoggerUtils.listToString(categories), LoggerUtils.listToString(domains),
LoggerUtils.listToString(classificationIds), LoggerUtils.listToString(excludedClassificationIds),
customAttributeName);
}
taskanaEngineImpl.checkRoleMembership(TaskanaRole.MONITOR);
try {
taskanaEngineImpl.openConnection();
if (customAttributeName == null || customAttributeName.isEmpty()) {
throw new InvalidArgumentException("customAttributeName must not be null.");
}
List<String> customAttributeValues = taskMonitorMapper.getCustomAttributeValuesForReport(workbasketIds,
states,
categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter,
"CUSTOM_" + customAttributeName);
return customAttributeValues;
} finally {
taskanaEngineImpl.returnConnection();
LOGGER.debug("exit from getCustomAttributeValuesForReport().");
}
}
@Override
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, NotAuthorizedException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("entry to getTaskIdsForSelectedItems(workbasketIds = {}, states = {}, "
+ "categories = {}, domains = {}, customField = {}, customFieldValues = {}, "
+ "columnHeaders = {}, inWorkingDays = {}, selectedItems = {}, dimension = {})",
LoggerUtils.listToString(workbasketIds), LoggerUtils.listToString(states),
LoggerUtils.listToString(categories), LoggerUtils.listToString(domains),
LoggerUtils.listToString(classificationIds), LoggerUtils.listToString(excludedClassificationIds),
customField,
LoggerUtils.listToString(customFieldValues), LoggerUtils.listToString(columnHeaders),
inWorkingDays, LoggerUtils.listToString(selectedItems), dimension);
}
taskanaEngineImpl.checkRoleMembership(TaskanaRole.MONITOR);
try {
taskanaEngineImpl.openConnection();
if (columnHeaders == null) {
throw new InvalidArgumentException("ColumnHeader must not be null.");
}
if (selectedItems == null || selectedItems.size() == 0) {
throw new InvalidArgumentException(
"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();
if (inWorkingDays) {
selectedItems = convertWorkingDaysToDays(selectedItems, columnHeaders);
}
List<String> taskIds = taskMonitorMapper.getTaskIdsForSelectedItems(workbasketIds, states,
categories, domains, classificationIds, excludedClassificationIds, customField, customFieldValues,
dimension, selectedItems, joinWithAttachments);
return taskIds;
} finally {
taskanaEngineImpl.returnConnection();
LOGGER.debug("exit from getTaskIdsForSelectedItems().");
}
}
@Override
public TaskStatusReport getTaskStatusReport() throws NotAuthorizedException {
return getTaskStatusReport(null, null);
}
@Override
public TaskStatusReport getTaskStatusReport(List<String> domains) throws NotAuthorizedException {
return getTaskStatusReport(domains, null);
}
@Override
public TaskStatusReport getTaskStatusReport(List<String> domains, List<TaskState> states)
throws NotAuthorizedException {
taskanaEngineImpl.checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN);
try {
taskanaEngineImpl.openConnection();
List<TaskQueryItem> tasks = taskMonitorMapper.getTasksCountByState(domains, states);
TaskStatusReport report = new TaskStatusReport(states);
report.addItems(tasks);
return report;
} finally {
taskanaEngineImpl.returnConnection();
}
}
private List<SelectedItem> convertWorkingDaysToDays(List<SelectedItem> selectedItems,
List<TimeIntervalColumnHeader> columnHeaders) throws InvalidArgumentException {
DaysToWorkingDaysConverter instance = DaysToWorkingDaysConverter.initialize(columnHeaders);
for (SelectedItem selectedItem : selectedItems) {
selectedItem
.setLowerAgeLimit(Collections.min(instance.convertWorkingDaysToDays(selectedItem.getLowerAgeLimit())));
selectedItem
.setUpperAgeLimit(Collections.max(instance.convertWorkingDaysToDays(selectedItem.getUpperAgeLimit())));
}
return selectedItems;
}
private void configureDaysToWorkingDaysConverter() {
DaysToWorkingDaysConverter.setCustomHolidays(taskanaEngineImpl.getConfiguration().getCustomHolidays());
DaysToWorkingDaysConverter.setGermanPublicHolidaysEnabled(
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;
} }
} }

View File

@ -0,0 +1,61 @@
package pro.taskana.impl;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.TaskState;
import pro.taskana.TaskStatusReportBuilder;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaRole;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.impl.TaskQueryItem;
import pro.taskana.impl.report.impl.TaskStatusReport;
import pro.taskana.mappings.TaskMonitorMapper;
/**
* The implementation of TaskStatusReportBuilder.
*/
public class TaskStatusReportBuilderImpl implements TaskStatusReportBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskStatusReportBuilderImpl.class);
private TaskanaEngineImpl taskanaEngine;
private TaskMonitorMapper taskMonitorMapper;
private List<String> domains;
private List<TaskState> states;
public TaskStatusReportBuilderImpl(TaskanaEngine taskanaEngine, TaskMonitorMapper taskMonitorMapper) {
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
this.taskMonitorMapper = taskMonitorMapper;
}
@Override
public TaskStatusReportBuilderImpl stateIn(List<TaskState> states) {
this.states = states;
return this;
}
@Override
public TaskStatusReportBuilderImpl domainIn(List<String> domains) {
this.domains = domains;
return this;
}
@Override
public TaskStatusReport buildReport() throws NotAuthorizedException {
LOGGER.debug("entry to buildReport(), this = {}", this);
this.taskanaEngine.checkRoleMembership(TaskanaRole.MONITOR, TaskanaRole.ADMIN);
try {
this.taskanaEngine.openConnection();
List<TaskQueryItem> tasks = this.taskMonitorMapper.getTasksCountByState(this.domains, this.states);
TaskStatusReport report = new TaskStatusReport(this.states);
report.addItems(tasks);
return report;
} finally {
this.taskanaEngine.returnConnection();
LOGGER.debug("exit from buildReport().");
}
}
}

View File

@ -0,0 +1,119 @@
package pro.taskana.impl;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.CustomField;
import pro.taskana.TaskState;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaRole;
import pro.taskana.WorkbasketReportBuilder;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.impl.CombinedClassificationFilter;
import pro.taskana.impl.report.impl.DaysToWorkingDaysPreProcessor;
import pro.taskana.impl.report.impl.MonitorQueryItem;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.impl.report.impl.WorkbasketReport;
import pro.taskana.mappings.TaskMonitorMapper;
/**
* The implementation of WorkbasketReportBuilder.
*/
public class WorkbasketReportBuilderImpl extends ReportBuilder implements WorkbasketReportBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketReportBuilderImpl.class);
private List<CombinedClassificationFilter> combinedClassificationFilter;
public WorkbasketReportBuilderImpl(TaskanaEngine taskanaEngine, TaskMonitorMapper taskMonitorMapper) {
super(taskanaEngine, taskMonitorMapper);
}
@Override
public WorkbasketReportBuilderImpl withColumnHeaders(List<TimeIntervalColumnHeader> columnHeaders) {
this.columnHeaders = columnHeaders;
return this;
}
@Override
public WorkbasketReportBuilderImpl inWorkingDays() {
this.inWorkingDays = true;
return this;
}
@Override
public WorkbasketReportBuilderImpl workbasketIdIn(List<String> workbasketIds) {
this.workbasketIds = workbasketIds;
return this;
}
@Override
public WorkbasketReportBuilderImpl stateIn(List<TaskState> states) {
this.states = states;
return this;
}
@Override
public WorkbasketReportBuilderImpl categoryIn(List<String> categories) {
this.categories = categories;
return this;
}
@Override
public WorkbasketReportBuilderImpl domainIn(List<String> domains) {
this.domains = domains;
return this;
}
@Override
public WorkbasketReportBuilderImpl classificationIdIn(List<String> classificationIds) {
this.classificationIds = classificationIds;
return this;
}
@Override
public WorkbasketReportBuilderImpl excludedClassificationIdIn(List<String> excludedClassificationIds) {
this.excludedClassificationIds = excludedClassificationIds;
return this;
}
@Override
public WorkbasketReportBuilderImpl customAttributeFilterIn(Map<CustomField, String> customAttributeFilter) {
this.customAttributeFilter = customAttributeFilter;
return this;
}
@Override
public WorkbasketReportBuilderImpl combinedClassificationFilterIn(
List<CombinedClassificationFilter> combinedClassificationFilter) {
this.combinedClassificationFilter = combinedClassificationFilter;
return this;
}
public List<CombinedClassificationFilter> getCombinedClassificationFilterIn() {
return this.combinedClassificationFilter;
}
@Override
public WorkbasketReport buildReport() throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug("entry to buildReport(), this = {}", this);
this.taskanaEngine.checkRoleMembership(TaskanaRole.MONITOR);
try {
this.taskanaEngine.openConnection();
WorkbasketReport report = new WorkbasketReport(this.columnHeaders);
List<MonitorQueryItem> monitorQueryItems = this.taskMonitorMapper.getTaskCountOfWorkbaskets(
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 buildReport().");
}
}
}

View File

@ -2,8 +2,8 @@ package pro.taskana.impl.report.impl;
/** /**
* The CombinedClassificationFilter is a pair of a classificationId for a task and a classificationId for the * The CombinedClassificationFilter is a pair of a classificationId for a task and a classificationId for the
* corresponding attachment that is used to filter the {@link WorkbasketLevelReport} by the classification of the * corresponding attachment that is used to filter the {@link WorkbasketReport} by the classification of the attachment.
* attachment. To filter by the classification of the task, the classificationId of the attachment should be null. * To filter by the classification of the task, the classificationId of the attachment should be null.
*/ */
public class CombinedClassificationFilter { public class CombinedClassificationFilter {

View File

@ -7,9 +7,9 @@ import pro.taskana.impl.report.Report;
/** /**
* TODO. * TODO.
*/ */
public class WorkbasketLevelReport extends Report<MonitorQueryItem, TimeIntervalColumnHeader> { public class WorkbasketReport extends Report<MonitorQueryItem, TimeIntervalColumnHeader> {
public WorkbasketLevelReport(List<TimeIntervalColumnHeader> timeIntervalColumnHeaders) { public WorkbasketReport(List<TimeIntervalColumnHeader> timeIntervalColumnHeaders) {
super(timeIntervalColumnHeaders, "WORKBASKET KEYS"); super(timeIntervalColumnHeaders, "WORKBASKET KEYS");
} }

View File

@ -39,8 +39,14 @@ public interface TaskMonitorMapper {
+ "<if test=\"domains != null\">" + "<if test=\"domains != null\">"
+ "AND T.DOMAIN IN (<foreach collection='domains' item='domain' separator=','>#{domain}</foreach>) " + "AND T.DOMAIN IN (<foreach collection='domains' item='domain' separator=','>#{domain}</foreach>) "
+ "</if>" + "</if>"
+ "<if test=\"customField != null and customFieldValues != null\">" + "<if test='classificationIds != null'>"
+ "AND ${customField} IN (<foreach collection='customFieldValues' item='customFieldValue' separator=','>#{customFieldValue}</foreach>) " + "AND CLASSIFICATION_ID IN (<foreach collection='classificationIds' item='classificationId' separator=','>#{classificationId}</foreach>) "
+ "</if>"
+ "<if test='excludedClassificationIds != null'>"
+ "AND CLASSIFICATION_ID NOT IN (<foreach collection='excludedClassificationIds' item='excludedClassificationId' separator=','>#{excludedClassificationId}</foreach>) "
+ "</if>"
+ "<if test='customAttributeFilter != null'>"
+ "AND (<foreach collection='customAttributeFilter.keys' item='key' separator=' AND '>(${key} = '${customAttributeFilter.get(key)}')</foreach>) "
+ "</if>" + "</if>"
+ "<if test=\"combinedClassificationFilter != null\">" + "<if test=\"combinedClassificationFilter != null\">"
+ "AND <foreach collection='combinedClassificationFilter' item='item' separator='OR'> " + "AND <foreach collection='combinedClassificationFilter' item='item' separator='OR'> "
@ -65,8 +71,9 @@ public interface TaskMonitorMapper {
@Param("states") List<TaskState> states, @Param("states") List<TaskState> states,
@Param("categories") List<String> categories, @Param("categories") List<String> categories,
@Param("domains") List<String> domains, @Param("domains") List<String> domains,
@Param("customField") CustomField customField, @Param("classificationIds") List<String> classificationIds,
@Param("customFieldValues") List<String> customFieldValues, @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter,
@Param("combinedClassificationFilter") List<CombinedClassificationFilter> combinedClassificationFilter); @Param("combinedClassificationFilter") List<CombinedClassificationFilter> combinedClassificationFilter);
@Select("<script>" @Select("<script>"
@ -87,8 +94,14 @@ public interface TaskMonitorMapper {
+ "<if test=\"domains != null\">" + "<if test=\"domains != null\">"
+ "AND DOMAIN IN (<foreach collection='domains' item='domain' separator=','>#{domain}</foreach>) " + "AND DOMAIN IN (<foreach collection='domains' item='domain' separator=','>#{domain}</foreach>) "
+ "</if>" + "</if>"
+ "<if test=\"customField != null and customFieldValues != null\">" + "<if test='classificationIds != null'>"
+ "AND ${customField} IN (<foreach collection='customFieldValues' item='customFieldValue' separator=','>#{customFieldValue}</foreach>) " + "AND CLASSIFICATION_ID IN (<foreach collection='classificationIds' item='classificationId' separator=','>#{classificationId}</foreach>) "
+ "</if>"
+ "<if test='excludedClassificationIds != null'>"
+ "AND CLASSIFICATION_ID NOT IN (<foreach collection='excludedClassificationIds' item='excludedClassificationId' separator=','>#{excludedClassificationId}</foreach>) "
+ "</if>"
+ "<if test='customAttributeFilter != null'>"
+ "AND (<foreach collection='customAttributeFilter.keys' item='key' separator=' AND '>(${key} = '${customAttributeFilter.get(key)}')</foreach>) "
+ "</if>" + "</if>"
+ "AND DUE IS NOT NULL " + "AND DUE IS NOT NULL "
+ "</where>" + "</where>"
@ -105,8 +118,9 @@ public interface TaskMonitorMapper {
@Param("states") List<TaskState> states, @Param("states") List<TaskState> states,
@Param("categories") List<String> categories, @Param("categories") List<String> categories,
@Param("domains") List<String> domains, @Param("domains") List<String> domains,
@Param("customField") CustomField customField, @Param("classificationIds") List<String> classificationIds,
@Param("customFieldValues") List<String> customFieldValues); @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter);
@Select("<script>" @Select("<script>"
+ "<if test=\"_databaseId == 'db2'\">SELECT CLASSIFICATION_KEY, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS</if> " + "<if test=\"_databaseId == 'db2'\">SELECT CLASSIFICATION_KEY, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS</if> "
@ -126,8 +140,14 @@ public interface TaskMonitorMapper {
+ "<if test=\"domains != null\">" + "<if test=\"domains != null\">"
+ "AND DOMAIN IN (<foreach collection='domains' item='domain' separator=','>#{domain}</foreach>) " + "AND DOMAIN IN (<foreach collection='domains' item='domain' separator=','>#{domain}</foreach>) "
+ "</if>" + "</if>"
+ "<if test=\"customField != null and customFieldValues != null\">" + "<if test='classificationIds != null'>"
+ "AND ${customField} IN (<foreach collection='customFieldValues' item='customFieldValue' separator=','>#{customFieldValue}</foreach>) " + "AND CLASSIFICATION_ID IN (<foreach collection='classificationIds' item='classificationId' separator=','>#{classificationId}</foreach>) "
+ "</if>"
+ "<if test='excludedClassificationIds != null'>"
+ "AND CLASSIFICATION_ID NOT IN (<foreach collection='excludedClassificationIds' item='excludedClassificationId' separator=','>#{excludedClassificationId}</foreach>) "
+ "</if>"
+ "<if test='customAttributeFilter != null'>"
+ "AND (<foreach collection='customAttributeFilter.keys' item='key' separator=' AND '>(${key} = '${customAttributeFilter.get(key)}')</foreach>) "
+ "</if>" + "</if>"
+ "AND DUE IS NOT NULL " + "AND DUE IS NOT NULL "
+ "</where>" + "</where>"
@ -144,8 +164,9 @@ public interface TaskMonitorMapper {
@Param("states") List<TaskState> states, @Param("states") List<TaskState> states,
@Param("categories") List<String> categories, @Param("categories") List<String> categories,
@Param("domains") List<String> domains, @Param("domains") List<String> domains,
@Param("customField") CustomField customField, @Param("classificationIds") List<String> classificationIds,
@Param("customFieldValues") List<String> customFieldValues); @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter);
@Select("<script>" @Select("<script>"
+ "<if test=\"_databaseId == 'db2'\">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</if> " + "<if test=\"_databaseId == 'db2'\">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</if> "
@ -165,8 +186,14 @@ public interface TaskMonitorMapper {
+ "<if test=\"domains != null\">" + "<if test=\"domains != null\">"
+ "AND DOMAIN IN (<foreach collection='domains' item='domain' separator=','>#{domain}</foreach>) " + "AND DOMAIN IN (<foreach collection='domains' item='domain' separator=','>#{domain}</foreach>) "
+ "</if>" + "</if>"
+ "<if test=\"customField != null and customFieldValues != null\">" + "<if test='classificationIds != null'>"
+ "AND ${customField} IN (<foreach collection='customFieldValues' item='customFieldValue' separator=','>#{customFieldValue}</foreach>) " + "AND CLASSIFICATION_ID IN (<foreach collection='classificationIds' item='classificationId' separator=','>#{classificationId}</foreach>) "
+ "</if>"
+ "<if test='excludedClassificationIds != null'>"
+ "AND CLASSIFICATION_ID NOT IN (<foreach collection='excludedClassificationIds' item='excludedClassificationId' separator=','>#{excludedClassificationId}</foreach>) "
+ "</if>"
+ "<if test='customAttributeFilter != null'>"
+ "AND (<foreach collection='customAttributeFilter.keys' item='key' separator=' AND '>(${key} = '${customAttributeFilter.get(key)}')</foreach>) "
+ "</if>" + "</if>"
+ "AND DUE IS NOT NULL " + "AND DUE IS NOT NULL "
+ "</where>" + "</where>"
@ -185,8 +212,9 @@ public interface TaskMonitorMapper {
@Param("states") List<TaskState> states, @Param("states") List<TaskState> states,
@Param("categories") List<String> categories, @Param("categories") List<String> categories,
@Param("domains") List<String> domains, @Param("domains") List<String> domains,
@Param("customField") CustomField customField, @Param("classificationIds") List<String> classificationIds,
@Param("customFieldValues") List<String> customFieldValues); @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter);
@Select("<script>" @Select("<script>"
+ "<if test=\"_databaseId == 'db2'\">SELECT ${customField} as CUSTOM_FIELD, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS</if> " + "<if test=\"_databaseId == 'db2'\">SELECT ${customField} as CUSTOM_FIELD, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS</if> "
@ -206,8 +234,14 @@ public interface TaskMonitorMapper {
+ "<if test=\"domains != null\">" + "<if test=\"domains != null\">"
+ "AND DOMAIN IN (<foreach collection='domains' item='domain' separator=','>#{domain}</foreach>) " + "AND DOMAIN IN (<foreach collection='domains' item='domain' separator=','>#{domain}</foreach>) "
+ "</if>" + "</if>"
+ "<if test=\"customField != null and customFieldValues != null\">" + "<if test='classificationIds != null'>"
+ "AND ${customField} IN (<foreach collection='customFieldValues' item='customFieldValue' separator=','>#{customFieldValue}</foreach>) " + "AND CLASSIFICATION_ID IN (<foreach collection='classificationIds' item='classificationId' separator=','>#{classificationId}</foreach>) "
+ "</if>"
+ "<if test='excludedClassificationIds != null'>"
+ "AND CLASSIFICATION_ID NOT IN (<foreach collection='excludedClassificationIds' item='excludedClassificationId' separator=','>#{excludedClassificationId}</foreach>) "
+ "</if>"
+ "<if test='customAttributeFilter != null'>"
+ "AND (<foreach collection='customAttributeFilter.keys' item='key' separator=' AND '>(${key} = '${customAttributeFilter.get(key)}')</foreach>) "
+ "</if>" + "</if>"
+ "AND DUE IS NOT NULL " + "AND DUE IS NOT NULL "
+ "</where>" + "</where>"
@ -220,12 +254,15 @@ public interface TaskMonitorMapper {
@Result(column = "CUSTOM_FIELD", property = "key"), @Result(column = "CUSTOM_FIELD", property = "key"),
@Result(column = "AGE_IN_DAYS", property = "ageInDays"), @Result(column = "AGE_IN_DAYS", property = "ageInDays"),
@Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")}) @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks")})
List<MonitorQueryItem> getTaskCountOfCustomFieldValues(@Param("workbasketIds") List<String> workbasketIds, List<MonitorQueryItem> getTaskCountOfCustomFieldValues(
@Param("customField") CustomField customField,
@Param("workbasketIds") List<String> workbasketIds,
@Param("states") List<TaskState> states, @Param("states") List<TaskState> states,
@Param("categories") List<String> categories, @Param("categories") List<String> categories,
@Param("domains") List<String> domains, @Param("domains") List<String> domains,
@Param("customField") CustomField customField, @Param("classificationIds") List<String> classificationIds,
@Param("customFieldValues") List<String> customFieldValues); @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter);
@Select("<script>" @Select("<script>"
+ "SELECT T.ID FROM TASKANA.TASK T " + "SELECT T.ID FROM TASKANA.TASK T "
@ -251,8 +288,8 @@ public interface TaskMonitorMapper {
+ "<if test='excludedClassificationIds != null'>" + "<if test='excludedClassificationIds != null'>"
+ "AND T.CLASSIFICATION_ID NOT IN (<foreach collection='excludedClassificationIds' item='excludedClassificationId' separator=','>#{excludedClassificationId}</foreach>) " + "AND T.CLASSIFICATION_ID NOT IN (<foreach collection='excludedClassificationIds' item='excludedClassificationId' separator=','>#{excludedClassificationId}</foreach>) "
+ "</if>" + "</if>"
+ "<if test=\"customField != null and customFieldValues != null\">" + "<if test='customAttributeFilter != null'>"
+ "AND T.${customField} IN (<foreach collection='customFieldValues' item='customFieldValue' separator=','>#{customFieldValue}</foreach>) " + "AND (<foreach collection='customAttributeFilter.keys' item='key' separator=' AND '>(${key} = '${customAttributeFilter.get(key)}')</foreach>) "
+ "</if>" + "</if>"
+ "AND T.DUE IS NOT NULL AND ( " + "AND T.DUE IS NOT NULL AND ( "
+ "<foreach collection='selectedItems' item='selectedItem' separator=' OR '>" + "<foreach collection='selectedItems' item='selectedItem' separator=' OR '>"
@ -278,10 +315,11 @@ public interface TaskMonitorMapper {
+ "</script>") + "</script>")
List<String> getTaskIdsForSelectedItems(@Param("workbasketIds") List<String> workbasketIds, List<String> getTaskIdsForSelectedItems(@Param("workbasketIds") List<String> workbasketIds,
@Param("states") List<TaskState> states, @Param("states") List<TaskState> states,
@Param("categories") List<String> categories, @Param("domains") List<String> domains, @Param("categories") List<String> categories,
@Param("domains") List<String> domains,
@Param("classificationIds") List<String> classificationIds, @Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds, @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customField") CustomField customField, @Param("customFieldValues") List<String> customFieldValues, @Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter,
@Param("groupedBy") String groupedBy, @Param("selectedItems") List<SelectedItem> selectedItems, @Param("groupedBy") String groupedBy, @Param("selectedItems") List<SelectedItem> selectedItems,
@Param("joinWithAttachments") boolean joinWithAttachments); @Param("joinWithAttachments") boolean joinWithAttachments);
@ -307,7 +345,7 @@ public interface TaskMonitorMapper {
@Param("states") List<TaskState> states); @Param("states") List<TaskState> states);
@Select("<script>" @Select("<script>"
+ "SELECT DISTINCT ${customAttributeName} " + "SELECT DISTINCT ${customField} "
+ "FROM TASKANA.TASK " + "FROM TASKANA.TASK "
+ "<where>" + "<where>"
+ "<if test='workbasketIds != null'>" + "<if test='workbasketIds != null'>"
@ -329,7 +367,7 @@ public interface TaskMonitorMapper {
+ "AND CLASSIFICATION_ID NOT IN (<foreach collection='excludedClassificationIds' item='excludedClassificationId' separator=','>#{excludedClassificationId}</foreach>) " + "AND CLASSIFICATION_ID NOT IN (<foreach collection='excludedClassificationIds' item='excludedClassificationId' separator=','>#{excludedClassificationId}</foreach>) "
+ "</if>" + "</if>"
+ "<if test='customAttributeFilter != null'>" + "<if test='customAttributeFilter != null'>"
+ "AND (<foreach collection='customAttributeFilter.keys' item='key' separator=' AND '>(CUSTOM_${key} = '${customAttributeFilter.get(key)}')</foreach>) " + "AND (<foreach collection='customAttributeFilter.keys' item='key' separator=' AND '>(${key} = '${customAttributeFilter.get(key)}')</foreach>) "
+ "</if>" + "</if>"
+ "</where>" + "</where>"
+ "</script>") + "</script>")
@ -338,7 +376,7 @@ public interface TaskMonitorMapper {
@Param("categories") List<String> categories, @Param("domains") List<String> domains, @Param("categories") List<String> categories, @Param("domains") List<String> domains,
@Param("classificationIds") List<String> classificationIds, @Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds, @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<String, String> customAttributeFilter, @Param("customAttributeFilter") Map<CustomField, String> customAttributeFilter,
@Param("customAttributeName") String customAttributeName); @Param("customField") CustomField customField);
} }

View File

@ -18,12 +18,12 @@ import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import pro.taskana.CustomField;
import pro.taskana.TaskMonitorService; import pro.taskana.TaskMonitorService;
import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaEngine.ConnectionManagementMode; import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.database.TestDataGenerator; import pro.taskana.database.TestDataGenerator;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.configuration.DBCleaner; import pro.taskana.impl.configuration.DBCleaner;
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest; import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
@ -59,25 +59,23 @@ public class GetCustomAttributeValuesForReportAcctest {
} }
@Test(expected = NotAuthorizedException.class) @Test(expected = NotAuthorizedException.class)
public void testRoleCheck() throws InvalidArgumentException, NotAuthorizedException { public void testRoleCheck() throws NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
taskMonitorService.getCustomAttributeValuesForReport( taskMonitorService.createWorkbasketReportBuilder()
Collections.singletonList("WBI:000000000000000000000000000000000001"), null, .listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_2);
null, null, null, null, null,
"2");
} }
@WithAccessId( @WithAccessId(
userName = "monitor") userName = "monitor")
@Test @Test
public void testGetCustomAttributeValuesForOneWorkbasket() throws InvalidArgumentException, NotAuthorizedException { public void testGetCustomAttributeValuesForOneWorkbasket() throws NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<String> values = taskMonitorService.getCustomAttributeValuesForReport( List<String> values = taskMonitorService.createWorkbasketReportBuilder()
Collections.singletonList("WBI:000000000000000000000000000000000001"), null, .workbasketIdIn(Collections.singletonList("WBI:000000000000000000000000000000000001"))
null, null, null, null, null, .listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_2);
"2");
assertNotNull(values); assertNotNull(values);
assertEquals(2, values.size()); assertEquals(2, values.size());
@ -88,14 +86,12 @@ public class GetCustomAttributeValuesForReportAcctest {
@WithAccessId( @WithAccessId(
userName = "monitor") userName = "monitor")
@Test @Test
public void testGetCustomAttributeValuesForOneDomain() throws InvalidArgumentException, NotAuthorizedException { public void testGetCustomAttributeValuesForOneDomain() throws NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<String> values = taskMonitorService.getCustomAttributeValuesForReport( List<String> values = taskMonitorService.createWorkbasketReportBuilder()
null, null, .domainIn(Collections.singletonList("DOMAIN_A"))
null, Collections.singletonList("DOMAIN_A"), null, null, null, .listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_16);
"16");
assertNotNull(values); assertNotNull(values);
assertEquals(26, values.size()); assertEquals(26, values.size());
} }
@ -104,16 +100,16 @@ public class GetCustomAttributeValuesForReportAcctest {
userName = "monitor") userName = "monitor")
@Test @Test
public void testGetCustomAttributeValuesForCustomAttribute() public void testGetCustomAttributeValuesForCustomAttribute()
throws InvalidArgumentException, NotAuthorizedException { throws NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
Map<String, String> props = new HashMap<>(); Map<CustomField, String> customAttributeFilter = new HashMap<>();
props.put("2", "Vollkasko"); customAttributeFilter.put(CustomField.CUSTOM_2, "Vollkasko");
props.put("1", "Geschaeftsstelle A"); customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<String> values = taskMonitorService.getCustomAttributeValuesForReport(
null, null, List<String> values = taskMonitorService.createCategoryReportBuilder()
null, null, null, null, props, .customAttributeFilterIn(customAttributeFilter)
"16"); .listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_16);
assertNotNull(values); assertNotNull(values);
assertEquals(12, values.size()); assertEquals(12, values.size());
@ -123,17 +119,18 @@ public class GetCustomAttributeValuesForReportAcctest {
userName = "monitor") userName = "monitor")
@Test @Test
public void testGetCustomAttributeValuesForExcludedClassifications() public void testGetCustomAttributeValuesForExcludedClassifications()
throws InvalidArgumentException, NotAuthorizedException { throws NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<String> domains = new ArrayList<>(); List<String> domains = new ArrayList<>();
domains.add("DOMAIN_A"); domains.add("DOMAIN_A");
domains.add("DOMAIN_B"); domains.add("DOMAIN_B");
domains.add("DOMAIN_C"); domains.add("DOMAIN_C");
List<String> values = taskMonitorService.getCustomAttributeValuesForReport(
null, null, List<String> values = taskMonitorService.createCategoryReportBuilder()
null, domains, null, Collections.singletonList("CLI:000000000000000000000000000000000003"), null, .domainIn(domains)
"16"); .excludedClassificationIdIn(Collections.singletonList("CLI:000000000000000000000000000000000003"))
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_16);
assertNotNull(values); assertNotNull(values);
assertEquals(43, values.size()); assertEquals(43, values.size());

View File

@ -8,7 +8,9 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -68,9 +70,8 @@ public class GetTaskIdsOfCategoryReportAccTest {
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
List<SelectedItem> selectedItems = new ArrayList<>(); List<SelectedItem> selectedItems = new ArrayList<>();
taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null,
null, null, null, taskMonitorService.createCategoryReportBuilder().listTaskIdsForSelectedItems(selectedItems);
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY);
} }
@WithAccessId( @WithAccessId(
@ -101,9 +102,10 @@ public class GetTaskIdsOfCategoryReportAccTest {
s3.setUpperAgeLimit(0); s3.setUpperAgeLimit(0);
selectedItems.add(s3); selectedItems.add(s3);
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null, List<String> ids = taskMonitorService.createCategoryReportBuilder()
null, null, null, .withColumnHeaders(columnHeaders)
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY); .inWorkingDays()
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(11, ids.size()); assertEquals(11, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000006")); assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
@ -149,9 +151,11 @@ public class GetTaskIdsOfCategoryReportAccTest {
s3.setUpperAgeLimit(0); s3.setUpperAgeLimit(0);
selectedItems.add(s3); selectedItems.add(s3);
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(workbasketIds, null, null, null, null, List<String> ids = taskMonitorService.createCategoryReportBuilder()
null, null, null, .withColumnHeaders(columnHeaders)
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY); .inWorkingDays()
.workbasketIdIn(workbasketIds)
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(4, ids.size()); assertEquals(4, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000006")); assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
@ -190,9 +194,11 @@ public class GetTaskIdsOfCategoryReportAccTest {
s3.setUpperAgeLimit(0); s3.setUpperAgeLimit(0);
selectedItems.add(s3); selectedItems.add(s3);
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, states, null, null, null, List<String> ids = taskMonitorService.createCategoryReportBuilder()
null, null, null, .withColumnHeaders(columnHeaders)
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY); .inWorkingDays()
.stateIn(states)
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(11, ids.size()); assertEquals(11, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000006")); assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
@ -232,9 +238,11 @@ public class GetTaskIdsOfCategoryReportAccTest {
s2.setUpperAgeLimit(0); s2.setUpperAgeLimit(0);
selectedItems.add(s2); selectedItems.add(s2);
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, categories, null, null, List<String> ids = taskMonitorService.createCategoryReportBuilder()
null, null, null, .withColumnHeaders(columnHeaders)
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY); .inWorkingDays()
.categoryIn(categories)
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(3, ids.size()); assertEquals(3, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000006")); assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
@ -272,9 +280,11 @@ public class GetTaskIdsOfCategoryReportAccTest {
s3.setUpperAgeLimit(0); s3.setUpperAgeLimit(0);
selectedItems.add(s3); selectedItems.add(s3);
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, domains, null, List<String> ids = taskMonitorService.createCategoryReportBuilder()
null, null, null, .withColumnHeaders(columnHeaders)
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY); .inWorkingDays()
.domainIn(domains)
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(4, ids.size()); assertEquals(4, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000020")); assertTrue(ids.contains("TKI:000000000000000000000000000000000020"));
@ -290,8 +300,8 @@ public class GetTaskIdsOfCategoryReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
CustomField customField = CustomField.CUSTOM_1; Map<CustomField, String> customAttributeFilter = new HashMap<>();
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A"); customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
List<SelectedItem> selectedItems = new ArrayList<>(); List<SelectedItem> selectedItems = new ArrayList<>();
@ -314,10 +324,11 @@ public class GetTaskIdsOfCategoryReportAccTest {
s3.setUpperAgeLimit(0); s3.setUpperAgeLimit(0);
selectedItems.add(s3); selectedItems.add(s3);
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null, null, List<String> ids = taskMonitorService.createCategoryReportBuilder()
customField, .withColumnHeaders(columnHeaders)
customFieldValues, .inWorkingDays()
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY); .customAttributeFilterIn(customAttributeFilter)
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(5, ids.size()); assertEquals(5, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000020")); assertTrue(ids.contains("TKI:000000000000000000000000000000000020"));
@ -344,9 +355,8 @@ public class GetTaskIdsOfCategoryReportAccTest {
s1.setUpperAgeLimit(-2); s1.setUpperAgeLimit(-2);
selectedItems.add(s1); selectedItems.add(s1);
taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null, taskMonitorService.createCategoryReportBuilder().withColumnHeaders(columnHeaders).listTaskIdsForSelectedItems(
null, null, null, selectedItems);
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_CATEGORY);
} }
private List<TimeIntervalColumnHeader> getListOfColumnHeaders() { private List<TimeIntervalColumnHeader> getListOfColumnHeaders() {

View File

@ -83,9 +83,7 @@ public class GetTaskIdsOfClassificationReportAccTest {
s3.setUpperAgeLimit(-11); s3.setUpperAgeLimit(-11);
selectedItems.add(s3); selectedItems.add(s3);
taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null, taskMonitorService.createClassificationReportBuilder().listTaskIdsForSelectedItems(selectedItems);
null, null, null,
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_KEY);
} }
@WithAccessId( @WithAccessId(
@ -116,9 +114,10 @@ public class GetTaskIdsOfClassificationReportAccTest {
s3.setUpperAgeLimit(-11); s3.setUpperAgeLimit(-11);
selectedItems.add(s3); selectedItems.add(s3);
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null, List<String> ids = taskMonitorService.createClassificationReportBuilder()
null, null, null, .withColumnHeaders(columnHeaders)
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_KEY); .inWorkingDays()
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(6, ids.size()); assertEquals(6, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000001")); assertTrue(ids.contains("TKI:000000000000000000000000000000000001"));
@ -160,9 +159,10 @@ public class GetTaskIdsOfClassificationReportAccTest {
s3.setUpperAgeLimit(-11); s3.setUpperAgeLimit(-11);
selectedItems.add(s3); selectedItems.add(s3);
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null, List<String> ids = taskMonitorService.createClassificationReportBuilder()
null, null, null, .withColumnHeaders(columnHeaders)
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_KEY); .inWorkingDays()
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(2, ids.size()); assertEquals(2, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000001")); assertTrue(ids.contains("TKI:000000000000000000000000000000000001"));
@ -202,9 +202,11 @@ public class GetTaskIdsOfClassificationReportAccTest {
domains.add("DOMAIN_B"); domains.add("DOMAIN_B");
domains.add("DOMAIN_C"); domains.add("DOMAIN_C");
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, domains, null, List<String> ids = taskMonitorService.createClassificationReportBuilder()
null, null, null, .withColumnHeaders(columnHeaders)
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_CLASSIFICATION_KEY); .inWorkingDays()
.domainIn(domains)
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(3, ids.size()); assertEquals(3, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000001")); assertTrue(ids.contains("TKI:000000000000000000000000000000000001"));

View File

@ -0,0 +1,372 @@
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.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import pro.taskana.CustomField;
import pro.taskana.TaskMonitorService;
import pro.taskana.TaskState;
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.exceptions.NotAuthorizedException;
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;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
/**
* Acceptance test for all "get task ids of category report" scenarios.
*/
@RunWith(JAASRunner.class)
public class GetTaskIdsOfCustomFieldValueReportAccTest {
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(expected = NotAuthorizedException.class)
public void testRoleCheck() throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
List<SelectedItem> selectedItems = new ArrayList<>();
taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.listTaskIdsForSelectedItems(selectedItems);
}
@WithAccessId(
userName = "monitor")
@Test
public void testGetTaskIdsOfCustomFieldValueReport() throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
List<SelectedItem> selectedItems = new ArrayList<>();
SelectedItem s1 = new SelectedItem();
s1.setKey("Geschaeftsstelle A");
s1.setLowerAgeLimit(-5);
s1.setUpperAgeLimit(-2);
selectedItems.add(s1);
SelectedItem s2 = new SelectedItem();
s2.setKey("Geschaeftsstelle B");
s2.setLowerAgeLimit(Integer.MIN_VALUE);
s2.setUpperAgeLimit(-11);
selectedItems.add(s2);
SelectedItem s3 = new SelectedItem();
s3.setKey("Geschaeftsstelle C");
s3.setLowerAgeLimit(0);
s3.setUpperAgeLimit(0);
selectedItems.add(s3);
List<String> ids = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(8, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000002"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000009"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000020"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000024"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000027"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000029"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000033"));
}
@WithAccessId(
userName = "monitor")
@Test
public void testGetTaskIdsOfCustomFieldValueReportWithWorkbasketFilter()
throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
List<SelectedItem> selectedItems = new ArrayList<>();
SelectedItem s1 = new SelectedItem();
s1.setKey("Geschaeftsstelle A");
s1.setLowerAgeLimit(-5);
s1.setUpperAgeLimit(-2);
selectedItems.add(s1);
SelectedItem s2 = new SelectedItem();
s2.setKey("Geschaeftsstelle B");
s2.setLowerAgeLimit(Integer.MIN_VALUE);
s2.setUpperAgeLimit(-11);
selectedItems.add(s2);
SelectedItem s3 = new SelectedItem();
s3.setKey("Geschaeftsstelle C");
s3.setLowerAgeLimit(0);
s3.setUpperAgeLimit(0);
selectedItems.add(s3);
List<String> ids = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.workbasketIdIn(workbasketIds)
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(3, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000009"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000020"));
}
@WithAccessId(
userName = "monitor")
@Test
public void testGetTaskIdsOfCustomFieldValueReportWithStateFilter()
throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
List<SelectedItem> selectedItems = new ArrayList<>();
SelectedItem s1 = new SelectedItem();
s1.setKey("Geschaeftsstelle A");
s1.setLowerAgeLimit(-5);
s1.setUpperAgeLimit(-2);
selectedItems.add(s1);
SelectedItem s2 = new SelectedItem();
s2.setKey("Geschaeftsstelle B");
s2.setLowerAgeLimit(Integer.MIN_VALUE);
s2.setUpperAgeLimit(-11);
selectedItems.add(s2);
SelectedItem s3 = new SelectedItem();
s3.setKey("Geschaeftsstelle C");
s3.setLowerAgeLimit(0);
s3.setUpperAgeLimit(0);
selectedItems.add(s3);
List<String> ids = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.stateIn(Collections.singletonList(TaskState.READY))
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(8, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000002"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000009"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000020"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000024"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000027"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000029"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000033"));
}
@WithAccessId(
userName = "monitor")
@Test
public void testGetTaskIdsOfCustomFieldValueReportWithCategoryFilter()
throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL");
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
List<SelectedItem> selectedItems = new ArrayList<>();
SelectedItem s1 = new SelectedItem();
s1.setKey("Geschaeftsstelle A");
s1.setLowerAgeLimit(-5);
s1.setUpperAgeLimit(-2);
selectedItems.add(s1);
SelectedItem s2 = new SelectedItem();
s2.setKey("Geschaeftsstelle B");
s2.setLowerAgeLimit(Integer.MIN_VALUE);
s2.setUpperAgeLimit(-11);
selectedItems.add(s2);
SelectedItem s3 = new SelectedItem();
s3.setKey("Geschaeftsstelle C");
s3.setLowerAgeLimit(0);
s3.setUpperAgeLimit(0);
selectedItems.add(s3);
List<String> ids = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.categoryIn(categories)
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(3, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000009"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000029"));
}
@WithAccessId(
userName = "monitor")
@Test
public void testGetTaskIdsOfCustomFieldValueReportWithDomainFilter()
throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
List<SelectedItem> selectedItems = new ArrayList<>();
SelectedItem s1 = new SelectedItem();
s1.setKey("Geschaeftsstelle A");
s1.setLowerAgeLimit(-5);
s1.setUpperAgeLimit(-2);
selectedItems.add(s1);
SelectedItem s2 = new SelectedItem();
s2.setKey("Geschaeftsstelle B");
s2.setLowerAgeLimit(Integer.MIN_VALUE);
s2.setUpperAgeLimit(-11);
selectedItems.add(s2);
SelectedItem s3 = new SelectedItem();
s3.setKey("Geschaeftsstelle C");
s3.setLowerAgeLimit(0);
s3.setUpperAgeLimit(0);
selectedItems.add(s3);
List<String> ids = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.domainIn(Collections.singletonList("DOMAIN_A"))
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(3, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000009"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000020"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000033"));
}
@WithAccessId(
userName = "monitor")
@Test
public void testGetTaskIdsOfCustomFieldValueReportWithCustomFieldValueFilter()
throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
List<SelectedItem> selectedItems = new ArrayList<>();
SelectedItem s1 = new SelectedItem();
s1.setKey("Geschaeftsstelle A");
s1.setLowerAgeLimit(-5);
s1.setUpperAgeLimit(-2);
selectedItems.add(s1);
SelectedItem s2 = new SelectedItem();
s2.setKey("Geschaeftsstelle B");
s2.setLowerAgeLimit(Integer.MIN_VALUE);
s2.setUpperAgeLimit(-11);
selectedItems.add(s2);
SelectedItem s3 = new SelectedItem();
s3.setKey("Geschaeftsstelle C");
s3.setLowerAgeLimit(0);
s3.setUpperAgeLimit(0);
selectedItems.add(s3);
List<String> ids = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.withColumnHeaders(columnHeaders)
.inWorkingDays()
.customAttributeFilterIn(customAttributeFilter)
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(4, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000020"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000024"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000027"));
assertTrue(ids.contains("TKI:000000000000000000000000000000000029"));
}
@WithAccessId(
userName = "monitor")
@Test(expected = InvalidArgumentException.class)
public void testThrowsExceptionIfSubKeysAreUsed() throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
List<SelectedItem> selectedItems = new ArrayList<>();
SelectedItem s1 = new SelectedItem();
s1.setKey("Geschaeftsstelle A");
s1.setSubKey("INVALID");
s1.setLowerAgeLimit(-5);
s1.setUpperAgeLimit(-2);
selectedItems.add(s1);
taskMonitorService.createCategoryReportBuilder().withColumnHeaders(columnHeaders).listTaskIdsForSelectedItems(
selectedItems);
}
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;
}
}

View File

@ -66,9 +66,7 @@ public class GetTaskIdsOfWorkbasketReportAccTest {
List<SelectedItem> selectedItems = new ArrayList<>(); List<SelectedItem> selectedItems = new ArrayList<>();
taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null, taskMonitorService.createWorkbasketReportBuilder().listTaskIdsForSelectedItems(selectedItems);
null, null, null,
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_WORKBASKET_KEY);
} }
@WithAccessId( @WithAccessId(
@ -99,9 +97,10 @@ public class GetTaskIdsOfWorkbasketReportAccTest {
s3.setUpperAgeLimit(Integer.MAX_VALUE); s3.setUpperAgeLimit(Integer.MAX_VALUE);
selectedItems.add(s3); selectedItems.add(s3);
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null, List<String> ids = taskMonitorService.createWorkbasketReportBuilder()
null, null, null, .withColumnHeaders(columnHeaders)
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_WORKBASKET_KEY); .inWorkingDays()
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(7, ids.size()); assertEquals(7, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000001")); assertTrue(ids.contains("TKI:000000000000000000000000000000000001"));
@ -142,9 +141,11 @@ public class GetTaskIdsOfWorkbasketReportAccTest {
s3.setUpperAgeLimit(Integer.MAX_VALUE); s3.setUpperAgeLimit(Integer.MAX_VALUE);
selectedItems.add(s3); selectedItems.add(s3);
List<String> ids = taskMonitorService.getTaskIdsForSelectedItems(null, null, null, null, null, List<String> ids = taskMonitorService.createWorkbasketReportBuilder()
Collections.singletonList("CLI:000000000000000000000000000000000001"), null, null, .withColumnHeaders(columnHeaders)
columnHeaders, true, selectedItems, TaskMonitorService.DIMENSION_WORKBASKET_KEY); .inWorkingDays()
.excludedClassificationIdIn(Collections.singletonList("CLI:000000000000000000000000000000000001"))
.listTaskIdsForSelectedItems(selectedItems);
assertEquals(4, ids.size()); assertEquals(4, ids.size());
assertTrue(ids.contains("TKI:000000000000000000000000000000000006")); assertTrue(ids.contains("TKI:000000000000000000000000000000000006"));

View File

@ -9,7 +9,9 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -70,7 +72,7 @@ public class ProvideCategoryReportAccTest {
public void testRoleCheck() throws InvalidArgumentException, NotAuthorizedException { public void testRoleCheck() throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
taskMonitorService.getCategoryReport(null, null, null, null, null, null); taskMonitorService.createCategoryReportBuilder().buildReport();
} }
@WithAccessId( @WithAccessId(
@ -79,7 +81,7 @@ public class ProvideCategoryReportAccTest {
public void testGetTotalNumbersOfTasksOfCategoryReport() throws InvalidArgumentException, NotAuthorizedException { public void testGetTotalNumbersOfTasksOfCategoryReport() throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
CategoryReport report = taskMonitorService.getCategoryReport(null, null, null, null, null, null); CategoryReport report = taskMonitorService.createCategoryReportBuilder().buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report)); LOGGER.debug(reportToString(report));
@ -106,8 +108,10 @@ public class ProvideCategoryReportAccTest {
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
CategoryReport report = taskMonitorService.getCategoryReport(null, null, null, null, null, null, CategoryReport report = taskMonitorService.createCategoryReportBuilder()
columnHeaders); .withColumnHeaders(columnHeaders)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -136,8 +140,10 @@ public class ProvideCategoryReportAccTest {
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CategoryReport report = taskMonitorService.getCategoryReport(null, null, null, null, null, null, CategoryReport report = taskMonitorService.createCategoryReportBuilder()
columnHeaders); .withColumnHeaders(columnHeaders)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -164,8 +170,9 @@ public class ProvideCategoryReportAccTest {
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CategoryReport report = taskMonitorService.getCategoryReport(null, null, null, null, null, null, CategoryReport report = taskMonitorService.createCategoryReportBuilder()
columnHeaders, false); .withColumnHeaders(columnHeaders)
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -194,8 +201,11 @@ public class ProvideCategoryReportAccTest {
List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001"); List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CategoryReport report = taskMonitorService.getCategoryReport(workbasketIds, null, null, null, null, null, CategoryReport report = taskMonitorService.createCategoryReportBuilder()
columnHeaders); .withColumnHeaders(columnHeaders)
.inWorkingDays()
.workbasketIdIn(workbasketIds)
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -223,8 +233,11 @@ public class ProvideCategoryReportAccTest {
List<TaskState> states = Collections.singletonList(TaskState.READY); List<TaskState> states = Collections.singletonList(TaskState.READY);
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CategoryReport report = taskMonitorService.getCategoryReport(null, states, null, null, null, null, CategoryReport report = taskMonitorService.createCategoryReportBuilder()
columnHeaders); .withColumnHeaders(columnHeaders)
.stateIn(states)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -253,8 +266,11 @@ public class ProvideCategoryReportAccTest {
List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL"); List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CategoryReport report = taskMonitorService.getCategoryReport(null, null, categories, null, null, null, CategoryReport report = taskMonitorService.createCategoryReportBuilder()
columnHeaders); .withColumnHeaders(columnHeaders)
.categoryIn(categories)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -280,8 +296,11 @@ public class ProvideCategoryReportAccTest {
List<String> domains = Collections.singletonList("DOMAIN_A"); List<String> domains = Collections.singletonList("DOMAIN_A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CategoryReport report = taskMonitorService.getCategoryReport(null, null, null, domains, null, null, CategoryReport report = taskMonitorService.createCategoryReportBuilder()
columnHeaders); .withColumnHeaders(columnHeaders)
.domainIn(domains)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -307,12 +326,15 @@ public class ProvideCategoryReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
CustomField customField = CustomField.CUSTOM_1; Map<CustomField, String> customAttributeFilter = new HashMap<>();
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A"); customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CategoryReport report = taskMonitorService.getCategoryReport(null, null, null, null, customField, CategoryReport report = taskMonitorService.createCategoryReportBuilder()
customFieldValues, columnHeaders); .withColumnHeaders(columnHeaders)
.customAttributeFilterIn(customAttributeFilter)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));

View File

@ -9,7 +9,9 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -71,7 +73,7 @@ public class ProvideClassificationReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
taskMonitorService.getClassificationReport(null, null, null, null, null, null); taskMonitorService.createClassificationReportBuilder().buildReport();
} }
@WithAccessId( @WithAccessId(
@ -81,7 +83,7 @@ public class ProvideClassificationReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
ClassificationReport report = taskMonitorService.getClassificationReport(null, null, null, null, null, null); ClassificationReport report = taskMonitorService.createClassificationReportBuilder().buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report)); LOGGER.debug(reportToString(report));
@ -110,13 +112,15 @@ public class ProvideClassificationReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TimeIntervalColumnHeader> reportLineItemDefinitions = getListOfColumnsHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnsHeaders();
ClassificationReport report = taskMonitorService.getClassificationReport(null, null, null, null, null, null, ClassificationReport report = taskMonitorService.createClassificationReportBuilder()
reportLineItemDefinitions); .withColumnHeaders(columnHeaders)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, reportLineItemDefinitions)); LOGGER.debug(reportToString(report, columnHeaders));
} }
int sumLineCount = IntStream.of(report.getSumRow().getCells()).sum(); int sumLineCount = IntStream.of(report.getSumRow().getCells()).sum();
@ -151,8 +155,10 @@ public class ProvideClassificationReportAccTest {
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
ClassificationReport report = taskMonitorService.getClassificationReport(null, null, null, null, null, null, ClassificationReport report = taskMonitorService.createClassificationReportBuilder()
columnHeaders); .withColumnHeaders(columnHeaders)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -184,13 +190,14 @@ public class ProvideClassificationReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TimeIntervalColumnHeader> reportLineItemDefinitions = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
ClassificationReport report = taskMonitorService.getClassificationReport(null, null, null, null, null, null, ClassificationReport report = taskMonitorService.createClassificationReportBuilder()
reportLineItemDefinitions, false); .withColumnHeaders(columnHeaders)
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, reportLineItemDefinitions)); LOGGER.debug(reportToString(report, columnHeaders));
} }
assertNotNull(report); assertNotNull(report);
@ -222,9 +229,11 @@ public class ProvideClassificationReportAccTest {
List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001"); List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
ClassificationReport report = taskMonitorService.getClassificationReport(workbasketIds, null, null, null, null, ClassificationReport report = taskMonitorService.createClassificationReportBuilder()
null, .withColumnHeaders(columnHeaders)
columnHeaders); .workbasketIdIn(workbasketIds)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -259,8 +268,11 @@ public class ProvideClassificationReportAccTest {
List<TaskState> states = Collections.singletonList(TaskState.READY); List<TaskState> states = Collections.singletonList(TaskState.READY);
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
ClassificationReport report = taskMonitorService.getClassificationReport(null, states, null, null, null, null, ClassificationReport report = taskMonitorService.createClassificationReportBuilder()
columnHeaders); .withColumnHeaders(columnHeaders)
.stateIn(states)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -295,8 +307,11 @@ public class ProvideClassificationReportAccTest {
List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL"); List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
ClassificationReport report = taskMonitorService.getClassificationReport(null, null, categories, null, null, ClassificationReport report = taskMonitorService.createClassificationReportBuilder()
null, columnHeaders); .withColumnHeaders(columnHeaders)
.categoryIn(categories)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -323,8 +338,11 @@ public class ProvideClassificationReportAccTest {
List<String> domains = Collections.singletonList("DOMAIN_A"); List<String> domains = Collections.singletonList("DOMAIN_A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
ClassificationReport report = taskMonitorService.getClassificationReport(null, null, null, domains, null, null, ClassificationReport report = taskMonitorService.createClassificationReportBuilder()
columnHeaders); .withColumnHeaders(columnHeaders)
.domainIn(domains)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -356,12 +374,15 @@ public class ProvideClassificationReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
CustomField customField = CustomField.CUSTOM_1; Map<CustomField, String> customAttributeFilter = new HashMap<>();
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A"); customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
ClassificationReport report = taskMonitorService.getClassificationReport(null, null, null, null, customField, ClassificationReport report = taskMonitorService.createClassificationReportBuilder()
customFieldValues, columnHeaders); .withColumnHeaders(columnHeaders)
.customAttributeFilterIn(customAttributeFilter)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));

View File

@ -9,7 +9,9 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -69,10 +71,7 @@ public class ProvideCustomFieldValueReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
CustomField customField = CustomField.CUSTOM_1; taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1).buildReport();
taskMonitorService.getCustomFieldValueReport(null, null, null, null,
customField, null);
} }
@WithAccessId( @WithAccessId(
@ -82,10 +81,8 @@ public class ProvideCustomFieldValueReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
CustomField customField = CustomField.CUSTOM_1; CustomFieldValueReport report = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.buildReport();
CustomFieldValueReport report = taskMonitorService.getCustomFieldValueReport(null, null, null, null,
customField, null);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report)); LOGGER.debug(reportToString(report));
@ -111,10 +108,8 @@ public class ProvideCustomFieldValueReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
CustomField customField = CustomField.CUSTOM_2; CustomFieldValueReport report = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_2)
.buildReport();
CustomFieldValueReport report = taskMonitorService.getCustomFieldValueReport(null, null, null, null,
customField, null);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report)); LOGGER.debug(reportToString(report));
@ -142,9 +137,10 @@ public class ProvideCustomFieldValueReportAccTest {
CustomField customField = CustomField.CUSTOM_1; CustomField customField = CustomField.CUSTOM_1;
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
CustomFieldValueReport report = taskMonitorService.getCustomFieldValueReport(null, null, null, null, CustomFieldValueReport report = taskMonitorService.createCustomFieldValueReportBuilder(customField)
customField, null, .withColumnHeaders(columnHeaders)
columnHeaders); .inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -168,12 +164,12 @@ public class ProvideCustomFieldValueReportAccTest {
public void testEachItemOfCustomFieldValueReport() throws InvalidArgumentException, NotAuthorizedException { public void testEachItemOfCustomFieldValueReport() throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
CustomField customField = CustomField.CUSTOM_1;
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = taskMonitorService.getCustomFieldValueReport(null, null, null, null, CustomFieldValueReport report = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
customField, null, .withColumnHeaders(columnHeaders)
columnHeaders); .inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -199,12 +195,11 @@ public class ProvideCustomFieldValueReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
CustomField customField = CustomField.CUSTOM_1;
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = taskMonitorService.getCustomFieldValueReport(null, null, null, null, CustomFieldValueReport report = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
customField, null, .withColumnHeaders(columnHeaders)
columnHeaders, false); .buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -231,12 +226,13 @@ public class ProvideCustomFieldValueReportAccTest {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001"); List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
CustomField customField = CustomField.CUSTOM_1;
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = taskMonitorService.getCustomFieldValueReport(workbasketIds, null, null, null, CustomFieldValueReport report = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
customField, null, .withColumnHeaders(columnHeaders)
columnHeaders); .inWorkingDays()
.workbasketIdIn(workbasketIds)
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -263,12 +259,13 @@ public class ProvideCustomFieldValueReportAccTest {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TaskState> states = Collections.singletonList(TaskState.READY); List<TaskState> states = Collections.singletonList(TaskState.READY);
CustomField customField = CustomField.CUSTOM_1;
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = taskMonitorService.getCustomFieldValueReport(null, states, null, null, CustomFieldValueReport report = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
customField, null, .withColumnHeaders(columnHeaders)
columnHeaders); .inWorkingDays()
.stateIn(states)
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -295,13 +292,13 @@ public class ProvideCustomFieldValueReportAccTest {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL"); List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL");
CustomField customField = CustomField.CUSTOM_1;
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = taskMonitorService.getCustomFieldValueReport(null, null, categories, null, CustomFieldValueReport report = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
customField, null, .withColumnHeaders(columnHeaders)
columnHeaders); .inWorkingDays()
.categoryIn(categories)
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -328,12 +325,13 @@ public class ProvideCustomFieldValueReportAccTest {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<String> domains = Collections.singletonList("DOMAIN_A"); List<String> domains = Collections.singletonList("DOMAIN_A");
CustomField customField = CustomField.CUSTOM_1;
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = taskMonitorService.getCustomFieldValueReport(null, null, null, domains, CustomFieldValueReport report = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
customField, null, .withColumnHeaders(columnHeaders)
columnHeaders); .inWorkingDays()
.domainIn(domains)
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -359,13 +357,15 @@ public class ProvideCustomFieldValueReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
CustomField customField = CustomField.CUSTOM_1; Map<CustomField, String> customAttributeFilter = new HashMap<>();
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A"); customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
CustomFieldValueReport report = taskMonitorService.getCustomFieldValueReport(null, null, null, null, CustomFieldValueReport report = taskMonitorService.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
customField, .customAttributeFilterIn(customAttributeFilter)
customFieldValues, columnHeaders); .withColumnHeaders(columnHeaders)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));

View File

@ -9,7 +9,9 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -73,8 +75,7 @@ public class ProvideDetailedClassificationReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
taskMonitorService.getDetailedClassificationReport(null, null, null, null, taskMonitorService.createClassificationReportBuilder().buildDetailedReport();
null, null);
} }
@WithAccessId( @WithAccessId(
@ -84,8 +85,8 @@ public class ProvideDetailedClassificationReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
DetailedClassificationReport report = taskMonitorService.getDetailedClassificationReport(null, null, null, null, DetailedClassificationReport report = taskMonitorService.createClassificationReportBuilder()
null, null); .buildDetailedReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report)); LOGGER.debug(reportToString(report));
@ -140,8 +141,10 @@ public class ProvideDetailedClassificationReportAccTest {
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
DetailedClassificationReport report = taskMonitorService.getDetailedClassificationReport(null, null, null, null, DetailedClassificationReport report = taskMonitorService.createClassificationReportBuilder()
null, null, columnHeaders); .inWorkingDays()
.withColumnHeaders(columnHeaders)
.buildDetailedReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -167,13 +170,15 @@ public class ProvideDetailedClassificationReportAccTest {
public void testEachItemOfDetailedClassificationReport() throws InvalidArgumentException, NotAuthorizedException { public void testEachItemOfDetailedClassificationReport() throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TimeIntervalColumnHeader> reportLineItemDefinitions = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
DetailedClassificationReport report = taskMonitorService.getDetailedClassificationReport(null, null, null, null, DetailedClassificationReport report = taskMonitorService.createClassificationReportBuilder()
null, null, reportLineItemDefinitions); .inWorkingDays()
.withColumnHeaders(columnHeaders)
.buildDetailedReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, reportLineItemDefinitions)); LOGGER.debug(reportToString(report, columnHeaders));
} }
assertNotNull(report); assertNotNull(report);
@ -230,13 +235,16 @@ public class ProvideDetailedClassificationReportAccTest {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001"); List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
List<TimeIntervalColumnHeader> reportLineItemDefinitions = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
DetailedClassificationReport report = taskMonitorService.getDetailedClassificationReport(workbasketIds, null, DetailedClassificationReport report = taskMonitorService.createClassificationReportBuilder()
null, null, null, null, reportLineItemDefinitions); .workbasketIdIn(workbasketIds)
.inWorkingDays()
.withColumnHeaders(columnHeaders)
.buildDetailedReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, reportLineItemDefinitions)); LOGGER.debug(reportToString(report, columnHeaders));
} }
assertNotNull(report); assertNotNull(report);
@ -292,8 +300,11 @@ public class ProvideDetailedClassificationReportAccTest {
List<TaskState> states = Collections.singletonList(TaskState.READY); List<TaskState> states = Collections.singletonList(TaskState.READY);
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
DetailedClassificationReport report = taskMonitorService.getDetailedClassificationReport(null, states, null, DetailedClassificationReport report = taskMonitorService.createClassificationReportBuilder()
null, null, null, columnHeaders); .stateIn(states)
.inWorkingDays()
.withColumnHeaders(columnHeaders)
.buildDetailedReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -351,8 +362,9 @@ public class ProvideDetailedClassificationReportAccTest {
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
DetailedClassificationReport report = taskMonitorService.getDetailedClassificationReport(null, null, null, null, DetailedClassificationReport report = taskMonitorService.createClassificationReportBuilder()
null, null, columnHeaders, false); .withColumnHeaders(columnHeaders)
.buildDetailedReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -414,8 +426,11 @@ public class ProvideDetailedClassificationReportAccTest {
List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL"); List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
DetailedClassificationReport report = taskMonitorService.getDetailedClassificationReport(null, null, categories, DetailedClassificationReport report = taskMonitorService.createClassificationReportBuilder()
null, null, null, columnHeaders); .categoryIn(categories)
.inWorkingDays()
.withColumnHeaders(columnHeaders)
.buildDetailedReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -454,8 +469,11 @@ public class ProvideDetailedClassificationReportAccTest {
List<String> domains = Collections.singletonList("DOMAIN_A"); List<String> domains = Collections.singletonList("DOMAIN_A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
DetailedClassificationReport report = taskMonitorService.getDetailedClassificationReport(null, null, null, DetailedClassificationReport report = taskMonitorService.createClassificationReportBuilder()
domains, null, null, columnHeaders); .inWorkingDays()
.withColumnHeaders(columnHeaders)
.domainIn(domains)
.buildDetailedReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -511,12 +529,15 @@ public class ProvideDetailedClassificationReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
CustomField customField = CustomField.CUSTOM_1; Map<CustomField, String> customAttributeFilter = new HashMap<>();
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A"); customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
DetailedClassificationReport report = taskMonitorService.getDetailedClassificationReport(null, null, DetailedClassificationReport report = taskMonitorService.createClassificationReportBuilder()
null, null, customField, customFieldValues, columnHeaders); .customAttributeFilterIn(customAttributeFilter)
.inWorkingDays()
.withColumnHeaders(columnHeaders)
.buildDetailedReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));

View File

@ -39,7 +39,7 @@ import pro.taskana.security.WithAccessId;
@RunWith(JAASRunner.class) @RunWith(JAASRunner.class)
public class ProvideTaskStatusReportAccTest { public class ProvideTaskStatusReportAccTest {
private static final Logger LOGGER = LoggerFactory.getLogger(ProvideWorkbasketLevelReportAccTest.class); private static final Logger LOGGER = LoggerFactory.getLogger(ProvideWorkbasketReportAccTest.class);
protected static TaskanaEngineConfiguration taskanaEngineConfiguration; protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
protected static TaskanaEngine taskanaEngine; protected static TaskanaEngine taskanaEngine;
@ -65,7 +65,7 @@ public class ProvideTaskStatusReportAccTest {
@Test(expected = NotAuthorizedException.class) @Test(expected = NotAuthorizedException.class)
public void testRoleCheck() throws NotAuthorizedException { public void testRoleCheck() throws NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
taskMonitorService.getTaskStatusReport(); taskMonitorService.createTaskStatusReportBuilder().buildReport();
} }
@WithAccessId( @WithAccessId(
@ -75,7 +75,7 @@ public class ProvideTaskStatusReportAccTest {
// given // given
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
// when // when
TaskStatusReport report = taskMonitorService.getTaskStatusReport(); TaskStatusReport report = taskMonitorService.createTaskStatusReportBuilder().buildReport();
// then // then
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report)); LOGGER.debug(reportToString(report));
@ -105,7 +105,7 @@ public class ProvideTaskStatusReportAccTest {
@Test @Test
public void testCompleteTaskStatusReportAsAdmin() throws NotAuthorizedException { public void testCompleteTaskStatusReportAsAdmin() throws NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
taskMonitorService.getTaskStatusReport(); taskMonitorService.createTaskStatusReportBuilder().buildReport();
} }
@WithAccessId( @WithAccessId(
@ -115,7 +115,10 @@ public class ProvideTaskStatusReportAccTest {
// given // given
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
// when // when
TaskStatusReport report = taskMonitorService.getTaskStatusReport(asList("DOMAIN_C", "DOMAIN_A")); TaskStatusReport report = taskMonitorService
.createTaskStatusReportBuilder()
.domainIn(asList("DOMAIN_C", "DOMAIN_A"))
.buildReport();
// then // then
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report)); LOGGER.debug(reportToString(report));
@ -143,8 +146,10 @@ public class ProvideTaskStatusReportAccTest {
// given // given
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
// when // when
TaskStatusReport report = taskMonitorService.getTaskStatusReport(null, TaskStatusReport report = taskMonitorService
Collections.singletonList(TaskState.READY)); .createTaskStatusReportBuilder()
.stateIn(Collections.singletonList(TaskState.READY))
.buildReport();
// then // then
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report)); LOGGER.debug(reportToString(report));

View File

@ -9,7 +9,9 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -33,7 +35,7 @@ import pro.taskana.impl.configuration.DBCleaner;
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest; import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
import pro.taskana.impl.report.impl.CombinedClassificationFilter; import pro.taskana.impl.report.impl.CombinedClassificationFilter;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader; import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.impl.report.impl.WorkbasketLevelReport; import pro.taskana.impl.report.impl.WorkbasketReport;
import pro.taskana.security.JAASRunner; import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId; import pro.taskana.security.WithAccessId;
@ -41,9 +43,9 @@ import pro.taskana.security.WithAccessId;
* Acceptance test for all "workbasket level report" scenarios. * Acceptance test for all "workbasket level report" scenarios.
*/ */
@RunWith(JAASRunner.class) @RunWith(JAASRunner.class)
public class ProvideWorkbasketLevelReportAccTest { public class ProvideWorkbasketReportAccTest {
private static final Logger LOGGER = LoggerFactory.getLogger(ProvideWorkbasketLevelReportAccTest.class); private static final Logger LOGGER = LoggerFactory.getLogger(ProvideWorkbasketReportAccTest.class);
protected static TaskanaEngineConfiguration taskanaEngineConfiguration; protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
protected static TaskanaEngine taskanaEngine; protected static TaskanaEngine taskanaEngine;
@ -71,19 +73,17 @@ public class ProvideWorkbasketLevelReportAccTest {
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
taskMonitorService.getWorkbasketLevelReport(null, null, null, null, null, null, taskMonitorService.createWorkbasketReportBuilder().buildReport();
null);
} }
@WithAccessId( @WithAccessId(
userName = "monitor") userName = "monitor")
@Test @Test
public void testGetTotalNumbersOfTasksOfWorkbasketLevelReport() public void testGetTotalNumbersOfTasksOfWorkbasketReport()
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
WorkbasketLevelReport report = taskMonitorService.getWorkbasketLevelReport(null, null, null, null, null, null, WorkbasketReport report = taskMonitorService.createWorkbasketReportBuilder().buildReport();
null);
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report)); LOGGER.debug(reportToString(report));
@ -102,14 +102,16 @@ public class ProvideWorkbasketLevelReportAccTest {
@WithAccessId( @WithAccessId(
userName = "monitor") userName = "monitor")
@Test @Test
public void testGetWorkbasketLevelReportWithReportLineItemDefinitions() public void testGetWorkbasketReportWithReportLineItemDefinitions()
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
WorkbasketLevelReport report = taskMonitorService.getWorkbasketLevelReport(null, null, null, null, null, null, WorkbasketReport report = taskMonitorService.createWorkbasketReportBuilder()
null, columnHeaders); .withColumnHeaders(columnHeaders)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -134,13 +136,15 @@ public class ProvideWorkbasketLevelReportAccTest {
@WithAccessId( @WithAccessId(
userName = "monitor") userName = "monitor")
@Test @Test
public void testEachItemOfWorkbasketLevelReport() throws InvalidArgumentException, NotAuthorizedException { public void testEachItemOfWorkbasketReport() throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
WorkbasketLevelReport report = taskMonitorService.getWorkbasketLevelReport(null, null, null, null, null, null, WorkbasketReport report = taskMonitorService.createWorkbasketReportBuilder()
null, columnHeaders); .withColumnHeaders(columnHeaders)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -162,14 +166,15 @@ public class ProvideWorkbasketLevelReportAccTest {
@WithAccessId( @WithAccessId(
userName = "monitor") userName = "monitor")
@Test @Test
public void testEachItemOfWorkbasketLevelReportNotInWorkingDays() public void testEachItemOfWorkbasketReportNotInWorkingDays()
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
WorkbasketLevelReport report = taskMonitorService.getWorkbasketLevelReport(null, null, null, null, null, null, WorkbasketReport report = taskMonitorService.createWorkbasketReportBuilder()
null, columnHeaders, false); .withColumnHeaders(columnHeaders)
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -191,15 +196,18 @@ public class ProvideWorkbasketLevelReportAccTest {
@WithAccessId( @WithAccessId(
userName = "monitor") userName = "monitor")
@Test @Test
public void testEachItemOfWorkbasketLevelReportWithWorkbasketFilter() public void testEachItemOfWorkbasketReportWithWorkbasketFilter()
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001"); List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
WorkbasketLevelReport report = taskMonitorService.getWorkbasketLevelReport(workbasketIds, null, null, null, WorkbasketReport report = taskMonitorService.createWorkbasketReportBuilder()
null, null, null, columnHeaders); .withColumnHeaders(columnHeaders)
.workbasketIdIn(workbasketIds)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -216,15 +224,18 @@ public class ProvideWorkbasketLevelReportAccTest {
@WithAccessId( @WithAccessId(
userName = "monitor") userName = "monitor")
@Test @Test
public void testEachItemOfWorkbasketLevelReportWithStateFilter() public void testEachItemOfWorkbasketReportWithStateFilter()
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<TaskState> states = Collections.singletonList(TaskState.READY); List<TaskState> states = Collections.singletonList(TaskState.READY);
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
WorkbasketLevelReport report = taskMonitorService.getWorkbasketLevelReport(null, states, null, null, null, null, WorkbasketReport report = taskMonitorService.createWorkbasketReportBuilder()
null, columnHeaders); .withColumnHeaders(columnHeaders)
.stateIn(states)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -246,15 +257,18 @@ public class ProvideWorkbasketLevelReportAccTest {
@WithAccessId( @WithAccessId(
userName = "monitor") userName = "monitor")
@Test @Test
public void testEachItemOfWorkbasketLevelReportWithCategoryFilter() public void testEachItemOfWorkbasketReportWithCategoryFilter()
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL"); List<String> categories = Arrays.asList("AUTOMATIC", "MANUAL");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
WorkbasketLevelReport report = taskMonitorService.getWorkbasketLevelReport(null, null, categories, null, null, WorkbasketReport report = taskMonitorService.createWorkbasketReportBuilder()
null, null, columnHeaders); .withColumnHeaders(columnHeaders)
.categoryIn(categories)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -277,15 +291,18 @@ public class ProvideWorkbasketLevelReportAccTest {
@WithAccessId( @WithAccessId(
userName = "monitor") userName = "monitor")
@Test @Test
public void testEachItemOfWorkbasketLevelReportWithDomainFilter() public void testEachItemOfWorkbasketReportWithDomainFilter()
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<String> domains = Collections.singletonList("DOMAIN_A"); List<String> domains = Collections.singletonList("DOMAIN_A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
WorkbasketLevelReport report = taskMonitorService.getWorkbasketLevelReport(null, null, null, domains, null, WorkbasketReport report = taskMonitorService.createWorkbasketReportBuilder()
null, null, columnHeaders); .withColumnHeaders(columnHeaders)
.domainIn(domains)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -307,16 +324,19 @@ public class ProvideWorkbasketLevelReportAccTest {
@WithAccessId( @WithAccessId(
userName = "monitor") userName = "monitor")
@Test @Test
public void testEachItemOfWorkbasketLevelReportWithCustomFieldValueFilter() public void testEachItemOfWorkbasketReportWithCustomFieldValueFilter()
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
CustomField customField = CustomField.CUSTOM_1; Map<CustomField, String> customAttributeFilter = new HashMap<>();
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A"); customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders(); List<TimeIntervalColumnHeader> columnHeaders = getShortListOfColumnHeaders();
WorkbasketLevelReport report = taskMonitorService.getWorkbasketLevelReport(null, null, null, null, WorkbasketReport report = taskMonitorService.createWorkbasketReportBuilder()
customField, customFieldValues, null, columnHeaders); .withColumnHeaders(columnHeaders)
.customAttributeFilterIn(customAttributeFilter)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -338,7 +358,7 @@ public class ProvideWorkbasketLevelReportAccTest {
@WithAccessId( @WithAccessId(
userName = "monitor") userName = "monitor")
@Test @Test
public void testEachItemOfWorkbasketLevelReportForSelectedClassifications() public void testEachItemOfWorkbasketReportForSelectedClassifications()
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService(); TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
@ -356,8 +376,11 @@ public class ProvideWorkbasketLevelReportAccTest {
combinedClassificationFilter combinedClassificationFilter
.add(new CombinedClassificationFilter("CLI:000000000000000000000000000000000005")); .add(new CombinedClassificationFilter("CLI:000000000000000000000000000000000005"));
WorkbasketLevelReport report = taskMonitorService.getWorkbasketLevelReport(null, null, null, null, null, WorkbasketReport report = taskMonitorService.createWorkbasketReportBuilder()
null, combinedClassificationFilter, columnHeaders, true); .withColumnHeaders(columnHeaders)
.combinedClassificationFilterIn(combinedClassificationFilter)
.inWorkingDays()
.buildReport();
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(reportToString(report, columnHeaders)); LOGGER.debug(reportToString(report, columnHeaders));
@ -400,11 +423,11 @@ public class ProvideWorkbasketLevelReportAccTest {
return columnHeaders; return columnHeaders;
} }
private String reportToString(WorkbasketLevelReport report) { private String reportToString(WorkbasketReport report) {
return reportToString(report, null); return reportToString(report, null);
} }
private String reportToString(WorkbasketLevelReport report, private String reportToString(WorkbasketReport report,
List<TimeIntervalColumnHeader> reportLineItemDefinitions) { List<TimeIntervalColumnHeader> reportLineItemDefinitions) {
String formatColumWidth = "| %-7s "; String formatColumWidth = "| %-7s ";
String formatFirstColumn = "| %-36s %-4s "; String formatFirstColumn = "| %-36s %-4s ";
@ -418,7 +441,7 @@ public class ProvideWorkbasketLevelReportAccTest {
builder.append("-"); builder.append("-");
} }
builder.append("\n"); builder.append("\n");
builder.append(String.format(formatFirstColumnFirstLine, "Workbasket levels", "Total")); builder.append(String.format(formatFirstColumnFirstLine, "Workbaskets", "Total"));
if (reportLineItemDefinitions != null) { if (reportLineItemDefinitions != null) {
for (TimeIntervalColumnHeader def : reportLineItemDefinitions) { for (TimeIntervalColumnHeader def : reportLineItemDefinitions) {
if (def.getLowerAgeLimit() == Integer.MIN_VALUE) { if (def.getLowerAgeLimit() == Integer.MIN_VALUE) {

View File

@ -0,0 +1,260 @@
package pro.taskana.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.powermock.api.mockito.PowerMockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import pro.taskana.CustomField;
import pro.taskana.TaskState;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.impl.CategoryReport;
import pro.taskana.impl.report.impl.MonitorQueryItem;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.mappings.TaskMonitorMapper;
/**
* Unit Test for CategoryBuilderImpl.
*/
@RunWith(MockitoJUnitRunner.class)
public class CategoryReportBuilderImplTest {
@InjectMocks
private TaskMonitorServiceImpl cut;
@Mock
private TaskanaEngineImpl taskanaEngineImplMock;
@Mock
private TaskanaEngineConfiguration taskanaEngineConfiguration;
@Mock
private TaskMonitorMapper taskMonitorMapperMock;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
Mockito.doNothing().when(taskanaEngineImplMock).openConnection();
Mockito.doNothing().when(taskanaEngineImplMock).returnConnection();
doReturn(taskanaEngineConfiguration).when(taskanaEngineImplMock).getConfiguration();
doReturn(true).when(taskanaEngineConfiguration).isGermanPublicHolidaysEnabled();
doReturn(null).when(taskanaEngineConfiguration).getCustomHolidays();
}
@Test
public void testGetTotalNumbersOfCatgoryReport() throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("EXTERN");
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfCategories(workbasketIds, states, categories,
domains, classificationIds, excludedClassificationIds, customAttributeFilter);
CategoryReport actualResult = cut.createCategoryReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.buildReport();
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfCategories(any(), any(), any(), any(), any(), any(),
any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(actualResult.getRow("EXTERN").getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetCategoryReportWithReportLineItemDefinitions()
throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("EXTERN");
monitorQueryItem.setAgeInDays(0);
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfCategories(workbasketIds, states, categories,
domains, classificationIds, excludedClassificationIds, customAttributeFilter);
CategoryReport actualResult = cut.createCategoryReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.buildReport();
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfCategories(any(), any(), any(), any(), any(), any(),
any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(actualResult.getRow("EXTERN").getTotalValue(), 1);
assertEquals(actualResult.getRow("EXTERN").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testListTaskIdsOfCategoryReportForSelectedItems()
throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
SelectedItem selectedItem = new SelectedItem();
selectedItem.setKey("EXTERN");
selectedItem.setLowerAgeLimit(1);
selectedItem.setUpperAgeLimit(5);
List<SelectedItem> selectedItems = Collections.singletonList(selectedItem);
List<String> expectedResult = Collections.singletonList("TKI:000000000000000000000000000000000001");
when(taskMonitorMapperMock.getTaskIdsForSelectedItems(workbasketIds,
states, categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter,
"CLASSIFICATION_CATEGORY", selectedItems, false)).thenReturn(expectedResult);
List<String> actualResult = cut.createCategoryReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.listTaskIdsForSelectedItems(selectedItems);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
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(), any(), eq(false));
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(expectedResult, actualResult);
}
@Test
public void testListCustomAttributeValuesForCustomAttributeName()
throws NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
SelectedItem selectedItem = new SelectedItem();
selectedItem.setKey("EXTERN");
selectedItem.setLowerAgeLimit(1);
selectedItem.setUpperAgeLimit(5);
List<SelectedItem> selectedItems = Collections.singletonList(selectedItem);
List<String> expectedResult = Collections.singletonList("Geschaeftsstelle A");
when(taskMonitorMapperMock.getCustomAttributeValuesForReport(workbasketIds,
states, categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter,
CustomField.CUSTOM_1)).thenReturn(expectedResult);
List<String> actualResult = cut.createCategoryReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1))
.getCustomAttributeValuesForReport(any(), any(), any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(expectedResult, actualResult);
}
}

View File

@ -0,0 +1,371 @@
package pro.taskana.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.powermock.api.mockito.PowerMockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import pro.taskana.CustomField;
import pro.taskana.TaskState;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.impl.ClassificationReport;
import pro.taskana.impl.report.impl.DetailedClassificationReport;
import pro.taskana.impl.report.impl.DetailedMonitorQueryItem;
import pro.taskana.impl.report.impl.DetailedReportRow;
import pro.taskana.impl.report.impl.MonitorQueryItem;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.mappings.TaskMonitorMapper;
/**
* Unit Test for ClassificationReportBuilderImpl.
*/
@RunWith(MockitoJUnitRunner.class)
public class ClassificationReportBuilderImplTest {
@InjectMocks
private TaskMonitorServiceImpl cut;
@Mock
private TaskanaEngineImpl taskanaEngineImplMock;
@Mock
private TaskanaEngineConfiguration taskanaEngineConfiguration;
@Mock
private TaskMonitorMapper taskMonitorMapperMock;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
Mockito.doNothing().when(taskanaEngineImplMock).openConnection();
Mockito.doNothing().when(taskanaEngineImplMock).returnConnection();
doReturn(taskanaEngineConfiguration).when(taskanaEngineImplMock).getConfiguration();
doReturn(true).when(taskanaEngineConfiguration).isGermanPublicHolidaysEnabled();
doReturn(null).when(taskanaEngineConfiguration).getCustomHolidays();
}
@Test
public void testGetTotalNumbersOfClassificationReport() throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("CLI:000000000000000000000000000000000001");
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfClassifications(workbasketIds, states,
categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter);
ClassificationReport actualResult = cut.createClassificationReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.buildReport();
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfClassifications(any(), any(), any(), any(), any(), any(),
any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(
actualResult.getRow("CLI:000000000000000000000000000000000001").getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetClassificationReportWithReportLineItemDefinitions()
throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("CLI:000000000000000000000000000000000001");
monitorQueryItem.setAgeInDays(0);
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfClassifications(workbasketIds, states,
categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter);
ClassificationReport actualResult = cut.createClassificationReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.buildReport();
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfClassifications(any(), any(), any(), any(), any(), any(),
any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(
actualResult.getRow("CLI:000000000000000000000000000000000001").getTotalValue(), 1);
assertEquals(actualResult.getRow("CLI:000000000000000000000000000000000001").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetTotalNumbersOfDetailedClassificationReport()
throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<DetailedMonitorQueryItem> expectedResult = new ArrayList<>();
DetailedMonitorQueryItem detailedMonitorQueryItem = new DetailedMonitorQueryItem();
detailedMonitorQueryItem.setKey("CLI:000000000000000000000000000000000001");
detailedMonitorQueryItem.setAttachmentKey("CLI:000000000000000000000000000000000006");
detailedMonitorQueryItem.setNumberOfTasks(1);
expectedResult.add(detailedMonitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfDetailedClassifications(workbasketIds,
states, categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter);
DetailedClassificationReport actualResult = cut.createClassificationReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.buildDetailedReport();
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfDetailedClassifications(any(), any(), any(), any(), any(),
any(),
any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
DetailedReportRow line = actualResult.getRow("CLI:000000000000000000000000000000000001");
assertNotNull(actualResult);
assertEquals(line.getTotalValue(), 1);
assertEquals(line.getDetailRows().get("CLI:000000000000000000000000000000000006").getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetDetailedClassificationReportWithReportLineItemDefinitions()
throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
List<DetailedMonitorQueryItem> expectedResult = new ArrayList<>();
DetailedMonitorQueryItem detailedMonitorQueryItem = new DetailedMonitorQueryItem();
detailedMonitorQueryItem.setKey("CLI:000000000000000000000000000000000001");
detailedMonitorQueryItem.setAttachmentKey("CLI:000000000000000000000000000000000006");
detailedMonitorQueryItem.setAgeInDays(0);
detailedMonitorQueryItem.setNumberOfTasks(1);
expectedResult.add(detailedMonitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfDetailedClassifications(workbasketIds,
states, categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter);
DetailedClassificationReport actualResult = cut.createClassificationReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.buildDetailedReport();
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfDetailedClassifications(any(), any(), any(), any(), any(),
any(),
any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
DetailedReportRow line = actualResult.getRow("CLI:000000000000000000000000000000000001");
assertNotNull(actualResult);
assertEquals(line.getTotalValue(), 1);
assertEquals(line.getDetailRows().get("CLI:000000000000000000000000000000000006").getTotalValue(), 1);
assertEquals(line.getCells()[0], 1);
assertEquals(line.getDetailRows().get("CLI:000000000000000000000000000000000006").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getCells()[0], 1);
}
@Test
public void testGetTaskIdsForSelectedItems() throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
SelectedItem selectedItem = new SelectedItem();
selectedItem.setKey("EXTERN");
selectedItem.setLowerAgeLimit(1);
selectedItem.setUpperAgeLimit(5);
List<SelectedItem> selectedItems = Collections.singletonList(selectedItem);
List<String> expectedResult = Collections.singletonList("TKI:000000000000000000000000000000000001");
when(taskMonitorMapperMock.getTaskIdsForSelectedItems(workbasketIds,
states, categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter,
"CLASSIFICATION_KEY", selectedItems, false)).thenReturn(expectedResult);
List<String> actualResult = cut.createClassificationReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.listTaskIdsForSelectedItems(selectedItems);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
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(), any(), eq(false));
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(expectedResult, actualResult);
}
@Test
public void testListCustomAttributeValuesForCustomAttributeName()
throws NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
SelectedItem selectedItem = new SelectedItem();
selectedItem.setKey("EXTERN");
selectedItem.setLowerAgeLimit(1);
selectedItem.setUpperAgeLimit(5);
List<SelectedItem> selectedItems = Collections.singletonList(selectedItem);
List<String> expectedResult = Collections.singletonList("Geschaeftsstelle A");
when(taskMonitorMapperMock.getCustomAttributeValuesForReport(workbasketIds,
states, categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter,
CustomField.CUSTOM_1)).thenReturn(expectedResult);
List<String> actualResult = cut.createClassificationReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1))
.getCustomAttributeValuesForReport(any(), any(), any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(expectedResult, actualResult);
}
}

View File

@ -0,0 +1,212 @@
package pro.taskana.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.powermock.api.mockito.PowerMockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import pro.taskana.CustomField;
import pro.taskana.TaskState;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.impl.CustomFieldValueReport;
import pro.taskana.impl.report.impl.MonitorQueryItem;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.mappings.TaskMonitorMapper;
/**
* Unit Test for CustomFieldValueReportBuilderImpl.
*/
@RunWith(MockitoJUnitRunner.class)
public class CustomFieldValueReportBuilderImplTest {
@InjectMocks
private TaskMonitorServiceImpl cut;
@Mock
private TaskanaEngineImpl taskanaEngineImplMock;
@Mock
private TaskanaEngineConfiguration taskanaEngineConfiguration;
@Mock
private TaskMonitorMapper taskMonitorMapperMock;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
Mockito.doNothing().when(taskanaEngineImplMock).openConnection();
Mockito.doNothing().when(taskanaEngineImplMock).returnConnection();
doReturn(taskanaEngineConfiguration).when(taskanaEngineImplMock).getConfiguration();
doReturn(true).when(taskanaEngineConfiguration).isGermanPublicHolidaysEnabled();
doReturn(null).when(taskanaEngineConfiguration).getCustomHolidays();
}
@Test
public void testGetTotalNumbersOfCustomFieldValueReport() throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("Geschaeftsstelle A");
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock)
.getTaskCountOfCustomFieldValues(CustomField.CUSTOM_1, workbasketIds, states, categories, domains,
classificationIds, excludedClassificationIds, customAttributeFilter);
CustomFieldValueReport actualResult = cut.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.buildReport();
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfCustomFieldValues(any(), any(), any(), any(), any(),
any(), any(),
any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(actualResult.getRow("Geschaeftsstelle A").getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetCustomFieldValueReportWithReportLineItemDefinitions()
throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("Geschaeftsstelle A");
monitorQueryItem.setAgeInDays(0);
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock)
.getTaskCountOfCustomFieldValues(CustomField.CUSTOM_1, workbasketIds, states, categories, domains,
classificationIds, excludedClassificationIds, customAttributeFilter);
CustomFieldValueReport actualResult = cut.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.buildReport();
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1))
.getTaskCountOfCustomFieldValues(any(), any(), any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(actualResult.getRow("Geschaeftsstelle A").getTotalValue(), 1);
assertEquals(actualResult.getRow("Geschaeftsstelle A").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testListCustomAttributeValuesForCustomAttributeName()
throws NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
SelectedItem selectedItem = new SelectedItem();
selectedItem.setKey("EXTERN");
selectedItem.setLowerAgeLimit(1);
selectedItem.setUpperAgeLimit(5);
List<SelectedItem> selectedItems = Collections.singletonList(selectedItem);
List<String> expectedResult = Collections.singletonList("Geschaeftsstelle A");
when(taskMonitorMapperMock.getCustomAttributeValuesForReport(workbasketIds,
states, categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter,
CustomField.CUSTOM_1)).thenReturn(expectedResult);
List<String> actualResult = cut.createCustomFieldValueReportBuilder(CustomField.CUSTOM_1)
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1))
.getCustomAttributeValuesForReport(any(), any(), any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(expectedResult, actualResult);
}
}

View File

@ -1,576 +0,0 @@
package pro.taskana.impl;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.powermock.api.mockito.PowerMockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
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;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.impl.CategoryReport;
import pro.taskana.impl.report.impl.ClassificationReport;
import pro.taskana.impl.report.impl.CombinedClassificationFilter;
import pro.taskana.impl.report.impl.CustomFieldValueReport;
import pro.taskana.impl.report.impl.DetailedClassificationReport;
import pro.taskana.impl.report.impl.DetailedMonitorQueryItem;
import pro.taskana.impl.report.impl.DetailedReportRow;
import pro.taskana.impl.report.impl.MonitorQueryItem;
import pro.taskana.impl.report.impl.TaskQueryItem;
import pro.taskana.impl.report.impl.TaskStatusReport;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.impl.report.impl.WorkbasketLevelReport;
import pro.taskana.mappings.TaskMonitorMapper;
/**
* Unit Test for TaskMonitorServiceImpl.
*/
@RunWith(MockitoJUnitRunner.class)
public class TaskMonitorServiceImplTest {
@InjectMocks
private TaskMonitorServiceImpl cut;
@Mock
private TaskanaEngineImpl taskanaEngineImplMock;
@Mock
private TaskanaEngineConfiguration taskanaEngineConfiguration;
@Mock
private TaskMonitorMapper taskMonitorMapperMock;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
Mockito.doNothing().when(taskanaEngineImplMock).openConnection();
Mockito.doNothing().when(taskanaEngineImplMock).returnConnection();
doReturn(taskanaEngineConfiguration).when(taskanaEngineImplMock).getConfiguration();
doReturn(true).when(taskanaEngineConfiguration).isGermanPublicHolidaysEnabled();
doReturn(null).when(taskanaEngineConfiguration).getCustomHolidays();
}
@Test
public void testGetTotalNumbersOfWorkbasketLevelReport() throws InvalidArgumentException, NotAuthorizedException {
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");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<CombinedClassificationFilter> combinedClassificationFilter = Arrays
.asList(new CombinedClassificationFilter("CLI:000000000000000000000000000000000003",
"CLI:000000000000000000000000000000000008"));
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("WBI:000000000000000000000000000000000001");
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfWorkbaskets(workbasketIds, states,
categories, domains, customField, customFieldValues, combinedClassificationFilter);
WorkbasketLevelReport actualResult = cut.getWorkbasketLevelReport(workbasketIds, states, categories, domains,
customField, customFieldValues, combinedClassificationFilter);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfWorkbaskets(any(), any(), any(), any(),
any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(
actualResult.getRow("WBI:000000000000000000000000000000000001").getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetWorkbasketLevelReportWithReportLineItemDefinitions()
throws InvalidArgumentException, NotAuthorizedException {
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");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<CombinedClassificationFilter> combinedClassificationFilter = Arrays
.asList(new CombinedClassificationFilter("CLI:000000000000000000000000000000000003",
"CLI:000000000000000000000000000000000008"));
List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("WBI:000000000000000000000000000000000001");
monitorQueryItem.setAgeInDays(0);
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfWorkbaskets(workbasketIds, states,
categories, domains, customField, customFieldValues, combinedClassificationFilter);
WorkbasketLevelReport actualResult = cut.getWorkbasketLevelReport(workbasketIds, states, categories, domains,
customField, customFieldValues, combinedClassificationFilter, reportLineItemDefinitions);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfWorkbaskets(any(), any(), any(), any(), any(), any(),
any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(
actualResult.getRow("WBI:000000000000000000000000000000000001").getTotalValue(), 1);
assertEquals(actualResult.getRow("WBI:000000000000000000000000000000000001").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetTotalNumbersOfCatgoryReport() throws InvalidArgumentException, NotAuthorizedException {
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");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("EXTERN");
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfCategories(workbasketIds, states, categories,
domains, customField, customFieldValues);
CategoryReport actualResult = cut.getCategoryReport(workbasketIds, states, categories, domains,
customField, customFieldValues);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfCategories(any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(actualResult.getRow("EXTERN").getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetCategoryReportWithReportLineItemDefinitions()
throws InvalidArgumentException, NotAuthorizedException {
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");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("EXTERN");
monitorQueryItem.setAgeInDays(0);
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfCategories(workbasketIds, states, categories,
domains, customField, customFieldValues);
CategoryReport actualResult = cut.getCategoryReport(workbasketIds, states, categories, domains,
customField, customFieldValues, reportLineItemDefinitions);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfCategories(any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(actualResult.getRow("EXTERN").getTotalValue(), 1);
assertEquals(actualResult.getRow("EXTERN").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetTotalNumbersOfClassificationReport() throws InvalidArgumentException, NotAuthorizedException {
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");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("CLI:000000000000000000000000000000000001");
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfClassifications(workbasketIds, states,
categories, domains, customField, customFieldValues);
ClassificationReport actualResult = cut.getClassificationReport(workbasketIds, states, categories, domains,
customField, customFieldValues);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfClassifications(any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(
actualResult.getRow("CLI:000000000000000000000000000000000001").getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetClassificationReportWithReportLineItemDefinitions()
throws InvalidArgumentException, NotAuthorizedException {
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");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("CLI:000000000000000000000000000000000001");
monitorQueryItem.setAgeInDays(0);
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfClassifications(workbasketIds, states,
categories, domains, customField, customFieldValues);
ClassificationReport actualResult = cut.getClassificationReport(workbasketIds, states, categories, domains,
customField, customFieldValues, reportLineItemDefinitions);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfClassifications(any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(
actualResult.getRow("CLI:000000000000000000000000000000000001").getTotalValue(), 1);
assertEquals(actualResult.getRow("CLI:000000000000000000000000000000000001").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetTotalNumbersOfDetailedClassificationReport()
throws InvalidArgumentException, NotAuthorizedException {
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");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<DetailedMonitorQueryItem> expectedResult = new ArrayList<>();
DetailedMonitorQueryItem detailedMonitorQueryItem = new DetailedMonitorQueryItem();
detailedMonitorQueryItem.setKey("CLI:000000000000000000000000000000000001");
detailedMonitorQueryItem.setAttachmentKey("CLI:000000000000000000000000000000000006");
detailedMonitorQueryItem.setNumberOfTasks(1);
expectedResult.add(detailedMonitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfDetailedClassifications(workbasketIds,
states, categories, domains, customField, customFieldValues);
DetailedClassificationReport actualResult = cut.getDetailedClassificationReport(workbasketIds, states,
categories, domains, customField, customFieldValues);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfDetailedClassifications(any(), any(), any(), any(), any(),
any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
DetailedReportRow line = actualResult.getRow("CLI:000000000000000000000000000000000001");
assertNotNull(actualResult);
assertEquals(line.getTotalValue(), 1);
assertEquals(line.getDetailRows().get("CLI:000000000000000000000000000000000006").getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetDetailedClassificationReportWithReportLineItemDefinitions()
throws InvalidArgumentException, NotAuthorizedException {
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");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
List<DetailedMonitorQueryItem> expectedResult = new ArrayList<>();
DetailedMonitorQueryItem detailedMonitorQueryItem = new DetailedMonitorQueryItem();
detailedMonitorQueryItem.setKey("CLI:000000000000000000000000000000000001");
detailedMonitorQueryItem.setAttachmentKey("CLI:000000000000000000000000000000000006");
detailedMonitorQueryItem.setAgeInDays(0);
detailedMonitorQueryItem.setNumberOfTasks(1);
expectedResult.add(detailedMonitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfDetailedClassifications(workbasketIds,
states, categories, domains, customField, customFieldValues);
DetailedClassificationReport actualResult = cut.getDetailedClassificationReport(workbasketIds, states,
categories, domains, customField, customFieldValues, reportLineItemDefinitions);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfDetailedClassifications(any(), any(), any(), any(), any(),
any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
DetailedReportRow line = actualResult.getRow("CLI:000000000000000000000000000000000001");
assertNotNull(actualResult);
assertEquals(line.getTotalValue(), 1);
assertEquals(line.getDetailRows().get("CLI:000000000000000000000000000000000006").getTotalValue(), 1);
assertEquals(line.getCells()[0], 1);
assertEquals(line.getDetailRows().get("CLI:000000000000000000000000000000000006").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getCells()[0], 1);
}
@Test
public void testGetTotalNumbersOfCustomFieldValueReport() throws InvalidArgumentException, NotAuthorizedException {
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");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("Geschaeftsstelle A");
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock)
.getTaskCountOfCustomFieldValues(workbasketIds, states, categories, domains, customField,
customFieldValues);
CustomFieldValueReport actualResult = cut.getCustomFieldValueReport(workbasketIds, states, categories, domains,
customField, customFieldValues);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfCustomFieldValues(any(), any(), any(), any(), any(),
any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(actualResult.getRow("Geschaeftsstelle A").getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetCustomFieldValueReportWithReportLineItemDefinitions()
throws InvalidArgumentException, NotAuthorizedException {
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");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("Geschaeftsstelle A");
monitorQueryItem.setAgeInDays(0);
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock)
.getTaskCountOfCustomFieldValues(workbasketIds, states, categories, domains, customField,
customFieldValues);
CustomFieldValueReport actualResult = cut.getCustomFieldValueReport(workbasketIds, states, categories, domains,
customField, customFieldValues, reportLineItemDefinitions);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1))
.getTaskCountOfCustomFieldValues(any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(actualResult.getRow("Geschaeftsstelle A").getTotalValue(), 1);
assertEquals(actualResult.getRow("Geschaeftsstelle A").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetTaskIdsForSelectedItems() throws InvalidArgumentException, NotAuthorizedException {
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(
new TimeIntervalColumnHeader(0, 0));
SelectedItem selectedItem = new SelectedItem();
selectedItem.setKey("EXTERN");
selectedItem.setLowerAgeLimit(1);
selectedItem.setUpperAgeLimit(5);
List<SelectedItem> selectedItems = Collections.singletonList(selectedItem);
List<String> expectedResult = Collections.singletonList("TKI:000000000000000000000000000000000001");
when(taskMonitorMapperMock.getTaskIdsForSelectedItems(workbasketIds,
states, categories, domains, classificationIds, excludedClassificationIds, customField, customFieldValues,
"CLASSIFICATION_CATEGORY", selectedItems, false)).thenReturn(expectedResult);
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(1)).checkRoleMembership(any());
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(), any(), any(),
eq(false));
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(expectedResult, actualResult);
}
@Test
public void testGetTaskStateReportWithoutFilters() throws NotAuthorizedException {
// given
TaskQueryItem queryItem1 = new TaskQueryItem();
queryItem1.setCount(50);
queryItem1.setState(TaskState.READY);
queryItem1.setDomain("DOMAIN_X");
TaskQueryItem queryItem2 = new TaskQueryItem();
queryItem2.setCount(30);
queryItem2.setState(TaskState.COMPLETED);
queryItem2.setDomain("DOMAIN_X");
List<TaskQueryItem> queryItems = Arrays.asList(queryItem1, queryItem2);
when(taskMonitorMapperMock.getTasksCountByState(null, null)).thenReturn(queryItems);
// when
TaskStatusReport report = cut.getTaskStatusReport();
// then
InOrder inOrder = inOrder(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineImplMock);
inOrder.verify(taskanaEngineImplMock).openConnection();
inOrder.verify(taskMonitorMapperMock).getTasksCountByState(eq(null), eq(null));
inOrder.verify(taskanaEngineImplMock).returnConnection();
assertNotNull(report);
assertEquals(1, report.rowSize());
assertArrayEquals(new int[] {50, 0, 30}, report.getRow("DOMAIN_X").getCells());
assertArrayEquals(new int[] {50, 0, 30}, report.getSumRow().getCells());
assertEquals(80, report.getRow("DOMAIN_X").getTotalValue());
assertEquals(80, report.getSumRow().getTotalValue());
}
@Test
public void testGetTotalNumberOfTaskStateReport() throws NotAuthorizedException {
// given
TaskQueryItem queryItem1 = new TaskQueryItem();
queryItem1.setCount(50);
queryItem1.setState(TaskState.READY);
queryItem1.setDomain("DOMAIN_X");
TaskQueryItem queryItem2 = new TaskQueryItem();
queryItem2.setCount(30);
queryItem2.setState(TaskState.COMPLETED);
queryItem2.setDomain("DOMAIN_X");
List<TaskQueryItem> queryItems = Arrays.asList(queryItem1, queryItem2);
when(taskMonitorMapperMock.getTasksCountByState(eq(null), eq(Collections.emptyList()))).thenReturn(queryItems);
// when
TaskStatusReport report = cut.getTaskStatusReport(null, Collections.emptyList());
// then
InOrder inOrder = inOrder(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineImplMock);
inOrder.verify(taskanaEngineImplMock).openConnection();
inOrder.verify(taskMonitorMapperMock).getTasksCountByState(eq(null), eq(Collections.emptyList()));
inOrder.verify(taskanaEngineImplMock).returnConnection();
assertNotNull(report);
assertEquals(1, report.rowSize());
assertArrayEquals(new int[0], report.getRow("DOMAIN_X").getCells());
assertArrayEquals(new int[0], report.getSumRow().getCells());
assertEquals(80, report.getRow("DOMAIN_X").getTotalValue());
assertEquals(80, report.getSumRow().getTotalValue());
}
}

View File

@ -0,0 +1,117 @@
package pro.taskana.impl;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.inOrder;
import static org.powermock.api.mockito.PowerMockito.when;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import pro.taskana.TaskState;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.impl.TaskQueryItem;
import pro.taskana.impl.report.impl.TaskStatusReport;
import pro.taskana.mappings.TaskMonitorMapper;
/**
* Unit Test for TaskStatusReportBuilderImpl.
*/
@RunWith(MockitoJUnitRunner.class)
public class TaskStatusReportBuilderImplTest {
@InjectMocks
private TaskMonitorServiceImpl cut;
@Mock
private TaskanaEngineImpl taskanaEngineImplMock;
@Mock
private TaskanaEngineConfiguration taskanaEngineConfiguration;
@Mock
private TaskMonitorMapper taskMonitorMapperMock;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
Mockito.doNothing().when(taskanaEngineImplMock).openConnection();
Mockito.doNothing().when(taskanaEngineImplMock).returnConnection();
}
@Test
public void testGetTaskStateReportWithoutFilters() throws NotAuthorizedException {
// given
TaskQueryItem queryItem1 = new TaskQueryItem();
queryItem1.setCount(50);
queryItem1.setState(TaskState.READY);
queryItem1.setDomain("DOMAIN_X");
TaskQueryItem queryItem2 = new TaskQueryItem();
queryItem2.setCount(30);
queryItem2.setState(TaskState.COMPLETED);
queryItem2.setDomain("DOMAIN_X");
List<TaskQueryItem> queryItems = Arrays.asList(queryItem1, queryItem2);
when(taskMonitorMapperMock.getTasksCountByState(null, null)).thenReturn(queryItems);
// when
TaskStatusReport report = cut.createTaskStatusReportBuilder().buildReport();
// then
InOrder inOrder = inOrder(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineImplMock);
inOrder.verify(taskanaEngineImplMock).openConnection();
inOrder.verify(taskMonitorMapperMock).getTasksCountByState(eq(null), eq(null));
inOrder.verify(taskanaEngineImplMock).returnConnection();
assertNotNull(report);
assertEquals(1, report.rowSize());
assertArrayEquals(new int[] {50, 0, 30}, report.getRow("DOMAIN_X").getCells());
assertArrayEquals(new int[] {50, 0, 30}, report.getSumRow().getCells());
assertEquals(80, report.getRow("DOMAIN_X").getTotalValue());
assertEquals(80, report.getSumRow().getTotalValue());
}
@Test
public void testGetTotalNumberOfTaskStateReport() throws NotAuthorizedException {
// given
TaskQueryItem queryItem1 = new TaskQueryItem();
queryItem1.setCount(50);
queryItem1.setState(TaskState.READY);
queryItem1.setDomain("DOMAIN_X");
TaskQueryItem queryItem2 = new TaskQueryItem();
queryItem2.setCount(30);
queryItem2.setState(TaskState.COMPLETED);
queryItem2.setDomain("DOMAIN_X");
List<TaskQueryItem> queryItems = Arrays.asList(queryItem1, queryItem2);
when(taskMonitorMapperMock.getTasksCountByState(eq(null), eq(Collections.emptyList()))).thenReturn(queryItems);
// when
TaskStatusReport report = cut.createTaskStatusReportBuilder().stateIn(Collections.emptyList()).buildReport();
// then
InOrder inOrder = inOrder(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineImplMock);
inOrder.verify(taskanaEngineImplMock).openConnection();
inOrder.verify(taskMonitorMapperMock).getTasksCountByState(eq(null), eq(Collections.emptyList()));
inOrder.verify(taskanaEngineImplMock).returnConnection();
assertNotNull(report);
assertEquals(1, report.rowSize());
assertArrayEquals(new int[0], report.getRow("DOMAIN_X").getCells());
assertArrayEquals(new int[0], report.getSumRow().getCells());
assertEquals(80, report.getRow("DOMAIN_X").getTotalValue());
assertEquals(80, report.getSumRow().getTotalValue());
}
}

View File

@ -0,0 +1,274 @@
package pro.taskana.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.powermock.api.mockito.PowerMockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import pro.taskana.CustomField;
import pro.taskana.TaskState;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.report.impl.CombinedClassificationFilter;
import pro.taskana.impl.report.impl.MonitorQueryItem;
import pro.taskana.impl.report.impl.TimeIntervalColumnHeader;
import pro.taskana.impl.report.impl.WorkbasketReport;
import pro.taskana.mappings.TaskMonitorMapper;
/**
* Unit Test for WorkbasketReportBuilderImpl.
*/
@RunWith(MockitoJUnitRunner.class)
public class WorkbasketReportBuilderImplTest {
@InjectMocks
private TaskMonitorServiceImpl cut;
@Mock
private TaskanaEngineImpl taskanaEngineImplMock;
@Mock
private TaskanaEngineConfiguration taskanaEngineConfiguration;
@Mock
private TaskMonitorMapper taskMonitorMapperMock;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
Mockito.doNothing().when(taskanaEngineImplMock).openConnection();
Mockito.doNothing().when(taskanaEngineImplMock).returnConnection();
doReturn(taskanaEngineConfiguration).when(taskanaEngineImplMock).getConfiguration();
doReturn(true).when(taskanaEngineConfiguration).isGermanPublicHolidaysEnabled();
doReturn(null).when(taskanaEngineConfiguration).getCustomHolidays();
}
@Test
public void testGetTotalNumbersOfWorkbasketReport() throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<CombinedClassificationFilter> combinedClassificationFilter = Arrays
.asList(new CombinedClassificationFilter("CLI:000000000000000000000000000000000003",
"CLI:000000000000000000000000000000000008"));
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("WBI:000000000000000000000000000000000001");
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfWorkbaskets(workbasketIds, states,
categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter,
combinedClassificationFilter);
WorkbasketReport actualResult = cut.createWorkbasketReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.combinedClassificationFilterIn(combinedClassificationFilter)
.buildReport();
verify(taskanaEngineImplMock, times(1))
.openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfWorkbaskets(any(), any(), any(), any(),
any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(
actualResult.getRow("WBI:000000000000000000000000000000000001").getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetWorkbasketReportWithReportLineItemDefinitions()
throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<CombinedClassificationFilter> combinedClassificationFilter = Arrays
.asList(new CombinedClassificationFilter("CLI:000000000000000000000000000000000003",
"CLI:000000000000000000000000000000000008"));
List<TimeIntervalColumnHeader> columnHeaders = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("WBI:000000000000000000000000000000000001");
monitorQueryItem.setAgeInDays(0);
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfWorkbaskets(workbasketIds, states,
categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter,
combinedClassificationFilter);
WorkbasketReport actualResult = cut.createWorkbasketReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.combinedClassificationFilterIn(combinedClassificationFilter)
.withColumnHeaders(columnHeaders)
.buildReport();
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfWorkbaskets(any(), any(), any(), any(), any(), any(),
any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(
actualResult.getRow("WBI:000000000000000000000000000000000001").getTotalValue(), 1);
assertEquals(actualResult.getRow("WBI:000000000000000000000000000000000001").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
@Test
public void testGetTaskIdsOfCategoryReportForSelectedItems()
throws InvalidArgumentException, NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
SelectedItem selectedItem = new SelectedItem();
selectedItem.setKey("EXTERN");
selectedItem.setLowerAgeLimit(1);
selectedItem.setUpperAgeLimit(5);
List<SelectedItem> selectedItems = Collections.singletonList(selectedItem);
List<String> expectedResult = Collections.singletonList("TKI:000000000000000000000000000000000001");
when(taskMonitorMapperMock.getTaskIdsForSelectedItems(workbasketIds,
states, categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter,
"WORKBASKET_KEY", selectedItems, false)).thenReturn(expectedResult);
List<String> actualResult = cut.createWorkbasketReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.listTaskIdsForSelectedItems(selectedItems);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
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(), any(), eq(false));
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(expectedResult, actualResult);
}
@Test
public void testListCustomAttributeValuesForCustomAttributeName()
throws NotAuthorizedException {
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");
Map<CustomField, String> customAttributeFilter = new HashMap<>();
customAttributeFilter.put(CustomField.CUSTOM_1, "Geschaeftsstelle A");
List<TimeIntervalColumnHeader> columnHeaders = Collections.singletonList(
new TimeIntervalColumnHeader(0, 0));
SelectedItem selectedItem = new SelectedItem();
selectedItem.setKey("EXTERN");
selectedItem.setLowerAgeLimit(1);
selectedItem.setUpperAgeLimit(5);
List<SelectedItem> selectedItems = Collections.singletonList(selectedItem);
List<String> expectedResult = Collections.singletonList("Geschaeftsstelle A");
when(taskMonitorMapperMock.getCustomAttributeValuesForReport(workbasketIds,
states, categories, domains, classificationIds, excludedClassificationIds, customAttributeFilter,
CustomField.CUSTOM_1)).thenReturn(expectedResult);
List<String> actualResult = cut.createWorkbasketReportBuilder()
.workbasketIdIn(workbasketIds)
.stateIn(states)
.categoryIn(categories)
.domainIn(domains)
.classificationIdIn(classificationIds)
.excludedClassificationIdIn(excludedClassificationIds)
.customAttributeFilterIn(customAttributeFilter)
.withColumnHeaders(columnHeaders)
.listCustomAttributeValuesForCustomAttributeName(CustomField.CUSTOM_1);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1))
.getCustomAttributeValuesForReport(any(), any(), any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(expectedResult, actualResult);
}
}

View File

@ -72,7 +72,11 @@ public class MonitorController {
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<ReportResource> getTaskStatusReport(@RequestParam(required = false) List<String> domains, public ResponseEntity<ReportResource> getTaskStatusReport(@RequestParam(required = false) List<String> domains,
@RequestParam(required = false) List<TaskState> states) throws NotAuthorizedException { @RequestParam(required = false) List<TaskState> states) throws NotAuthorizedException {
// return ResponseEntity.status(HttpStatus.OK)
// .body(reportAssembler.toResource(taskMonitorService.getTaskStatusReport(domains, states), domains, states));
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(reportAssembler.toResource(taskMonitorService.getTaskStatusReport(domains, states), domains, states)); .body(reportAssembler.toResource(
taskMonitorService.createTaskStatusReportBuilder().stateIn(states).domainIn(domains).buildReport(),
domains, states));
} }
} }