Search in sources :

Example 1 with ProcessInstanceCustomDesc

use of org.jbpm.services.api.model.ProcessInstanceCustomDesc in project jbpm by kiegroup.

the class ProcessInstanceCustomQueryMapper method map.

@Override
public List<ProcessInstanceCustomDesc> map(Object result) {
    if (result instanceof DataSet) {
        DataSet dataSetResult = (DataSet) result;
        List<ProcessInstanceCustomDesc> mappedResult = new ArrayList<ProcessInstanceCustomDesc>();
        Map<Long, ProcessInstanceCustomDesc> tmp = new HashMap<Long, ProcessInstanceCustomDesc>();
        if (dataSetResult != null) {
            for (int i = 0; i < dataSetResult.getRowCount(); i++) {
                Long processInstanceId = getColumnLongValue(dataSetResult, COLUMN_PROCESSINSTANCEID, i);
                ProcessInstanceCustomDesc pi = tmp.get(processInstanceId);
                if (pi == null) {
                    pi = buildInstance(dataSetResult, i);
                    mappedResult.add(pi);
                    tmp.put(processInstanceId, pi);
                }
                // now add variable
                String varName = getColumnStringValue(dataSetResult, COLUMN_VAR_NAME, i);
                String varValue = getColumnStringValue(dataSetResult, COLUMN_VAR_VALUE, i);
                if (varName != null) {
                    ((org.jbpm.kie.services.impl.model.ProcessInstanceCustomDesc) pi).addVariable(varName, varValue);
                }
            }
        }
        tmp = null;
        return mappedResult;
    }
    throw new IllegalArgumentException("Unsupported result for mapping " + result);
}
Also used : DataSet(org.dashbuilder.dataset.DataSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProcessInstanceCustomDesc(org.jbpm.services.api.model.ProcessInstanceCustomDesc)

Example 2 with ProcessInstanceCustomDesc

use of org.jbpm.services.api.model.ProcessInstanceCustomDesc in project jbpm by kiegroup.

the class QueryServiceImplTest method testGetProcessInstancesCustomWithoutVars.

@Test
public void testGetProcessInstancesCustomWithoutVars() {
    query = new SqlQueryDefinition("jbpmProcessSearchWithoutVars", dataSourceJNDIname);
    query.setExpression("select p.PROCESSINSTANCEID, p.PROCESSID, p.PROCESSNAME, p.PROCESSVERSION, " + "p.STATUS, p.EXTERNALID, pr.STARTDATE, p.USER_IDENTITY, p.PROCESSINSTANCEDESCRIPTION, " + "p.CORRELATIONKEY, p.PARENTPROCESSINSTANCEID, pr.LASTMODIFICATIONDATE " + "from PROCESSINSTANCELOG p inner join PROCESSINSTANCEINFO pr on p.PROCESSINSTANCEID = pr.INSTANCEID");
    queryService.registerQuery(query);
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    List<ProcessInstanceCustomDesc> processInstanceLogs = queryService.query(query.getName(), ProcessInstanceCustomQueryMapper.get(), new QueryContext());
    assertNotNull(processInstanceLogs);
    assertEquals(1, processInstanceLogs.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
}
Also used : SqlQueryDefinition(org.jbpm.kie.services.impl.query.SqlQueryDefinition) AdvancedQueryContext(org.kie.api.runtime.query.AdvancedQueryContext) QueryContext(org.kie.api.runtime.query.QueryContext) ProcessInstanceCustomDesc(org.jbpm.services.api.model.ProcessInstanceCustomDesc) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 3 with ProcessInstanceCustomDesc

use of org.jbpm.services.api.model.ProcessInstanceCustomDesc in project jbpm by kiegroup.

the class QueryServiceImplTest method testGetProcessInstancesCustomWithVars.

@Test
public void testGetProcessInstancesCustomWithVars() {
    query = new SqlQueryDefinition("jbpmProcessSearchWithVars", dataSourceJNDIname);
    query.setExpression("select p.PROCESSINSTANCEID, p.PROCESSID, p.PROCESSNAME, p.PROCESSVERSION, " + "p.STATUS, p.EXTERNALID, pr.STARTDATE, p.USER_IDENTITY, p.PROCESSINSTANCEDESCRIPTION, " + "p.CORRELATIONKEY, p.PARENTPROCESSINSTANCEID, pr.LASTMODIFICATIONDATE, var.variableId, " + "var.value from PROCESSINSTANCELOG p inner join PROCESSINSTANCEINFO pr on " + "p.PROCESSINSTANCEID = pr.INSTANCEID inner join (select v.processInstanceId, v.variableId, " + "v.value from VariableInstanceLog v where v.id = (select MAX(vil.id) from VariableInstanceLog " + "vil where v.variableId = vil.variableId and v.processInstanceId = vil.processInstanceId)) " + "var on  p.PROCESSINSTANCEID = var.PROCESSINSTANCEID");
    queryService.registerQuery(query);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("approval_document", "initial content");
    params.put("approval_translatedDocument", "translated content");
    params.put("approval_reviewComment", "reviewed content");
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
    assertNotNull(processInstanceId);
    List<ProcessInstanceCustomDesc> processInstanceLogs = queryService.query(query.getName(), ProcessInstanceCustomQueryMapper.get(), new QueryContext());
    assertNotNull(processInstanceLogs);
    assertEquals(1, processInstanceLogs.size());
    ProcessInstanceWithVarsDesc instance = processInstanceLogs.get(0);
    assertEquals(3, instance.getVariables().size());
    processInstanceLogs = queryService.query(query.getName(), ProcessInstanceCustomQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_VAR_NAME, "approval_document"));
    assertNotNull(processInstanceLogs);
    assertEquals(1, processInstanceLogs.size());
    processInstanceLogs = queryService.query(query.getName(), ProcessInstanceCustomQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_VAR_NAME, "not existing"));
    assertNotNull(processInstanceLogs);
    assertEquals(0, processInstanceLogs.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
}
Also used : HashMap(java.util.HashMap) ProcessInstanceWithVarsDesc(org.jbpm.services.api.model.ProcessInstanceWithVarsDesc) SqlQueryDefinition(org.jbpm.kie.services.impl.query.SqlQueryDefinition) AdvancedQueryContext(org.kie.api.runtime.query.AdvancedQueryContext) QueryContext(org.kie.api.runtime.query.QueryContext) ProcessInstanceCustomDesc(org.jbpm.services.api.model.ProcessInstanceCustomDesc) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 4 with ProcessInstanceCustomDesc

use of org.jbpm.services.api.model.ProcessInstanceCustomDesc in project droolsjbpm-integration by kiegroup.

the class ConvertUtils method convertToProcessInstanceCustomVarsList.

public static ProcessInstanceCustomVarsList convertToProcessInstanceCustomVarsList(Collection<ProcessInstanceCustomDesc> instances) {
    if (instances == null) {
        return new ProcessInstanceCustomVarsList(new org.kie.server.api.model.instance.ProcessInstanceCustomVars[0]);
    }
    List<ProcessInstanceCustomVars> processInstances = new ArrayList<ProcessInstanceCustomVars>(instances.size());
    for (ProcessInstanceCustomDesc pi : instances) {
        org.kie.server.api.model.instance.ProcessInstanceCustomVars instance = convertToProcessInstanceCustomVars(pi);
        processInstances.add(instance);
    }
    return new ProcessInstanceCustomVarsList(processInstances);
}
Also used : ProcessInstanceCustomVars(org.kie.server.api.model.instance.ProcessInstanceCustomVars) ArrayList(java.util.ArrayList) ProcessInstanceCustomVarsList(org.kie.server.api.model.instance.ProcessInstanceCustomVarsList) ProcessInstanceCustomVars(org.kie.server.api.model.instance.ProcessInstanceCustomVars) ProcessInstanceCustomDesc(org.jbpm.services.api.model.ProcessInstanceCustomDesc)

Aggregations

ProcessInstanceCustomDesc (org.jbpm.services.api.model.ProcessInstanceCustomDesc)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)2 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)2 Test (org.junit.Test)2 AdvancedQueryContext (org.kie.api.runtime.query.AdvancedQueryContext)2 QueryContext (org.kie.api.runtime.query.QueryContext)2 DataSet (org.dashbuilder.dataset.DataSet)1 ProcessInstanceWithVarsDesc (org.jbpm.services.api.model.ProcessInstanceWithVarsDesc)1 ProcessInstanceCustomVars (org.kie.server.api.model.instance.ProcessInstanceCustomVars)1 ProcessInstanceCustomVarsList (org.kie.server.api.model.instance.ProcessInstanceCustomVarsList)1