use of org.kie.kogito.serialization.process.protobuf.KogitoTypesProtobuf.WorkflowContext in project kogito-runtimes by kiegroup.
the class ProtobufProcessInstanceReader method buildWorkflowContext.
private void buildWorkflowContext(CompositeContextNodeInstance container, WorkflowContext workflowContext) {
if (workflowContext.getNodeInstanceCount() > 0) {
for (KogitoTypesProtobuf.NodeInstance nodeInstanceProtobuf : workflowContext.getNodeInstanceList()) {
buildNodeInstance(nodeInstanceProtobuf, container);
}
}
for (KogitoTypesProtobuf.NodeInstanceGroup group : workflowContext.getExclusiveGroupList()) {
Function<String, KogitoNodeInstance> finder = nodeInstanceId -> container.getNodeInstance(nodeInstanceId, true);
container.addContextInstance(ExclusiveGroup.EXCLUSIVE_GROUP, buildExclusiveGroupInstance(group, finder));
}
container.addContextInstance(VariableScope.VARIABLE_SCOPE, new VariableScopeInstance());
if (workflowContext.getVariableCount() > 0) {
VariableScopeInstance variableScopeInstance = (VariableScopeInstance) container.getContextInstance(VariableScope.VARIABLE_SCOPE);
varReader.buildVariables(workflowContext.getVariableList()).forEach(v -> variableScopeInstance.internalSetVariable(v.getName(), v.getValue()));
}
if (workflowContext.getIterationLevelsCount() > 0) {
container.getIterationLevels().putAll(buildIterationLevels(workflowContext.getIterationLevelsList()));
}
}
use of org.kie.kogito.serialization.process.protobuf.KogitoTypesProtobuf.WorkflowContext in project kogito-runtimes by kiegroup.
the class ProtobufProcessInstanceReader method buildWorkflow.
private RuleFlowProcessInstance buildWorkflow(KogitoProcessInstanceProtobuf.ProcessInstance processInstanceProtobuf) {
RuleFlowProcessInstance processInstance = ruleFlowProcessInstance;
processInstance.setProcess(((AbstractProcess<?>) context.get(MarshallerContextName.MARSHALLER_PROCESS)).get());
processInstance.setId(processInstanceProtobuf.getId());
processInstance.setProcessId(processInstanceProtobuf.getProcessId());
processInstance.setState(processInstanceProtobuf.getState());
processInstance.setSignalCompletion(processInstanceProtobuf.getSignalCompletion());
processInstance.setStartDate(new Date(processInstanceProtobuf.getStartDate()));
processInstance.setDescription(processInstanceProtobuf.getDescription());
processInstance.setDeploymentId(processInstanceProtobuf.getDeploymentId());
for (String completedNodeId : processInstanceProtobuf.getCompletedNodeIdsList()) {
processInstance.addCompletedNodeId(completedNodeId);
}
processInstance.setCorrelationKey(processInstanceProtobuf.getBusinessKey());
SLAContext slaContext = processInstanceProtobuf.getSla();
if (slaContext.getSlaDueDate() > 0) {
processInstance.internalSetSlaDueDate(new Date(slaContext.getSlaDueDate()));
}
processInstance.internalSetSlaTimerId(slaContext.getSlaTimerId());
processInstance.internalSetSlaCompliance(slaContext.getSlaCompliance());
processInstance.setParentProcessInstanceId(processInstanceProtobuf.getParentProcessInstanceId());
processInstance.setRootProcessInstanceId(processInstanceProtobuf.getRootProcessInstanceId());
processInstance.setRootProcessId(processInstanceProtobuf.getRootProcessId());
processInstance.internalSetErrorNodeId(processInstanceProtobuf.getErrorNodeId());
processInstance.internalSetErrorMessage(processInstanceProtobuf.getErrorMessage());
processInstance.setReferenceId(processInstanceProtobuf.getReferenceId());
if (processInstanceProtobuf.getSwimlaneContextCount() > 0) {
SwimlaneContextInstance swimlaneContextInstance = (SwimlaneContextInstance) processInstance.getContextInstance(SwimlaneContext.SWIMLANE_SCOPE);
for (KogitoTypesProtobuf.SwimlaneContext _swimlane : processInstanceProtobuf.getSwimlaneContextList()) {
swimlaneContextInstance.setActorId(_swimlane.getSwimlane(), _swimlane.getActorId());
}
}
WorkflowContext workflowContext = processInstanceProtobuf.getContext();
for (KogitoTypesProtobuf.NodeInstance nodeInstanceProtobuf : workflowContext.getNodeInstanceList()) {
NodeInstanceImpl nodeInstanceImpl = buildNodeInstance(nodeInstanceProtobuf, processInstance);
if (nodeInstanceProtobuf.hasTriggerDate()) {
nodeInstanceImpl.internalSetTriggerTime(new Date(nodeInstanceProtobuf.getTriggerDate()));
}
}
for (KogitoTypesProtobuf.NodeInstanceGroup group : workflowContext.getExclusiveGroupList()) {
Function<String, KogitoNodeInstance> finder = nodeInstanceId -> processInstance.getNodeInstance(nodeInstanceId, true);
processInstance.addContextInstance(ExclusiveGroup.EXCLUSIVE_GROUP, buildExclusiveGroupInstance(group, finder));
}
processInstance.addContextInstance(VariableScope.VARIABLE_SCOPE, new VariableScopeInstance());
if (workflowContext.getVariableCount() > 0) {
VariableScopeInstance variableScopeInstance = (VariableScopeInstance) processInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
varReader.buildVariables(workflowContext.getVariableList()).forEach(v -> variableScopeInstance.internalSetVariable(v.getName(), v.getValue()));
}
if (workflowContext.getIterationLevelsCount() > 0) {
processInstance.getIterationLevels().putAll(buildIterationLevels(workflowContext.getIterationLevelsList()));
}
return processInstance;
}
Aggregations