Search in sources :

Example 1 with IconFactory

use of com.centurylink.mdw.designer.icons.IconFactory in project mdw-designer by CenturyLinkCloud.

the class ImageServletHelper method loadCompletionMap.

private Graph loadCompletionMap(ProcessVO procdef, ProcessInstanceVO processInstance, DesignerDataAccess dao, NodeMetaInfo metainfo) throws Exception {
    ProcessInstanceVO fullInfo = dao.getProcessInstanceAll(processInstance.getId(), procdef);
    processInstance.copyFrom(fullInfo);
    IconFactory iconFactory = new IconFactory();
    iconFactory.setDesignerDataAccess(dao);
    Graph graph = new Graph(procdef, processInstance, metainfo, iconFactory);
    if (graph.subgraphs != null) {
        if (procdef.isInRuleSet()) {
            Map<String, String> pMap = new HashMap<>();
            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<>();
                            subgraph.setInstances(insts);
                        }
                        insts.add(childInst);
                        break;
                    }
                }
            }
        } else {
            for (SubGraph subgraph : graph.subgraphs) {
                Map<String, String> pMap = new HashMap<>();
                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);
                }
            }
        }
    }
    graph.setStatus(new StringBuffer());
    return graph;
}
Also used : HashMap(java.util.HashMap) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) IconFactory(com.centurylink.mdw.designer.icons.IconFactory)

Example 2 with IconFactory

use of com.centurylink.mdw.designer.icons.IconFactory in project mdw-designer by CenturyLinkCloud.

the class NodeChoicePane method init.

private void init() {
    next_choice_y = 10;
    int i, n = page.getDataModel().getNodeMetaInfo().count();
    ActivityImplementorVO nmi;
    node_y = new int[n];
    icon = new javax.swing.Icon[n];
    for (i = hidden_count; i < n; i++) {
        nmi = page.getDataModel().getNodeMetaInfo().get(i);
        if (nmi != null) {
            node_y[i] = next_choice_y;
            // next_choice_y += 10 + nmi.shape_h;
            next_choice_y += row_height;
            IconFactory iconFactory = page.frame.getIconFactory();
            icon[i] = iconFactory.getIcon(nmi.getIconName(), page);
            icon[i] = iconFactory.scaleIconToMax(icon[i], 24, 24);
        }
    }
    setPreferredSize(new Dimension(300, next_choice_y));
    selected_node = -1;
}
Also used : ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) Dimension(java.awt.Dimension) Point(java.awt.Point) IconFactory(com.centurylink.mdw.designer.icons.IconFactory)

Example 3 with IconFactory

use of com.centurylink.mdw.designer.icons.IconFactory in project mdw-designer by CenturyLinkCloud.

the class WorkflowImageHelper method generateImage.

/**
 * Generate a process instance image.
 */
private BufferedImage generateImage(DesignerDataAccess dao) throws Exception {
    NodeMetaInfo metainfo = new NodeMetaInfo();
    metainfo.init(dao.getActivityImplementors(), DataAccess.currentSchemaVersion);
    new ProcessWorker().convert_to_designer(process);
    IconFactory iconFactory = new IconFactory();
    iconFactory.setDesignerDataAccess(dao);
    Graph graph = null;
    Node selectedNode = null;
    if (processInstance != null) {
        processInstance.setProcessName(process.getProcessName());
        graph = new Graph(process, processInstance, metainfo, iconFactory);
        graph.setStatus(new StringBuffer());
        if (embeddedInstances != null) {
            for (ProcessInstanceVO embeddedInstance : embeddedInstances) {
                if (embeddedInstance.getStatusCode() == null && embeddedInstance.getStatus() != null)
                    embeddedInstance.setStatusCode(WorkStatuses.getCode(embeddedInstance.getStatus()));
                Long embeddedProcId = new Long(embeddedInstance.getComment());
                SubGraph subgraph = graph.getSubGraph(embeddedProcId);
                if (subgraph != null) {
                    List<ProcessInstanceVO> insts = subgraph.getInstances();
                    if (insts == null) {
                        insts = new ArrayList<ProcessInstanceVO>();
                        subgraph.setInstances(insts);
                    }
                    insts.add(embeddedInstance);
                }
            }
            for (SubGraph subgraph : graph.subgraphs) subgraph.setStatus(new StringBuffer());
        }
        if (selectedActivityInstanceId != null) {
            ActivityInstanceVO selectedInstance = processInstance.getActivity(selectedActivityInstanceId);
            if (selectedInstance == null) {
                for (SubGraph subgraph : graph.subgraphs) {
                    if (subgraph.getInstances() != null) {
                        for (ProcessInstanceVO subinst : subgraph.getInstances()) {
                            selectedInstance = subinst.getActivity(selectedActivityInstanceId);
                            if (selectedInstance != null)
                                break;
                        }
                    }
                    if (selectedInstance != null)
                        break;
                }
            }
            if (selectedInstance != null)
                selectedNode = graph.getNode("A" + selectedInstance.getDefinitionId());
        }
    } else {
        graph = new Graph(process, metainfo, iconFactory);
        if (selectedActivity != null)
            selectedNode = graph.getNode(selectedActivity);
    }
    Dimension graphsize = graph.getGraphSize();
    WorkflowImage canvas = new WorkflowImage(graph, dao);
    if (selectedNode != null)
        canvas.setSelectedObject(selectedNode);
    int h_margin = 72, v_margin = 72;
    BufferedImage image = new BufferedImage(graphsize.width + h_margin, graphsize.height + v_margin, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = image.createGraphics();
    canvas.paintComponent(g2);
    g2.dispose();
    return image;
}
Also used : NodeMetaInfo(com.centurylink.mdw.designer.utils.NodeMetaInfo) ActivityInstanceVO(com.centurylink.mdw.model.value.work.ActivityInstanceVO) Dimension(java.awt.Dimension) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) IconFactory(com.centurylink.mdw.designer.icons.IconFactory)

Aggregations

IconFactory (com.centurylink.mdw.designer.icons.IconFactory)3 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)2 Dimension (java.awt.Dimension)2 NodeMetaInfo (com.centurylink.mdw.designer.utils.NodeMetaInfo)1 ProcessWorker (com.centurylink.mdw.designer.utils.ProcessWorker)1 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)1 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)1 Graphics2D (java.awt.Graphics2D)1 Point (java.awt.Point)1 BufferedImage (java.awt.image.BufferedImage)1 HashMap (java.util.HashMap)1