Search in sources :

Example 1 with ActivityVO

use of com.centurylink.mdw.model.value.activity.ActivityVO in project mdw-designer by CenturyLinkCloud.

the class Graph method compareProcess.

public void compareProcess(ProcessVO otherproc) {
    this.save_temp_vars();
    HashMap<String, Node> nodemap = new HashMap<String, Node>();
    HashMap<String, Link> linkmap = new HashMap<String, Link>();
    HashMap<String, SubGraph> subgraphmap = new HashMap<String, SubGraph>();
    HashMap<Long, Long> delidmap = new HashMap<Long, Long>();
    String lid;
    for (Node node : nodes) {
        node.getChanges().setChangeType(Changes.NEW);
        lid = getOrGenerateLogicalId(node.nodet);
        nodemap.put(lid, node);
    }
    for (Link link : links) {
        link.getChanges().setChangeType(Changes.NEW);
        lid = getOrGenerateLogicalId(link.conn);
        linkmap.put(lid, link);
    }
    for (SubGraph subgraph : subgraphs) {
        subgraph.getChanges().setChangeType(Changes.NEW);
        lid = getOrGenerateLogicalId(subgraph.getProcessVO());
        subgraphmap.put(lid, subgraph);
        for (Node node : subgraph.nodes) {
            node.getChanges().setChangeType(Changes.NEW);
            lid = getOrGenerateLogicalId(node.nodet);
            nodemap.put(lid, node);
        }
        for (Link link : subgraph.links) {
            link.getChanges().setChangeType(Changes.NEW);
            lid = getOrGenerateLogicalId(link.conn);
            linkmap.put(lid, link);
        }
    }
    for (ActivityVO a : otherproc.getActivities()) {
        checkActivityInSource(a, this, nodemap, delidmap);
    }
    for (WorkTransitionVO t : otherproc.getTransitions()) {
        checkTransitionInSource(t, this, linkmap, delidmap);
    }
    if (otherproc.getSubProcesses() != null) {
        for (ProcessVO subproc : otherproc.getSubProcesses()) {
            lid = subproc.getAttribute(WorkAttributeConstant.LOGICAL_ID);
            SubGraph subgraph;
            if (lid != null && lid.length() > 0)
                subgraph = subgraphmap.get(lid);
            else
                subgraph = null;
            if (subgraph == null) {
                subgraph = this.addSubGraph(subproc, 0, 0, false);
                if (subgraph != null) {
                    if (lid == null || lid.length() == 0) {
                        lid = this.generateLogicalId("P");
                        subgraph.setAttribute(WorkAttributeConstant.LOGICAL_ID, lid);
                    }
                    subgraph.getChanges().setChangeType(Changes.DELETE);
                    delidmap.put(subproc.getProcessId(), subgraph.getId());
                    subgraphmap.put(lid, subgraph);
                } else {
                // TODO when both have same type of subprocesses, cannot
                // add the other one. How do we show the difference?
                }
            } else {
                subgraph.getChanges().setChangeType(Changes.NONE);
                for (ActivityVO a : subproc.getActivities()) {
                    checkActivityInSource(a, subgraph, nodemap, delidmap);
                }
                for (WorkTransitionVO t : subproc.getTransitions()) {
                    checkTransitionInSource(t, subgraph, linkmap, delidmap);
                }
            }
        }
    }
}
Also used : WorkTransitionVO(com.centurylink.mdw.model.value.work.WorkTransitionVO) HashMap(java.util.HashMap) ActivityVO(com.centurylink.mdw.model.value.activity.ActivityVO) MbengNode(com.qwest.mbeng.MbengNode) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO)

Example 2 with ActivityVO

use of com.centurylink.mdw.model.value.activity.ActivityVO in project mdw-designer by CenturyLinkCloud.

the class Graph method reinit.

/**
 * Invoked loading an existing process definition or process instance
 * Invoked after saving the process
 * Also invoked by constructor above.
 */
public void reinit(ProcessVO processVO) {
    this.processVO = processVO;
    this.geo_attribute = WorkAttributeConstant.WORK_DISPLAY_INFO;
    nodes = new Vector<Node>();
    links = new Vector<Link>();
    subgraphs = new ArrayList<SubGraph>();
    notes = null;
    dirtyLevel = CLEAN;
    originalName = processVO.getProcessName();
    zoom = 100;
    largestActivityLogicalId = -1;
    largestTransitionLogicalId = -1;
    Node node, node2;
    Link link;
    ActivityVO nodet;
    WorkTransitionVO conn;
    parseCoord(geo_attribute);
    arrowstyle = getAttribute(Link.ATTRIBUTE_ARROW_STYLE);
    if (arrowstyle == null)
        arrowstyle = Link.ARROW_STYLE_END;
    nodestyle = getAttribute(Node.ATTRIBUTE_NODE_STYLE);
    if (nodestyle == null)
        nodestyle = Node.NODE_STYLE_ICON;
    int i, n;
    List<ActivityVO> nodes0 = processVO.getActivities();
    n = nodes0 == null ? 0 : nodes0.size();
    for (i = 0; i < n; i++) {
        nodet = processVO.getActivities().get(i);
        node = new Node(nodet, this, metainfo);
        nodes.add(node);
    }
    List<WorkTransitionVO> connectors = processVO.getTransitions();
    n = connectors == null ? 0 : connectors.size();
    for (i = 0; i < n; i++) {
        conn = processVO.getTransitions().get(i);
        node = findNode(conn.getFromWorkId());
        node2 = findNode(conn.getToWorkId());
        if (node != null && node2 != null) {
            link = new Link(node, node2, conn, arrowstyle);
            links.add(link);
        }
    }
    List<ProcessVO> subprocs = processVO.getSubProcesses();
    if (subprocs != null) {
        for (ProcessVO subproc : subprocs) {
            SubGraph subgraph = new SubGraph(subproc, this, metainfo, getIconFactory());
            subgraphs.add(subgraph);
        }
    }
    if (processVO.getTextNotes() != null) {
        for (TextNoteVO note : processVO.getTextNotes()) {
            if (notes == null)
                notes = new ArrayList<TextNote>();
            notes.add(new TextNote(note, this));
        }
    }
}
Also used : WorkTransitionVO(com.centurylink.mdw.model.value.work.WorkTransitionVO) ActivityVO(com.centurylink.mdw.model.value.activity.ActivityVO) MbengNode(com.qwest.mbeng.MbengNode) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) TextNoteVO(com.centurylink.mdw.model.value.activity.TextNoteVO)

Example 3 with ActivityVO

use of com.centurylink.mdw.model.value.activity.ActivityVO in project mdw-designer by CenturyLinkCloud.

the class Graph method addSubGraph.

public SubGraph addSubGraph(int x, int y, String subtype, boolean recordchange) {
    Long pProcessId = genNodeId();
    String pDesc = null;
    List<ExternalEventVO> pExtEvents = null;
    ProcessVO subproc = new ProcessVO(pProcessId, subtype, pDesc, pExtEvents);
    if (getProcessVO() != null && getProcessVO().isInRuleSet())
        subproc.setInRuleSet(true);
    List<AttributeVO> attributes = new ArrayList<AttributeVO>();
    AttributeVO a = new AttributeVO(null, WorkAttributeConstant.PROCESS_VISIBILITY, ProcessVisibilityConstant.EMBEDDED);
    attributes.add(a);
    a = new AttributeVO(null, WorkAttributeConstant.EMBEDDED_PROCESS_TYPE, subtype);
    attributes.add(a);
    subproc.setAttributes(attributes);
    subproc.setActivities(new ArrayList<ActivityVO>());
    subproc.setTransitions(new ArrayList<WorkTransitionVO>());
    subproc.setVariables(new ArrayList<VariableVO>());
    List<ProcessVO> subprocs = processVO.getSubProcesses();
    if (subprocs == null) {
        subprocs = new ArrayList<ProcessVO>();
        processVO.setSubProcesses(subprocs);
    }
    subprocs.add(subproc);
    SubGraph subgraph = new SubGraph(subproc, this, metainfo, getIconFactory());
    subgraph.x = x;
    subgraph.y = y;
    subgraph.w = 440;
    subgraph.h = 120;
    // need to add it before generating first node to avoid dup id
    subgraphs.add(subgraph);
    Node node1 = addNode(subgraph, metainfo.getStartActivity(), x + 40, y + 40, recordchange);
    node1.nodet.setActivityName("Start");
    if (subtype.equals(ProcessVisibilityConstant.EMBEDDED_ERROR_PROCESS)) {
        ActivityImplementorVO nmi = metainfo.getTaskActivity();
        Node node2 = addNode(subgraph, nmi, x + 170, y + 30, recordchange);
        Node node3 = addNode(subgraph, metainfo.getStopActivity(), x + 340, y + 40, recordchange);
        node3.nodet.setActivityName("Stop");
        addLink(node1, node2, EventType.FINISH, Link.ELBOW, 2, recordchange);
        addLink(node2, node3, EventType.FINISH, Link.ELBOW, 2, recordchange);
    } else {
        Node node3 = addNode(subgraph, metainfo.getStopActivity(), x + 340, y + 40, recordchange);
        node3.nodet.setActivityName("Stop");
        addLink(node1, node3, EventType.FINISH, Link.ELBOW, 2, recordchange);
    }
    if (recordchange)
        subgraph.getChanges().setChangeType(Changes.NEW);
    setDirtyLevel(DIRTY);
    return subgraph;
}
Also used : WorkTransitionVO(com.centurylink.mdw.model.value.work.WorkTransitionVO) AttributeVO(com.centurylink.mdw.model.value.attribute.AttributeVO) ActivityVO(com.centurylink.mdw.model.value.activity.ActivityVO) ExternalEventVO(com.centurylink.mdw.model.value.event.ExternalEventVO) MbengNode(com.qwest.mbeng.MbengNode) ArrayList(java.util.ArrayList) ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO)

Example 4 with ActivityVO

use of com.centurylink.mdw.model.value.activity.ActivityVO in project mdw-designer by CenturyLinkCloud.

the class Graph method addSubGraph.

/**
 * This is for paste
 * @param source
 * @return
 */
public SubGraph addSubGraph(ProcessVO source, int xoff, int yoff, boolean recordchange) {
    Long pProcessId = genNodeId();
    String subproctype = source.getAttribute(WorkAttributeConstant.EMBEDDED_PROCESS_TYPE);
    if (subproctype == null)
        subproctype = ProcessVisibilityConstant.EMBEDDED_ERROR_PROCESS;
    ProcessVO existing = processVO.findEmbeddedProcess(subproctype);
    if (existing != null)
        return null;
    String subprocName = subproctype;
    ProcessVO subproc = new ProcessVO(pProcessId, subprocName, source.getProcessDescription(), null);
    List<AttributeVO> attributes = new ArrayList<AttributeVO>();
    for (AttributeVO a : source.getAttributes()) {
        if (a.getAttributeName().equals(WorkAttributeConstant.ENTRY_TRANSITION_ID))
            continue;
        if (a.getAttributeName().equals(WorkAttributeConstant.START_TRANSITION_ID))
            continue;
        AttributeVO attr = new AttributeVO(a.getAttributeName(), a.getAttributeValue());
        attributes.add(attr);
    }
    subproc.setAttributes(attributes);
    subproc.setActivities(new ArrayList<ActivityVO>());
    subproc.setTransitions(new ArrayList<WorkTransitionVO>());
    subproc.setVariables(new ArrayList<VariableVO>());
    String lid = generateLogicalId("P");
    subproc.setAttribute(WorkAttributeConstant.LOGICAL_ID, lid);
    List<ProcessVO> subprocs = processVO.getSubProcesses();
    if (subprocs == null) {
        subprocs = new ArrayList<ProcessVO>();
        processVO.setSubProcesses(subprocs);
    }
    subprocs.add(subproc);
    SubGraph subgraph = new SubGraph(subproc, this, metainfo, getIconFactory());
    subgraphs.add(subgraph);
    HashMap<Long, Long> map = new HashMap<Long, Long>();
    for (ActivityVO a : source.getActivities()) {
        Node node = this.addNode(subgraph, a, 0, 0, recordchange, true);
        map.put(a.getActivityId(), node.getActivityId());
    }
    for (WorkTransitionVO t : source.getTransitions()) {
        this.addLink(subgraph, t, map.get(t.getFromWorkId()), map.get(t.getToWorkId()), 0, 0, recordchange, true);
    }
    if (xoff != 0 || yoff != 0) {
        subgraph.move(subgraph.x + xoff, subgraph.y + yoff, arrowstyle);
    }
    if (recordchange)
        subgraph.getChanges().setChangeType(Changes.NEW);
    setDirtyLevel(DIRTY);
    return subgraph;
}
Also used : WorkTransitionVO(com.centurylink.mdw.model.value.work.WorkTransitionVO) AttributeVO(com.centurylink.mdw.model.value.attribute.AttributeVO) ActivityVO(com.centurylink.mdw.model.value.activity.ActivityVO) HashMap(java.util.HashMap) MbengNode(com.qwest.mbeng.MbengNode) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO)

Example 5 with ActivityVO

use of com.centurylink.mdw.model.value.activity.ActivityVO in project mdw-designer by CenturyLinkCloud.

the class Graph method addNode.

private Node addNode(GraphCommon owner, ActivityImplementorVO nmi, int x, int y, boolean recordchange) {
    String name = "New " + nmi.getLabel();
    if (nmi.isManualTask()) {
        if (owner instanceof SubGraph)
            name = processVO.getProcessName() + " Fallout";
        else
            name = "New Task for " + processVO.getProcessName();
    }
    Long pActId = genNodeId();
    String pDesc = null;
    String pActImplClass = nmi.getImplementorClassName();
    ArrayList<AttributeVO> pAttribs = new ArrayList<AttributeVO>();
    if (nmi.isManualTask()) {
        pAttribs.add(new AttributeVO(TaskActivity.ATTRIBUTE_TASK_NAME, name));
        pAttribs.add(new AttributeVO(TaskActivity.ATTRIBUTE_TASK_CATEGORY, "COM"));
        pAttribs.add(new AttributeVO(TaskActivity.ATTRIBUTE_TASK_VARIABLES, TaskVO.getVariablesAsString(processVO.getVariables(), null)));
    }
    ActivityVO nodet = new ActivityVO(pActId, name, pDesc, pActImplClass, pAttribs);
    owner.getProcessVO().getActivities().add(nodet);
    Node node = new Node(nodet, owner, metainfo);
    String iconname = node.getIconName();
    javax.swing.Icon icon = getIconFactory().getIcon(iconname);
    if (nodestyle.equals(Node.NODE_STYLE_ICON)) {
        node.w = icon.getIconWidth();
        node.h = icon.getIconHeight();
    } else {
        if (icon instanceof ImageIcon) {
            node.w = 100;
            node.h = 60;
        } else {
            node.w = 60;
            node.h = 40;
        }
    }
    node.x = x;
    node.y = y;
    owner.nodes.add(node);
    String xmldesc = nmi.getAttributeDescription();
    if (xmldesc != null && xmldesc.length() > 0) {
        FormatDom fmter = new FormatDom();
        DomDocument doc = new DomDocument();
        try {
            fmter.load(doc, xmldesc);
            MbengNode widget;
            String default_value, attr_name;
            for (widget = doc.getRootNode().getFirstChild(); widget != null; widget = widget.getNextSibling()) {
                default_value = widget.getAttribute("DEFAULT");
                if (default_value == null)
                    continue;
                if (widget.getAttribute("UNITS_ATTR") != null)
                    continue;
                attr_name = widget.getAttribute("NAME");
                if (attr_name == null)
                    continue;
                if (default_value.equals("$DefaultNotices")) {
                    node.setAttribute(attr_name, TaskVO.getDefaultNotices());
                } else
                    node.setAttribute(attr_name, default_value);
            }
        } catch (MbengException e) {
        }
    }
    if (recordchange)
        node.getChanges().setChangeType(Changes.NEW);
    setDirtyLevel(DIRTY);
    return node;
}
Also used : ImageIcon(javax.swing.ImageIcon) MbengException(com.qwest.mbeng.MbengException) AttributeVO(com.centurylink.mdw.model.value.attribute.AttributeVO) ActivityVO(com.centurylink.mdw.model.value.activity.ActivityVO) MbengNode(com.qwest.mbeng.MbengNode) FormatDom(com.qwest.mbeng.FormatDom) ArrayList(java.util.ArrayList) MbengNode(com.qwest.mbeng.MbengNode) DomDocument(com.qwest.mbeng.DomDocument)

Aggregations

ActivityVO (com.centurylink.mdw.model.value.activity.ActivityVO)17 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)11 ArrayList (java.util.ArrayList)8 WorkTransitionVO (com.centurylink.mdw.model.value.work.WorkTransitionVO)6 MbengNode (com.qwest.mbeng.MbengNode)6 HashMap (java.util.HashMap)5 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)4 AttributeVO (com.centurylink.mdw.model.value.attribute.AttributeVO)4 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)3 HashSet (java.util.HashSet)2 TextNoteVO (com.centurylink.mdw.model.value.activity.TextNoteVO)1 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)1 ExternalEventVO (com.centurylink.mdw.model.value.event.ExternalEventVO)1 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)1 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)1 DomDocument (com.qwest.mbeng.DomDocument)1 FormatDom (com.qwest.mbeng.FormatDom)1 MbengException (com.qwest.mbeng.MbengException)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1