Search in sources :

Example 1 with ExtensibleXmlParser

use of io.automatiko.engine.workflow.compiler.xml.ExtensibleXmlParser in project automatiko-engine by automatiko-io.

the class AbstractNodeHandler method findVariable.

/**
 * Finds the right variable by its name to make sure that when given as id it
 * will be also matched
 *
 * @param variableName name or id of the variable
 * @param parser parser instance
 * @return returns found variable name or given 'variableName' otherwise
 */
protected String findVariable(String variableName, final ExtensibleXmlParser parser) {
    if (variableName == null) {
        return null;
    }
    List<?> parents = parser.getParents();
    for (Object parent : parents) {
        if (parent instanceof ContextContainer) {
            ContextContainer contextContainer = (ContextContainer) parent;
            VariableScope variableScope = (VariableScope) contextContainer.getDefaultContext(VariableScope.VARIABLE_SCOPE);
            return variableScope.getVariables().stream().filter(v -> v.matchByIdOrName(variableName)).map(v -> v.getName()).findFirst().orElse(variableName);
        }
    }
    return variableName;
}
Also used : Text(org.w3c.dom.Text) COMPLETION_CONDITION(io.automatiko.engine.workflow.process.executable.core.Metadata.COMPLETION_CONDITION) Handler(io.automatiko.engine.workflow.compiler.xml.Handler) ItemDefinition(io.automatiko.engine.workflow.bpmn2.core.ItemDefinition) LoggerFactory(org.slf4j.LoggerFactory) DataType(io.automatiko.engine.api.workflow.datatype.DataType) Definitions(io.automatiko.engine.workflow.bpmn2.core.Definitions) XmlDumper(io.automatiko.engine.workflow.compiler.xml.XmlDumper) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) HashMap(java.util.HashMap) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) FloatDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.FloatDataType) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) IntegerDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType) Error(io.automatiko.engine.workflow.bpmn2.core.Error) BooleanDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) Map(java.util.Map) Attributes(org.xml.sax.Attributes) Node(io.automatiko.engine.workflow.process.core.Node) Association(io.automatiko.engine.workflow.bpmn2.core.Association) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) Logger(org.slf4j.Logger) NodeList(org.w3c.dom.NodeList) Signal(io.automatiko.engine.workflow.bpmn2.core.Signal) ExtendedNodeImpl(io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl) ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) Set(java.util.Set) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope) ClassUtils.constructClass(io.automatiko.engine.workflow.compiler.util.ClassUtils.constructClass) List(java.util.List) SAXParseException(org.xml.sax.SAXParseException) Element(org.w3c.dom.Element) SequenceFlow(io.automatiko.engine.workflow.bpmn2.core.SequenceFlow) ExtensibleXmlParser(io.automatiko.engine.workflow.compiler.xml.ExtensibleXmlParser) SAXException(org.xml.sax.SAXException) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) BaseAbstractHandler(io.automatiko.engine.workflow.compiler.xml.BaseAbstractHandler) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) StringDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) Lane(io.automatiko.engine.workflow.bpmn2.core.Lane) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Aggregations

DataType (io.automatiko.engine.api.workflow.datatype.DataType)1 ContextContainer (io.automatiko.engine.workflow.base.core.ContextContainer)1 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)1 VariableScope (io.automatiko.engine.workflow.base.core.context.variable.VariableScope)1 BooleanDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType)1 FloatDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.FloatDataType)1 IntegerDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType)1 ObjectDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType)1 StringDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType)1 Association (io.automatiko.engine.workflow.bpmn2.core.Association)1 Definitions (io.automatiko.engine.workflow.bpmn2.core.Definitions)1 Error (io.automatiko.engine.workflow.bpmn2.core.Error)1 ItemDefinition (io.automatiko.engine.workflow.bpmn2.core.ItemDefinition)1 Lane (io.automatiko.engine.workflow.bpmn2.core.Lane)1 SequenceFlow (io.automatiko.engine.workflow.bpmn2.core.SequenceFlow)1 Signal (io.automatiko.engine.workflow.bpmn2.core.Signal)1 ClassUtils.constructClass (io.automatiko.engine.workflow.compiler.util.ClassUtils.constructClass)1 BaseAbstractHandler (io.automatiko.engine.workflow.compiler.xml.BaseAbstractHandler)1 ExtensibleXmlParser (io.automatiko.engine.workflow.compiler.xml.ExtensibleXmlParser)1 Handler (io.automatiko.engine.workflow.compiler.xml.Handler)1