Search in sources :

Example 1 with AttributeVO

use of com.centurylink.mdw.model.value.attribute.AttributeVO in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method exportTaskTemplates.

public String exportTaskTemplates(Long packageId, ProgressMonitor monitor) throws DataAccessException, ActionCancelledException {
    monitor.subTask("Loading package");
    PackageVO packageVO = loadPackage(packageId, true);
    monitor.progress(30);
    if (monitor.isCanceled())
        throw new ActionCancelledException();
    if (monitor != null)
        monitor.progress(5);
    if (monitor != null)
        monitor.subTask(EXPORTXML);
    PackageDocument pkgDoc = PackageDocument.Factory.newInstance();
    MDWPackage pkg = pkgDoc.addNewPackage();
    pkg.setName(packageVO.getName());
    pkg.setVersion(PackageVO.formatVersion(packageVO.getVersion()));
    TaskTemplatesDocument.TaskTemplates templates = pkg.addNewTaskTemplates();
    if (packageVO.getTaskTemplates() != null) {
        for (TaskVO taskVO : packageVO.getTaskTemplates()) {
            if (taskVO.getVersion() > 0) {
                TaskTemplate templateDef = templates.addNewTask();
                templateDef.setLogicalId(taskVO.getLogicalId());
                templateDef.setVersion(RuleSetVO.formatVersion(taskVO.getVersion()));
                templateDef.setAssetName(taskVO.getName());
                templateDef.setName(taskVO.getTaskName());
                if (taskVO.getTaskCategory() != null)
                    templateDef.setCategory(taskVO.getTaskCategory());
                if (taskVO.getComment() != null)
                    templateDef.setDescription(taskVO.getComment());
                if (taskVO.getAttributes() != null) {
                    for (AttributeVO attrVO : taskVO.getAttributes()) {
                        if (!"TaskDescription".equals(attrVO.getAttributeName())) {
                            Attribute attr = templateDef.addNewAttribute();
                            attr.setName(attrVO.getAttributeName());
                            attr.setStringValue(attrVO.getAttributeValue());
                        }
                    }
                }
            }
        }
    }
    String xml = pkgDoc.xmlText(new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(2));
    if (monitor != null && monitor.isCanceled())
        throw new ActionCancelledException();
    if (monitor != null)
        monitor.progress(40);
    return xml;
}
Also used : PackageDocument(com.centurylink.mdw.bpm.PackageDocument) TaskTemplate(com.centurylink.mdw.task.TaskTemplate) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) AttributeVO(com.centurylink.mdw.model.value.attribute.AttributeVO) CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) TaskTemplatesDocument(com.centurylink.mdw.task.TaskTemplatesDocument) Attribute(com.centurylink.mdw.task.Attribute) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) XmlOptions(org.apache.xmlbeans.XmlOptions) TaskVO(com.centurylink.mdw.model.value.task.TaskVO) MDWPackage(com.centurylink.mdw.bpm.MDWPackage)

Example 2 with AttributeVO

use of com.centurylink.mdw.model.value.attribute.AttributeVO 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 3 with AttributeVO

use of com.centurylink.mdw.model.value.attribute.AttributeVO 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 4 with AttributeVO

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

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

AttributeVO (com.centurylink.mdw.model.value.attribute.AttributeVO)24 ArrayList (java.util.ArrayList)15 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)5 ActivityVO (com.centurylink.mdw.model.value.activity.ActivityVO)4 WorkTransitionVO (com.centurylink.mdw.model.value.work.WorkTransitionVO)4 MbengNode (com.qwest.mbeng.MbengNode)4 List (java.util.List)4 PackageDocument (com.centurylink.mdw.bpm.PackageDocument)3 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)3 CustomAttributeVO (com.centurylink.mdw.model.value.attribute.CustomAttributeVO)3 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)3 ProcessDefinitionDocument (com.centurylink.mdw.bpm.ProcessDefinitionDocument)2 Property (com.centurylink.mdw.bpm.PropertyDocument.Property)2 PropertyGroup (com.centurylink.mdw.bpm.PropertyGroupDocument.PropertyGroup)2 ExternalEventVO (com.centurylink.mdw.model.value.event.ExternalEventVO)2 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)2 AttributeDialog (com.centurylink.mdw.plugin.designer.dialogs.AttributeDialog)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 XmlOptions (org.apache.xmlbeans.XmlOptions)2