TSK-1769: TaskQuery on CustomFields distinguishes between empty / null.

This commit is contained in:
holgerhagen 2021-11-18 14:12:21 +01:00 committed by holgerhagen
parent bd2c2746cb
commit 2c89353fc7
23 changed files with 439 additions and 482 deletions

View File

@ -24,7 +24,7 @@ INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000020', 'ETI:0000000
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000021', 'ETI:000000000000000000000000000000000021', '2018-01-29 15:55:21', null , null , '2018-01-29 15:55:21', null , '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , -1 , 'READY' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000001' , 'GPK_KSC' , 'DOMAIN_A', 'PI_0000000000021' , 'DOC_0000000000000000021' , null , '00' , 'PASystem' , '00' , 'SDNR' , '11223344' , false , false , null , 'NONE' , null , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , 'abc' , '' , '' , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000022', 'ETI:000000000000000000000000000000000022', '2018-01-29 15:55:22', null , null , '2018-01-29 15:55:22', null , '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , -1 , 'READY' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000001' , 'GPK_KSC' , 'DOMAIN_A', 'PI_0000000000022' , 'DOC_0000000000000000022' , null , '00' , 'PASystem' , '00' , 'SDNR' , '11223344' , false , false , null , 'NONE' , null , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , 'abc' , '' , '' , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000023', 'ETI:000000000000000000000000000000000023', '2018-01-29 15:55:23', null , null , '2018-01-29 15:55:23', null , '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , -1 , 'READY' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000001' , 'GPK_KSC' , 'DOMAIN_A', 'PI_0000000000023' , 'DOC_0000000000000000023' , null , '00' , 'PASystem' , '00' , 'SDNR' , '11223344' , false , false , null , 'NONE' , null , '' , '' , '' , '' , '' , '' , '' , 'lnp' , '' , '' , '' , '' , '' , 'abc' , '' , '' , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000024', 'ETI:000000000000000000000000000000000024', '2018-01-29 15:55:24', null , null , '2018-01-29 15:55:24', null , '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , -1 , 'READY' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000001' , 'GPK_KSC' , 'DOMAIN_A', 'PI_0000000000024' , 'DOC_0000000000000000024' , null , '00' , 'PASystem' , '00' , 'SDNR' , '11223344' , false , false , null , 'NONE' , null , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , 'abc' , '' , '' , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000024', 'ETI:000000000000000000000000000000000024', '2018-01-29 15:55:24', null , null , '2018-01-29 15:55:24', null , '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , -1 , 'READY' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000001' , 'GPK_KSC' , 'DOMAIN_A', 'PI_0000000000024' , 'DOC_0000000000000000024' , null , '00' , 'PASystem' , '00' , 'SDNR' , '11223344' , false , false , null , 'NONE' , null , '' , '' , '' , '' , '' , '' , '' , '' , null , '' , '' , '' , '' , 'abc' , '' , '' , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );
-- Tasks for WorkOnTaskAccTest
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000025', 'ETI:000000000000000000000000000000000025', '2018-01-29 15:55:24', null , null , '2018-01-29 15:55:24', '2018-01-29 15:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , -1 , 'READY' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000007' , 'USER-1-2' , 'DOMAIN_A', 'PI_0000000000025' , 'DOC_0000000000000000025' , null , 'abcd00' , 'PASystem' , '00' , 'SDNR' , '98765432' , false , false , null , 'NONE' , null , '' , '' , '' , '' , '' , '' , '' , '' , '' , 'ert' , 'ert' , 'ert' , 'ert' , 'abc' , 'ert' , 'ert' , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000026', 'ETI:000000000000000000000000000000000026', '2018-01-29 15:55:24', '2018-01-30 15:55:24', null , '2018-01-30 15:55:24', '2018-01-29 15:55:24', '2018-01-29 15:55:00', '2018-01-30 15:55:00', 'Widerruf' , 'creator_user_id' , 'Widerruf' , null , 2 , -1 , 'CLAIMED' , 'EXTERN' , 'L1050' , 'CLI:100000000000000000000000000000000003', 'WBI:100000000000000000000000000000000007' , 'USER-1-2' , 'DOMAIN_A', 'PI_0000000000026' , 'DOC_0000000000000000026' , 'user-1-1' , 'bcde00' , 'PASystem' , '00' , 'SDNR' , '98765432' , true , false , null , 'NONE' , null , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , 'abc' , '' , '' , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );

View File

@ -12,13 +12,22 @@ public class SqlProviderUtil {
private SqlProviderUtil() {}
public static StringBuilder whereIn(String collection, String column, StringBuilder sb) {
return sb.append("<if test='")
sb.append("<if test='")
.append(collection)
.append(" != null'>AND ")
.append(" != null'>AND (")
.append("<choose>")
.append("<when test='" + collection + ".length > 0'>")
.append(column)
.append(" IN(<foreach item='item' collection='")
.append(collection)
.append("' separator=',' >#{item}</foreach>)</if> ");
.append("' separator=',' >#{item}</foreach>)")
.append("</when>")
.append("<otherwise>0=1</otherwise>")
.append("</choose>");
if (column.contains("t.CUSTOM_")) {
sb.append("<if test='" + collection + "ContainsNull'> OR " + column + " IS NULL </if>");
}
return sb.append(")</if> ");
}
public static StringBuilder whereIn(String collection, String column) {
@ -26,13 +35,24 @@ public class SqlProviderUtil {
}
public static StringBuilder whereNotIn(String collection, String column, StringBuilder sb) {
return sb.append("<if test='")
sb.append("<if test='")
.append(collection)
.append(" != null'>AND ")
.append(" != null'>AND (")
.append("<choose>")
.append("<when test='" + collection + ".length > 0'>")
.append(column)
.append(" NOT IN(<foreach item='item' collection='")
.append(collection)
.append("' separator=',' >#{item}</foreach>)</if> ");
.append("' separator=',' >#{item}</foreach>)")
.append("</when>")
.append("<otherwise>1=1</otherwise>")
.append("</choose>");
if (column.contains("t.CUSTOM_")) {
sb.append("<if test='" + collection + "ContainsNull'> AND " + column + " IS NOT NULL </if>");
sb.append("<if test='!" + collection + "ContainsNull'> OR " + column + " IS NULL </if>");
}
sb.append(")</if> ");
return sb;
}
public static StringBuilder whereNotIn(String collection, String column) {

View File

@ -83,9 +83,6 @@ public class ClassificationImpl extends ClassificationSummaryImpl implements Cla
@Override
public void setCustomAttribute(ClassificationCustomField customField, String value) {
if (value == null) {
value = "";
}
switch (customField) {
case CUSTOM_1:
custom1 = value;

View File

@ -20,14 +20,14 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
protected int priority;
protected String serviceLevel; // PddDThhHmmM
protected String type;
protected String custom1 = "";
protected String custom2 = "";
protected String custom3 = "";
protected String custom4 = "";
protected String custom5 = "";
protected String custom6 = "";
protected String custom7 = "";
protected String custom8 = "";
protected String custom1;
protected String custom2;
protected String custom3;
protected String custom4;
protected String custom5;
protected String custom6;
protected String custom7;
protected String custom8;
public ClassificationSummaryImpl() {}
@ -179,11 +179,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
}
public void setCustom1(String custom1) {
if (custom1 == null) {
this.custom1 = "";
} else {
this.custom1 = custom1;
}
this.custom1 = custom1;
}
public String getCustom2() {
@ -191,11 +187,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
}
public void setCustom2(String custom2) {
if (custom2 == null) {
this.custom2 = "";
} else {
this.custom2 = custom2;
}
this.custom2 = custom2;
}
public String getCustom3() {
@ -203,11 +195,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
}
public void setCustom3(String custom3) {
if (custom3 == null) {
this.custom3 = "";
} else {
this.custom3 = custom3;
}
this.custom3 = custom3;
}
public String getCustom4() {
@ -215,11 +203,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
}
public void setCustom4(String custom4) {
if (custom4 == null) {
this.custom4 = "";
} else {
this.custom4 = custom4;
}
this.custom4 = custom4;
}
public String getCustom5() {
@ -227,11 +211,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
}
public void setCustom5(String custom5) {
if (custom5 == null) {
this.custom5 = "";
} else {
this.custom5 = custom5;
}
this.custom5 = custom5;
}
public String getCustom6() {
@ -239,11 +219,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
}
public void setCustom6(String custom6) {
if (custom6 == null) {
this.custom6 = "";
} else {
this.custom6 = custom6;
}
this.custom6 = custom6;
}
public String getCustom7() {
@ -251,11 +227,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
}
public void setCustom7(String custom7) {
if (custom7 == null) {
this.custom7 = "";
} else {
this.custom7 = custom7;
}
this.custom7 = custom7;
}
public String getCustom8() {
@ -263,11 +235,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
}
public void setCustom8(String custom8) {
if (custom8 == null) {
this.custom8 = "";
} else {
this.custom8 = custom8;
}
this.custom8 = custom8;
}
@Override

View File

@ -89,9 +89,9 @@ public interface MonitorMapper {
@Result(column = "STATE", property = "state")
@Result(column = "COUNT", property = "count")
List<TaskQueryItem> getTasksCountByState(
@Param("domains") List<String> domains,
@Param("states") List<TaskState> states,
@Param("workbasketIds") List<String> workbasketIds,
@Param("domains") String[] domains,
@Param("states") TaskState[] states,
@Param("workbasketIds") String[] workbasketIds,
@Param("priorityMinimum") Integer priorityMinimum);
@SelectProvider(

View File

@ -62,7 +62,7 @@ public class ClassificationReportBuilderImpl
report.getRows().isEmpty()
? null
: report.getRows().keySet().toArray(new String[0]))
.domainIn(domains != null ? domains.toArray(new String[0]) : null)
.domainIn(this.domains)
.list()
.stream()
.collect(
@ -106,7 +106,7 @@ public class ClassificationReportBuilderImpl
classificationService
.createClassificationQuery()
.keyIn(keys.length == 0 ? null : keys)
.domainIn(domains != null ? domains.toArray(new String[0]) : null)
.domainIn(this.domains)
.list()
.stream()
.collect(

View File

@ -1,5 +1,6 @@
package pro.taskana.monitor.internal.reports;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -21,9 +22,9 @@ public class TaskStatusReportBuilderImpl implements TaskStatusReport.Builder {
private final InternalTaskanaEngine taskanaEngine;
private final MonitorMapper monitorMapper;
private final WorkbasketService workbasketService;
private List<String> domains;
private List<TaskState> states;
private List<String> workbasketIds;
private String[] domains;
private TaskState[] states;
private String[] workbasketIds;
private Integer priorityMinimum;
public TaskStatusReportBuilderImpl(
@ -41,7 +42,8 @@ public class TaskStatusReportBuilderImpl implements TaskStatusReport.Builder {
List<TaskQueryItem> tasks =
this.monitorMapper.getTasksCountByState(
this.domains, this.states, this.workbasketIds, this.priorityMinimum);
TaskStatusReport report = new TaskStatusReport(this.states);
TaskStatusReport report =
new TaskStatusReport(this.states != null ? Arrays.asList(this.states) : null);
report.addItems(tasks);
Map<String, String> displayMap =
taskanaEngine
@ -51,7 +53,7 @@ public class TaskStatusReportBuilderImpl implements TaskStatusReport.Builder {
workbasketService
.createWorkbasketQuery()
.keyIn(report.getRows().keySet().toArray(new String[0]))
.domainIn(domains != null ? domains.toArray(new String[0]) : null)
.domainIn(domains)
.list()
.stream()
.collect(
@ -68,7 +70,9 @@ public class TaskStatusReportBuilderImpl implements TaskStatusReport.Builder {
@Override
public TaskStatusReportBuilderImpl stateIn(List<TaskState> states) {
this.states = states;
if (states != null) {
this.states = states.toArray(new TaskState[0]);
}
return this;
}
@ -80,13 +84,17 @@ public class TaskStatusReportBuilderImpl implements TaskStatusReport.Builder {
@Override
public TaskStatusReportBuilderImpl domainIn(List<String> domains) {
this.domains = domains;
if (domains != null) {
this.domains = domains.toArray(new String[0]);
}
return this;
}
@Override
public Builder workbasketIdsIn(List<String> workbasketIds) {
this.workbasketIds = workbasketIds;
if (workbasketIds != null) {
this.workbasketIds = workbasketIds.toArray(new String[0]);
}
return this;
}
}

View File

@ -1,7 +1,6 @@
package pro.taskana.monitor.internal.reports;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -41,12 +40,12 @@ abstract class TimeIntervalReportBuilderImpl<
protected MonitorMapper monitorMapper;
protected List<H> columnHeaders;
protected boolean inWorkingDays;
protected List<String> workbasketIds;
protected List<TaskState> states;
protected List<String> classificationCategories;
protected List<String> domains;
protected List<String> classificationIds;
protected List<String> excludedClassificationIds;
protected String[] workbasketIds;
protected TaskState[] states;
protected String[] classificationCategories;
protected String[] domains;
protected String[] classificationIds;
protected String[] excludedClassificationIds;
protected WorkingDaysToDaysConverter converter;
private String[] custom1In;
private String[] custom1NotIn;
@ -118,37 +117,49 @@ abstract class TimeIntervalReportBuilderImpl<
@Override
public B workbasketIdIn(List<String> workbasketIds) {
this.workbasketIds = new ArrayList<>(workbasketIds);
if (workbasketIds != null) {
this.workbasketIds = workbasketIds.toArray(new String[0]);
}
return _this();
}
@Override
public B stateIn(List<TaskState> states) {
this.states = new ArrayList<>(states);
if (states != null) {
this.states = states.toArray(new TaskState[0]);
}
return _this();
}
@Override
public B classificationCategoryIn(List<String> classificationCategories) {
this.classificationCategories = new ArrayList<>(classificationCategories);
if (classificationCategories != null) {
this.classificationCategories = classificationCategories.toArray(new String[0]);
}
return _this();
}
@Override
public B classificationIdIn(List<String> classificationIds) {
this.classificationIds = new ArrayList<>(classificationIds);
if (classificationIds != null) {
this.classificationIds = classificationIds.toArray(new String[0]);
}
return _this();
}
@Override
public B excludedClassificationIdIn(List<String> excludedClassificationIds) {
this.excludedClassificationIds = new ArrayList<>(excludedClassificationIds);
if (excludedClassificationIds != null) {
this.excludedClassificationIds = excludedClassificationIds.toArray(new String[0]);
}
return _this();
}
@Override
public B domainIn(List<String> domains) {
this.domains = new ArrayList<>(domains);
if (domains != null) {
this.domains = domains.toArray(new String[0]);
}
return _this();
}

View File

@ -1,6 +1,5 @@
package pro.taskana.monitor.internal.reports;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -25,12 +24,12 @@ public class WorkbasketPriorityReportBuilderImpl implements WorkbasketPriorityRe
private final MonitorMapper monitorMapper;
protected List<PriorityColumnHeader> columnHeaders;
protected boolean inWorkingDays;
protected List<String> workbasketIds;
protected List<TaskState> states;
protected List<String> classificationCategories;
protected List<String> domains;
protected List<String> classificationIds;
protected List<String> excludedClassificationIds;
protected String[] workbasketIds;
protected TaskState[] states;
protected String[] classificationCategories;
protected String[] domains;
protected String[] classificationIds;
protected String[] excludedClassificationIds;
protected WorkingDaysToDaysConverter converter;
private WorkbasketType[] workbasketTypes;
private String[] custom1In;
@ -121,37 +120,49 @@ public class WorkbasketPriorityReportBuilderImpl implements WorkbasketPriorityRe
@Override
public Builder workbasketIdIn(List<String> workbasketIds) {
this.workbasketIds = new ArrayList<>(workbasketIds);
if (workbasketIds != null) {
this.workbasketIds = workbasketIds.toArray(new String[0]);
}
return this;
}
@Override
public Builder stateIn(List<TaskState> states) {
this.states = new ArrayList<>(states);
if (states != null) {
this.states = states.toArray(new TaskState[0]);
}
return this;
}
@Override
public Builder classificationCategoryIn(List<String> classificationCategories) {
this.classificationCategories = new ArrayList<>(classificationCategories);
if (classificationCategories != null) {
this.classificationCategories = classificationCategories.toArray(new String[0]);
}
return this;
}
@Override
public Builder classificationIdIn(List<String> classificationIds) {
this.classificationIds = new ArrayList<>(classificationIds);
if (classificationIds != null) {
this.classificationIds = classificationIds.toArray(new String[0]);
}
return this;
}
@Override
public Builder excludedClassificationIdIn(List<String> excludedClassificationIds) {
this.excludedClassificationIds = new ArrayList<>(excludedClassificationIds);
if (excludedClassificationIds != null) {
this.excludedClassificationIds = excludedClassificationIds.toArray(new String[0]);
}
return this;
}
@Override
public Builder domainIn(List<String> domains) {
this.domains = new ArrayList<>(domains);
if (domains != null) {
this.domains = domains.toArray(new String[0]);
}
return this;
}

View File

@ -60,7 +60,7 @@ public class WorkbasketReportBuilderImpl
workbasketService
.createWorkbasketQuery()
.keyIn(report.getRows().keySet().toArray(new String[0]))
.domainIn(domains != null ? domains.toArray(new String[0]) : null)
.domainIn(domains)
.list()
.stream()
.collect(

View File

@ -257,67 +257,99 @@ public class TaskQueryImpl implements TaskQuery {
// endregion
// region customAttributes
private String[] custom1In;
private boolean custom1InContainsNull;
private String[] custom1NotIn;
private boolean custom1NotInContainsNull;
private String[] custom1Like;
private String[] custom1NotLike;
private String[] custom2In;
private boolean custom2InContainsNull;
private String[] custom2NotIn;
private boolean custom2NotInContainsNull;
private String[] custom2Like;
private String[] custom2NotLike;
private String[] custom3In;
private boolean custom3InContainsNull;
private String[] custom3NotIn;
private boolean custom3NotInContainsNull;
private String[] custom3Like;
private String[] custom3NotLike;
private String[] custom4In;
private boolean custom4InContainsNull;
private String[] custom4NotIn;
private boolean custom4NotInContainsNull;
private String[] custom4Like;
private String[] custom4NotLike;
private String[] custom5In;
private boolean custom5InContainsNull;
private String[] custom5NotIn;
private boolean custom5NotInContainsNull;
private String[] custom5Like;
private String[] custom5NotLike;
private String[] custom6In;
private boolean custom6InContainsNull;
private String[] custom6NotIn;
private boolean custom6NotInContainsNull;
private String[] custom6Like;
private String[] custom6NotLike;
private String[] custom7In;
private boolean custom7InContainsNull;
private String[] custom7NotIn;
private boolean custom7NotInContainsNull;
private String[] custom7Like;
private String[] custom7NotLike;
private String[] custom8In;
private boolean custom8InContainsNull;
private String[] custom8NotIn;
private boolean custom8NotInContainsNull;
private String[] custom8Like;
private String[] custom8NotLike;
private String[] custom9In;
private boolean custom9InContainsNull;
private String[] custom9NotIn;
private boolean custom9NotInContainsNull;
private String[] custom9Like;
private String[] custom9NotLike;
private String[] custom10In;
private boolean custom10InContainsNull;
private String[] custom10NotIn;
private boolean custom10NotInContainsNull;
private String[] custom10Like;
private String[] custom10NotLike;
private String[] custom11In;
private boolean custom11InContainsNull;
private String[] custom11NotIn;
private boolean custom11NotInContainsNull;
private String[] custom11Like;
private String[] custom11NotLike;
private String[] custom12In;
private boolean custom12InContainsNull;
private String[] custom12NotIn;
private boolean custom12NotInContainsNull;
private String[] custom12Like;
private String[] custom12NotLike;
private String[] custom13In;
private boolean custom13InContainsNull;
private String[] custom13NotIn;
private boolean custom13NotInContainsNull;
private String[] custom13Like;
private String[] custom13NotLike;
private String[] custom14In;
private boolean custom14InContainsNull;
private String[] custom14NotIn;
private boolean custom14NotInContainsNull;
private String[] custom14Like;
private String[] custom14NotLike;
private String[] custom15In;
private boolean custom15InContainsNull;
private String[] custom15NotIn;
private boolean custom15NotInContainsNull;
private String[] custom15Like;
private String[] custom15NotLike;
private String[] custom16In;
private boolean custom16InContainsNull;
private String[] custom16NotIn;
private boolean custom16NotInContainsNull;
private String[] custom16Like;
private String[] custom16NotLike;
// endregion
@ -1363,54 +1395,109 @@ public class TaskQueryImpl implements TaskQuery {
throw new InvalidArgumentException(
"At least one string has to be provided as a search parameter");
}
List<String> conditionList = new ArrayList<>(Arrays.asList(strings));
boolean containsNull = conditionList.contains(null);
if (containsNull) {
conditionList.remove(null);
}
switch (customField) {
case CUSTOM_1:
this.custom1In = strings;
this.custom1In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom1InContainsNull = true;
}
break;
case CUSTOM_2:
this.custom2In = strings;
this.custom2In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom2InContainsNull = true;
}
break;
case CUSTOM_3:
this.custom3In = strings;
this.custom3In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom3InContainsNull = true;
}
break;
case CUSTOM_4:
this.custom4In = strings;
this.custom4In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom4InContainsNull = true;
}
break;
case CUSTOM_5:
this.custom5In = strings;
this.custom5In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom5InContainsNull = true;
}
break;
case CUSTOM_6:
this.custom6In = strings;
this.custom6In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom6InContainsNull = true;
}
break;
case CUSTOM_7:
this.custom7In = strings;
this.custom7In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom7InContainsNull = true;
}
break;
case CUSTOM_8:
this.custom8In = strings;
this.custom8In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom8InContainsNull = true;
}
break;
case CUSTOM_9:
this.custom9In = strings;
this.custom9In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom9InContainsNull = true;
}
break;
case CUSTOM_10:
this.custom10In = strings;
this.custom10In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom10InContainsNull = true;
}
break;
case CUSTOM_11:
this.custom11In = strings;
this.custom11In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom11InContainsNull = true;
}
break;
case CUSTOM_12:
this.custom12In = strings;
this.custom12In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom12InContainsNull = true;
}
break;
case CUSTOM_13:
this.custom13In = strings;
this.custom13In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom13InContainsNull = true;
}
break;
case CUSTOM_14:
this.custom14In = strings;
this.custom14In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom14InContainsNull = true;
}
break;
case CUSTOM_15:
this.custom15In = strings;
this.custom15In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom15InContainsNull = true;
}
break;
case CUSTOM_16:
this.custom16In = strings;
this.custom16In = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom16InContainsNull = true;
}
break;
default:
throw new SystemException("Unknown custom attribute '" + customField + "'");
@ -1426,54 +1513,107 @@ public class TaskQueryImpl implements TaskQuery {
throw new InvalidArgumentException(
"At least one string has to be provided as a search parameter");
}
List<String> conditionList = new ArrayList<>(Arrays.asList(strings));
boolean containsNull = conditionList.contains(null);
if (containsNull) {
conditionList.remove(null);
}
switch (customField) {
case CUSTOM_1:
this.custom1NotIn = strings;
this.custom1NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom1NotInContainsNull = true;
}
break;
case CUSTOM_2:
this.custom2NotIn = strings;
this.custom2NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom2NotInContainsNull = true;
}
break;
case CUSTOM_3:
this.custom3NotIn = strings;
this.custom3NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom3NotInContainsNull = true;
}
break;
case CUSTOM_4:
this.custom4NotIn = strings;
this.custom4NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom4NotInContainsNull = true;
}
break;
case CUSTOM_5:
this.custom5NotIn = strings;
this.custom5NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom5NotInContainsNull = true;
}
break;
case CUSTOM_6:
this.custom6NotIn = strings;
this.custom6NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom6NotInContainsNull = true;
}
break;
case CUSTOM_7:
this.custom7NotIn = strings;
this.custom7NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom7NotInContainsNull = true;
}
break;
case CUSTOM_8:
this.custom8NotIn = strings;
this.custom8NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom8NotInContainsNull = true;
}
break;
case CUSTOM_9:
this.custom9NotIn = strings;
this.custom9NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom9NotInContainsNull = true;
}
break;
case CUSTOM_10:
this.custom10NotIn = strings;
this.custom10NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom10NotInContainsNull = true;
}
break;
case CUSTOM_11:
this.custom11NotIn = strings;
this.custom11NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom11NotInContainsNull = true;
}
break;
case CUSTOM_12:
this.custom12NotIn = strings;
this.custom12NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom12NotInContainsNull = true;
}
break;
case CUSTOM_13:
this.custom13NotIn = strings;
this.custom13NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom13NotInContainsNull = true;
}
break;
case CUSTOM_14:
this.custom14NotIn = strings;
this.custom14NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom14NotInContainsNull = true;
}
break;
case CUSTOM_15:
this.custom15NotIn = strings;
this.custom15NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom15NotInContainsNull = true;
}
break;
case CUSTOM_16:
this.custom16NotIn = strings;
this.custom16NotIn = conditionList.toArray(new String[0]);
if (containsNull) {
this.custom16NotInContainsNull = true;
}
break;
default:
throw new SystemException("Unknown custom attribute '" + customField + "'");

View File

@ -110,9 +110,6 @@ public class TaskImpl extends TaskSummaryImpl implements Task {
@Override
public void setCustomAttribute(TaskCustomField customField, String value) {
if (value == null) {
value = "";
}
switch (customField) {
case CUSTOM_1:
custom1 = value;

View File

@ -46,22 +46,22 @@ public class TaskSummaryImpl implements TaskSummary {
protected boolean isTransferred;
// All objects have to be serializable
protected List<AttachmentSummary> attachmentSummaries = new ArrayList<>();
protected String custom1 = "";
protected String custom2 = "";
protected String custom3 = "";
protected String custom4 = "";
protected String custom5 = "";
protected String custom6 = "";
protected String custom7 = "";
protected String custom8 = "";
protected String custom9 = "";
protected String custom10 = "";
protected String custom11 = "";
protected String custom12 = "";
protected String custom13 = "";
protected String custom14 = "";
protected String custom15 = "";
protected String custom16 = "";
protected String custom1;
protected String custom2;
protected String custom3;
protected String custom4;
protected String custom5;
protected String custom6;
protected String custom7;
protected String custom8;
protected String custom9;
protected String custom10;
protected String custom11;
protected String custom12;
protected String custom13;
protected String custom14;
protected String custom15;
protected String custom16;
public TaskSummaryImpl() {}
@ -422,11 +422,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom1(String custom1) {
if (custom1 == null) {
this.custom1 = "";
} else {
this.custom1 = custom1;
}
this.custom1 = custom1;
}
public String getCustom2() {
@ -435,11 +431,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom2(String custom2) {
if (custom2 == null) {
this.custom2 = "";
} else {
this.custom2 = custom2;
}
this.custom2 = custom2;
}
public String getCustom3() {
@ -448,11 +440,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom3(String custom3) {
if (custom3 == null) {
this.custom3 = "";
} else {
this.custom3 = custom3;
}
this.custom3 = custom3;
}
public String getCustom4() {
@ -461,11 +449,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom4(String custom4) {
if (custom4 == null) {
this.custom4 = "";
} else {
this.custom4 = custom4;
}
this.custom4 = custom4;
}
public String getCustom5() {
@ -474,11 +458,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom5(String custom5) {
if (custom5 == null) {
this.custom5 = "";
} else {
this.custom5 = custom5;
}
this.custom5 = custom5;
}
public String getCustom6() {
@ -487,11 +467,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom6(String custom6) {
if (custom6 == null) {
this.custom6 = "";
} else {
this.custom6 = custom6;
}
this.custom6 = custom6;
}
public String getCustom7() {
@ -500,11 +476,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom7(String custom7) {
if (custom7 == null) {
this.custom7 = "";
} else {
this.custom7 = custom7;
}
this.custom7 = custom7;
}
public String getCustom8() {
@ -513,11 +485,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom8(String custom8) {
if (custom8 == null) {
this.custom8 = "";
} else {
this.custom8 = custom8;
}
this.custom8 = custom8;
}
public String getCustom9() {
@ -526,11 +494,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom9(String custom9) {
if (custom9 == null) {
this.custom9 = "";
} else {
this.custom9 = custom9;
}
this.custom9 = custom9;
}
public String getCustom10() {
@ -539,11 +503,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom10(String custom10) {
if (custom10 == null) {
this.custom10 = "";
} else {
this.custom10 = custom10;
}
this.custom10 = custom10;
}
public String getCustom11() {
@ -552,11 +512,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom11(String custom11) {
if (custom11 == null) {
this.custom11 = "";
} else {
this.custom11 = custom11;
}
this.custom11 = custom11;
}
public String getCustom12() {
@ -565,11 +521,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom12(String custom12) {
if (custom12 == null) {
this.custom12 = "";
} else {
this.custom12 = custom12;
}
this.custom12 = custom12;
}
public String getCustom13() {
@ -578,11 +530,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom13(String custom13) {
if (custom13 == null) {
this.custom13 = "";
} else {
this.custom13 = custom13;
}
this.custom13 = custom13;
}
public String getCustom14() {
@ -591,11 +539,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom14(String custom14) {
if (custom14 == null) {
this.custom14 = "";
} else {
this.custom14 = custom14;
}
this.custom14 = custom14;
}
public String getCustom15() {
@ -604,11 +548,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom15(String custom15) {
if (custom15 == null) {
this.custom15 = "";
} else {
this.custom15 = custom15;
}
this.custom15 = custom15;
}
public String getCustom16() {
@ -617,11 +557,7 @@ public class TaskSummaryImpl implements TaskSummary {
// auxiliary Method needed by Mybatis
public void setCustom16(String custom16) {
if (custom16 == null) {
this.custom16 = "";
} else {
this.custom16 = custom16;
}
this.custom16 = custom16;
}
protected boolean canEqual(Object other) {

View File

@ -26,9 +26,6 @@ public class WorkbasketImpl extends WorkbasketSummaryImpl implements Workbasket
@Override
public void setCustomAttribute(WorkbasketCustomField customField, String value) {
if (value == null) {
value = "";
}
switch (customField) {
case CUSTOM_1:
custom1 = value;

View File

@ -17,10 +17,10 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
protected String owner;
protected String domain;
protected WorkbasketType type;
protected String custom1 = "";
protected String custom2 = "";
protected String custom3 = "";
protected String custom4 = "";
protected String custom1;
protected String custom2;
protected String custom3;
protected String custom4;
protected String orgLevel1;
protected String orgLevel2;
protected String orgLevel3;
@ -130,11 +130,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
}
public void setCustom1(String custom1) {
if (custom1 == null) {
this.custom1 = "";
} else {
this.custom1 = custom1;
}
this.custom1 = custom1;
}
public String getCustom2() {
@ -142,11 +138,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
}
public void setCustom2(String custom2) {
if (custom2 == null) {
this.custom2 = "";
} else {
this.custom2 = custom2;
}
this.custom2 = custom2;
}
public String getCustom3() {
@ -154,11 +146,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
}
public void setCustom3(String custom3) {
if (custom3 == null) {
this.custom3 = "";
} else {
this.custom3 = custom3;
}
this.custom3 = custom3;
}
public String getCustom4() {
@ -166,11 +154,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
}
public void setCustom4(String custom4) {
if (custom4 == null) {
this.custom4 = "";
} else {
this.custom4 = custom4;
}
this.custom4 = custom4;
}
@Override

View File

@ -4,14 +4,11 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import java.util.Arrays;
import org.assertj.core.api.SoftAssertions;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.classification.api.ClassificationCustomField;
import pro.taskana.classification.api.ClassificationService;
import pro.taskana.classification.api.exceptions.ClassificationAlreadyExistException;
import pro.taskana.classification.api.exceptions.MalformedServiceLevelException;
@ -55,48 +52,6 @@ class CreateClassificationAccTest extends AbstractAccTest {
assertThat(classification.getId()).startsWith(IdGenerator.ID_PREFIX_CLASSIFICATION);
}
@WithAccessId(user = "businessadmin")
@Test
void should_InitializeCustomFieldsToEmptyString_When_ClassificationIsCreated() throws Exception {
Classification classification = CLASSIFICATION_SERVICE.newClassification("Key01", "", "TASK");
classification.setIsValidInDomain(true);
classification.setServiceLevel("P1D");
Classification createdClassification =
CLASSIFICATION_SERVICE.createClassification(classification);
SoftAssertions softly = new SoftAssertions();
Arrays.stream(ClassificationCustomField.values())
.forEach(
customField ->
softly
.assertThat(createdClassification.getCustomAttribute(customField))
.describedAs("CustomField was null: " + customField)
.isNotNull());
softly.assertAll();
}
@WithAccessId(user = "businessadmin")
@Test
void should_SetCustomFieldToEmptyString_When_SetToNullByUser() throws Exception {
Classification classification = CLASSIFICATION_SERVICE.newClassification("Key02", "", "TASK");
classification.setIsValidInDomain(true);
classification.setServiceLevel("P1D");
Arrays.stream(ClassificationCustomField.values())
.forEach(customField -> classification.setCustomAttribute(customField, null));
Classification createdClassification =
CLASSIFICATION_SERVICE.createClassification(classification);
SoftAssertions softly = new SoftAssertions();
Arrays.stream(ClassificationCustomField.values())
.forEach(
customField ->
softly
.assertThat(createdClassification.getCustomAttribute(customField))
.describedAs("CustomField was null: " + customField)
.isNotNull());
softly.assertAll();
}
@WithAccessId(user = "businessadmin")
@Test
void testCreateClassificationWithMasterCopy() throws Exception {

View File

@ -7,9 +7,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
import java.util.List;
import org.assertj.core.api.SoftAssertions;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
@ -76,26 +74,6 @@ class UpdateClassificationAccTest extends AbstractAccTest {
assertThat(modifiedBefore).isBefore(updatedClassification.getModified());
}
@WithAccessId(user = "businessadmin")
@Test
void should_SetCustomAttributeToEmptyString_When_SetToNullDuringUpdate() throws Exception {
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
Arrays.stream(ClassificationCustomField.values())
.forEach(customField -> classification.setCustomAttribute(customField, null));
Classification updatedClassification =
classificationService.updateClassification(classification);
SoftAssertions softly = new SoftAssertions();
Arrays.stream(ClassificationCustomField.values())
.forEach(
customField ->
softly
.assertThat(updatedClassification.getCustomAttribute(customField))
.describedAs("CustomField was null: " + customField)
.isNotNull());
softly.assertAll();
}
@Test
void should_ThrowException_When_UserIsNotAuthorized() throws Exception {
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");

View File

@ -8,7 +8,6 @@ import acceptance.TaskTestMapper;
import acceptance.TaskanaEngineProxy;
import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
@ -16,7 +15,6 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
import org.assertj.core.api.SoftAssertions;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
@ -576,52 +574,6 @@ class CreateTaskAccTest extends AbstractAccTest {
assertThat(createdTask.getName()).isEqualTo("Test Name");
}
@WithAccessId(user = "user-1-1")
@Test
void should_SetCustomFieldToEmptyString_When_SetToNullByUser() throws Exception {
Task newTask = taskService.newTask("USER-1-1", "DOMAIN_A");
newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
newTask.setName("Test Name");
Arrays.stream(TaskCustomField.values())
.forEach(customField -> newTask.setCustomAttribute(customField, null));
Task createdTask = taskService.createTask(newTask);
SoftAssertions softly = new SoftAssertions();
Arrays.stream(TaskCustomField.values())
.forEach(
customField ->
softly
.assertThat(createdTask.getCustomAttribute(customField))
.describedAs("CustomField was null: " + customField)
.isNotNull());
softly.assertAll();
}
@WithAccessId(user = "user-1-1")
@Test
void should_InitializeCustomFieldsToEmptyString_When_TaskIsCreated() throws Exception {
Task newTask = taskService.newTask("USER-1-1", "DOMAIN_A");
newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef(
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
newTask.setName("Test Name");
Task createdTask = taskService.createTask(newTask);
SoftAssertions softly = new SoftAssertions();
Arrays.stream(TaskCustomField.values())
.forEach(
customField ->
softly
.assertThat(createdTask.getCustomAttribute(customField))
.describedAs("CustomField was null: " + customField)
.isNotNull());
softly.assertAll();
}
@WithAccessId(user = "user-1-1")
@Test
void testUseClassificationMetadataFromCorrectDomainForNewTask() throws Exception {

View File

@ -343,6 +343,102 @@ class QueryTasksAccTest extends AbstractAccTest {
assertThat(results).isEqualTo(expectedCount);
}
@WithAccessId(user = "admin")
@Test
void should_ReturnTasksWithEmptyCustomField_When_QueriedByCustomFieldWhichIsNull()
throws InvalidArgumentException {
List<TaskSummary> results =
taskService
.createTaskQuery()
.customAttributeIn(TaskCustomField.CUSTOM_9, new String[] {null})
.list();
assertThat(results).hasSize(1);
results =
taskService
.createTaskQuery()
.customAttributeIn(TaskCustomField.CUSTOM_9, null, "custom9")
.list();
assertThat(results).hasSize(2);
results =
taskService
.createTaskQuery()
.customAttributeIn(TaskCustomField.CUSTOM_9, new String[] {null})
.customAttributeIn(TaskCustomField.CUSTOM_14, "abc")
.list();
assertThat(results).hasSize(1);
}
@WithAccessId(user = "admin")
@Test
void should_ReturnTasksWithNullCustomField_When_QueriedByCustomFieldWhichIsEmpty()
throws InvalidArgumentException {
List<TaskSummary> results =
taskService.createTaskQuery().customAttributeIn(TaskCustomField.CUSTOM_9, "").list();
assertThat(results).hasSize(86);
}
@WithAccessId(user = "admin")
@Test
void should_AllowToQueryTasksByCustomFieldWithNullAndEmptyInParallel()
throws InvalidArgumentException {
List<TaskSummary> results =
taskService
.createTaskQuery()
.customAttributeIn(TaskCustomField.CUSTOM_9, "", null)
.list();
assertThat(results).hasSize(87);
}
@WithAccessId(user = "admin")
@Test
void should_ReturnTasksWithEmptyCustomField_When_QueriedByCustomFieldWhichIsNotNull()
throws InvalidArgumentException {
List<TaskSummary> results =
taskService
.createTaskQuery()
.customAttributeNotIn(TaskCustomField.CUSTOM_9, new String[] {null})
.list();
assertThat(results).hasSize(87);
results =
taskService
.createTaskQuery()
.customAttributeNotIn(TaskCustomField.CUSTOM_9, null, "custom9")
.list();
assertThat(results).hasSize(86);
results =
taskService
.createTaskQuery()
.customAttributeNotIn(TaskCustomField.CUSTOM_9, new String[] {null})
.customAttributeNotIn(TaskCustomField.CUSTOM_10, "custom10")
.list();
assertThat(results).hasSize(86);
}
@WithAccessId(user = "admin")
@Test
void should_ReturnTasksWithNullCustomField_When_QueriedByCustomFieldWhichIsNotEmpty()
throws InvalidArgumentException {
List<TaskSummary> results =
taskService.createTaskQuery().customAttributeNotIn(TaskCustomField.CUSTOM_9, "").list();
assertThat(results).hasSize(2);
}
@WithAccessId(user = "admin")
@Test
void should_AllowToQueryTasksByCustomFieldWithNeitherNullOrEmptyInParallel()
throws InvalidArgumentException {
List<TaskSummary> results =
taskService
.createTaskQuery()
.customAttributeNotIn(TaskCustomField.CUSTOM_9, "", null)
.list();
assertThat(results).hasSize(1);
}
@WithAccessId(user = "admin")
@Test
void should_ThrowException_When_SearchArgumentInLikeQueryIsNotGiven() {

View File

@ -15,11 +15,9 @@ import static pro.taskana.task.api.TaskCustomField.CUSTOM_7;
import acceptance.AbstractAccTest;
import java.time.Instant;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.assertj.core.api.SoftAssertions;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
@ -245,25 +243,6 @@ class UpdateTaskAccTest extends AbstractAccTest {
assertThat(updatedTask).isNotNull();
}
@WithAccessId(user = "user-1-1")
@Test
void should_SetCustomAttributeToEmptyString_When_SetToNullDuringUpdate() throws Exception {
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
Arrays.stream(TaskCustomField.values())
.forEach(customField -> task.setCustomAttribute(customField, null));
Task updatedTask = taskService.updateTask(task);
SoftAssertions softly = new SoftAssertions();
Arrays.stream(TaskCustomField.values())
.forEach(
customField ->
softly
.assertThat(updatedTask.getCustomAttribute(customField))
.describedAs("CustomField was null: " + customField)
.isNotNull());
softly.assertAll();
}
@WithAccessId(user = "user-1-1")
@Test
void should_ThrowException_When_ModificationOfWorkbasketKeyIsAttempted() throws Exception {
@ -317,7 +296,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
assertThat(task.getCustomAttribute(CUSTOM_3)).isEqualTo("This is modifiedValue 3");
assertThat(task.getCustomAttribute(CUSTOM_7)).isEqualTo("This is modifiedValue 7");
assertThat(task.getCustomAttribute(CUSTOM_16)).isEqualTo("This is modifiedValue 16");
assertThat(task.getCustomAttribute(CUSTOM_14)).isEmpty();
assertThat(task.getCustomAttribute(CUSTOM_14)).isNull();
}
}
@ -345,7 +324,7 @@ class UpdateTaskAccTest extends AbstractAccTest {
assertThat(task.getCustomAttribute(CUSTOM_10)).isEqualTo("This is modifiedValue 10");
assertThat(task.getCustomAttribute(CUSTOM_12)).isEqualTo("This is modifiedValue 12");
assertThat(task.getCustomAttribute(CUSTOM_2)).isNotNull();
assertThat(task.getCustomAttribute(CUSTOM_16)).isEmpty();
assertThat(task.getCustomAttribute(CUSTOM_16)).isNull();
}
}

View File

@ -4,9 +4,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import java.util.Arrays;
import java.util.List;
import org.assertj.core.api.SoftAssertions;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
@ -17,7 +15,6 @@ import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketCustomField;
import pro.taskana.workbasket.api.WorkbasketPermission;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.WorkbasketType;
@ -102,56 +99,6 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
assertThatThrownBy(call).isInstanceOf(DomainNotFoundException.class);
}
@WithAccessId(user = "businessadmin")
@Test
void should_InitializeCustomFieldsToEmptyString_When_WorkbasketIsCreated()
throws InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException,
NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.newWorkbasket("GPK_NULL1", "DOMAIN_A");
workbasket.setName("Megabasket");
workbasket.setType(WorkbasketType.GROUP);
workbasket.setOrgLevel1("company");
Workbasket createdWorkbasket = workbasketService.createWorkbasket(workbasket);
SoftAssertions softly = new SoftAssertions();
Arrays.stream(WorkbasketCustomField.values())
.forEach(
customField ->
softly
.assertThat(createdWorkbasket.getCustomAttribute(customField))
.describedAs("CustomField was null: " + customField)
.isNotNull());
softly.assertAll();
}
@WithAccessId(user = "businessadmin")
@Test
void should_SetCustomFieldToEmptyString_When_SetToNullByUser()
throws InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException,
NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.newWorkbasket("GPK_NULL2", "DOMAIN_A");
workbasket.setName("Megabasket");
workbasket.setType(WorkbasketType.GROUP);
workbasket.setOrgLevel1("company");
Arrays.stream(WorkbasketCustomField.values())
.forEach(customField -> workbasket.setCustomAttribute(customField, null));
Workbasket createdWorkbasket = workbasketService.createWorkbasket(workbasket);
SoftAssertions softly = new SoftAssertions();
Arrays.stream(WorkbasketCustomField.values())
.forEach(
customField ->
softly
.assertThat(createdWorkbasket.getCustomAttribute(customField))
.describedAs("CustomField was null: " + customField)
.isNotNull());
softly.assertAll();
}
@WithAccessId(user = "businessadmin")
@Test
void testCreateWorkbasketWithMissingRequiredField() {

View File

@ -7,8 +7,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
@ -60,28 +58,6 @@ class UpdateWorkbasketAccTest extends AbstractAccTest {
assertThat(updatedWorkbasket.getModified()).isNotEqualTo(modified);
}
@WithAccessId(user = "businessadmin")
@Test
void should_SetCustomAttributeToEmptyString_When_SetToNullDuringUpdate() throws Exception {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A");
Arrays.stream(WorkbasketCustomField.values())
.forEach(customField -> workbasket.setCustomAttribute(customField, null));
workbasketService.updateWorkbasket(workbasket);
Workbasket updatedWorkbasket = workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A");
SoftAssertions softly = new SoftAssertions();
Arrays.stream(WorkbasketCustomField.values())
.forEach(
customField ->
softly
.assertThat(updatedWorkbasket.getCustomAttribute(customField))
.describedAs("CustomField was null: " + customField)
.isNotNull());
softly.assertAll();
}
@WithAccessId(user = "businessadmin")
@Test
void should_ThrowException_When_UpdatingWorkbasketWithInvalidName() throws Exception {

View File

@ -21,6 +21,7 @@ import pro.taskana.monitor.api.TaskTimestamp;
import pro.taskana.monitor.api.reports.ClassificationCategoryReport;
import pro.taskana.monitor.api.reports.ClassificationReport;
import pro.taskana.monitor.api.reports.TaskCustomFieldValueReport;
import pro.taskana.monitor.api.reports.TaskStatusReport;
import pro.taskana.monitor.api.reports.TimestampReport;
import pro.taskana.monitor.api.reports.WorkbasketPriorityReport;
import pro.taskana.monitor.api.reports.WorkbasketReport;
@ -298,19 +299,23 @@ public class MonitorController {
@RequestParam(name = "priority-minimum", required = false) Integer priorityMinimum)
throws NotAuthorizedException {
TaskStatusReport.Builder builder = monitorService.createTaskStatusReportBuilder();
if (states != null && !states.isEmpty()) {
builder = builder.stateIn(states);
}
if (domains != null && !domains.isEmpty()) {
builder.domainIn(domains);
}
if (workbasketIds != null && !workbasketIds.isEmpty()) {
builder.workbasketIdsIn(workbasketIds);
}
if (priorityMinimum != null) {
builder.priorityMinimum(priorityMinimum);
}
return ResponseEntity.ok(
reportRepresentationModelAssembler.toModel(
monitorService
.createTaskStatusReportBuilder()
.stateIn(states)
.domainIn(domains)
.workbasketIdsIn(workbasketIds)
.priorityMinimum(priorityMinimum)
.buildReport(),
domains,
states,
workbasketIds,
priorityMinimum));
builder.buildReport(), domains, states, workbasketIds, priorityMinimum));
}
/**