use of com.centurylink.mdw.designer.display.SubGraph 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;
}
use of com.centurylink.mdw.designer.display.SubGraph in project mdw-designer by CenturyLinkCloud.
the class ProcessCanvasWrapper method handleSelection.
private void handleSelection(MouseEvent mouseEvent) {
Graph lProcess = null;
if (isInstance())
lProcess = getProcessInstancePage().getProcess();
else
lProcess = getFlowchartPage().getProcess();
int mouseX = mouseEvent.getX();
int mouseY = mouseEvent.getY();
if (lProcess.zoom != 100) {
mouseX = mouseX * 100 / lProcess.zoom;
mouseY = mouseY * 100 / lProcess.zoom;
}
Object obj = null;
if (mouseEvent.getID() == MouseEvent.MOUSE_PRESSED) {
if (isInstance())
obj = getProcessInstancePage().canvas.objectAt(lProcess, mouseX, mouseY, getProcessInstancePage().canvas.getGraphics());
else
obj = getFlowchartPage().canvas.objectAt(lProcess, mouseX, mouseY, getFlowchartPage().canvas.getGraphics());
} else {
obj = lProcess.objectAt(mouseX, mouseY, isInstance() ? getProcessInstancePage().canvas.getGraphics() : getFlowchartPage().canvas.getGraphics());
}
if (obj != null) {
DesignerProxy designerProxy = getProcess().getProject().getDesignerProxy();
// create the appropriate DesignerCanvasSelection
if (obj instanceof Node) {
ActivityImpl actImpl = getProcess().getProject().getActivityImpl(((Node) obj).nodet.getImplementorClassName());
Activity activity = new Activity((Node) obj, getProcess(), actImpl);
if (isInstance()) {
activity.setProcessInstance(getProcess().getProcessInstance());
List<ActivityInstanceVO> activityInstances = getProcess().getProcessInstance().getActivityInstances(activity.getId());
if (activityInstances.isEmpty() && getProcess().getEmbeddedSubProcessInstances() != null) {
// try embedded subprocess instances
for (ProcessInstanceVO embeddedSubProcessInstance : getProcess().getEmbeddedSubProcessInstances()) activityInstances.addAll(embeddedSubProcessInstance.getActivityInstances(activity.getId()));
}
activity.setInstances(activityInstances);
if (activity.isManualTask()) {
activity.setTaskInstances(getProcess().getMainTaskInstances(activity.getId()));
activity.setSubTaskInstances(getProcess().getSubTaskInstances(activity.getId()));
}
if (activity.isSubProcessInvoke()) {
// TODO: load subprocess instances when process instance
// id loaded (like manual task instances above)
List<ProcessInstanceVO> subProcessInstances = designerProxy.getSubProcessInstances(getProcess(), activity);
if (subProcessInstances.isEmpty() && getProcess().getEmbeddedSubProcessInstances() != null) {
for (ProcessInstanceVO embeddedSubProcessInstance : getProcess().getEmbeddedSubProcessInstances()) subProcessInstances.addAll(designerProxy.getSubProcessInstances(embeddedSubProcessInstance, activity));
}
activity.setSubProcessInstances(subProcessInstances);
}
} else {
if (activity.getLogicalId() == null)
activity.setLogicalId(lProcess.generateLogicalId("A"));
if (Node.ID_SEQUENCE.equals(getNodeIdType()) && activity.getSequenceId() == 0)
lProcess.assignSequenceIds();
}
designerCanvasSelection = activity;
} else if (obj instanceof Link) {
Transition transition = new Transition((Link) obj, getProcess());
if (isInstance())
transition.setInstances(getProcess().getProcessInstance().getTransitionInstances(transition.getId()));
designerCanvasSelection = transition;
} else if (obj instanceof SubGraph) {
EmbeddedSubProcess embeddedSubProcess = new EmbeddedSubProcess((SubGraph) obj, getProcess());
if (isInstance()) {
embeddedSubProcess.setSubProcessInstances(((SubGraph) obj).getInstances());
}
designerCanvasSelection = embeddedSubProcess;
} else if (obj instanceof TextNote) {
TextNote textNote = (TextNote) obj;
Note note = new Note(textNote, getProcess());
designerCanvasSelection = note;
} else {
designerCanvasSelection = getProcess();
}
} else {
designerCanvasSelection = getProcess();
}
designerCanvasSelection.addDirtyStateListener(this);
}
use of com.centurylink.mdw.designer.display.SubGraph in project mdw-designer by CenturyLinkCloud.
the class DesignerCanvas method resizeSubGraph.
protected void resizeSubGraph(int x, int y) {
SubGraph subgraph = (SubGraph) selected_obj;
Rectangle rect = new Rectangle(subgraph.x, subgraph.y, subgraph.w, subgraph.h);
resizeRectangle(rect, x, y, 80);
subgraph.resize(rect);
if (!page.getProcess().isReadonly())
page.getProcess().setDirtyLevel(Graph.GEOCHANGE);
}
use of com.centurylink.mdw.designer.display.SubGraph in project mdw-designer by CenturyLinkCloud.
the class ExportHelper method printProcessDocx.
private DocxBuilder printProcessDocx(Graph process, DesignerCanvas canvas) throws Exception {
DocxBuilder builder = new DocxBuilder();
// title
String title = "Workflow: \"" + process.getName() + "\"";
builder.addParagraph("Heading1", title);
// process image
int zoomSave = process.zoom;
process.zoom = 100;
byte[] imgBytes = printImage(-1f, canvas, process.getGraphSize(), "png");
process.zoom = zoomSave;
builder.addImage(imgBytes);
printProcessBodyDocx(builder, process);
// embedded subprocesses
for (SubGraph subprocess : process.getSubgraphs(nodeIdType)) {
String id = subprocess.getDisplayId(nodeIdType);
String spTitle = "Embedded Subprocess " + id + ": \"" + subprocess.getName() + "\"";
builder.addParagraph("Heading1", spTitle);
printProcessBodyDocx(builder, subprocess);
}
// process variables
if (options.contains(VARIABLES)) {
List<VariableVO> variables = process.getProcessVO().getVariables();
if (variables != null && !variables.isEmpty()) {
builder.addParagraph("Heading2", "Process Variables");
String[] headers = new String[] { "Name", "Type", "Mode", "Description" };
String[][] values = new String[4][variables.size()];
for (int i = 0; i < variables.size(); i++) {
VariableVO var = variables.get(i);
values[0][i] = var.getName();
values[1][i] = var.getVariableType();
values[2][i] = VariableVO.VariableCategories[var.getVariableCategory()];
values[3][i] = var.getVariableReferredAs();
}
builder.addTable(headers, values, 11, 120);
}
}
return builder;
}
use of com.centurylink.mdw.designer.display.SubGraph in project mdw-designer by CenturyLinkCloud.
the class ExportHelper method printProcessHtml.
private void printProcessHtml(StringBuilder sb, DesignerCanvas canvas, int chapter, Graph process, String filename) throws Exception {
sb.append("<h1>");
if (chapter > 0)
sb.append(Integer.toString(chapter)).append(". ");
sb.append("Workflow: \"").append(process.getName()).append("\"</h1>\n");
// print image
printGraphHtml(sb, canvas, process, filename, chapter);
// print documentation text
sb.append(BR);
printProcessBodyHtml(sb, process);
for (Node node : process.getNodes(nodeIdType)) {
printActivityHtml(sb, node);
}
for (SubGraph subgraph : process.getSubgraphs(nodeIdType)) {
printProcessBodyHtml(sb, subgraph);
for (Node node : subgraph.getNodes(nodeIdType)) {
printActivityHtml(sb, node);
}
}
if (options.contains(VARIABLES)) {
List<VariableVO> variables = process.getProcessVO().getVariables();
if (variables != null && !variables.isEmpty()) {
sb.append("<h2>Process Variables</h2>\n");
String[] headers = new String[] { "Name", "Type", "Mode", "Description" };
String[][] values = new String[4][variables.size()];
for (int i = 0; i < variables.size(); i++) {
VariableVO var = variables.get(i);
values[0][i] = var.getName();
values[1][i] = var.getVariableType();
values[2][i] = VariableVO.VariableCategories[var.getVariableCategory()];
values[3][i] = var.getVariableReferredAs();
}
printTableHtml(sb, headers, values);
}
}
}
Aggregations