use of io.automatiko.engine.api.runtime.process.WorkflowProcessInstance in project automatiko-engine by automatiko-io.
the class ProcessInstanceEventBatch method create.
protected ProcessInstanceEventBody create(ProcessEvent event) {
WorkflowProcessInstance pi = (WorkflowProcessInstance) event.getProcessInstance();
ProcessInstanceEventBody.Builder eventBuilder = ProcessInstanceEventBody.create().id(pi.getId()).parentInstanceId(pi.getParentProcessInstanceId()).rootInstanceId(pi.getRootProcessInstanceId()).processId(pi.getProcessId()).rootProcessId(pi.getRootProcessId()).processName(pi.getProcessName()).startDate(pi.getStartDate()).endDate(pi.getEndDate()).state(pi.getState()).businessKey(pi.getCorrelationKey()).variables(pi.getPublicVariables()).milestones(createMilestones(pi));
if (pi.getState() == ProcessInstance.STATE_ERROR) {
for (ExecutionsErrorInfo error : pi.errors()) {
eventBuilder.error(ProcessErrorEventBody.create().nodeDefinitionId(error.getFailedNodeId()).errorMessage(error.getErrorMessage()).build());
}
}
String securityRoles = (String) pi.getProcess().getMetaData().get("securityRoles");
if (securityRoles != null) {
eventBuilder.roles(securityRoles.split(","));
}
Collection<Tag> tags = pi.getTags();
if (tags != null) {
eventBuilder.tags(tags.stream().map(t -> t.getValue()).toArray(String[]::new));
}
io.automatiko.engine.api.workflow.ProcessInstance<?> instance = (io.automatiko.engine.api.workflow.ProcessInstance<?>) pi.getMetaData("AutomatikProcessInstance");
if (instance != null) {
Set<String> visibleTo = instance.process().accessPolicy().visibleTo(instance);
if (visibleTo != null) {
eventBuilder.visibleTo(visibleTo.toArray(String[]::new));
}
eventBuilder.instance(instance);
}
return eventBuilder.build();
}
use of io.automatiko.engine.api.runtime.process.WorkflowProcessInstance in project automatiko-engine by automatiko-io.
the class DatabaseProcessInstances method unmarshallInstance.
@SuppressWarnings("unchecked")
protected ProcessInstance<ProcessInstanceEntity> unmarshallInstance(ProcessInstanceReadMode mode, ProcessInstanceEntity entity) {
ProcessInstance<ProcessInstanceEntity> pi;
if (mode == MUTABLE) {
WorkflowProcessInstance wpi = marshaller.unmarshallWorkflowProcessInstance(codec.decode(entity.content), process);
entity.toMap().forEach((k, v) -> {
if (v != null) {
v.toString();
VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((ProcessInstanceImpl) wpi).getContextInstance(VariableScope.VARIABLE_SCOPE);
variableScopeInstance.internalSetVariable(k, v);
}
});
pi = ((AbstractProcess<ProcessInstanceEntity>) process).createInstance(wpi, entity, entity.version);
} else {
WorkflowProcessInstance wpi = marshaller.unmarshallWorkflowProcessInstance(codec.decode(entity.content), process);
entity.toMap().forEach((k, v) -> {
if (v != null) {
v.toString();
VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((ProcessInstanceImpl) wpi).getContextInstance(VariableScope.VARIABLE_SCOPE);
variableScopeInstance.internalSetVariable(k, v);
}
});
pi = ((AbstractProcess<ProcessInstanceEntity>) process).createReadOnlyInstance(wpi, entity);
}
return pi;
}
use of io.automatiko.engine.api.runtime.process.WorkflowProcessInstance in project automatiko-engine by automatiko-io.
the class JbpmBpmn2TestCase method assertNodeActive.
public void assertNodeActive(String processInstanceId, InternalProcessRuntime processRuntime, String... name) {
List<String> names = new ArrayList<String>();
for (String n : name) {
names.add(n);
}
ProcessInstance processInstance = processRuntime.getProcessInstance(processInstanceId);
if (processInstance instanceof WorkflowProcessInstance) {
assertNodeActive((WorkflowProcessInstance) processInstance, names);
}
if (!names.isEmpty()) {
String s = names.get(0);
for (int i = 1; i < names.size(); i++) {
s += ", " + names.get(i);
}
fail("Node(s) not active: " + s);
}
}
Aggregations