use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.
the class ProcessServiceImplPerProcessInstanceTest method testGetProcessInstanceWithCorrelationKeyAbortedProcess.
@Test
public void testGetProcessInstanceWithCorrelationKeyAbortedProcess() {
CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey("my business key");
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), PROCESS_ID_SIGNAL, key);
assertNotNull(processInstanceId);
processService.abortProcessInstance(processInstanceId);
ProcessInstance processInstance = processService.getProcessInstance(key);
assertNull(processInstance);
}
use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.
the class ProcessServiceImplTest method testStartProcessWithCorrelationKey.
@Test
public void testStartProcessWithCorrelationKey() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
assertNotNull(processService);
CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey("my business key");
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "customtask", key);
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(key);
assertNull(pi);
}
use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.
the class AuditQueryTest method simpleProcessInstanceLogQueryBuilderTest.
@Test
public void simpleProcessInstanceLogQueryBuilderTest() {
int p = 0;
long duration = pilTestData[p++].getDuration();
ProcessInstanceLogQueryBuilder builder = this.processInstanceLogQuery().duration(duration);
List<org.kie.api.runtime.manager.audit.ProcessInstanceLog> resultList = builder.build().getResultList();
assertEquals("duration query result", 2, resultList.size());
{
Date end = pilTestData[p++].getEnd();
builder = this.processInstanceLogQuery().endDate(end);
resultList = builder.build().getResultList();
assertEquals("end date query result", 2, resultList.size());
}
{
String identity = pilTestData[p++].getIdentity();
builder = this.processInstanceLogQuery().identity(identity);
resultList = builder.build().getResultList();
assertEquals("identity query result", 2, resultList.size());
}
{
String processId = pilTestData[p++].getProcessId();
builder = this.processInstanceLogQuery().processId(processId);
resultList = builder.build().getResultList();
assertEquals("process id query result", 2, resultList.size());
}
{
long processInstanceId = pilTestData[p++].getProcessInstanceId();
builder = this.processInstanceLogQuery().processInstanceId(processInstanceId);
resultList = builder.build().getResultList();
assertEquals("process instance id query result", 2, resultList.size());
}
{
String processName = pilTestData[p++].getProcessName();
builder = this.processInstanceLogQuery().processName(processName);
resultList = builder.build().getResultList();
assertEquals("process name query result", 2, resultList.size());
}
{
String version = pilTestData[p++].getProcessVersion();
builder = this.processInstanceLogQuery().processVersion(version);
resultList = builder.build().getResultList();
assertEquals("process version query result", 2, resultList.size());
}
{
Date start = pilTestData[p++].getStart();
builder = this.processInstanceLogQuery().startDate(start);
resultList = builder.build().getResultList();
assertEquals("start date query result", 2, resultList.size());
}
{
int status = pilTestData[p++].getStatus();
builder = this.processInstanceLogQuery().status(status);
resultList = builder.build().getResultList();
assertEquals("status query result", 2, resultList.size());
}
{
String outcome = pilTestData[p++].getOutcome();
builder = this.processInstanceLogQuery().outcome(outcome);
resultList = builder.build().getResultList();
assertEquals("outcome query result", 2, resultList.size());
}
{
String correlationKey = pilTestData[p++].getCorrelationKey();
CorrelationKey ck = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey(correlationKey);
builder = this.processInstanceLogQuery().correlationKey(ck);
resultList = builder.build().getResultList();
assertEquals("identity query result", 1, resultList.size());
}
}
use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.
the class DefaultAuditEventBuilderImpl method buildEvent.
@Override
public AuditEvent buildEvent(ProcessStartedEvent pse) {
ProcessInstanceImpl pi = (ProcessInstanceImpl) pse.getProcessInstance();
ProcessInstanceLog log = new ProcessInstanceLog(pi.getId(), pi.getProcessId());
log.setExternalId("" + ((KieSession) pse.getKieRuntime()).getIdentifier());
log.setProcessName(pi.getProcess().getName());
log.setProcessVersion(pi.getProcess().getVersion());
log.setStatus(ProcessInstance.STATE_ACTIVE);
log.setProcessInstanceDescription(pi.getDescription());
log.setProcessType(((WorkflowProcess) pi.getProcess()).getProcessType());
log.setSlaCompliance(pi.getSlaCompliance());
log.setSlaDueDate(pi.getSlaDueDate());
// store correlation key in its external form
CorrelationKey correlationKey = (CorrelationKey) pi.getMetaData().get("CorrelationKey");
if (correlationKey != null) {
log.setCorrelationKey(correlationKey.toExternalForm());
}
long parentProcessInstanceId = (Long) pi.getMetaData().getOrDefault("ParentProcessInstanceId", -1L);
log.setParentProcessInstanceId(parentProcessInstanceId);
return log;
}
use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.
the class RuntimeDataServiceImplSecurityTest method testGetProcessInstancesByPartialCorrelationKey.
@Test
public void testGetProcessInstancesByPartialCorrelationKey() {
// let's grant managers role so process can be started
List<String> roles = new ArrayList<String>();
roles.add("managers");
identityProvider.setRoles(roles);
Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
List<String> props = new ArrayList<String>();
props.add("first");
props.add("second");
props.add("third");
List<String> partial1props = new ArrayList<String>();
partial1props.add("first");
partial1props.add("second");
List<String> partial2props = new ArrayList<String>();
partial2props.add("first");
CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey(props);
CorrelationKey partialKey1 = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey(partial1props);
CorrelationKey partialKey2 = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey(partial2props);
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", key);
assertNotNull(processInstanceId);
Collection<ProcessInstanceDesc> keyedInstances = runtimeDataService.getProcessInstancesByCorrelationKey(key, new QueryContext());
assertNotNull(keyedInstances);
assertEquals(1, keyedInstances.size());
ProcessInstanceDesc instance = keyedInstances.iterator().next();
assertNotNull(instance);
assertEquals(1, (int) instance.getState());
assertEquals("org.jbpm.writedocument", instance.getProcessId());
assertEquals("first:second:third", instance.getCorrelationKey());
List<UserTaskInstanceDesc> tasks = instance.getActiveTasks();
assertNull(tasks);
// search by partial key 1
keyedInstances = runtimeDataService.getProcessInstancesByCorrelationKey(partialKey1, new QueryContext());
assertNotNull(keyedInstances);
assertEquals(1, keyedInstances.size());
instance = keyedInstances.iterator().next();
assertNotNull(instance);
assertEquals(1, (int) instance.getState());
assertEquals("org.jbpm.writedocument", instance.getProcessId());
assertEquals("first:second:third", instance.getCorrelationKey());
// search by partial key 2
keyedInstances = runtimeDataService.getProcessInstancesByCorrelationKey(partialKey2, new QueryContext());
assertNotNull(keyedInstances);
assertEquals(1, keyedInstances.size());
instance = keyedInstances.iterator().next();
assertNotNull(instance);
assertEquals(1, (int) instance.getState());
assertEquals("org.jbpm.writedocument", instance.getProcessId());
assertEquals("first:second:third", instance.getCorrelationKey());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
Aggregations