Search in sources :

Example 1 with ScriptNode

use of ru.runa.wfe.lang.ScriptNode in project runawfe-free-server by processtech.

the class JpdlXmlReader method readNode.

private void readNode(ProcessDefinition processDefinition, Element element, Node node) {
    node.setNodeId(element.attributeValue(ID_ATTR));
    node.setName(element.attributeValue(NAME_ATTR));
    node.setDescription(element.elementTextTrim(DESCRIPTION_NODE));
    String nodeAsyncExecutionString = element.attributeValue(NODE_ASYNC_EXECUTION);
    if (!Strings.isNullOrEmpty(nodeAsyncExecutionString)) {
        node.setAsyncExecution("new".equals(nodeAsyncExecutionString));
    }
    processDefinition.addNode(node);
    readEvents(processDefinition, element, node);
    // save the transitions and parse them at the end
    addUnresolvedTransitionDestination(element, node);
    if (node instanceof StartNode) {
        StartNode startNode = (StartNode) node;
        Element startTaskElement = element.element(TASK_NODE);
        if (startTaskElement != null) {
            readTask(processDefinition, startTaskElement, startNode, element);
        }
    }
    // }
    if (node instanceof VariableContainerNode) {
        VariableContainerNode variableContainerNode = (VariableContainerNode) node;
        variableContainerNode.setVariableMappings(readVariableMappings(processDefinition, element));
    }
    if (node instanceof TaskNode) {
        TaskNode taskNode = (TaskNode) node;
        taskNode.setAsync(Boolean.valueOf(element.attributeValue(ASYNC_ATTR, "false")));
        taskNode.setCompletionMode(AsyncCompletionMode.valueOf(element.attributeValue(ASYNC_COMPLETION_MODE_ATTR, AsyncCompletionMode.NEVER.name())));
        readTasks(processDefinition, element, taskNode);
    }
    if (node instanceof MultiTaskNode) {
        MultiTaskNode multiTaskNode = (MultiTaskNode) node;
        multiTaskNode.setAsync(Boolean.valueOf(element.attributeValue(ASYNC_ATTR, "false")));
        multiTaskNode.setCompletionMode(AsyncCompletionMode.valueOf(element.attributeValue(ASYNC_COMPLETION_MODE_ATTR, AsyncCompletionMode.NEVER.name())));
        multiTaskNode.setSynchronizationMode(MultiTaskSynchronizationMode.valueOf(element.attributeValue(TASK_EXECUTION_MODE_ATTR, MultiTaskSynchronizationMode.LAST.name())));
        multiTaskNode.setDiscriminatorVariableName(element.attributeValue(TASK_EXECUTORS_ATTR));
        multiTaskNode.setDiscriminatorUsage(element.attributeValue(TASK_EXECUTORS_USAGE));
        multiTaskNode.setCreationMode(MultiTaskCreationMode.valueOf(element.attributeValue(MULTI_TASK_CREATION_MODE, MultiTaskCreationMode.BY_EXECUTORS.name())));
        multiTaskNode.setVariableMappings(readVariableMappings(processDefinition, element));
        multiTaskNode.setDiscriminatorCondition(element.attributeValue(EXECUTION_CONDITION));
        readTasks(processDefinition, element, multiTaskNode);
    }
    if (node instanceof SubprocessNode) {
        SubprocessNode subprocessNode = (SubprocessNode) node;
        Element subProcessElement = element.element(SUB_PROCESS_NODE);
        if (subProcessElement != null) {
            subprocessNode.setSubProcessName(subProcessElement.attributeValue(NAME_ATTR));
            subprocessNode.setEmbedded(Boolean.parseBoolean(subProcessElement.attributeValue(EMBEDDED, "false")));
            subprocessNode.setTransactional(Boolean.parseBoolean(subProcessElement.attributeValue(TRANSACTIONAL, "false")));
            subprocessNode.setValidateAtStart(Boolean.parseBoolean(subProcessElement.attributeValue(VALIDATE_AT_START, "false")));
            subprocessNode.setDisableCascadingSuspension(Boolean.parseBoolean(subProcessElement.attributeValue(DISABLE_CASCADING_SUSPENSION, "false")));
        }
        if (node instanceof MultiSubprocessNode) {
            ((MultiSubprocessNode) node).setDiscriminatorCondition(element.attributeValue(EXECUTION_CONDITION));
        }
    }
    if (node instanceof Decision) {
        Decision decision = (Decision) node;
        Element decisionHandlerElement = element.element(HANDLER_NODE);
        if (decisionHandlerElement == null) {
            throw new InvalidDefinitionException(processDefinition.getName(), "No handler in decision found: " + node);
        }
        decision.setDelegation(readDelegation(processDefinition, decisionHandlerElement));
    }
    if (node instanceof SendMessageNode) {
        SendMessageNode sendMessageNode = (SendMessageNode) node;
        sendMessageNode.setTtlDuration(element.attributeValue(DUEDATE_ATTR, "1 days"));
    }
    if (node instanceof ScriptNode) {
        ScriptNode serviceTask = (ScriptNode) node;
        Element actionElement = element.element(ACTION_NODE);
        Preconditions.checkNotNull(actionElement, "No action defined in " + serviceTask);
        serviceTask.setDelegation(readDelegation(processDefinition, actionElement));
    }
    readNodeTimers(processDefinition, element, node);
}
Also used : SendMessageNode(ru.runa.wfe.lang.SendMessageNode) StartNode(ru.runa.wfe.lang.StartNode) EmbeddedSubprocessStartNode(ru.runa.wfe.lang.EmbeddedSubprocessStartNode) TaskNode(ru.runa.wfe.lang.TaskNode) MultiTaskNode(ru.runa.wfe.lang.MultiTaskNode) MultiTaskNode(ru.runa.wfe.lang.MultiTaskNode) InvalidDefinitionException(ru.runa.wfe.definition.InvalidDefinitionException) GraphElement(ru.runa.wfe.lang.GraphElement) Element(org.dom4j.Element) MultiSubprocessNode(ru.runa.wfe.lang.MultiSubprocessNode) SubprocessNode(ru.runa.wfe.lang.SubprocessNode) ScriptNode(ru.runa.wfe.lang.ScriptNode) MultiSubprocessNode(ru.runa.wfe.lang.MultiSubprocessNode) Decision(ru.runa.wfe.lang.jpdl.Decision) VariableContainerNode(ru.runa.wfe.lang.VariableContainerNode)

Example 2 with ScriptNode

use of ru.runa.wfe.lang.ScriptNode in project runawfe-free-server by processtech.

the class BpmnXmlReader method readNode.

private void readNode(ProcessDefinition processDefinition, Element element, Map<String, String> properties, Node node) {
    node.setNodeId(element.attributeValue(ID));
    node.setName(element.attributeValue(NAME));
    node.setDescription(element.elementTextTrim(DOCUMENTATION));
    if (properties.containsKey(NODE_ASYNC_EXECUTION)) {
        node.setAsyncExecution("new".equals(properties.get(NODE_ASYNC_EXECUTION)));
    }
    processDefinition.addNode(node);
    if (node instanceof StartNode) {
        StartNode startNode = (StartNode) node;
        readTask(processDefinition, element, properties, startNode);
    }
    if (node instanceof BaseTaskNode) {
        BaseTaskNode taskNode = (BaseTaskNode) node;
        readTask(processDefinition, element, properties, taskNode);
        if (properties.containsKey(ASYNC)) {
            taskNode.setAsync(Boolean.valueOf(properties.get(ASYNC)));
        }
        if (properties.containsKey(ASYNC_COMPLETION_MODE)) {
            taskNode.setCompletionMode(AsyncCompletionMode.valueOf(properties.get(ASYNC_COMPLETION_MODE)));
        }
        readActionHandlers(processDefinition, taskNode, element);
    }
    if (node instanceof VariableContainerNode) {
        VariableContainerNode variableContainerNode = (VariableContainerNode) node;
        variableContainerNode.setVariableMappings(readVariableMappings(element));
    }
    if (node instanceof SubprocessNode) {
        SubprocessNode subprocessNode = (SubprocessNode) node;
        subprocessNode.setSubProcessName(element.attributeValue(QName.get(PROCESS, RUNA_NAMESPACE)));
        if (properties.containsKey(TRANSACTIONAL)) {
            subprocessNode.setTransactional(Boolean.parseBoolean(properties.get(TRANSACTIONAL)));
        }
        if (properties.containsKey(EMBEDDED)) {
            subprocessNode.setEmbedded(Boolean.parseBoolean(properties.get(EMBEDDED)));
        }
        if (properties.containsKey(ASYNC)) {
            subprocessNode.setAsync(Boolean.valueOf(properties.get(ASYNC)));
        }
        if (properties.containsKey(ASYNC_COMPLETION_MODE)) {
            subprocessNode.setCompletionMode(AsyncCompletionMode.valueOf(properties.get(ASYNC_COMPLETION_MODE)));
        }
        if (properties.containsKey(VALIDATE_AT_START)) {
            subprocessNode.setValidateAtStart(Boolean.parseBoolean(properties.get(VALIDATE_AT_START)));
        }
        if (properties.containsKey(DISABLE_CASCADING_SUSPENSION)) {
            subprocessNode.setDisableCascadingSuspension(Boolean.parseBoolean(properties.get(DISABLE_CASCADING_SUSPENSION)));
        }
        if (node instanceof MultiSubprocessNode && properties.containsKey(DISCRIMINATOR_CONDITION)) {
            ((MultiSubprocessNode) node).setDiscriminatorCondition(properties.get(DISCRIMINATOR_CONDITION));
        }
    }
    if (node instanceof ExclusiveGateway) {
        ExclusiveGateway gateway = (ExclusiveGateway) node;
        gateway.setDelegation(readDelegation(element, properties, false));
    }
    if (node instanceof BusinessRule) {
        BusinessRule businessRule = (BusinessRule) node;
        businessRule.setDelegation(readDelegation(element, properties, false));
    }
    if (node instanceof TimerNode) {
        TimerNode timerNode = (TimerNode) node;
        readTimer(timerNode, element);
    }
    if (node instanceof ScriptNode) {
        ScriptNode serviceTask = (ScriptNode) node;
        serviceTask.setDelegation(readDelegation(element, properties, true));
    }
    if (node instanceof BaseMessageNode) {
        BaseMessageNode baseMessageNode = (BaseMessageNode) node;
        baseMessageNode.setEventType(MessageEventType.valueOf(element.attributeValue(QName.get(TYPE, RUNA_NAMESPACE), MessageEventType.message.name())));
    }
    if (node instanceof SendMessageNode) {
        SendMessageNode sendMessageNode = (SendMessageNode) node;
        sendMessageNode.setTtlDuration(element.attributeValue(QName.get(TIME_DURATION, RUNA_NAMESPACE), "1 days"));
    }
    if (node instanceof TextAnnotation) {
        node.setName("TextAnnotation_" + node.getNodeId());
        node.setDescription(element.elementTextTrim(TEXT));
    }
}
Also used : SendMessageNode(ru.runa.wfe.lang.SendMessageNode) StartNode(ru.runa.wfe.lang.StartNode) EmbeddedSubprocessStartNode(ru.runa.wfe.lang.EmbeddedSubprocessStartNode) ExclusiveGateway(ru.runa.wfe.lang.bpmn2.ExclusiveGateway) BaseMessageNode(ru.runa.wfe.lang.BaseMessageNode) MultiSubprocessNode(ru.runa.wfe.lang.MultiSubprocessNode) SubprocessNode(ru.runa.wfe.lang.SubprocessNode) TimerNode(ru.runa.wfe.lang.bpmn2.TimerNode) ScriptNode(ru.runa.wfe.lang.ScriptNode) TextAnnotation(ru.runa.wfe.lang.bpmn2.TextAnnotation) MultiSubprocessNode(ru.runa.wfe.lang.MultiSubprocessNode) BusinessRule(ru.runa.wfe.lang.bpmn2.BusinessRule) BaseTaskNode(ru.runa.wfe.lang.BaseTaskNode) VariableContainerNode(ru.runa.wfe.lang.VariableContainerNode)

Aggregations

EmbeddedSubprocessStartNode (ru.runa.wfe.lang.EmbeddedSubprocessStartNode)2 MultiSubprocessNode (ru.runa.wfe.lang.MultiSubprocessNode)2 ScriptNode (ru.runa.wfe.lang.ScriptNode)2 SendMessageNode (ru.runa.wfe.lang.SendMessageNode)2 StartNode (ru.runa.wfe.lang.StartNode)2 SubprocessNode (ru.runa.wfe.lang.SubprocessNode)2 VariableContainerNode (ru.runa.wfe.lang.VariableContainerNode)2 Element (org.dom4j.Element)1 InvalidDefinitionException (ru.runa.wfe.definition.InvalidDefinitionException)1 BaseMessageNode (ru.runa.wfe.lang.BaseMessageNode)1 BaseTaskNode (ru.runa.wfe.lang.BaseTaskNode)1 GraphElement (ru.runa.wfe.lang.GraphElement)1 MultiTaskNode (ru.runa.wfe.lang.MultiTaskNode)1 TaskNode (ru.runa.wfe.lang.TaskNode)1 BusinessRule (ru.runa.wfe.lang.bpmn2.BusinessRule)1 ExclusiveGateway (ru.runa.wfe.lang.bpmn2.ExclusiveGateway)1 TextAnnotation (ru.runa.wfe.lang.bpmn2.TextAnnotation)1 TimerNode (ru.runa.wfe.lang.bpmn2.TimerNode)1 Decision (ru.runa.wfe.lang.jpdl.Decision)1