TSK-1378: now support combinedClassificationfilter in WorkbasketReport#listCustomAttributeValuesForCustomAttributeName

This commit is contained in:
Mustapha Zorgati 2020-09-15 11:47:41 +02:00
parent 51a2410afc
commit 0a5ec9e701
7 changed files with 57 additions and 12 deletions

View File

@ -381,28 +381,39 @@ public interface MonitorMapper {
@Select( @Select(
"<script>" "<script>"
+ "SELECT DISTINCT ${customField} " + "SELECT DISTINCT ${customField} "
+ "FROM TASK " + "FROM TASK T"
+ "<if test=\"combinedClassificationFilter != null\">"
+ "LEFT JOIN ATTACHMENT A ON T.ID = A.TASK_ID "
+ "</if>"
+ "<where>" + "<where>"
+ "<if test='workbasketIds != null'>" + "<if test='workbasketIds != null'>"
+ "WORKBASKET_ID IN (<foreach collection='workbasketIds' item='workbasketId' separator=','>#{workbasketId}</foreach>) " + "T.WORKBASKET_ID IN (<foreach collection='workbasketIds' item='workbasketId' separator=','>#{workbasketId}</foreach>) "
+ "</if>" + "</if>"
+ "<if test='states != null'>" + "<if test='states != null'>"
+ "AND STATE IN (<foreach collection='states' item='state' separator=','>#{state}</foreach>) " + "AND T.STATE IN (<foreach collection='states' item='state' separator=','>#{state}</foreach>) "
+ "</if>" + "</if>"
+ "<if test='classificationCategories != null'>" + "<if test='classificationCategories != null'>"
+ "AND CLASSIFICATION_CATEGORY IN (<foreach collection='classificationCategories' item='category' separator=','>#{category}</foreach>) " + "AND T.CLASSIFICATION_CATEGORY IN (<foreach collection='classificationCategories' item='category' separator=','>#{category}</foreach>) "
+ "</if>" + "</if>"
+ "<if test='domains != null'>" + "<if test='domains != null'>"
+ "AND 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='classificationIds != null'>" + "<if test='classificationIds != null'>"
+ "AND CLASSIFICATION_ID IN (<foreach collection='classificationIds' item='classificationId' separator=','>#{classificationId}</foreach>) " + "AND T.CLASSIFICATION_ID IN (<foreach collection='classificationIds' item='classificationId' separator=','>#{classificationId}</foreach>) "
+ "</if>" + "</if>"
+ "<if test='excludedClassificationIds != null'>" + "<if test='excludedClassificationIds != null'>"
+ "AND 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='customAttributeFilter != null'>" + "<if test='customAttributeFilter != null'>"
+ "AND (<foreach collection='customAttributeFilter.keys' item='key' separator=' AND '>(${key} = '${customAttributeFilter.get(key)}')</foreach>) " + "AND (<foreach collection='customAttributeFilter.keys' item='key' separator=' AND '>(T.${key} = '${customAttributeFilter.get(key)}')</foreach>) "
+ "</if>"
+ "<if test=\"combinedClassificationFilter != null\">"
+ "AND <foreach collection='combinedClassificationFilter' item='item' separator='OR'> "
+ "T.CLASSIFICATION_ID = #{item.taskClassificationId} "
+ "<if test=\"item.attachmentClassificationId != null\">"
+ "AND A.CLASSIFICATION_ID = #{item.attachmentClassificationId} "
+ "</if>"
+ "</foreach>"
+ "</if>" + "</if>"
+ "</where>" + "</where>"
+ "</script>") + "</script>")
@ -414,6 +425,8 @@ public interface MonitorMapper {
@Param("classificationIds") List<String> classificationIds, @Param("classificationIds") List<String> classificationIds,
@Param("excludedClassificationIds") List<String> excludedClassificationIds, @Param("excludedClassificationIds") List<String> excludedClassificationIds,
@Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter, @Param("customAttributeFilter") Map<TaskCustomField, String> customAttributeFilter,
@Param("combinedClassificationFilter")
List<CombinedClassificationFilter> combinedClassificationFilter,
@Param("customField") TaskCustomField taskCustomField); @Param("customField") TaskCustomField taskCustomField);
@Select( @Select(

View File

@ -182,6 +182,7 @@ abstract class TimeIntervalReportBuilderImpl<
this.classificationIds, this.classificationIds,
this.excludedClassificationIds, this.excludedClassificationIds,
this.customAttributeFilter, this.customAttributeFilter,
getCombinedClassificationFilter(),
taskCustomField); taskCustomField);
} finally { } finally {
this.taskanaEngine.returnConnection(); this.taskanaEngine.returnConnection();

View File

@ -393,6 +393,29 @@ class ProvideWorkbasketReportAccTest extends AbstractReportAccTest {
assertThat(report.getSumRow().getTotalValue()).isEqualTo(50); assertThat(report.getSumRow().getTotalValue()).isEqualTo(50);
} }
@WithAccessId(user = "monitor")
@Test
void should_ReturnCustomFieldValues_When_CombinedClassificationFilterIsApplied()
throws Exception {
List<TimeIntervalColumnHeader> columnHeaders = getListOfColumnHeaders();
List<CombinedClassificationFilter> combinedClassificationFilters =
Collections.singletonList(
new CombinedClassificationFilter(
"CLI:000000000000000000000000000000000001",
"CLI:000000000000000000000000000000000006"));
List<String> customValues =
MONITOR_SERVICE
.createWorkbasketReportBuilder()
.withColumnHeaders(columnHeaders)
.combinedClassificationFilterIn(combinedClassificationFilters)
.listCustomAttributeValuesForCustomAttributeName(TaskCustomField.CUSTOM_1);
assertThat(customValues)
.containsExactlyInAnyOrder(
"Geschaeftsstelle A", "Geschaeftsstelle B", "Geschaeftsstelle C");
}
private List<TimeIntervalColumnHeader> getListOfColumnHeaders() { private List<TimeIntervalColumnHeader> getListOfColumnHeaders() {
List<TimeIntervalColumnHeader> columnHeaders = new ArrayList<>(); List<TimeIntervalColumnHeader> columnHeaders = new ArrayList<>();
columnHeaders.add(new TimeIntervalColumnHeader(Integer.MIN_VALUE, -11)); columnHeaders.add(new TimeIntervalColumnHeader(Integer.MIN_VALUE, -11));

View File

@ -276,6 +276,7 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
classificationIds, classificationIds,
excludedClassificationIds, excludedClassificationIds,
customAttributeFilter, customAttributeFilter,
null,
TaskCustomField.CUSTOM_1)) TaskCustomField.CUSTOM_1))
.thenReturn(expectedResult); .thenReturn(expectedResult);
@ -296,7 +297,8 @@ class ClassificationClassificationCategoryReportBuilderImplTest {
verify(taskanaEngineMock).checkRoleMembership(any()); verify(taskanaEngineMock).checkRoleMembership(any());
verify(taskanaEngineMock).getWorkingDaysToDaysConverter(); verify(taskanaEngineMock).getWorkingDaysToDaysConverter();
verify(monitorMapperMock) verify(monitorMapperMock)
.getCustomAttributeValuesForReport(any(), any(), any(), any(), any(), any(), any(), any()); .getCustomAttributeValuesForReport(
any(), any(), any(), any(), any(), any(), any(), any(), any());
verify(internalTaskanaEngineMock).returnConnection(); verify(internalTaskanaEngineMock).returnConnection();
verifyNoMoreInteractions( verifyNoMoreInteractions(
internalTaskanaEngineMock, internalTaskanaEngineMock,

View File

@ -446,6 +446,7 @@ class ClassificationReportBuilderImplTest {
classificationIds, classificationIds,
excludedClassificationIds, excludedClassificationIds,
customAttributeFilter, customAttributeFilter,
null,
TaskCustomField.CUSTOM_1)) TaskCustomField.CUSTOM_1))
.thenReturn(expectedResult); .thenReturn(expectedResult);
@ -467,7 +468,8 @@ class ClassificationReportBuilderImplTest {
verify(internalTaskanaEngineMock, times(3)).getEngine(); verify(internalTaskanaEngineMock, times(3)).getEngine();
verify(monitorMapperMock) verify(monitorMapperMock)
.getCustomAttributeValuesForReport(any(), any(), any(), any(), any(), any(), any(), any()); .getCustomAttributeValuesForReport(
any(), any(), any(), any(), any(), any(), any(), any(), any());
verify(internalTaskanaEngineMock).returnConnection(); verify(internalTaskanaEngineMock).returnConnection();
verify(taskanaEngineMock).getClassificationService(); verify(taskanaEngineMock).getClassificationService();
verifyNoMoreInteractions(mocks); verifyNoMoreInteractions(mocks);

View File

@ -195,6 +195,7 @@ class TaskCustomFieldValueReportBuilderImplTest {
classificationIds, classificationIds,
excludedClassificationIds, excludedClassificationIds,
customAttributeFilter, customAttributeFilter,
null,
TaskCustomField.CUSTOM_1)) TaskCustomField.CUSTOM_1))
.thenReturn(expectedResult); .thenReturn(expectedResult);
@ -215,7 +216,8 @@ class TaskCustomFieldValueReportBuilderImplTest {
verify(taskanaEngineMock).getWorkingDaysToDaysConverter(); verify(taskanaEngineMock).getWorkingDaysToDaysConverter();
verify(internalTaskanaEngineMock, times(2)).getEngine(); verify(internalTaskanaEngineMock, times(2)).getEngine();
verify(monitorMapperMock) verify(monitorMapperMock)
.getCustomAttributeValuesForReport(any(), any(), any(), any(), any(), any(), any(), any()); .getCustomAttributeValuesForReport(
any(), any(), any(), any(), any(), any(), any(), any(), any());
verify(internalTaskanaEngineMock).returnConnection(); verify(internalTaskanaEngineMock).returnConnection();
verifyNoMoreInteractions( verifyNoMoreInteractions(
internalTaskanaEngineMock, internalTaskanaEngineMock,

View File

@ -295,6 +295,7 @@ class WorkbasketReportBuilderImplTest {
classificationIds, classificationIds,
excludedClassificationIds, excludedClassificationIds,
customAttributeFilter, customAttributeFilter,
null,
TaskCustomField.CUSTOM_1)) TaskCustomField.CUSTOM_1))
.thenReturn(expectedResult); .thenReturn(expectedResult);
@ -315,7 +316,8 @@ class WorkbasketReportBuilderImplTest {
verify(taskanaEngineMock).getWorkingDaysToDaysConverter(); verify(taskanaEngineMock).getWorkingDaysToDaysConverter();
verify(internalTaskanaEngineMock, times(3)).getEngine(); verify(internalTaskanaEngineMock, times(3)).getEngine();
verify(monitorMapperMock) verify(monitorMapperMock)
.getCustomAttributeValuesForReport(any(), any(), any(), any(), any(), any(), any(), any()); .getCustomAttributeValuesForReport(
any(), any(), any(), any(), any(), any(), any(), any(), any());
verify(internalTaskanaEngineMock).returnConnection(); verify(internalTaskanaEngineMock).returnConnection();
verify(taskanaEngineMock).getWorkbasketService(); verify(taskanaEngineMock).getWorkbasketService();
verifyNoMoreInteractions(internalTaskanaEngineMock, taskanaEngineMock, monitorMapperMock); verifyNoMoreInteractions(internalTaskanaEngineMock, taskanaEngineMock, monitorMapperMock);