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);
}
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;
}
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;
}
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);
}
Aggregations