Search in sources :

Example 1 with QueryParam

use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.

the class ProcessInstanceQueryFilterSpecBuilderTest method testGetEqualsToAndBetween.

@Test
public void testGetEqualsToAndBetween() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date from = null;
    Date to = null;
    try {
        from = sdf.parse("2017-05-10");
        to = sdf.parse("2017-05-14");
    } catch (ParseException e) {
        e.printStackTrace();
    }
    ProcessInstanceQueryFilterSpec filterSpec = new ProcessInstanceQueryFilterSpecBuilder().equalsTo(ProcessInstanceField.PROCESSID, "test-process").between(ProcessInstanceField.START_DATE, from, to).get();
    QueryParam[] params = filterSpec.getParameters();
    assertEquals(2, params.length);
    QueryParam paramEqualsTo = params[0];
    assertEquals(ProcessInstanceField.PROCESSID.toString(), paramEqualsTo.getColumn());
    assertEquals("EQUALS_TO", paramEqualsTo.getOperator());
    assertEquals("test-process", paramEqualsTo.getValue().stream().findFirst().get());
    QueryParam paramBetween = params[1];
    assertEquals(ProcessInstanceField.START_DATE.toString(), paramBetween.getColumn());
    assertEquals("BETWEEN", paramBetween.getOperator());
    List<?> values = paramBetween.getValue();
    assertEquals(2, values.size());
    assertEquals(from, values.get(0));
    assertEquals(to, values.get(1));
}
Also used : QueryParam(org.kie.server.api.model.definition.QueryParam) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) ProcessInstanceQueryFilterSpec(org.kie.server.api.model.definition.ProcessInstanceQueryFilterSpec) Test(org.junit.Test)

Example 2 with QueryParam

use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.

the class TaskQueryFilterSpecBuilderTest method testGetEqualsTo.

@Test
public void testGetEqualsTo() {
    TaskQueryFilterSpec filterSpec = new TaskQueryFilterSpecBuilder().equalsTo(TaskField.PROCESSID, "test-process").get();
    QueryParam[] params = filterSpec.getParameters();
    assertEquals(1, params.length);
    QueryParam param = params[0];
    assertEquals(TaskField.PROCESSID.toString(), param.getColumn());
    assertEquals("EQUALS_TO", param.getOperator());
    assertEquals("test-process", param.getValue().stream().findFirst().get());
}
Also used : TaskQueryFilterSpec(org.kie.server.api.model.definition.TaskQueryFilterSpec) QueryParam(org.kie.server.api.model.definition.QueryParam) Test(org.junit.Test)

Example 3 with QueryParam

use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.

the class TaskQueryFilterSpecBuilderTest method testGetEqualsToAndBetween.

@Test
public void testGetEqualsToAndBetween() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date from = null;
    Date to = null;
    try {
        from = sdf.parse("2017-05-10");
        to = sdf.parse("2017-05-14");
    } catch (ParseException e) {
        e.printStackTrace();
    }
    TaskQueryFilterSpec filterSpec = new TaskQueryFilterSpecBuilder().equalsTo(TaskField.PROCESSID, "test-process").between(TaskField.CREATEDON, from, to).get();
    QueryParam[] params = filterSpec.getParameters();
    assertEquals(2, params.length);
    QueryParam paramEqualsTo = params[0];
    assertEquals(TaskField.PROCESSID.toString(), paramEqualsTo.getColumn());
    assertEquals("EQUALS_TO", paramEqualsTo.getOperator());
    assertEquals("test-process", paramEqualsTo.getValue().stream().findFirst().get());
    QueryParam paramBetween = params[1];
    assertEquals(TaskField.CREATEDON.toString(), paramBetween.getColumn());
    assertEquals("BETWEEN", paramBetween.getOperator());
    List<?> values = paramBetween.getValue();
    assertEquals(2, values.size());
    assertEquals(from, values.get(0));
    assertEquals(to, values.get(1));
}
Also used : TaskQueryFilterSpec(org.kie.server.api.model.definition.TaskQueryFilterSpec) QueryParam(org.kie.server.api.model.definition.QueryParam) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 4 with QueryParam

use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.

the class TaskQueryFilterSpecBuilderTest method testGetBetween.

@Test
public void testGetBetween() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date from = null;
    Date to = null;
    try {
        from = sdf.parse("2017-05-10");
        to = sdf.parse("2017-05-14");
    } catch (ParseException e) {
        e.printStackTrace();
    }
    TaskQueryFilterSpec filterSpec = new TaskQueryFilterSpecBuilder().between(TaskField.CREATEDON, from, to).get();
    QueryParam[] params = filterSpec.getParameters();
    assertEquals(1, params.length);
    QueryParam param = params[0];
    assertEquals(TaskField.CREATEDON.toString(), param.getColumn());
    assertEquals("BETWEEN", param.getOperator());
    List<?> values = param.getValue();
    assertEquals(2, values.size());
    assertEquals(from, values.get(0));
    assertEquals(to, values.get(1));
}
Also used : TaskQueryFilterSpec(org.kie.server.api.model.definition.TaskQueryFilterSpec) QueryParam(org.kie.server.api.model.definition.QueryParam) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 5 with QueryParam

use of org.kie.server.api.model.definition.QueryParam in project droolsjbpm-integration by kiegroup.

the class QueryDataServiceIntegrationTest method testQueryDataServiceUsingComplexCustomQueryBuilderFilterSpecWithOrderByClause.

@Test
public void testQueryDataServiceUsingComplexCustomQueryBuilderFilterSpecWithOrderByClause() throws Exception {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("stringData", "waiting for signal");
    parameters.put("personData", createPersonInstance(USER_JOHN));
    List<Long> processInstanceIds = createProcessInstances(parameters);
    final QueryDefinition query = getProcessInstanceWithVariablesQueryDefinition();
    try {
        queryClient.registerQuery(query);
        QueryParam expression = or(equalsTo("PROCESSINSTANCEID", processInstanceIds.get(0)), equalsTo("PROCESSINSTANCEID", processInstanceIds.get(1)));
        QueryFilterSpec filterSpec = QueryFilterSpec.builder().where(expression).get();
        List<ProcessInstance> instances = queryClient.query(query.getName(), QueryServicesClient.QUERY_MAP_PI_WITH_VARS, filterSpec, 0, 10, ProcessInstance.class);
        assertNotNull(instances);
        assertEquals(2, instances.size());
    } finally {
        abortProcessInstances(processInstanceIds);
        queryClient.unregisterQuery(query.getName());
    }
}
Also used : QueryDefinition(org.kie.server.api.model.definition.QueryDefinition) QueryFilterSpec(org.kie.server.api.model.definition.QueryFilterSpec) HashMap(java.util.HashMap) QueryParam(org.kie.server.api.model.definition.QueryParam) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 QueryParam (org.kie.server.api.model.definition.QueryParam)14 ParseException (java.text.ParseException)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Date (java.util.Date)4 JSONMarshaller (org.kie.server.api.marshalling.json.JSONMarshaller)4 ProcessInstanceQueryFilterSpec (org.kie.server.api.model.definition.ProcessInstanceQueryFilterSpec)3 TaskQueryFilterSpec (org.kie.server.api.model.definition.TaskQueryFilterSpec)3 File (java.io.File)2 URL (java.net.URL)2 HashMap (java.util.HashMap)2 QueryFilterSpec (org.kie.server.api.model.definition.QueryFilterSpec)2 List (java.util.List)1 CaseInstance (org.kie.server.api.model.cases.CaseInstance)1 CaseInstanceCustomVars (org.kie.server.api.model.cases.CaseInstanceCustomVars)1 CaseUserTaskWithVariables (org.kie.server.api.model.cases.CaseUserTaskWithVariables)1 QueryDefinition (org.kie.server.api.model.definition.QueryDefinition)1 SearchQueryFilterSpec (org.kie.server.api.model.definition.SearchQueryFilterSpec)1 ProcessInstance (org.kie.server.api.model.instance.ProcessInstance)1 JbpmKieServerBaseIntegrationTest (org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)1