TSK-105 Add DB operators to query conditions in QueryBuilder interfaces
This commit is contained in:
parent
11c12422be
commit
cf7d795e3c
|
@ -57,7 +57,7 @@ public interface ClassificationQuery extends BaseQuery<ClassificationSummary> {
|
|||
* a simple flag showing if domain is valid
|
||||
* @return the query
|
||||
*/
|
||||
ClassificationQuery validInDomain(Boolean validInDomain);
|
||||
ClassificationQuery validInDomainEquals(Boolean validInDomain);
|
||||
|
||||
/**
|
||||
* Add your created-Dates to your query.
|
||||
|
@ -103,7 +103,7 @@ public interface ClassificationQuery extends BaseQuery<ClassificationSummary> {
|
|||
* as integers
|
||||
* @return the query
|
||||
*/
|
||||
ClassificationQuery priority(int... priorities);
|
||||
ClassificationQuery priorityIn(int... priorities);
|
||||
|
||||
/**
|
||||
* Add your serviceLevel to your query.
|
||||
|
|
|
@ -6,43 +6,49 @@ import pro.taskana.impl.ObjectReference;
|
|||
* ObjectReferenceQuery for generating dynamic sql.
|
||||
*/
|
||||
public interface ObjectReferenceQuery extends BaseQuery<ObjectReference> {
|
||||
|
||||
/**
|
||||
* Add your company to your query.
|
||||
*
|
||||
* @param companies
|
||||
* as Strings
|
||||
* @return the query
|
||||
*/
|
||||
ObjectReferenceQuery company(String... companies);
|
||||
ObjectReferenceQuery companyIn(String... companies);
|
||||
|
||||
/**
|
||||
* Add your system to your query.
|
||||
*
|
||||
* @param systems
|
||||
* as Strings
|
||||
* @return the query
|
||||
*/
|
||||
ObjectReferenceQuery system(String... systems);
|
||||
ObjectReferenceQuery systemIn(String... systems);
|
||||
|
||||
/**
|
||||
* Add your systemInstance to your query.
|
||||
*
|
||||
* @param systemInstances
|
||||
* as Strings
|
||||
* @return the query
|
||||
*/
|
||||
ObjectReferenceQuery systemInstance(String... systemInstances);
|
||||
ObjectReferenceQuery systemInstanceIn(String... systemInstances);
|
||||
|
||||
/**
|
||||
* Add your type to your query.
|
||||
*
|
||||
* @param types
|
||||
* as Strings
|
||||
* @return the query
|
||||
*/
|
||||
ObjectReferenceQuery type(String... types);
|
||||
ObjectReferenceQuery typeIn(String... types);
|
||||
|
||||
/**
|
||||
* Add your value to your query.
|
||||
*
|
||||
* @param values
|
||||
* as Strings
|
||||
* @return the query
|
||||
*/
|
||||
ObjectReferenceQuery value(String... values);
|
||||
ObjectReferenceQuery valueIn(String... values);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package pro.taskana;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.impl.WorkbasketAuthorization;
|
||||
import pro.taskana.impl.WorkbasketType;
|
||||
|
@ -84,40 +82,28 @@ public interface WorkbasketQuery extends BaseQuery<WorkbasketSummary> {
|
|||
WorkbasketQuery typeIn(WorkbasketType... type);
|
||||
|
||||
/**
|
||||
* Add your createdAfter-Date to your query.
|
||||
* Add the time intervals within which the workbasket was created to your query. For each time interval, the
|
||||
* database query will search for workbaskets whose created timestamp is after or at the interval's begin and before
|
||||
* or at the interval's end. If more than one interval is specified, the query will connect them with the OR
|
||||
* keyword. If either begin or end of an interval are null, these values will not be specified in the query.
|
||||
*
|
||||
* @param createdAfter
|
||||
* as Instant
|
||||
* @param intervals
|
||||
* - the TimeIntervals within which the workbasket was created
|
||||
* @return the query
|
||||
*/
|
||||
WorkbasketQuery createdAfter(Instant createdAfter);
|
||||
WorkbasketQuery createdWithin(TimeInterval... intervals);
|
||||
|
||||
/**
|
||||
* Add your createdBefore-Date to your query.
|
||||
* Add the time intervals within which the workbasket was modified to your query. For each time interval, the
|
||||
* database query will search for workbaskets whose created timestamp is after or at the interval's begin and before
|
||||
* or at the interval's end. If more than one interval is specified, the query will connect them with the OR
|
||||
* keyword. If either begin or end of an interval are null, these values will not be specified in the query.
|
||||
*
|
||||
* @param createdBefore
|
||||
* as Instant
|
||||
* @param intervals
|
||||
* - the TimeIntervals within which the workbasket was created
|
||||
* @return the query
|
||||
*/
|
||||
WorkbasketQuery createdBefore(Instant createdBefore);
|
||||
|
||||
/**
|
||||
* Add your modifiedAfter-Date to your query.
|
||||
*
|
||||
* @param modifiedAfter
|
||||
* as Instant
|
||||
* @return the query
|
||||
*/
|
||||
WorkbasketQuery modifiedAfter(Instant modifiedAfter);
|
||||
|
||||
/**
|
||||
* Add your modifiedBefore-Date to your query.
|
||||
*
|
||||
* @param modifiedBefore
|
||||
* as Instant
|
||||
* @return the query
|
||||
*/
|
||||
WorkbasketQuery modifiedBefore(Instant modifiedBefore);
|
||||
WorkbasketQuery modifiedWithin(TimeInterval... intervals);
|
||||
|
||||
/**
|
||||
* Add your description to your query. It will be compared case-insensitively to the descriptions of workbaskets
|
||||
|
|
|
@ -93,7 +93,7 @@ public class ClassificationQueryImpl implements ClassificationQuery {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery validInDomain(Boolean validInDomain) {
|
||||
public ClassificationQuery validInDomainEquals(Boolean validInDomain) {
|
||||
this.validInDomain = validInDomain;
|
||||
return this;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class ClassificationQueryImpl implements ClassificationQuery {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery priority(int... priorities) {
|
||||
public ClassificationQuery priorityIn(int... priorities) {
|
||||
this.priority = priorities;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -36,31 +36,31 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ObjectReferenceQuery company(String... companies) {
|
||||
public ObjectReferenceQuery companyIn(String... companies) {
|
||||
this.company = companies;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReferenceQuery system(String... systems) {
|
||||
public ObjectReferenceQuery systemIn(String... systems) {
|
||||
this.system = systems;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReferenceQuery systemInstance(String... systemInstances) {
|
||||
public ObjectReferenceQuery systemInstanceIn(String... systemInstances) {
|
||||
this.systemInstance = systemInstances;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReferenceQuery type(String... types) {
|
||||
public ObjectReferenceQuery typeIn(String... types) {
|
||||
this.type = types;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReferenceQuery value(String... values) {
|
||||
public ObjectReferenceQuery valueIn(String... values) {
|
||||
this.value = values;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package pro.taskana.impl;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -11,6 +10,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.TimeInterval;
|
||||
import pro.taskana.WorkbasketQuery;
|
||||
import pro.taskana.WorkbasketSummary;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
|
@ -38,10 +38,8 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
private String[] keyOrNameLike;
|
||||
private String[] domain;
|
||||
private WorkbasketType[] type;
|
||||
private Instant createdAfter;
|
||||
private Instant createdBefore;
|
||||
private Instant modifiedAfter;
|
||||
private Instant modifiedBefore;
|
||||
private TimeInterval[] createdIn;
|
||||
private TimeInterval[] modifiedIn;
|
||||
private String[] descriptionLike;
|
||||
private String[] ownerIn;
|
||||
private String[] ownerLike;
|
||||
|
@ -96,26 +94,24 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
}
|
||||
|
||||
@Override
|
||||
public WorkbasketQuery createdAfter(Instant createdAfter) {
|
||||
this.createdAfter = createdAfter;
|
||||
public WorkbasketQuery createdWithin(TimeInterval... intervals) {
|
||||
this.createdIn = intervals;
|
||||
for (TimeInterval ti : intervals) {
|
||||
if (!ti.isValid()) {
|
||||
throw new IllegalArgumentException("TimeInterval " + ti + " is invalid.");
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkbasketQuery createdBefore(Instant createdBefore) {
|
||||
this.createdBefore = createdBefore;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkbasketQuery modifiedAfter(Instant modifiedAfter) {
|
||||
this.modifiedAfter = modifiedAfter;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkbasketQuery modifiedBefore(Instant modifiedBefore) {
|
||||
this.modifiedBefore = modifiedBefore;
|
||||
public WorkbasketQuery modifiedWithin(TimeInterval... intervals) {
|
||||
this.modifiedIn = intervals;
|
||||
for (TimeInterval ti : intervals) {
|
||||
if (!ti.isValid()) {
|
||||
throw new IllegalArgumentException("TimeInterval " + ti + " is invalid.");
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -301,20 +297,12 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
return type;
|
||||
}
|
||||
|
||||
public Instant getCreatedAfter() {
|
||||
return createdAfter;
|
||||
public TimeInterval[] getCreatedIn() {
|
||||
return createdIn;
|
||||
}
|
||||
|
||||
public Instant getCreatedBefore() {
|
||||
return createdBefore;
|
||||
}
|
||||
|
||||
public Instant getModifiedAfter() {
|
||||
return modifiedAfter;
|
||||
}
|
||||
|
||||
public Instant getModifiedBefore() {
|
||||
return modifiedBefore;
|
||||
public TimeInterval[] getModifiedIn() {
|
||||
return modifiedIn;
|
||||
}
|
||||
|
||||
public String[] getDescriptionLike() {
|
||||
|
@ -368,14 +356,10 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
builder.append(Arrays.toString(domain));
|
||||
builder.append(", type=");
|
||||
builder.append(Arrays.toString(type));
|
||||
builder.append(", createdAfter=");
|
||||
builder.append(createdAfter);
|
||||
builder.append(", createdBefore=");
|
||||
builder.append(createdBefore);
|
||||
builder.append(", modifiedAfter=");
|
||||
builder.append(modifiedAfter);
|
||||
builder.append(", modifiedBefore=");
|
||||
builder.append(modifiedBefore);
|
||||
builder.append(", createdIn=");
|
||||
builder.append(Arrays.toString(createdIn));
|
||||
builder.append(", modifiedIn=");
|
||||
builder.append(Arrays.toString(modifiedIn));
|
||||
builder.append(", descriptionLike=");
|
||||
builder.append(Arrays.toString(descriptionLike));
|
||||
builder.append(", ownerIn=");
|
||||
|
|
|
@ -206,10 +206,8 @@ public interface QueryMapper {
|
|||
+ "<if test='keyOrNameLike != null'>AND (<foreach item='item' collection='keyOrNameLike' separator=' OR ' >UPPER(w.NAME) LIKE #{item} OR UPPER(w.KEY) LIKE #{item}</foreach>)</if> "
|
||||
+ "<if test='domain != null'>AND w.DOMAIN IN(<foreach item='item' collection='domain' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='type!= null'>AND w.TYPE IN(<foreach item='item' collection='type' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='createdAfter != null'>AND w.CREATED > #{createdAfter}</if> "
|
||||
+ "<if test='createdBefore != null'>AND w.CREATED < #{createdBefore}</if> "
|
||||
+ "<if test='modifiedAfter != null'>AND w.MODIFIED > #{modifiedAfter}</if> "
|
||||
+ "<if test='modifiedBefore != null'>AND w.MODIFIED < #{modifiedBefore}</if> "
|
||||
+ "<if test='createdIn !=null'> AND ( <foreach item='item' collection='createdIn' separator=' OR ' > ( <if test='item.begin!=null'> w.CREATED >= #{item.begin} </if> <if test='item.begin!=null and item.end!=null'> AND </if><if test='item.end!=null'> w.CREATED <=#{item.end} </if>)</foreach>)</if> "
|
||||
+ "<if test='modifiedIn !=null'> AND ( <foreach item='item' collection='modifiedIn' separator=' OR ' > ( <if test='item.begin!=null'> w.MODIFIED >= #{item.begin} </if> <if test='item.begin!=null and item.end!=null'> AND </if><if test='item.end!=null'> w.MODIFIED <=#{item.end} </if>)</foreach>)</if> "
|
||||
+ "<if test='descriptionLike != null'>AND (<foreach item='item' collection='descriptionLike' separator=' OR '>UPPER(w.DESCRIPTION) LIKE #{item}</foreach>)</if> "
|
||||
+ "<if test='accessId != null'>AND a.ACCESS_ID IN(<foreach item='item' collection='accessId' separator=',' >#{item}</foreach>) AND PERM_READ = 1 </if> "
|
||||
+ "<if test='authorization != null'>AND "
|
||||
|
@ -409,10 +407,8 @@ public interface QueryMapper {
|
|||
+ "<if test='keyOrNameLike != null'>AND (<foreach item='item' collection='keyOrNameLike' separator=' OR ' >UPPER(w.NAME) LIKE #{item} OR UPPER(w.KEY) LIKE #{item}</foreach>)</if> "
|
||||
+ "<if test='domain != null'>AND w.DOMAIN IN(<foreach item='item' collection='domain' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='type!= null'>AND w.TYPE IN(<foreach item='item' collection='type' separator=',' >#{item}</foreach>)</if> "
|
||||
+ "<if test='createdAfter != null'>AND w.CREATED > #{createdAfter}</if> "
|
||||
+ "<if test='createdBefore != null'>AND w.CREATED < #{createdBefore}</if> "
|
||||
+ "<if test='modifiedAfter != null'>AND w.MODIFIED > #{modifiedAfter}</if> "
|
||||
+ "<if test='modifiedBefore != null'>AND w.MODIFIED < #{modifiedBefore}</if> "
|
||||
+ "<if test='createdIn !=null'> AND ( <foreach item='item' collection='createdIn' separator=' OR ' > ( <if test='item.begin!=null'> w.CREATED >= #{item.begin} </if> <if test='item.begin!=null and item.end!=null'> AND </if><if test='item.end!=null'> w.CREATED <=#{item.end} </if>)</foreach>)</if> "
|
||||
+ "<if test='modifiedIn !=null'> AND ( <foreach item='item' collection='modifiedIn' separator=' OR ' > ( <if test='item.begin!=null'> w.MODIFIED >= #{item.begin} </if> <if test='item.begin!=null and item.end!=null'> AND </if><if test='item.end!=null'> w.MODIFIED <=#{item.end} </if>)</foreach>)</if> "
|
||||
+ "<if test='descriptionLike != null'>AND (<foreach item='item' collection='descriptionLike' separator=' OR '>UPPER(w.DESCRIPTION) LIKE #{item}</foreach>)</if> "
|
||||
+ "<if test='accessId != null'>AND a.ACCESS_ID IN(<foreach item='item' collection='accessId' separator=',' >#{item}</foreach>) AND PERM_READ = 1 </if> "
|
||||
+ "<if test='authorization != null'>AND "
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.sql.SQLException;
|
|||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.HashMap;
|
||||
|
@ -16,6 +17,7 @@ import org.junit.BeforeClass;
|
|||
import pro.taskana.Attachment;
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.TimeInterval;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.database.TestDataGenerator;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
|
@ -97,6 +99,12 @@ public abstract class AbstractAccTest {
|
|||
return attachment;
|
||||
}
|
||||
|
||||
protected TimeInterval todaysInterval() {
|
||||
Instant begin = LocalDateTime.of(LocalDate.now(), LocalTime.MIN).atZone(ZoneId.systemDefault()).toInstant();
|
||||
Instant end = LocalDateTime.of(LocalDate.now(), LocalTime.MAX).atZone(ZoneId.systemDefault()).toInstant();
|
||||
return new TimeInterval(begin, end);
|
||||
}
|
||||
|
||||
protected Instant getInstant(String datetime) {
|
||||
return LocalDateTime.parse(datetime).atZone(ZoneId.systemDefault()).toInstant();
|
||||
}
|
||||
|
|
|
@ -131,9 +131,9 @@ public class QueryClassificationAccTest extends AbstractAccTest {
|
|||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
|
||||
ClassificationService classificationService = taskanaEngine.getClassificationService();
|
||||
List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
|
||||
.custom1Like("VNR,RVNR,KOLVNR", "VNR")
|
||||
.domainIn("DOMAIN_A")
|
||||
.list();
|
||||
.custom1Like("VNR,RVNR,KOLVNR", "VNR")
|
||||
.domainIn("DOMAIN_A")
|
||||
.list();
|
||||
assertNotNull(classifications);
|
||||
assertEquals(12, classifications.size());
|
||||
}
|
||||
|
@ -143,10 +143,10 @@ public class QueryClassificationAccTest extends AbstractAccTest {
|
|||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
|
||||
ClassificationService classificationService = taskanaEngine.getClassificationService();
|
||||
List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
|
||||
.custom1Like("%RVNR%")
|
||||
.domainIn("DOMAIN_A")
|
||||
.typeIn("TASK")
|
||||
.list();
|
||||
.custom1Like("%RVNR%")
|
||||
.domainIn("DOMAIN_A")
|
||||
.typeIn("TASK")
|
||||
.list();
|
||||
assertNotNull(classifications);
|
||||
assertEquals(10, classifications.size());
|
||||
}
|
||||
|
@ -156,14 +156,39 @@ public class QueryClassificationAccTest extends AbstractAccTest {
|
|||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
|
||||
ClassificationService classificationService = taskanaEngine.getClassificationService();
|
||||
List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
|
||||
.parentClassificationKeyIn("L11010")
|
||||
.custom2Like("TEXT_1", "TEXT_2")
|
||||
.parentClassificationKeyIn("L11010")
|
||||
.custom2Like("TEXT_1", "TEXT_2")
|
||||
.list();
|
||||
// zwei tests
|
||||
assertNotNull(classifications);
|
||||
assertEquals(3, classifications.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindClassificationsByCreatedTimestamp()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
|
||||
ClassificationService classificationService = taskanaEngine.getClassificationService();
|
||||
List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery()
|
||||
.domainIn("DOMAIN_A")
|
||||
.createdWithin(todaysInterval())
|
||||
.list();
|
||||
|
||||
assertNotNull(classificationSummaryList);
|
||||
assertEquals(15, classificationSummaryList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindClassificationsByPriorityAndValidInDomain()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
|
||||
ClassificationService classificationService = taskanaEngine.getClassificationService();
|
||||
List<ClassificationSummary> list = classificationService.createClassificationQuery()
|
||||
.validInDomainEquals(Boolean.TRUE)
|
||||
.priorityIn(1, 2, 3)
|
||||
.list();
|
||||
assertEquals(20, list.size());
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanUpClass() {
|
||||
FileUtils.deleteRecursive("~/data", true);
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
package acceptance.objectreference;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.h2.store.fs.FileUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import pro.taskana.TaskQuery;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.impl.ObjectReference;
|
||||
|
||||
/**
|
||||
* Acceptance test for all "get classification" scenarios.
|
||||
*/
|
||||
public class QueryObjectReferenceAccTest extends AbstractAccTest {
|
||||
|
||||
public QueryObjectReferenceAccTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindObjectReferenceByCompany()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
|
||||
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
|
||||
|
||||
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery()
|
||||
.companyIn("Company1", "Company2")
|
||||
.list();
|
||||
|
||||
assertNotNull(objectReferenceList);
|
||||
assertEquals(2, objectReferenceList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindObjectReferenceBySystem()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
|
||||
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
|
||||
|
||||
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery()
|
||||
.companyIn("Company1", "Company2")
|
||||
.systemIn("System2")
|
||||
.list();
|
||||
|
||||
assertNotNull(objectReferenceList);
|
||||
assertEquals(1, objectReferenceList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindObjectReferenceBySystemInstance()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
|
||||
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
|
||||
|
||||
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery()
|
||||
.companyIn("Company1", "Company2")
|
||||
.systemInstanceIn("Instance1")
|
||||
.list();
|
||||
|
||||
assertNotNull(objectReferenceList);
|
||||
assertEquals(1, objectReferenceList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindObjectReferenceByType()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
|
||||
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
|
||||
|
||||
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery()
|
||||
.typeIn("Type2", "Type3")
|
||||
.list();
|
||||
|
||||
assertNotNull(objectReferenceList);
|
||||
assertEquals(2, objectReferenceList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindObjectReferenceByValue()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
|
||||
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
|
||||
|
||||
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery()
|
||||
.valueIn("Value1", "Value3")
|
||||
.list();
|
||||
|
||||
assertNotNull(objectReferenceList);
|
||||
assertEquals(2, objectReferenceList.size());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanUpClass() {
|
||||
FileUtils.deleteRecursive("~/data", true);
|
||||
}
|
||||
}
|
|
@ -265,4 +265,24 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryWorkbasketByCreated()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
|
||||
.createdWithin(todaysInterval())
|
||||
.list();
|
||||
Assert.assertEquals(26L, results.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryWorkbasketByModified()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
|
||||
.modifiedWithin(todaysInterval())
|
||||
.list();
|
||||
Assert.assertEquals(26L, results.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class ClassificationQueryImplTest {
|
|||
|
||||
List<ClassificationSummary> result = classificationQueryImpl.nameIn("test", "asd", "blubber")
|
||||
.typeIn("cool", "bla")
|
||||
.priority(1, 2)
|
||||
.priorityIn(1, 2)
|
||||
.parentClassificationKeyIn("superId")
|
||||
.list();
|
||||
Assert.assertNotNull(result);
|
||||
|
@ -60,7 +60,7 @@ public class ClassificationQueryImplTest {
|
|||
|
||||
List<ClassificationSummary> result = classificationQueryImpl.nameIn("test", "asd", "blubber")
|
||||
.typeIn("cool", "bla")
|
||||
.priority(1, 2)
|
||||
.priorityIn(1, 2)
|
||||
.parentClassificationKeyIn("superId")
|
||||
.list(1, 1);
|
||||
Assert.assertNotNull(result);
|
||||
|
@ -73,7 +73,7 @@ public class ClassificationQueryImplTest {
|
|||
|
||||
ClassificationSummary result = classificationQueryImpl.nameIn("test", "asd", "blubber")
|
||||
.typeIn("cool", "bla")
|
||||
.priority(1, 2)
|
||||
.priorityIn(1, 2)
|
||||
.parentClassificationKeyIn("superId")
|
||||
.single();
|
||||
Assert.assertNotNull(result);
|
||||
|
|
|
@ -43,10 +43,10 @@ public class ObjectReferenceQueryImplTest {
|
|||
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectList(any(), any())).thenReturn(new ArrayList<>());
|
||||
|
||||
List<ObjectReference> result = objectReferenceQueryImpl.value("test", "asd", "blubber")
|
||||
.type("cool", "bla")
|
||||
.systemInstance("1", "2")
|
||||
.system("superId")
|
||||
List<ObjectReference> result = objectReferenceQueryImpl.valueIn("test", "asd", "blubber")
|
||||
.typeIn("cool", "bla")
|
||||
.systemInstanceIn("1", "2")
|
||||
.systemIn("superId")
|
||||
.list();
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
@ -57,10 +57,10 @@ public class ObjectReferenceQueryImplTest {
|
|||
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectList(any(), any(), any())).thenReturn(new ArrayList<>());
|
||||
|
||||
List<ObjectReference> result = objectReferenceQueryImpl.value("test", "asd", "blubber")
|
||||
.type("cool", "bla")
|
||||
.systemInstance("1", "2")
|
||||
.system("superId")
|
||||
List<ObjectReference> result = objectReferenceQueryImpl.valueIn("test", "asd", "blubber")
|
||||
.typeIn("cool", "bla")
|
||||
.systemInstanceIn("1", "2")
|
||||
.systemIn("superId")
|
||||
.list(1, 1);
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
@ -70,10 +70,10 @@ public class ObjectReferenceQueryImplTest {
|
|||
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
|
||||
when(sqlSession.selectOne(any(), any())).thenReturn(new ObjectReference());
|
||||
|
||||
ObjectReference result = objectReferenceQueryImpl.value("test", "asd", "blubber")
|
||||
.type("cool", "bla")
|
||||
.systemInstance("1", "2")
|
||||
.system("superId")
|
||||
ObjectReference result = objectReferenceQueryImpl.valueIn("test", "asd", "blubber")
|
||||
.typeIn("cool", "bla")
|
||||
.systemInstanceIn("1", "2")
|
||||
.systemIn("superId")
|
||||
.single();
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class TestClassificationQuery implements ClassificationQuery {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery validInDomain(Boolean validInDomain) {
|
||||
public ClassificationQuery validInDomainEquals(Boolean validInDomain) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class TestClassificationQuery implements ClassificationQuery {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery priority(int... priorities) {
|
||||
public ClassificationQuery priorityIn(int... priorities) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
classification = classificationService.createClassification(classification);
|
||||
|
||||
List<ClassificationSummary> list = classificationService.createClassificationQuery()
|
||||
.validInDomain(Boolean.TRUE)
|
||||
.validInDomainEquals(Boolean.TRUE)
|
||||
.createdWithin(today())
|
||||
.list();
|
||||
|
||||
|
@ -206,7 +206,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
classification = classificationService.updateClassification(classification);
|
||||
|
||||
List<ClassificationSummary> list = classificationService.createClassificationQuery()
|
||||
.validInDomain(true)
|
||||
.validInDomainEquals(true)
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
|
||||
|
@ -305,10 +305,10 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
.parentClassificationKeyIn(classification.getKey())
|
||||
.list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
list = classificationService.createClassificationQuery().typeIn("type1").priority(Integer.decode("5")).list();
|
||||
list = classificationService.createClassificationQuery().typeIn("type1").priorityIn(Integer.decode("5")).list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
list = classificationService.createClassificationQuery()
|
||||
.priority(Integer.decode("5"))
|
||||
.priorityIn(Integer.decode("5"))
|
||||
.typeIn("type1")
|
||||
.parentClassificationKeyIn(classification1.getKey())
|
||||
.list();
|
||||
|
@ -379,13 +379,13 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
list = classificationService.createClassificationQuery().list();
|
||||
Assert.assertEquals(listAll.size(), list.size());
|
||||
|
||||
list = classificationService.createClassificationQuery().validInDomain(true).list();
|
||||
list = classificationService.createClassificationQuery().validInDomainEquals(true).list();
|
||||
Assert.assertEquals(listAll.size(), list.size());
|
||||
|
||||
list = classificationService.createClassificationQuery().createdWithin(today()).list();
|
||||
Assert.assertEquals(listAll.size(), list.size());
|
||||
|
||||
list = classificationService.createClassificationQuery().domainIn("domain1").validInDomain(false).list();
|
||||
list = classificationService.createClassificationQuery().domainIn("domain1").validInDomainEquals(false).list();
|
||||
Assert.assertEquals(0, list.size());
|
||||
|
||||
list = classificationService.createClassificationQuery()
|
||||
|
|
|
@ -211,7 +211,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
Classification classification = this.createNewClassificationWithUniqueKey("", "t1");
|
||||
classificationService.createClassification(classification);
|
||||
List<ClassificationSummary> list = classificationService.createClassificationQuery()
|
||||
.validInDomain(Boolean.TRUE)
|
||||
.validInDomainEquals(Boolean.TRUE)
|
||||
.createdWithin(today())
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
|
@ -231,7 +231,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
List<ClassificationSummary> list = classificationService.createClassificationQuery()
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
list = classificationService.createClassificationQuery().validInDomain(true).list();
|
||||
list = classificationService.createClassificationQuery().validInDomainEquals(true).list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
classification = classificationService.getClassification(classification.getKey(), classification.getDomain());
|
||||
assertThat(classification.getDescription(), equalTo("description"));
|
||||
|
@ -340,10 +340,10 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
.parentClassificationKeyIn(classification.getKey())
|
||||
.list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
list = classificationService.createClassificationQuery().typeIn("type1").priority(Integer.decode("5")).list();
|
||||
list = classificationService.createClassificationQuery().typeIn("type1").priorityIn(Integer.decode("5")).list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
list = classificationService.createClassificationQuery()
|
||||
.priority(Integer.decode("5"))
|
||||
.priorityIn(Integer.decode("5"))
|
||||
.typeIn("type1")
|
||||
.parentClassificationKeyIn(classification1.getKey())
|
||||
.list();
|
||||
|
@ -415,11 +415,11 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
Assert.assertEquals(2, list.size());
|
||||
connection.commit();
|
||||
|
||||
list = classificationService.createClassificationQuery().validInDomain(true).list();
|
||||
list = classificationService.createClassificationQuery().validInDomainEquals(true).list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
list = classificationService.createClassificationQuery().createdWithin(today()).list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
list = classificationService.createClassificationQuery().domainIn("domain1").validInDomain(false).list();
|
||||
list = classificationService.createClassificationQuery().domainIn("domain1").validInDomainEquals(false).list();
|
||||
Assert.assertEquals(0, list.size());
|
||||
list = classificationService.createClassificationQuery()
|
||||
.keyIn(classification1.getKey())
|
||||
|
|
|
@ -6,6 +6,10 @@ import java.io.FileNotFoundException;
|
|||
import java.sql.SQLException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -22,8 +26,10 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import pro.taskana.BaseQuery.SortDirection;
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.TimeInterval;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.WorkbasketQuery;
|
||||
|
@ -289,8 +295,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
Assert.assertEquals(1, result4.size());
|
||||
|
||||
WorkbasketQuery query0 = workBasketService.createWorkbasketQuery()
|
||||
.createdBefore(tomorrow)
|
||||
.createdAfter(yesterday)
|
||||
.createdWithin(today())
|
||||
.nameIn("Basket1", "Basket2", "Basket3");
|
||||
List<WorkbasketSummary> result0 = query0.list();
|
||||
assertTrue(result0.size() == THREE);
|
||||
|
@ -301,8 +306,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
|
||||
Thread.sleep(20L);
|
||||
WorkbasketQuery query5 = workBasketService.createWorkbasketQuery()
|
||||
.modifiedAfter(Instant.now().minus(Duration.ofDays(31)))
|
||||
.modifiedBefore(Instant.now().minus(Duration.ofDays(14)));
|
||||
.modifiedWithin(
|
||||
new TimeInterval(Instant.now().minus(Duration.ofDays(31)), Instant.now().minus(Duration.ofDays(14))));
|
||||
List<WorkbasketSummary> result5 = query5.list();
|
||||
assertTrue(result5.size() == 3);
|
||||
for (WorkbasketSummary workbasket : result5) {
|
||||
|
@ -312,10 +317,11 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
}
|
||||
|
||||
WorkbasketQuery query6 = workBasketService.createWorkbasketQuery()
|
||||
.modifiedAfter(twentyDaysAgo)
|
||||
.domainIn("novatec", "consulting");
|
||||
.modifiedWithin(new TimeInterval(now.minus(Duration.ofDays(21L)), null))
|
||||
.domainIn("novatec", "consulting")
|
||||
.orderByName(SortDirection.ASCENDING);
|
||||
List<WorkbasketSummary> result6 = query6.list();
|
||||
assertTrue(result6.size() == 1);
|
||||
assertTrue(result6.size() == 2);
|
||||
assertTrue("Basket1".equals(result6.get(0).getName()));
|
||||
|
||||
WorkbasketQuery query7 = workBasketService.createWorkbasketQuery()
|
||||
|
@ -435,6 +441,12 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
return wb;
|
||||
}
|
||||
|
||||
private TimeInterval today() {
|
||||
Instant begin = LocalDateTime.of(LocalDate.now(), LocalTime.MIN).atZone(ZoneId.systemDefault()).toInstant();
|
||||
Instant end = LocalDateTime.of(LocalDate.now(), LocalTime.MAX).atZone(ZoneId.systemDefault()).toInstant();
|
||||
return new TimeInterval(begin, end);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanUpClass() {
|
||||
FileUtils.deleteRecursive("~/data", true);
|
||||
|
|
Loading…
Reference in New Issue