use of com.centurylink.mdw.designer.runtime.ProcessInstanceTreeModel in project mdw-designer by CenturyLinkCloud.
the class DesignerDataModel method findInstanceTreeAndNode.
public ProcessInstanceTreeModel findInstanceTreeAndNode(Long procInstId, String server, String masterId) {
if (masterId == null)
return null;
ProcessInstanceTreeNode node;
for (int i = 0; i < instanceTrees.size(); i++) {
ProcessInstanceTreeModel model = instanceTrees.get(i);
if (!masterId.equals(model.getMasterRequestId()))
continue;
node = model.find(procInstId, server);
if (node != null) {
model.setCurrentProcess(node);
return model;
}
}
return null;
}
use of com.centurylink.mdw.designer.runtime.ProcessInstanceTreeModel in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method loadProcessInstance.
public RunTimeDesignerCanvas loadProcessInstance(WorkflowProcess processVersion, ProcessInstancePage processInstancePage) {
CodeTimer timer = new CodeTimer("loadProcessInstance()");
ProcessInstanceVO processInstanceInfo = processVersion.getProcessInstance();
ProcessInstanceLoader instanceLoadThread = new ProcessInstanceLoader(processInstanceInfo, processInstancePage);
String errorMessage = null;
try {
Graph processGraph = dataAccess.getDesignerDataModel().findProcessGraph(processVersion.getId(), null);
if (processGraph == null)
processGraph = processInstancePage.loadProcess(processInstanceInfo.getProcessId(), null);
processVersion.setProcessVO(processGraph.getProcessVO());
DesignerDataAccess dao = processVersion.getDesignerDataAccess() == null ? processInstancePage.frame.dao : processVersion.getDesignerDataAccess();
Graph procInstGraph = instanceLoadThread.loadCompletionMap(processGraph.getProcessVO(), processInstanceInfo, dao);
ProcessInstanceTreeModel model = instanceLoadThread.createOrUpdateModel(null);
model.getCurrentProcess().setGraph(procInstGraph);
processInstancePage.setData(model, processInstancePage);
Map<Long, List<TaskInstanceVO>> taskInstances = new HashMap<>();
// embedded subprocesses
List<ProcessInstanceVO> embeddedSubs = new ArrayList<>();
if (procInstGraph.subgraphs != null) {
for (SubGraph instSubGraph : procInstGraph.subgraphs) {
if (instSubGraph.getInstances() != null) {
if (instSubGraph.nodes != null) {
List<Long> taskActivityIds = new ArrayList<>();
for (Node node : instSubGraph.nodes) {
if (node.isTaskActivity()) {
for (ProcessInstanceVO embeddedProcInst : instSubGraph.getInstances()) {
if (!embeddedProcInst.getActivityInstances(node.getActivityId()).isEmpty())
taskActivityIds.add(node.getActivityId());
}
}
}
if (!taskActivityIds.isEmpty()) {
for (ProcessInstanceVO embeddedProcInst : instSubGraph.getInstances()) {
ProcessVO embeddedProc = instSubGraph.getGraph().getProcessVO();
Map<Long, List<TaskInstanceVO>> embeddedTaskInsts = dao.getTaskInstances(embeddedProc, embeddedProcInst, taskActivityIds);
for (Map.Entry<Long, List<TaskInstanceVO>> embeddedTaskInst : embeddedTaskInsts.entrySet()) {
if (taskInstances.get(embeddedTaskInst.getKey()) == null)
taskInstances.put(embeddedTaskInst.getKey(), new ArrayList<TaskInstanceVO>());
taskInstances.get(embeddedTaskInst.getKey()).addAll(embeddedTaskInst.getValue());
}
}
}
}
embeddedSubs.addAll(instSubGraph.getInstances());
}
}
}
processVersion.setEmbeddedSubProcessInstances(embeddedSubs);
// manual task instances
if (processGraph.nodes != null) {
List<Long> taskActivityIds = new ArrayList<>();
for (Node node : processGraph.nodes) {
if (node.isTaskActivity() && !processInstanceInfo.getActivityInstances(node.getActivityId()).isEmpty())
taskActivityIds.add(node.getActivityId());
}
if (!taskActivityIds.isEmpty()) {
Map<Long, List<TaskInstanceVO>> taskInsts = dao.getTaskInstances(processVersion.getProcessVO(), processInstanceInfo, taskActivityIds);
for (Map.Entry<Long, List<TaskInstanceVO>> taskInst : taskInsts.entrySet()) {
if (taskInstances.get(taskInst.getKey()) == null)
taskInstances.put(taskInst.getKey(), new ArrayList<TaskInstanceVO>());
taskInstances.get(taskInst.getKey()).addAll(taskInst.getValue());
}
}
}
processVersion.setTaskInstances(taskInstances);
} catch (Exception ex) {
PluginMessages.log(ex);
errorMessage = PluginMessages.getUserMessage(ex);
}
if (errorMessage == null)
errorMessage = instanceLoadThread.getErrorMessage();
if (errorMessage != null) {
PluginMessages.uiError(errorMessage, "Load Process Instance");
}
timer.stopAndLog();
return processInstancePage.canvas;
}
Aggregations