Search in sources :

Example 1 with ElementLink

use of de.hpi.bpt.scylla.creation.ElementLink in project scylla by bptlab.

the class SimulationConfigurationCreator method createModelElement.

/**
 * Parses a process model element to a new sc element with wrapper object
 * @param child : Process model element to be parsed (e.g. Task)
 * @param addTo : Context for the new sc element to be added to (normally sc root or a subprocess)
 */
private void createModelElement(Element child, ElementLink addTo) {
    String id = child.getAttributeValue("id");
    // Don't add elements that are already parsed (e.g when loading an existing, incomplete SC)
    if (id != null && !id.isEmpty() && elements.containsKey(id))
        return;
    String name = child.getName();
    switch(name) {
        case "startEvent":
            // ignore subProcess startEvents
            if (!addTo.equals(this))
                break;
            setStartEvent(new StartEvent(id));
            getStartEvent().addTo(addTo);
            elements.put(getStartEvent().getId(), getStartEvent());
            break;
        case "subProcess":
            SubProcess s = new SubProcess(id, child.getAttributeValue("name"));
            s.addTo(addTo);
            elements.put(s.getId(), s);
            addProcessModelElements(child, s);
            break;
        case "exclusiveGateway":
            // Note: getChildren("outgoing",Nsp); not possible as there is no single unique namespace
            List<Element> branches = child.getChildren();
            List<String> branchids = new ArrayList<String>();
            for (Element b : branches) {
                if (b.getName().equals("outgoing"))
                    branchids.add(b.getValue());
            }
            if (branchids.size() <= 1) {
                elements.put(id, new ElementLink(child) {
                });
                // No branching probabilities for a join gateway - no definition needed
                break;
            }
            ExclusiveGateway eg = new ExclusiveGateway(id, branchids);
            elements.put(eg.getId(), eg);
            eg.addTo(addTo);
            break;
        case "sequenceFlow":
            flows.put(id, new String[] { child.getAttributeValue("sourceRef"), child.getAttributeValue("targetRef") });
            break;
        default:
            if (name.equals("task") || name.endsWith("Task")) {
                Task t = new Task(id, child.getAttributeValue("name"));
                t.addTo(addTo);
                elements.put(t.getId(), t);
            } else if (name.endsWith("Event")) {
                elements.put(id, new ElementLink(child) {
                });
            }
            break;
    }
}
Also used : Element(org.jdom2.Element) ElementLink(de.hpi.bpt.scylla.creation.ElementLink) ArrayList(java.util.ArrayList)

Example 2 with ElementLink

use of de.hpi.bpt.scylla.creation.ElementLink in project scylla by bptlab.

the class ExclusiveGatewayPanel method initBranches.

public void initBranches() {
    for (String branch : gateway.getBranches()) {
        ElementLink target = scCreator.getFlowTarget(branch);
        panelBranches.add(createBranchPanel(branch, target.getName()));
    }
}
Also used : ElementLink(de.hpi.bpt.scylla.creation.ElementLink)

Aggregations

ElementLink (de.hpi.bpt.scylla.creation.ElementLink)2 ArrayList (java.util.ArrayList)1 Element (org.jdom2.Element)1