Search in sources :

Example 6 with ProcessInstanceVO

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

the class SubGraph method setInstanceStatus.

/**
 * For immediate-display when running process in designer
 */
public void setInstanceStatus(Long procInstId, Integer statusCode) {
    if (instances == null)
        return;
    int n = instances.size();
    for (int i = 0; i < n; i++) {
        ProcessInstanceVO pi1 = instances.get(i);
        if (pi1.getId().equals(procInstId)) {
            pi1.setStatusCode(statusCode);
            String newStatus = Integer.toString(statusCode);
            if (status == null)
                status = newStatus;
            else if (i >= status.length())
                status = status + newStatus;
            else if (i == 0)
                status = newStatus + status.substring(1);
            else if (i == n - 1)
                status = status.substring(0, i) + newStatus;
            else
                status = status.substring(0, i) + newStatus + status.substring(i + 1);
            break;
        }
    }
}
Also used : ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 7 with ProcessInstanceVO

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

the class ProcessInstanceUpdater method updateTransitionInstance.

private void updateTransitionInstance(ProcessInstancePage procInstPage, Long procId, Long procInstId, String timestr, String id, String msg) {
    ProcessInstanceVO procInst = procInstPage.getProcessInstance();
    if (!isShowingThisInstance(procInst.getId()))
        this.showInstance(procInstPage);
    int k = id.indexOf('.');
    String transId = id.substring(0, k);
    String transInstId = id.substring(k + 1);
    Link link;
    if (!procInst.getId().equals(procInstId)) {
        // embedded process
        link = findLinkInSubgraph(procInstPage.getProcess(), new Long(transId));
        procInst = this.findEmbeddedProcessInstance(procInstPage.getProcess(), procInstId);
    } else {
        link = procInstPage.getProcess().findLink(new Long(transId));
    }
    if (link != null) {
        WorkTransitionInstanceVO transInst = null;
        for (WorkTransitionInstanceVO ti : procInst.getTransitions()) {
            if (ti.getTransitionInstanceID().toString().equals(transInstId)) {
                transInst = ti;
                break;
            }
        }
        // Date time = df.parse(timestr);
        if (transInst == null) {
            transInst = new WorkTransitionInstanceVO();
            procInst.getTransitions().add(transInst);
            transInst.setTransitionID(new Long(transId));
            transInst.setTransitionInstanceID(new Long(transInstId));
            transInst.setProcessInstanceID(procInst.getId());
            transInst.setStartDate(timestr);
            transInst.setEndDate(timestr);
            transInst.setStatusCode(WorkTransitionStatus.STATUS_COMPLETED);
            link.addInstance(transInst);
        }
    } else {
        System.out.println("Cannot find link with ID " + transId);
    }
    procInstPage.repaint();
}
Also used : WorkTransitionInstanceVO(com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) Link(com.centurylink.mdw.designer.display.Link)

Example 8 with ProcessInstanceVO

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

the class ProcessInstanceLoader method loadCompletionMap.

public Graph loadCompletionMap(ProcessVO procdef, ProcessInstanceVO processInstance, DesignerDataAccess dao) throws Exception {
    ProcessInstanceVO fullInfo = dao.getProcessInstanceAll(processInstance.getId(), procdef);
    processInstance.copyFrom(fullInfo);
    Graph graph = new Graph(procdef, processInstance, page.getDataModel().getNodeMetaInfo(), page.frame.getIconFactory());
    if (graph.subgraphs != null) {
        if (procdef.isInRuleSet()) {
            Map<String, String> pMap = new HashMap<String, String>();
            pMap.put("owner", OwnerType.MAIN_PROCESS_INSTANCE);
            pMap.put("ownerId", processInstance.getId().toString());
            pMap.put("processId", procdef.getProcessId().toString());
            List<ProcessInstanceVO> childProcessInstances = dao.getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, procdef, null).getItems();
            for (ProcessInstanceVO childInst : childProcessInstances) {
                ProcessInstanceVO fullChildInfo = dao.getProcessInstanceAll(childInst.getId(), procdef);
                childInst.copyFrom(fullChildInfo);
                Long subprocId = new Long(childInst.getComment());
                for (SubGraph subgraph : graph.subgraphs) {
                    if (subgraph.getProcessVO().getProcessId().equals(subprocId)) {
                        List<ProcessInstanceVO> insts = subgraph.getInstances();
                        if (insts == null) {
                            insts = new ArrayList<ProcessInstanceVO>();
                            subgraph.setInstances(insts);
                        }
                        insts.add(childInst);
                        break;
                    }
                }
            }
        } else {
            for (SubGraph subgraph : graph.subgraphs) {
                Map<String, String> pMap = new HashMap<String, String>();
                pMap.put("owner", OwnerType.PROCESS_INSTANCE);
                pMap.put("ownerId", processInstance.getId().toString());
                pMap.put("processId", subgraph.getProcessVO().getProcessId().toString());
                List<ProcessInstanceVO> childProcessInstances = dao.getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, procdef, null).getItems();
                subgraph.setInstances(childProcessInstances);
                for (ProcessInstanceVO childInst : childProcessInstances) {
                    ProcessInstanceVO fullChildInfo = dao.getProcessInstanceAll(childInst.getId(), procdef);
                    childInst.copyFrom(fullChildInfo);
                }
            }
        }
    }
    StringBuffer errmsg_buffer = new StringBuffer();
    graph.setStatus(errmsg_buffer);
    if (errmsg_buffer.length() > 0) {
        errmsg = "There are runtime information about activities and transitions\n" + " that are not found in process definition.\n" + "This may happen when the process definition has been modified.\n" + errmsg_buffer.toString();
    }
    return graph;
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) HashMap(java.util.HashMap) SubGraph(com.centurylink.mdw.designer.display.SubGraph) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 9 with ProcessInstanceVO

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

the class ProcessStatusPane method paintComponent.

protected void paintComponent(Graphics 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);
    }
    super.paintComponent(g);
    int nodeLegendY = 5;
    g.setColor(new Color(0.8f, 0.8f, 0.5f));
    g.drawRect(5, nodeLegendY, 175, nodeLegends.length * 25 + 25);
    g.fillRect(5, nodeLegendY, 175, 20);
    g.setColor(Color.BLACK);
    g.drawString("Activity Status", 10, nodeLegendY + 15);
    for (int i = 0; i < nodeLegends.length; i++) {
        g.setColor(nodeColors[i]);
        g.fillRect(10, nodeLegendY + 25 + i * 25, 20, 20);
        g.setColor(Color.BLACK);
        g.drawString(nodeLegends[i], 40, nodeLegendY + 40 + 25 * i);
    }
    int infoY = nodeLegends.length * 25 + 55;
    if (page != null) {
        ProcessInstanceVO procInst = page.getProcessInstance();
        g.drawString("Instance ID: " + procInst.getId(), 10, infoY);
        infoY += 20;
        g.drawString("Process ID: " + procInst.getProcessId(), 10, infoY);
        infoY += 20;
        g.drawString("Master ID: " + procInst.getMasterRequestId(), 10, infoY);
        infoY += 20;
        g.drawString("Process Name: " + procInst.getProcessName(), 10, infoY);
        infoY += 20;
        g.drawString("Owner Type: " + procInst.getOwner(), 10, infoY);
        infoY += 20;
        g.drawString("Owner ID: " + procInst.getOwnerId(), 10, infoY);
        infoY += 20;
        g.drawString("Status: " + workStatuses.get(new Integer(procInst.getStatusCode())), 10, infoY);
        infoY += 20;
        g.drawString("Start: " + procInst.getStartDate(), 10, infoY);
        infoY += 20;
        g.drawString("Finish: " + procInst.getEndDate(), 10, infoY);
        infoY += 20;
    }
}
Also used : Color(java.awt.Color) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) Graphics2D(java.awt.Graphics2D)

Example 10 with ProcessInstanceVO

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

the class RuntimeDataAccessRest method getProcessInstanceAll.

public ProcessInstanceVO getProcessInstanceAll(Long processInstanceId) throws DataAccessException {
    try {
        String pathWithArgs = "Processes/" + processInstanceId;
        if (!getServer().isSchemaVersion61())
            pathWithArgs = "ProcessInstance?format=json&instanceId=" + processInstanceId;
        String response = invokeResourceService(pathWithArgs);
        return new ProcessInstanceVO(new JSONObject(response));
    } catch (IOException ex) {
        throw new DataAccessOfflineException(ex.getMessage(), ex);
    } catch (Exception ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) JSONObject(org.json.JSONObject) IOException(java.io.IOException) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) JSONException(org.json.JSONException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

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