Search in sources :

Example 31 with ProcessInstanceVO

use of com.centurylink.mdw.model.value.process.ProcessInstanceVO in project mdw-designer by CenturyLinkCloud.

the class ProcessInstanceUpdater method updateActivityInstance.

private void updateActivityInstance(ProcessInstancePage procInstPage, Long procId, Long procInstId, String timestr, String id, String msg) {
    ProcessInstanceVO procInst = procInstPage.getProcessInstance();
    if (!isShowingThisInstance(procInst.getId()))
        showInstance(procInstPage);
    int k = id.indexOf('.');
    String actId = id.substring(0, k);
    String actInstId = id.substring(k + 1);
    Node node;
    if (!procInst.getId().equals(procInstId)) {
        // embedded process
        node = this.findNodeInSubgraph(procInstPage.getProcess(), new Long(actId));
        procInst = this.findEmbeddedProcessInstance(procInstPage.getProcess(), procInstId);
    } else {
        node = procInstPage.getProcess().findNode(new Long(actId));
    }
    if (node != null) {
        ActivityInstanceVO actInst = null;
        for (ActivityInstanceVO ai : procInst.getActivities()) {
            if (ai.getId().toString().equals(actInstId)) {
                actInst = ai;
                break;
            }
        }
        if (actInst == null) {
            actInst = new ActivityInstanceVO();
            procInst.getActivities().add(actInst);
            actInst.setId(new Long(actInstId));
            actInst.setDefinitionId(new Long(actId));
            actInst.setOwnerId(procInst.getId());
            actInst.setStartDate(timestr);
            actInst.setStatusCode(WorkStatus.STATUS_IN_PROGRESS);
            node.addInstance(actInst, false);
        }
        if (msg.startsWith(WorkStatus.LOGMSG_COMPLETE)) {
            actInst.setEndDate(timestr);
            actInst.setStatusCode(WorkStatus.STATUS_COMPLETED);
            node.setInstanceStatus(actInst);
        } else if (msg.startsWith(WorkStatus.LOGMSG_START)) {
        // do nothing - already loaded by code above or by full load
        } else if (msg.startsWith(WorkStatus.LOGMSG_FAILED)) {
            actInst.setEndDate(timestr);
            actInst.setStatusCode(WorkStatus.STATUS_FAILED);
            node.setInstanceStatus(actInst);
        } else if (msg.startsWith(WorkStatus.LOGMSG_SUSPEND)) {
            actInst.setStatusCode(WorkStatus.STATUS_WAITING);
            node.setInstanceStatus(actInst);
        } else if (msg.startsWith(WorkStatus.LOGMSG_HOLD)) {
            actInst.setStatusCode(WorkStatus.STATUS_HOLD);
            node.setInstanceStatus(actInst);
        } else {
        // System.out.println("How to handle activity message '" + msg +"'?");
        }
        Rectangle aRect = new java.awt.Rectangle(node.x - 10, node.y - 10, node.w + 20, node.h + 30);
        procInstPage.canvas.scrollRectToVisible(aRect);
    } else {
        System.out.println("Cannot find node with ID " + actId);
    }
    procInstPage.repaint();
}
Also used : ActivityInstanceVO(com.centurylink.mdw.model.value.work.ActivityInstanceVO) Node(com.centurylink.mdw.designer.display.Node) Rectangle(java.awt.Rectangle) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 32 with ProcessInstanceVO

use of com.centurylink.mdw.model.value.process.ProcessInstanceVO in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getProcessInstanceList.

public ProcessList getProcessInstanceList(Map<String, String> pMap, int pageIndex, int pageSize, ProcessVO procdef, String orderBy) throws DataAccessException {
    if (procdef != null && procdef.isRemote()) {
        RuntimeDataAccess runTimeInfo = remoteAccess.get(procdef.getRemoteServer()).getRuntimeDataAccess();
        ProcessList ret = runTimeInfo.getProcessInstanceList(pMap, pageIndex, pageSize, orderBy);
        for (ProcessInstanceVO one : ret.getProcesses()) {
            one.setRemoteServer(procdef.getRemoteServer());
        }
        return ret;
    } else {
        return rtinfo.getProcessInstanceList(pMap, pageIndex, pageSize, orderBy);
    }
}
Also used : RuntimeDataAccess(com.centurylink.mdw.dataaccess.RuntimeDataAccess) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 33 with ProcessInstanceVO

use of com.centurylink.mdw.model.value.process.ProcessInstanceVO in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getChildProcessInstance.

/**
 * Does not work for embedded subprocs in asset processes.
 */
public List<ProcessInstanceVO> getChildProcessInstance(Long processInstanceId, ProcessVO childProcess, ProcessVO parentProcess) throws DataAccessException {
    Map<String, String> pMap = new HashMap<>();
    if (childProcess.isRemote()) {
        RuntimeDataAccess runTimeInfo = remoteAccess.get(childProcess.getRemoteServer()).getRuntimeDataAccess();
        List<ProcessInstanceVO> ret;
        String ownerType = OwnerType.PROCESS_INSTANCE;
        if (parentProcess.isRemote()) {
            if (!parentProcess.getRemoteServer().equals(childProcess.getRemoteServer()))
                ownerType = parentProcess.getRemoteServer();
        } else {
            ownerType = currentServer.getApplicationName();
        }
        pMap.put("owner", ownerType);
        pMap.put("ownerId", processInstanceId.toString());
        pMap.put(PROCESSID, childProcess.getProcessId().toString());
        ProcessList procList = runTimeInfo.getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, null);
        ret = procList.getProcesses();
        for (ProcessInstanceVO one : ret) {
            one.setRemoteServer(childProcess.getRemoteServer());
        }
        return ret;
    } else {
        pMap.put("owner", OwnerType.PROCESS_INSTANCE);
        pMap.put("ownerId", processInstanceId.toString());
        pMap.put(PROCESSID, childProcess.getProcessId().toString());
        return getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, childProcess, null).getProcesses();
    }
}
Also used : RuntimeDataAccess(com.centurylink.mdw.dataaccess.RuntimeDataAccess) HashMap(java.util.HashMap) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 34 with ProcessInstanceVO

use of com.centurylink.mdw.model.value.process.ProcessInstanceVO in project mdw-designer by CenturyLinkCloud.

the class ProcessInstanceLoader method createOrUpdateModelRecursive.

private ProcessInstanceTreeModel createOrUpdateModelRecursive(ProcessInstanceVO procInst) throws Exception {
    ProcessInstanceTreeModel model;
    ProcessInstanceTreeNode node;
    if (OwnerType.PROCESS_INSTANCE.equals(procInst.getOwner())) {
        // parent is a process instance
        model = page.getDataModel().findInstanceTreeAndNode(procInst.getOwnerId(), procInst.getRemoteServer(), procInst.getMasterRequestId());
        if (model == null) {
            ProcessInstanceVO parentInst = page.frame.dao.getProcessInstanceBase(procInst.getOwnerId(), procInst.getRemoteServer());
            model = createOrUpdateModelRecursive(parentInst);
        } else {
        }
        ProcessInstanceTreeNode parentNode = model.getCurrentProcess();
        node = parentNode.addChild(model.new ProcessInstanceTreeNode(procInst));
        model.setCurrentProcess(node);
    } else {
        // top level node
        model = new ProcessInstanceTreeModel();
        node = model.getRoot();
        node.setEntry(procInst);
        model.setCurrentProcess(node);
    }
    return model;
}
Also used : ProcessInstanceTreeNode(com.centurylink.mdw.designer.runtime.ProcessInstanceTreeModel.ProcessInstanceTreeNode) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 35 with ProcessInstanceVO

use of com.centurylink.mdw.model.value.process.ProcessInstanceVO in project mdw-designer by CenturyLinkCloud.

the class RunTimeDesignerCanvas method mouseClicked.

public void mouseClicked(MouseEvent arg0) {
    if (arg0.getButton() != 1)
        return;
    if (arg0.getClickCount() != 2)
        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 Link) {
        Link link = (Link) obj;
        try {
            List<WorkTransitionInstanceVO> workTransitionList;
            Long linkId = new Long(link.conn.getWorkTransitionId());
            if (link.from.graph instanceof SubGraph) {
                workTransitionList = new ArrayList<WorkTransitionInstanceVO>();
                SubGraph subgraph = (SubGraph) link.from.graph;
                if (subgraph.getInstances() != null) {
                    for (ProcessInstanceVO inst : subgraph.getInstances()) {
                        List<WorkTransitionInstanceVO> coll1 = inst.getTransitionInstances(linkId);
                        workTransitionList.addAll(coll1);
                    }
                }
            } else {
                workTransitionList = page.getProcessInstance().getTransitionInstances(linkId);
            }
            WorkTransitionsDialog workTransDialog = new WorkTransitionsDialog(page.frame);
            workTransDialog.setWorkTransitionList(workTransitionList);
            workTransDialog.setVisible(true);
        } catch (Exception ex) {
            ex.printStackTrace();
            page.frame.setNewServer();
        }
    }
}
Also used : WorkTransitionInstanceVO(com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO) Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Link(com.centurylink.mdw.designer.display.Link) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Aggregations

ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)40 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)10 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)9 IOException (java.io.IOException)9 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)7 HashMap (java.util.HashMap)7 DesignerDataAccess (com.centurylink.mdw.designer.DesignerDataAccess)6 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)6 ArrayList (java.util.ArrayList)6 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)5 ProcessList (com.centurylink.mdw.model.value.process.ProcessList)5 XmlException (org.apache.xmlbeans.XmlException)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 JSONException (org.json.JSONException)5 Graph (com.centurylink.mdw.designer.display.Graph)4 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)4 Menu (org.eclipse.swt.widgets.Menu)4 MenuItem (org.eclipse.swt.widgets.MenuItem)4 PartInitException (org.eclipse.ui.PartInitException)4