Search in sources :

Example 6 with Graph

use of com.centurylink.mdw.designer.display.Graph in project mdw-designer by CenturyLinkCloud.

the class RunTimeDesignerCanvas method mouseReleased.

public void mouseReleased(MouseEvent arg0) {
    if (arg0.getButton() == 1)
        return;
    if (!arg0.isPopupTrigger())
        return;
    Graph process = page.getProcess();
    int x = arg0.getX();
    int y = arg0.getY();
    if (process.zoom != 100) {
        x = x * 100 / process.zoom;
        y = y * 100 / process.zoom;
    }
    Object obj = process.objectAt(x, y, getGraphics());
    if (obj == null)
        return;
    if (obj instanceof Selectable) {
    // JPopupMenu popup = this.popup_activity; // TODO
    // if (popup!=null) popup.show(this, arg0.getX(), arg0.getY());
    } else if (obj instanceof Link) {
    }
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Selectable(com.centurylink.mdw.designer.display.Selectable) Link(com.centurylink.mdw.designer.display.Link)

Example 7 with Graph

use of com.centurylink.mdw.designer.display.Graph in project mdw-designer by CenturyLinkCloud.

the class DesignerCanvas method paintComponent.

/* (non-Javadoc)
	 * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
	 */
protected void paintComponent(Graphics g) {
    Graph process = page.getProcess();
    super.paintComponent(g);
    if (g instanceof Graphics2D) {
        Graphics2D g2d = (Graphics2D) g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
        if (process.zoom != 100) {
            double scale = process.zoom / 100.0;
            g2d.scale(scale, scale);
        }
    }
    // draw graph itself
    draw_graph(g, process, false);
    // then draw dragging and selected stuff
    super.paintDraggingAndSelection(g);
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Graphics2D(java.awt.Graphics2D)

Example 8 with Graph

use of com.centurylink.mdw.designer.display.Graph in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method loadProcess.

public DesignerCanvas loadProcess(WorkflowProcess processVersion, FlowchartPage flowchartPage) {
    CodeTimer timer = new CodeTimer("loadProcess()");
    Graph graph = flowchartPage.loadProcess(processVersion.getId(), null);
    flowchartPage.setProcess(graph);
    if (project.isRemote() && project.isFilePersist()) {
        graph.setReadonly(true);
    }
    processVersion.setProcessVO(graph.getProcessVO());
    processVersion.setReadOnly(graph.isReadonly());
    timer.stopAndLog();
    return flowchartPage.canvas;
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) CodeTimer(com.centurylink.mdw.plugin.CodeTimer)

Example 9 with Graph

use of com.centurylink.mdw.designer.display.Graph in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method saveProcess.

/**
 * Relies on classic designer page to update the processVO with the reloaded
 * data.
 */
public void saveProcess(WorkflowProcess process, FlowchartPage flowchartPage, PersistType persistType, int version, boolean validate, boolean lock) throws ValidationException, DataAccessException, RemoteException {
    CodeTimer timer = new CodeTimer("saveProcess()");
    Graph graph = flowchartPage.getProcess();
    graph.save_temp_vars();
    // refresh variable type cache since Designer Classic uses a single,
    // static cache
    // calls
    dataAccess.loadVariableTypes();
    if (validate)
        new ProcessValidator(process.getProcessVO()).validate(getNodeMetaInfo());
    if (!process.getProject().checkRequiredVersion(5, 5))
        flowchartPage.setProcessVersions(flowchartPage.getProcess(), // not
        !process.getProject().checkRequiredVersion(5, 2));
    // sure
    // why
    // this
    // was
    // ever
    // needed
    Map<String, String> overrideAttributes = null;
    if (process.getProcessVO() != null && process.getProject().isFilePersist() && process.overrideAttributesApplied())
        overrideAttributes = process.getProcessVO().getOverrideAttributes();
    Graph reloaded = null;
    try {
        reloaded = flowchartPage.saveProcess(graph, mainFrame, persistType, version, lock);
    } catch (ValidationException ex) {
        graph.setDirtyLevel(Graph.DIRTY);
        if (ex.getMessage() != null && ex.getMessage().contains(ORA_02292))
            throw new ValidationException("There are instances associated with this process version.\n       Please increment the version when saving.");
        else
            throw ex;
    }
    process.setProcessVO(reloaded.getProcessVO());
    flowchartPage.setProcess(reloaded);
    WorkflowPackage pkg = process.getPackage();
    if (pkg != null && !pkg.isDefaultPackage() && persistType == PersistType.NEW_VERSION) {
        if (project.isFilePersist()) {
            pkg.setVersion(pkg.getVersion() + 1);
            // exported not relevant for vcs
            pkg.setExported(false);
            // processes since pkg will be archived
            // anyway
            savePackage(pkg, true);
        } else {
            savePackage(pkg);
        }
    }
    if (process.getProject().isFilePersist() && version != 0 && persistType == PersistType.NEW_VERSION && overrideAttributes != null && !overrideAttributes.isEmpty() && MdwPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREFS_CARRY_FORWARD_OVERRIDE_ATTRS)) {
        if (!process.overrideAttributesApplied())
            throw new DataAccessException("Override attributes not applied");
        reloaded.getProcessVO().applyOverrideAttributes(overrideAttributes);
        getDesignerDataAccess().setOverrideAttributes(reloaded.getProcessVO());
    }
    cacheRefresh.fireRefresh(reloaded.getProcessVO().hasDynamicJavaActivity());
    timer.stopAndLog();
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) ProcessValidator(com.centurylink.mdw.designer.utils.ProcessValidator) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 10 with Graph

use of com.centurylink.mdw.designer.display.Graph 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;
}
Also used : HashMap(java.util.HashMap) Node(com.centurylink.mdw.designer.display.Node) ProcessInstanceTreeModel(com.centurylink.mdw.designer.runtime.ProcessInstanceTreeModel) ArrayList(java.util.ArrayList) ProcessInstanceLoader(com.centurylink.mdw.designer.runtime.ProcessInstanceLoader) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ArrayList(java.util.ArrayList) List(java.util.List) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Map(java.util.Map) HashMap(java.util.HashMap) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Aggregations

Graph (com.centurylink.mdw.designer.display.Graph)31 SubGraph (com.centurylink.mdw.designer.display.SubGraph)31 Link (com.centurylink.mdw.designer.display.Link)9 Node (com.centurylink.mdw.designer.display.Node)9 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)7 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)6 TextNote (com.centurylink.mdw.designer.display.TextNote)5 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)5 RemoteException (java.rmi.RemoteException)5 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)4 CodeTimer (com.centurylink.mdw.plugin.CodeTimer)4 FlowchartPage (com.centurylink.mdw.designer.pages.FlowchartPage)3 GraphFragment (com.centurylink.mdw.designer.display.GraphFragment)2 ProcessValidator (com.centurylink.mdw.designer.utils.ProcessValidator)2 ProcessWorker (com.centurylink.mdw.designer.utils.ProcessWorker)2 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)2 WorkTransitionInstanceVO (com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO)2 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)2 Graphics2D (java.awt.Graphics2D)2 ArrayList (java.util.ArrayList)2