Search in sources :

Example 1 with WorkTransitionVO

use of com.centurylink.mdw.model.value.work.WorkTransitionVO 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 WorkTransitionVO

use of com.centurylink.mdw.model.value.work.WorkTransitionVO 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 WorkTransitionVO

use of com.centurylink.mdw.model.value.work.WorkTransitionVO 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 WorkTransitionVO

use of com.centurylink.mdw.model.value.work.WorkTransitionVO in project mdw-designer by CenturyLinkCloud.

the class Graph method addLink.

/**
 * @param from
 * @param to
 * @param type
 * @param style
 * @param control_points
 * @return
 */
public Link addLink(Node from, Node to, Integer type, String style, int control_points, boolean recordchange) {
    GraphCommon owner = from.graph;
    WorkTransitionVO conn = new WorkTransitionVO();
    conn.setFromWorkId(from.nodet.getActivityId());
    conn.setToWorkId(to.nodet.getActivityId());
    conn.setEventType(EventType.FINISH);
    conn.setWorkTransitionId(new Long(0));
    conn.setAttributes(new ArrayList<AttributeVO>());
    String av = processVO.getAttribute(WorkTransitionAttributeConstant.TRANSITION_RETRY_COUNT);
    if (av != null)
        conn.setAttribute(WorkTransitionAttributeConstant.TRANSITION_RETRY_COUNT, av);
    owner.getProcessVO().getTransitions().add(conn);
    if (null != type)
        conn.setEventType(type);
    Link link = new Link(from, to, conn, arrowstyle);
    link.setType(style);
    owner.links.add(link);
    setDirtyLevel(DIRTY);
    link.calcLinkPosition(control_points, arrowstyle);
    if (recordchange)
        link.getChanges().setChangeType(Changes.NEW);
    return link;
}
Also used : WorkTransitionVO(com.centurylink.mdw.model.value.work.WorkTransitionVO) AttributeVO(com.centurylink.mdw.model.value.attribute.AttributeVO)

Example 5 with WorkTransitionVO

use of com.centurylink.mdw.model.value.work.WorkTransitionVO 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)

Aggregations

WorkTransitionVO (com.centurylink.mdw.model.value.work.WorkTransitionVO)13 ActivityVO (com.centurylink.mdw.model.value.activity.ActivityVO)6 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)6 ArrayList (java.util.ArrayList)6 AttributeVO (com.centurylink.mdw.model.value.attribute.AttributeVO)4 MbengNode (com.qwest.mbeng.MbengNode)4 HashMap (java.util.HashMap)3 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)2 HashSet (java.util.HashSet)2 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 FormDataDocument (com.centurylink.mdw.model.FormDataDocument)1 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)1 TextNoteVO (com.centurylink.mdw.model.value.activity.TextNoteVO)1 ExternalEventVO (com.centurylink.mdw.model.value.event.ExternalEventVO)1 TaskInstanceVO (com.centurylink.mdw.model.value.task.TaskInstanceVO)1 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)1 WorkTransitionInstanceVO (com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO)1 MbengException (com.qwest.mbeng.MbengException)1