use of io.automatiko.engine.workflow.process.instance.node.LambdaSubProcessNodeInstance in project automatiko-engine by automatiko-io.
the class AbstractProtobufProcessInstanceMarshaller method readNodeInstanceContent.
protected NodeInstanceImpl readNodeInstanceContent(AutomatikoMessages.ProcessInstance.NodeInstance _node, MarshallerReaderContext context, WorkflowProcessInstance processInstance) throws IOException {
NodeInstanceImpl nodeInstance = null;
NodeInstanceContent _content = _node.getContent();
switch(_content.getType()) {
case RULE_SET_NODE:
nodeInstance = new RuleSetNodeInstance();
if (_content.getRuleSet().getTimerInstanceIdCount() > 0) {
List<String> timerInstances = new ArrayList<>();
for (String _timerId : _content.getRuleSet().getTimerInstanceIdList()) {
timerInstances.add(_timerId);
}
((RuleSetNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
}
break;
case HUMAN_TASK_NODE:
nodeInstance = new HumanTaskNodeInstance();
((HumanTaskNodeInstance) nodeInstance).internalSetWorkItemId(_content.getHumanTask().getWorkItemId());
((HumanTaskNodeInstance) nodeInstance).internalSetWorkItem((WorkItemImpl) readHumanTaskWorkItem(processInstance, context, _content.getHumanTask().getWorkitem()));
if (_content.getHumanTask().getTimerInstanceIdCount() > 0) {
List<String> timerInstances = new ArrayList<>();
for (String _timerId : _content.getHumanTask().getTimerInstanceIdList()) {
timerInstances.add(_timerId);
}
((HumanTaskNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
}
((WorkItemNodeInstance) nodeInstance).internalSetProcessInstanceId(_content.getHumanTask().getErrorHandlingProcessInstanceId());
break;
case WORK_ITEM_NODE:
nodeInstance = new WorkItemNodeInstance();
((WorkItemNodeInstance) nodeInstance).internalSetWorkItemId(_content.getWorkItem().getWorkItemId());
((WorkItemNodeInstance) nodeInstance).internalSetWorkItem((WorkItemImpl) readWorkItem(processInstance, context, _content.getWorkItem().getWorkitem()));
if (_content.getWorkItem().getTimerInstanceIdCount() > 0) {
List<String> timerInstances = new ArrayList<>();
for (String _timerId : _content.getWorkItem().getTimerInstanceIdList()) {
timerInstances.add(_timerId);
}
((WorkItemNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
}
((WorkItemNodeInstance) nodeInstance).internalSetProcessInstanceId(_content.getWorkItem().getErrorHandlingProcessInstanceId());
break;
case SUBPROCESS_NODE:
nodeInstance = new SubProcessNodeInstance();
((SubProcessNodeInstance) nodeInstance).internalSetProcessInstanceId(_content.getSubProcess().getProcessInstanceId());
if (_content.getSubProcess().getTimerInstanceIdCount() > 0) {
List<String> timerInstances = new ArrayList<>();
for (String _timerId : _content.getSubProcess().getTimerInstanceIdList()) {
timerInstances.add(_timerId);
}
((SubProcessNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
}
break;
case SUB_PROCESS_NODE:
nodeInstance = new LambdaSubProcessNodeInstance();
((LambdaSubProcessNodeInstance) nodeInstance).internalSetProcessInstanceId(_content.getSubProcess().getProcessInstanceId());
((LambdaSubProcessNodeInstance) nodeInstance).internalSetProcessInstanceName(_content.getSubProcess().getProcessInstanceName());
if (_content.getSubProcess().getTimerInstanceIdCount() > 0) {
List<String> timerInstances = new ArrayList<>();
for (String _timerId : _content.getSubProcess().getTimerInstanceIdList()) {
timerInstances.add(_timerId);
}
((LambdaSubProcessNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
}
break;
case MILESTONE_NODE:
nodeInstance = new MilestoneNodeInstance();
if (_content.getMilestone().getTimerInstanceIdCount() > 0) {
List<String> timerInstances = new ArrayList<>();
for (String _timerId : _content.getMilestone().getTimerInstanceIdList()) {
timerInstances.add(_timerId);
}
((MilestoneNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
}
break;
case TIMER_NODE:
nodeInstance = new TimerNodeInstance();
((TimerNodeInstance) nodeInstance).internalSetTimerId(_content.getTimer().getTimerId());
break;
case EVENT_NODE:
nodeInstance = new EventNodeInstance();
break;
case JOIN_NODE:
nodeInstance = new JoinInstance();
if (_content.getJoin().getTriggerCount() > 0) {
Map<Long, Integer> triggers = new HashMap<Long, Integer>();
for (AutomatikoMessages.ProcessInstance.NodeInstanceContent.JoinNode.JoinTrigger _join : _content.getJoin().getTriggerList()) {
triggers.put(_join.getNodeId(), _join.getCounter());
}
((JoinInstance) nodeInstance).internalSetTriggers(triggers);
}
break;
case FOR_EACH_NODE:
nodeInstance = new ForEachNodeInstance();
((ForEachNodeInstance) nodeInstance).setInternalSequentialCounter(_content.getForEach().getSequentialCounter());
break;
case COMPOSITE_CONTEXT_NODE:
nodeInstance = new CompositeContextNodeInstance();
if (_content.getComposite().getTimerInstanceIdCount() > 0) {
List<String> timerInstances = new ArrayList<>();
for (String _timerId : _content.getComposite().getTimerInstanceIdList()) {
timerInstances.add(_timerId);
}
((CompositeContextNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
}
break;
case DYNAMIC_NODE:
nodeInstance = new DynamicNodeInstance();
if (_content.getComposite().getTimerInstanceIdCount() > 0) {
List<String> timerInstances = new ArrayList<>();
for (String _timerId : _content.getComposite().getTimerInstanceIdList()) {
timerInstances.add(_timerId);
}
((CompositeContextNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
}
break;
case STATE_NODE:
nodeInstance = new StateNodeInstance();
if (_content.getState().getTimerInstanceIdCount() > 0) {
List<String> timerInstances = new ArrayList<>();
for (String _timerId : _content.getState().getTimerInstanceIdList()) {
timerInstances.add(_timerId);
}
((CompositeContextNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
}
break;
case EVENT_SUBPROCESS_NODE:
nodeInstance = new EventSubProcessNodeInstance();
if (_content.getComposite().getTimerInstanceIdCount() > 0) {
List<String> timerInstances = new ArrayList<>();
for (String _timerId : _content.getComposite().getTimerInstanceIdList()) {
timerInstances.add(_timerId);
}
((CompositeContextNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
}
break;
default:
throw new IllegalArgumentException("Unknown node type: " + _content.getType());
}
return nodeInstance;
}
use of io.automatiko.engine.workflow.process.instance.node.LambdaSubProcessNodeInstance in project automatiko-engine by automatiko-io.
the class AbstractProtobufProcessInstanceMarshaller method writeNodeInstanceContent.
protected AutomatikoMessages.ProcessInstance.NodeInstanceContent writeNodeInstanceContent(AutomatikoMessages.ProcessInstance.NodeInstance.Builder _node, NodeInstance nodeInstance, MarshallerWriteContext context) throws IOException {
AutomatikoMessages.ProcessInstance.NodeInstanceContent.Builder _content = null;
if (nodeInstance instanceof RuleSetNodeInstance) {
_content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.RULE_SET_NODE);
List<String> timerInstances = ((RuleSetNodeInstance) nodeInstance).getTimerInstances();
AutomatikoMessages.ProcessInstance.NodeInstanceContent.RuleSetNode.Builder _ruleSet = AutomatikoMessages.ProcessInstance.NodeInstanceContent.RuleSetNode.newBuilder();
if (timerInstances != null) {
for (String id : timerInstances) {
_ruleSet.addTimerInstanceId(id);
}
}
_content.setRuleSet(_ruleSet.build());
} else if (nodeInstance instanceof HumanTaskNodeInstance) {
AutomatikoMessages.ProcessInstance.NodeInstanceContent.HumanTaskNode.Builder _task = AutomatikoMessages.ProcessInstance.NodeInstanceContent.HumanTaskNode.newBuilder().setWorkItemId(((HumanTaskNodeInstance) nodeInstance).getWorkItemId()).setWorkitem(writeHumanTaskWorkItem(context, (HumanTaskWorkItem) ((HumanTaskNodeInstance) nodeInstance).getWorkItem()));
List<String> timerInstances = ((HumanTaskNodeInstance) nodeInstance).getTimerInstances();
if (timerInstances != null) {
for (String id : timerInstances) {
_task.addTimerInstanceId(id);
}
}
if (((WorkItemNodeInstance) nodeInstance).getExceptionHandlingProcessInstanceId() != null) {
_task.setErrorHandlingProcessInstanceId(((HumanTaskNodeInstance) nodeInstance).getExceptionHandlingProcessInstanceId());
}
_content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.HUMAN_TASK_NODE).setHumanTask(_task.build());
} else if (nodeInstance instanceof WorkItemNodeInstance) {
AutomatikoMessages.ProcessInstance.NodeInstanceContent.WorkItemNode.Builder _wi = AutomatikoMessages.ProcessInstance.NodeInstanceContent.WorkItemNode.newBuilder().setWorkItemId(((WorkItemNodeInstance) nodeInstance).getWorkItemId()).setWorkitem(writeWorkItem(context, ((WorkItemNodeInstance) nodeInstance).getWorkItem()));
List<String> timerInstances = ((WorkItemNodeInstance) nodeInstance).getTimerInstances();
if (timerInstances != null) {
for (String id : timerInstances) {
_wi.addTimerInstanceId(id);
}
}
if (((WorkItemNodeInstance) nodeInstance).getExceptionHandlingProcessInstanceId() != null) {
_wi.setErrorHandlingProcessInstanceId(((WorkItemNodeInstance) nodeInstance).getExceptionHandlingProcessInstanceId());
}
_content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.WORK_ITEM_NODE).setWorkItem(_wi.build());
} else if (nodeInstance instanceof LambdaSubProcessNodeInstance) {
AutomatikoMessages.ProcessInstance.NodeInstanceContent.SubProcessNode.Builder _sp = AutomatikoMessages.ProcessInstance.NodeInstanceContent.SubProcessNode.newBuilder().setProcessInstanceId(((LambdaSubProcessNodeInstance) nodeInstance).getProcessInstanceId()).setProcessInstanceName(((LambdaSubProcessNodeInstance) nodeInstance).getProcessInstanceName());
List<String> timerInstances = ((LambdaSubProcessNodeInstance) nodeInstance).getTimerInstances();
if (timerInstances != null) {
for (String id : timerInstances) {
_sp.addTimerInstanceId(id);
}
}
_content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.SUB_PROCESS_NODE).setSubProcess(_sp.build());
} else if (nodeInstance instanceof SubProcessNodeInstance) {
AutomatikoMessages.ProcessInstance.NodeInstanceContent.SubProcessNode.Builder _sp = AutomatikoMessages.ProcessInstance.NodeInstanceContent.SubProcessNode.newBuilder().setProcessInstanceId(((SubProcessNodeInstance) nodeInstance).getProcessInstanceId());
List<String> timerInstances = ((SubProcessNodeInstance) nodeInstance).getTimerInstances();
if (timerInstances != null) {
for (String id : timerInstances) {
_sp.addTimerInstanceId(id);
}
}
_content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.SUBPROCESS_NODE).setSubProcess(_sp.build());
} else if (nodeInstance instanceof MilestoneNodeInstance) {
AutomatikoMessages.ProcessInstance.NodeInstanceContent.MilestoneNode.Builder _ms = AutomatikoMessages.ProcessInstance.NodeInstanceContent.MilestoneNode.newBuilder();
List<String> timerInstances = ((MilestoneNodeInstance) nodeInstance).getTimerInstances();
if (timerInstances != null) {
for (String id : timerInstances) {
_ms.addTimerInstanceId(id);
}
}
_content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.MILESTONE_NODE).setMilestone(_ms.build());
} else if (nodeInstance instanceof EventNodeInstance) {
_content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.EVENT_NODE);
} else if (nodeInstance instanceof TimerNodeInstance) {
_content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.TIMER_NODE).setTimer(AutomatikoMessages.ProcessInstance.NodeInstanceContent.TimerNode.newBuilder().setTimerId(((TimerNodeInstance) nodeInstance).getTimerId()).build());
} else if (nodeInstance instanceof JoinInstance) {
AutomatikoMessages.ProcessInstance.NodeInstanceContent.JoinNode.Builder _join = AutomatikoMessages.ProcessInstance.NodeInstanceContent.JoinNode.newBuilder();
Map<Long, Integer> triggers = ((JoinInstance) nodeInstance).getTriggers();
List<Long> keys = new ArrayList<Long>(triggers.keySet());
Collections.sort(keys, new Comparator<Long>() {
public int compare(Long o1, Long o2) {
return o1.compareTo(o2);
}
});
for (Long key : keys) {
_join.addTrigger(AutomatikoMessages.ProcessInstance.NodeInstanceContent.JoinNode.JoinTrigger.newBuilder().setNodeId(key).setCounter(triggers.get(key)).build());
}
_content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.JOIN_NODE).setJoin(_join.build());
} else if (nodeInstance instanceof StateNodeInstance) {
AutomatikoMessages.ProcessInstance.NodeInstanceContent.StateNode.Builder _state = AutomatikoMessages.ProcessInstance.NodeInstanceContent.StateNode.newBuilder();
List<String> timerInstances = ((StateNodeInstance) nodeInstance).getTimerInstances();
if (timerInstances != null) {
for (String id : timerInstances) {
_state.addTimerInstanceId(id);
}
}
_content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.STATE_NODE).setState(_state.build());
} else if (nodeInstance instanceof ForEachNodeInstance) {
AutomatikoMessages.ProcessInstance.NodeInstanceContent.ForEachNode.Builder _foreach = AutomatikoMessages.ProcessInstance.NodeInstanceContent.ForEachNode.newBuilder();
ForEachNodeInstance forEachNodeInstance = (ForEachNodeInstance) nodeInstance;
List<NodeInstance> nodeInstances = new ArrayList<NodeInstance>(forEachNodeInstance.getNodeInstances());
Collections.sort(nodeInstances, new Comparator<NodeInstance>() {
public int compare(NodeInstance o1, NodeInstance o2) {
return (int) (o1.getId().compareTo(o2.getId()));
}
});
for (NodeInstance subNodeInstance : nodeInstances) {
if (subNodeInstance instanceof CompositeContextNodeInstance) {
_foreach.addNodeInstance(writeNodeInstance(context, subNodeInstance));
}
}
VariableScopeInstance variableScopeInstance = (VariableScopeInstance) forEachNodeInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
if (variableScopeInstance != null) {
List<Map.Entry<String, Object>> variables = new ArrayList<Map.Entry<String, Object>>(variableScopeInstance.getVariables().entrySet());
Collections.sort(variables, new Comparator<Map.Entry<String, Object>>() {
public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) {
return o1.getKey().compareTo(o2.getKey());
}
});
for (Map.Entry<String, Object> variable : variables) {
_foreach.addVariable(ProtobufProcessMarshaller.marshallVariable(context, variable.getKey(), variable.getValue(), false));
}
}
List<Map.Entry<String, Integer>> iterationlevels = new ArrayList<Map.Entry<String, Integer>>(forEachNodeInstance.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.getKey() != null && level.getValue() != null) {
_foreach.addIterationLevels(AutomatikoMessages.IterationLevel.newBuilder().setId(level.getKey()).setLevel(level.getValue()));
}
}
_foreach.setSequentialCounter(forEachNodeInstance.getSequentialCounter());
_content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.FOR_EACH_NODE).setForEach(_foreach.build());
} else if (nodeInstance instanceof CompositeContextNodeInstance) {
AutomatikoMessages.ProcessInstance.NodeInstanceContent.CompositeContextNode.Builder _composite = AutomatikoMessages.ProcessInstance.NodeInstanceContent.CompositeContextNode.newBuilder();
AutomatikoMessages.ProcessInstance.NodeInstanceType _type = null;
if (nodeInstance instanceof DynamicNodeInstance) {
_type = AutomatikoMessages.ProcessInstance.NodeInstanceType.DYNAMIC_NODE;
} else if (nodeInstance instanceof EventSubProcessNodeInstance) {
_type = AutomatikoMessages.ProcessInstance.NodeInstanceType.EVENT_SUBPROCESS_NODE;
} else {
_type = AutomatikoMessages.ProcessInstance.NodeInstanceType.COMPOSITE_CONTEXT_NODE;
}
CompositeContextNodeInstance compositeNodeInstance = (CompositeContextNodeInstance) nodeInstance;
List<String> timerInstances = ((CompositeContextNodeInstance) nodeInstance).getTimerInstances();
if (timerInstances != null) {
for (String id : timerInstances) {
_composite.addTimerInstanceId(id);
}
}
VariableScopeInstance variableScopeInstance = (VariableScopeInstance) compositeNodeInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
if (variableScopeInstance != null) {
List<Map.Entry<String, Object>> variables = new ArrayList<Map.Entry<String, Object>>(variableScopeInstance.getVariables().entrySet());
Collections.sort(variables, new Comparator<Map.Entry<String, Object>>() {
public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) {
return o1.getKey().compareTo(o2.getKey());
}
});
for (Map.Entry<String, Object> variable : variables) {
_composite.addVariable(ProtobufProcessMarshaller.marshallVariable(context, variable.getKey(), variable.getValue(), true));
}
}
List<Map.Entry<String, Integer>> iterationlevels = new ArrayList<Map.Entry<String, Integer>>(compositeNodeInstance.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.getKey() != null && level.getValue() != null) {
_composite.addIterationLevels(AutomatikoMessages.IterationLevel.newBuilder().setId(level.getKey()).setLevel(level.getValue()));
}
}
List<NodeInstance> nodeInstances = new ArrayList<NodeInstance>(compositeNodeInstance.getNodeInstances());
Collections.sort(nodeInstances, new Comparator<NodeInstance>() {
public int compare(NodeInstance o1, NodeInstance o2) {
return (int) (o1.getId().compareTo(o2.getId()));
}
});
for (NodeInstance subNodeInstance : nodeInstances) {
_composite.addNodeInstance(writeNodeInstance(context, subNodeInstance));
}
List<ContextInstance> exclusiveGroupInstances = compositeNodeInstance.getContextInstances(ExclusiveGroup.EXCLUSIVE_GROUP);
if (exclusiveGroupInstances != null) {
for (ContextInstance contextInstance : exclusiveGroupInstances) {
AutomatikoMessages.ProcessInstance.ExclusiveGroupInstance.Builder _excl = AutomatikoMessages.ProcessInstance.ExclusiveGroupInstance.newBuilder();
ExclusiveGroupInstance exclusiveGroupInstance = (ExclusiveGroupInstance) contextInstance;
Collection<NodeInstance> groupNodeInstances = exclusiveGroupInstance.getNodeInstances();
for (NodeInstance groupNodeInstance : groupNodeInstances) {
_excl.addGroupNodeInstanceId(groupNodeInstance.getId());
}
_composite.addExclusiveGroup(_excl.build());
}
}
_content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(_type).setComposite(_composite.build());
} else {
throw new IllegalArgumentException("Unknown node instance type: " + nodeInstance);
}
return _content.build();
}
use of io.automatiko.engine.workflow.process.instance.node.LambdaSubProcessNodeInstance in project automatiko-engine by automatiko-io.
the class AbstractProcessInstance method image.
@Override
public String image(String path) {
if (process().image() == null) {
return null;
}
StringBuilder script = new StringBuilder();
String image = process().image();
List<String> completedNodes = ((WorkflowProcessInstanceImpl) processInstance()).getCompletedNodeIds();
Collection<NodeInstance> activeInstances = ((WorkflowProcessInstanceImpl) processInstance()).getNodeInstances(true);
if (!activeInstances.isEmpty() || !completedNodes.isEmpty() || status == STATE_ERROR) {
script.append("<script>");
script.append("function remove(item) {if (item != null) {var parent = item.parentNode; parent.removeChild(item);}}");
script.append("function linkSet(item, link) {if (item != null) {item.setAttribute('xlink:href', link);}}");
script.append("function urlSet(item, url) {if (item != null) {item.onclick=function (e) {openInNewTab(url);};}}");
script.append("function fill(item, rgb) {if (item != null) {item.style['fill']=rgb;}}");
script.append("function highlight(item) {if (item != null) {item.style['stroke']='rgb(255, 0, 0)';item.style['stroke-width']='2';}}");
script.append("var warnIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABz0lEQVQ4y2NgoBAwYhNsK7HVdbOWCpCX5FJjYGRgePzi+63dR59tKO86dBmvAQlB2kJT6ixncLN+CWH4/xvVcEbW/9//8q4taDuZPmvFpXcYBsQFagktaDM7zPj3sxZM7Or93wwMDAwM2oqscHP+M/Ney2g8aztrxeV3KAZ8Phe/moftSwiypfVzPjEwMDAwNKbwoTjm+x/e1VwGC8IYGBgYWBgYGBga88x1edi+BhMbcJwsX0I6S610y7uPXWZhYGBgcLUUDmBg+M9IfNj/Z3SxEA5gYGCAGCArzqpGavTJSUD0sDAwMDC8ef+VUUaMnyQDXr/9wgg34Oi5N3cM1DENkBfH7avDZ1/fgceCpb6Q8dElDqcZGRlRdPz//x8S16jCDP////9vF3/Q9Mi5t2dZGBgYGI5ffHd2475nWwOcpX2QFTbO+8zAwMDA0JCMGo2b9j/feuTc27Mo6UBUkE3q0EKHQxpKvMowsZNXvzMwMDAwmGtzwjXfuP/5rn38QbtX734+w0jKwgJsMjPrjWYHuUi5Y/HO/3V7nu3MaDyX+ubDryf4MhOzvjq/lb+TVIC6Ao86AwMDw80HX25u3Pds48WbH48xMDD8YaAmAAAYL5tXiXxXawAAAABJRU5ErkJggg==';");
script.append("var errorIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAC80lEQVR42m2TD0yMYRzHP897d65y0akzUTYjVEKnMNQw2RqbzVrzd2wopkwrFrMw//8sDBtbNmZj5k9tDYXMbEYRM8oiSwqp6E53qbvu8uuG5c+zvXv37v09n+f3+36/j+I/azkERsJsM4zVg74D3tfC3ePw4e9a1fdjLvgnQJ5Z0zKGx8ebQqKi0BkM2OrqqH/wwGPr6LjaDDmHoeEfQDxY5kNJZHi4NTYzE1NY2B90l8NBVUEBNRUVLe9g3lF4/BswWNpcAWXxZnNibMZadCYjOk1D9Sh6usHrgW6PB6UUtZcuUVVd3XwPYovhow8wB1YthoKY5NkYJ0czKi2HugsnMdqbUN0aNqdi9IYt1F+5iquykprCQso9nnPHYKXqB1oWVEzVaZNGpE6he1oS1vU7cDu+Ub43DVfLJ2JzTzNoVCS114tp2LUbd81r3thsXUdgmDJBiMzzOdwfLTTBiNMcgHtaOjMy99L5zUZ78wcGR4zjVUkRb/LWYGn5juO9kyYvnIEFahhMPADPhgaJipPBbyi+n/bxeczL3ukT8EXZLar2zCfaz01XIzhExeZ2OA8ZSgSMFn9fWgIhOA76CfGVaxBx224THmP1AZxtX7mRlcSYzqfSq8CroUX8PAXpSoOBZ8XXED2BQePhi0U2599mSJSV+ofXaH1bjnXpfhmnjfubkghueIr9kUBssBUSe10wbITLM2UezQKhm3OJy9nHR9nceHERpgFu9DHZRKQe4vPjUp5nJtP1RBrx0rhWkuqzcTjMOgGl4pjBG6oYmbYaW8VZgkLcGPpLiCQL/Scso6msmLYyO3o7nJRE3oT8X2EzLoTt6ZBrV5IfuQT+oSKovHsBvXN2tkK7zB7gBGmgdAek9IiefdM6IEUA6yDbIVo6ZZNHQqJ0EhSXwNwgvJ47UHQQ1rl9cv51mWQFhMH0JVIghiRIRoLlFCUTOOTwyitifaUApK79v7fx59J6QfKY/QQgDeikaxmANnmkObx9i38AhmwGt8LiZCUAAAAASUVORK5CYII=';");
script.append("function openInNewTab(url) {var win = window.open(url, '_blank');win.focus();}");
for (NodeInstance nodeInstance : activeInstances) {
if (((NodeInstanceImpl) nodeInstance).getNode().getMetaData().containsKey("hidden_node") || nodeInstance.getNodeDefinitionId().startsWith("_jbpm-unique")) {
continue;
}
script.append("highlight(document.getElementById('").append(nodeInstance.getNodeDefinitionId()).append("'));\n");
if (nodeInstance instanceof LambdaSubProcessNodeInstance) {
// add links for call activity
LambdaSubProcessNodeInstance subprocess = (LambdaSubProcessNodeInstance) nodeInstance;
String url = path + "/" + ((SubProcessNode) subprocess.getNode()).getProcessId() + "/" + subprocess.getProcessInstanceId() + "/image";
script.append("urlSet(document.getElementById('").append(nodeInstance.getNodeDefinitionId()).append("_image'), '" + url + "');\n");
}
if (nodeInstance instanceof EventSubProcessNodeInstance) {
if (((EventSubProcessNodeInstance) nodeInstance).getTimerInstances() != null && !((EventSubProcessNodeInstance) nodeInstance).getTimerInstances().isEmpty()) {
String nodeDefId = (String) ((EventSubProcessNode) ((EventSubProcessNodeInstance) nodeInstance).getEventBasedNode()).findStartNode().getMetaData("UniqueId");
if (nodeDefId != null) {
script.append("highlight(document.getElementById('").append(nodeDefId).append("'));\n");
}
}
}
if (nodeInstance.getNodeInstanceState().equals(NodeInstanceState.Retrying)) {
script.append("linkSet(document.getElementById('").append(nodeInstance.getNodeDefinitionId()).append("_warn_image'), warnIcon);\n");
} else if (nodeInstance.getNodeInstanceState().equals(NodeInstanceState.Failed)) {
script.append("linkSet(document.getElementById('").append(nodeInstance.getNodeDefinitionId()).append("_warn_image'), errorIcon);\n");
} else {
script.append("remove(document.getElementById('").append(nodeInstance.getNodeDefinitionId()).append("_warn_image'));\n");
}
}
for (String nodeInstanceId : completedNodes) {
script.append("remove(document.getElementById('").append(nodeInstanceId).append("_warn_image'));\n");
script.append("fill(document.getElementById('").append(nodeInstanceId).append("'), 'rgb(160, 160, 160)');\n");
}
if (status == STATE_ERROR) {
for (ProcessError error : errors().get().errors()) {
String failedNodeId = error.failedNodeId();
script.append("highlight(document.getElementById('").append(failedNodeId).append("'));\n");
script.append("linkSet(document.getElementById('").append(failedNodeId).append("_warn_image'), errorIcon);\n");
}
}
script.append("</script></svg>");
image = image.replaceAll("</svg>", script.toString());
}
return image;
}
Aggregations