use of io.automatiko.engine.workflow.base.instance.ContextInstance in project automatiko-engine by automatiko-io.
the class WorkItemNodeInstance method getContextInstance.
@Override
public ContextInstance getContextInstance(Context context) {
ContextInstanceFactory conf = ContextInstanceFactoryRegistry.INSTANCE.getContextInstanceFactory(context);
if (conf == null) {
throw new IllegalArgumentException("Illegal context type (registry not found): " + context.getClass());
}
ContextInstance contextInstance = conf.getContextInstance(context, this, getProcessInstance());
if (contextInstance == null) {
throw new IllegalArgumentException("Illegal context type (instance not found): " + context.getClass());
}
return contextInstance;
}
use of io.automatiko.engine.workflow.base.instance.ContextInstance in project automatiko-engine by automatiko-io.
the class LambdaSubProcessNodeInstance method getContextInstance.
@Override
public ContextInstance getContextInstance(Context context) {
ContextInstanceFactory conf = ContextInstanceFactoryRegistry.INSTANCE.getContextInstanceFactory(context);
if (conf == null) {
throw new IllegalArgumentException("Illegal context type (registry not found): " + context.getClass());
}
ContextInstance contextInstance = (ContextInstance) conf.getContextInstance(context, this, (ProcessInstance) getProcessInstance());
if (contextInstance == null) {
throw new IllegalArgumentException("Illegal context type (instance not found): " + context.getClass());
}
return contextInstance;
}
use of io.automatiko.engine.workflow.base.instance.ContextInstance in project automatiko-engine by automatiko-io.
the class RuleSetNodeInstance method getContextInstance.
@Override
public ContextInstance getContextInstance(Context context) {
ContextInstanceFactory conf = ContextInstanceFactoryRegistry.INSTANCE.getContextInstanceFactory(context);
if (conf == null) {
throw new IllegalArgumentException("Illegal context type (registry not found): " + context.getClass());
}
ContextInstance contextInstance = conf.getContextInstance(context, this, getProcessInstance());
if (contextInstance == null) {
throw new IllegalArgumentException("Illegal context type (instance not found): " + context.getClass());
}
return contextInstance;
}
use of io.automatiko.engine.workflow.base.instance.ContextInstance in project automatiko-engine by automatiko-io.
the class ForEachNodeInstance method getContextInstance.
@Override
public ContextInstance getContextInstance(String contextId) {
ContextInstance contextInstance = super.getContextInstance(contextId);
if (contextInstance == null) {
contextInstance = resolveContextInstance(contextId, TEMP_OUTPUT_VAR);
setContextInstance(contextId, contextInstance);
}
return contextInstance;
}
use of io.automatiko.engine.workflow.base.instance.ContextInstance in project automatiko-engine by automatiko-io.
the class AbstractProtobufProcessInstanceMarshaller method writeProcessInstance.
// Output methods
public AutomatikoMessages.ProcessInstance writeProcessInstance(MarshallerWriteContext context, ProcessInstance processInstance) throws IOException {
WorkflowProcessInstanceImpl workFlow = (WorkflowProcessInstanceImpl) processInstance;
AutomatikoMessages.ProcessInstance.Builder _instance = AutomatikoMessages.ProcessInstance.newBuilder().setId(workFlow.getId()).setProcessId(workFlow.getProcessId()).setState(workFlow.getState()).setProcessType(workFlow.getProcess().getType()).setSignalCompletion(workFlow.isSignalCompletion()).setSlaCompliance(workFlow.getSlaCompliance()).setStartDate(workFlow.getStartDate().getTime());
if (workFlow.getProcessXml() != null) {
_instance.setProcessXml(workFlow.getProcessXml());
}
if (workFlow.getDescription() != null) {
_instance.setDescription(workFlow.getDescription());
}
if (workFlow.getInitiator() != null) {
_instance.setInitiator(workFlow.getInitiator());
}
_instance.addAllCompletedNodeIds(workFlow.getCompletedNodeIds());
if (workFlow.getCorrelationKey() != null) {
_instance.setCorrelationKey(workFlow.getCorrelationKey());
}
if (workFlow.getSlaDueDate() != null) {
_instance.setSlaDueDate(workFlow.getSlaDueDate().getTime());
}
if (workFlow.getSlaTimerId() != null) {
_instance.setSlaTimerId(workFlow.getSlaTimerId());
}
if (workFlow.getParentProcessInstanceId() != null) {
_instance.setParentProcessInstanceId(workFlow.getParentProcessInstanceId());
}
if (workFlow.getRootProcessInstanceId() != null) {
_instance.setRootProcessInstanceId(workFlow.getRootProcessInstanceId());
}
if (workFlow.getRootProcessId() != null) {
_instance.setRootProcessId(workFlow.getRootProcessId());
}
if (workFlow.getReferenceFromRoot() != null) {
_instance.setReferenceFromRoot(workFlow.getReferenceFromRoot());
}
if (workFlow.getProcess().getVersion() != null) {
_instance.setProcessVersion(workFlow.getProcess().getVersion());
}
List<ExecutionsErrorInfo> errors = workFlow.errors();
if (errors != null) {
for (ExecutionsErrorInfo error : errors) {
_instance.addErrors(AutomatikoMessages.ProcessInstance.Error.newBuilder().setErrorNodeId(error.getFailedNodeId()).setErrorId(error.getErrorId()).setErrorMessage(error.getErrorMessage() == null ? "" : error.getErrorMessage()).setErrorDetails(error.getErrorDetails() == null ? "" : error.getErrorDetails()));
}
}
if (workFlow.getReferenceId() != null) {
_instance.setReferenceId(workFlow.getReferenceId());
}
Map<String, List<String>> children = workFlow.getChildren();
if (children != null) {
for (Entry<String, List<String>> entry : children.entrySet()) {
_instance.addChildren(AutomatikoMessages.ProcessInstance.ProcessInstanchChildren.newBuilder().setProcessId(entry.getKey()).addAllIds(entry.getValue()).build());
}
}
Collection<Tag> tags = workFlow.getTags();
if (tags != null) {
for (Tag tag : tags) {
_instance.addTags(AutomatikoMessages.ProcessInstance.Tag.newBuilder().setId(tag.getId()).setValue(tag.getValue()));
}
}
SwimlaneContextInstance swimlaneContextInstance = (SwimlaneContextInstance) workFlow.getContextInstance(SwimlaneContext.SWIMLANE_SCOPE);
if (swimlaneContextInstance != null) {
Map<String, String> swimlaneActors = swimlaneContextInstance.getSwimlaneActors();
for (Map.Entry<String, String> entry : swimlaneActors.entrySet()) {
_instance.addSwimlaneContext(AutomatikoMessages.ProcessInstance.SwimlaneContextInstance.newBuilder().setSwimlane(entry.getKey()).setActorId(entry.getValue()).build());
}
}
List<NodeInstance> nodeInstances = new ArrayList<NodeInstance>(workFlow.getNodeInstances());
Collections.sort(nodeInstances, new Comparator<NodeInstance>() {
public int compare(NodeInstance o1, NodeInstance o2) {
return (int) (o1.getId().compareTo(o2.getId()));
}
});
for (NodeInstance nodeInstance : nodeInstances) {
_instance.addNodeInstance(writeNodeInstance(context, nodeInstance));
}
List<ContextInstance> exclusiveGroupInstances = workFlow.getContextInstances(ExclusiveGroup.EXCLUSIVE_GROUP);
if (exclusiveGroupInstances != null) {
for (ContextInstance contextInstance : exclusiveGroupInstances) {
AutomatikoMessages.ProcessInstance.ExclusiveGroupInstance.Builder _exclusive = AutomatikoMessages.ProcessInstance.ExclusiveGroupInstance.newBuilder();
ExclusiveGroupInstance exclusiveGroupInstance = (ExclusiveGroupInstance) contextInstance;
Collection<NodeInstance> groupNodeInstances = exclusiveGroupInstance.getNodeInstances();
for (NodeInstance nodeInstance : groupNodeInstances) {
_exclusive.addGroupNodeInstanceId(nodeInstance.getId());
}
_instance.addExclusiveGroup(_exclusive.build());
}
}
if (!(boolean) context.env.getOrDefault("_ignore_vars_", false)) {
writeVariableScope(context, workFlow, _instance);
}
List<Map.Entry<String, Integer>> iterationlevels = new ArrayList<Map.Entry<String, Integer>>(workFlow.getIterationLevels().entrySet());
Collections.sort(iterationlevels, new Comparator<Map.Entry<String, Integer>>() {
public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
return o1.getKey().compareTo(o2.getKey());
}
});
for (Map.Entry<String, Integer> level : iterationlevels) {
if (level.getValue() != null) {
_instance.addIterationLevels(AutomatikoMessages.IterationLevel.newBuilder().setId(level.getKey()).setLevel(level.getValue()));
}
}
return _instance.build();
}
Aggregations