Search in sources :

Example 1 with ProcessBuildData

use of org.jbpm.compiler.xml.ProcessBuildData in project jbpm by kiegroup.

the class ProcessHandler method start.

public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    final String id = attrs.getValue("id");
    final String name = attrs.getValue("name");
    final String version = attrs.getValue("version");
    final String type = attrs.getValue("type");
    final String packageName = attrs.getValue("package-name");
    final String routerLayout = attrs.getValue("routerLayout");
    RuleFlowProcess process = new RuleFlowProcess();
    process.setId(id);
    process.setName(name);
    process.setVersion(version);
    process.setType(type);
    process.setPackageName(packageName);
    if (routerLayout != null) {
        process.setMetaData("routerLayout", new Integer(routerLayout));
    }
    ((ProcessBuildData) parser.getData()).addProcess(process);
    return process;
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData)

Example 2 with ProcessBuildData

use of org.jbpm.compiler.xml.ProcessBuildData in project jbpm by kiegroup.

the class TaskHandler method handleNode.

protected void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    super.handleNode(node, element, uri, localName, parser);
    itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
    dataTypeInputs.clear();
    dataTypeOutputs.clear();
    WorkItemNode workItemNode = (WorkItemNode) node;
    String name = getTaskName(element);
    Work work = new WorkImpl();
    work.setName(name);
    workItemNode.setWork(work);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("ioSpecification".equals(nodeName)) {
            readIoSpecification(xmlNode, dataInputs, dataOutputs);
        } else if ("dataInputAssociation".equals(nodeName)) {
            readDataInputAssociation(xmlNode, workItemNode, dataInputs);
        } else if ("dataOutputAssociation".equals(nodeName)) {
            readDataOutputAssociation(xmlNode, workItemNode, dataOutputs);
        }
        xmlNode = xmlNode.getNextSibling();
    }
    workItemNode.setMetaData("DataInputs", new HashMap<String, String>(dataTypeInputs));
    workItemNode.setMetaData("DataOutputs", new HashMap<String, String>(dataTypeOutputs));
    handleScript(workItemNode, element, "onEntry");
    handleScript(workItemNode, element, "onExit");
    String compensation = element.getAttribute("isForCompensation");
    if (compensation != null) {
        boolean isForCompensation = Boolean.parseBoolean(compensation);
        if (isForCompensation) {
            workItemNode.setMetaData("isForCompensation", isForCompensation);
        }
    }
}
Also used : ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) ItemDefinition(org.jbpm.bpmn2.core.ItemDefinition) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) Work(org.jbpm.process.core.Work) WorkImpl(org.jbpm.process.core.impl.WorkImpl)

Example 3 with ProcessBuildData

use of org.jbpm.compiler.xml.ProcessBuildData in project jbpm by kiegroup.

the class PropertyHandler method start.

@SuppressWarnings("unchecked")
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    final String id = attrs.getValue("id");
    final String name = attrs.getValue("name");
    final String itemSubjectRef = attrs.getValue("itemSubjectRef");
    Object parent = parser.getParent();
    if (parent instanceof ContextContainer) {
        ContextContainer contextContainer = (ContextContainer) parent;
        VariableScope variableScope = (VariableScope) contextContainer.getDefaultContext(VariableScope.VARIABLE_SCOPE);
        List variables = variableScope.getVariables();
        Variable variable = new Variable();
        // if name is given use it as variable name instead of id
        if (name != null && name.length() > 0) {
            variable.setName(name);
        } else {
            variable.setName(id);
        }
        variable.setMetaData("ItemSubjectRef", itemSubjectRef);
        variables.add(variable);
        ((ProcessBuildData) parser.getData()).setMetaData("Variable", variable);
        return variable;
    }
    return new Variable();
}
Also used : ContextContainer(org.jbpm.process.core.ContextContainer) Variable(org.jbpm.process.core.context.variable.Variable) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) List(java.util.List) VariableScope(org.jbpm.process.core.context.variable.VariableScope)

Example 4 with ProcessBuildData

use of org.jbpm.compiler.xml.ProcessBuildData in project jbpm by kiegroup.

the class SignalHandler method start.

@SuppressWarnings("unchecked")
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    // according to the (Semantic.)xsd, both the name and structureRef are optional
    String id = attrs.getValue("id");
    // referred to by the signalEventDefinition.signalRef attr
    String name = attrs.getValue("name");
    String structureRef = attrs.getValue("structureRef");
    ProcessBuildData buildData = (ProcessBuildData) parser.getData();
    Map<String, Signal> signals = (Map<String, Signal>) buildData.getMetaData("Signals");
    if (signals == null) {
        signals = new HashMap<String, Signal>();
        buildData.setMetaData("Signals", signals);
    }
    Signal s = new Signal(id, name, structureRef);
    signals.put(id, s);
    return s;
}
Also used : ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with ProcessBuildData

use of org.jbpm.compiler.xml.ProcessBuildData in project jbpm by kiegroup.

the class BoundaryEventHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Node node = (Node) parser.getCurrent();
    String attachedTo = element.getAttribute("attachedToRef");
    Attr cancelActivityAttr = element.getAttributeNode("cancelActivity");
    boolean cancelActivity = Boolean.parseBoolean(cancelActivityAttr.getValue());
    // determine type of event definition, so the correct type of node can be generated
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("escalationEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleEscalationNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        } else if ("errorEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleErrorNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        } else if ("timerEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleTimerNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        } else if ("compensateEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleCompensationNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        } else if ("signalEventDefinition".equals(nodeName)) {
            // reuse already created EventNode
            handleSignalNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        } else if ("conditionalEventDefinition".equals(nodeName)) {
            handleConditionNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        } else if ("messageEventDefinition".equals(nodeName)) {
            handleMessageNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) Element(org.w3c.dom.Element) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.jbpm.workflow.core.Node) NodeContainer(org.jbpm.workflow.core.NodeContainer) Attr(org.w3c.dom.Attr)

Aggregations

ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)28 Map (java.util.Map)12 Element (org.w3c.dom.Element)11 Node (org.jbpm.workflow.core.Node)8 NodeContainer (org.jbpm.workflow.core.NodeContainer)8 HashMap (java.util.HashMap)7 List (java.util.List)7 ArrayList (java.util.ArrayList)5 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)4 ActionNode (org.jbpm.workflow.core.node.ActionNode)4 ForEachNode (org.jbpm.workflow.core.node.ForEachNode)4 Error (org.jbpm.bpmn2.core.Error)3 Escalation (org.jbpm.bpmn2.core.Escalation)3 ItemDefinition (org.jbpm.bpmn2.core.ItemDefinition)3 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)3 EndNode (org.jbpm.workflow.core.node.EndNode)3 EventNode (org.jbpm.workflow.core.node.EventNode)3 FaultNode (org.jbpm.workflow.core.node.FaultNode)3 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)3 Message (org.jbpm.bpmn2.core.Message)2