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);
}
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));
}
}
Aggregations