Search in sources :

Example 1 with BooleanDataType

use of io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType in project automatiko-engine by automatiko-io.

the class DmnDecisionInProcessTest method createProcess.

private ExecutableProcess createProcess(String namespace, String modelName, String decisionName) {
    DMNRuntime dmnRuntime = DmnRuntimeProvider.fromClassPath("PersonDecisions.dmn");
    DmnDecisionModel dmnDecisionModel = new DmnDecisionModel(dmnRuntime, namespace, modelName);
    ExecutableProcess process = new ExecutableProcess();
    process.setId("process");
    process.setName("Process");
    List<Variable> variables = new ArrayList<Variable>();
    Variable variable1 = new Variable();
    variable1.setName("person");
    variable1.setType(new ObjectDataType(Person.class));
    variables.add(variable1);
    Variable variable2 = new Variable();
    variable2.setName("isAdult");
    variable2.setType(new BooleanDataType());
    variables.add(variable2);
    process.getVariableScope().setVariables(variables);
    StartNode startNode = new StartNode();
    startNode.setName("Start");
    startNode.setId(1);
    RuleSetNode ruleSetNode = new RuleSetNode();
    ruleSetNode.setName("RuleSetNode");
    ruleSetNode.setId(2);
    ruleSetNode.setRuleType(RuleSetNode.RuleType.decision(namespace, modelName, null));
    ruleSetNode.setLanguage(RuleSetNode.DMN_LANG);
    ruleSetNode.setDecisionModel(() -> dmnDecisionModel);
    ruleSetNode.addInMapping("Person", "person");
    ruleSetNode.addOutMapping("isAdult", "isAdult");
    EndNode endNode = new EndNode();
    endNode.setName("End");
    endNode.setId(3);
    connect(startNode, ruleSetNode);
    connect(ruleSetNode, endNode);
    process.addNode(startNode);
    process.addNode(ruleSetNode);
    process.addNode(endNode);
    return process;
}
Also used : StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) DmnDecisionModel(io.automatiko.engine.decision.dmn.DmnDecisionModel) ArrayList(java.util.ArrayList) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) BooleanDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType) DMNRuntime(org.kie.dmn.api.core.DMNRuntime)

Example 2 with BooleanDataType

use of io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType in project automatiko-engine by automatiko-io.

the class DefinitionsHandler method setVariableDataType.

private void setVariableDataType(Variable variable, Map<String, ItemDefinition> itemDefinitions, ClassLoader cl) {
    // retrieve type from item definition
    String itemSubjectRef = (String) variable.getMetaData("ItemSubjectRef");
    if (UndefinedDataType.getInstance().equals(variable.getType()) && itemDefinitions != null && itemSubjectRef != null) {
        DataType dataType = new ObjectDataType();
        ItemDefinition itemDefinition = itemDefinitions.get(itemSubjectRef);
        if (itemDefinition != null) {
            String structureRef = itemDefinition.getStructureRef();
            if ("java.lang.Boolean".equals(structureRef) || "Boolean".equals(structureRef)) {
                dataType = new BooleanDataType();
            } else if ("java.lang.Integer".equals(structureRef) || "Integer".equals(structureRef)) {
                dataType = new IntegerDataType();
            } else if ("java.lang.Float".equals(structureRef) || "Float".equals(structureRef)) {
                dataType = new FloatDataType();
            } else if ("java.lang.String".equals(structureRef) || "String".equals(structureRef)) {
                dataType = new StringDataType();
            } else if ("java.lang.Object".equals(structureRef) || "Object".equals(structureRef)) {
                // use FQCN of Object
                dataType = new ObjectDataType(java.lang.Object.class, structureRef);
            } else {
                dataType = new ObjectDataType(constructClass(structureRef, cl), structureRef);
            }
        }
        variable.setType(dataType);
    }
}
Also used : StringDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType) FloatDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.FloatDataType) IntegerDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType) ItemDefinition(io.automatiko.engine.workflow.bpmn2.core.ItemDefinition) DataType(io.automatiko.engine.api.workflow.datatype.DataType) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) FloatDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.FloatDataType) IntegerDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType) BooleanDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType) UndefinedDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.UndefinedDataType) StringDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) BooleanDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType)

Example 3 with BooleanDataType

use of io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType in project automatiko-engine by automatiko-io.

the class DataObjectHandler 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);
        if (variableScope == null) {
            return null;
        }
        List variables = variableScope.getVariables();
        Variable variable = new Variable();
        variable.setMetaData("DataObject", "true");
        variable.setId(id);
        variable.setName(name);
        variable.setMetaData(id, variable.getName());
        if (localName.equals("dataInput")) {
            variable.setMetaData("DataInput", true);
        } else if (localName.equals("dataOutput")) {
            variable.setMetaData("DataOutput", true);
        }
        // retrieve type from item definition
        DataType dataType = new ObjectDataType();
        Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
        if (itemDefinitions != null) {
            ItemDefinition itemDefinition = itemDefinitions.get(itemSubjectRef);
            if (itemDefinition != null) {
                String structureRef = itemDefinition.getStructureRef();
                if ("java.lang.Boolean".equals(structureRef) || "Boolean".equals(structureRef)) {
                    dataType = new BooleanDataType();
                } else if ("java.lang.Integer".equals(structureRef) || "Integer".equals(structureRef)) {
                    dataType = new IntegerDataType();
                } else if ("java.lang.Float".equals(structureRef) || "Float".equals(structureRef)) {
                    dataType = new FloatDataType();
                } else if ("java.lang.String".equals(structureRef) || "String".equals(structureRef)) {
                    dataType = new StringDataType();
                } else if ("java.lang.Object".equals(structureRef) || "Object".equals(structureRef)) {
                    // use FQCN of Object
                    dataType = new ObjectDataType(java.lang.Object.class, structureRef);
                } else {
                    dataType = new ObjectDataType(constructClass(structureRef, parser.getClassLoader()), structureRef);
                }
            }
        }
        variable.setType(dataType);
        variables.add(variable);
        return variable;
    }
    return new Variable();
}
Also used : FloatDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.FloatDataType) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) IntegerDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType) ItemDefinition(io.automatiko.engine.workflow.bpmn2.core.ItemDefinition) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) StringDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType) ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) DataType(io.automatiko.engine.api.workflow.datatype.DataType) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) FloatDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.FloatDataType) IntegerDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType) BooleanDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType) StringDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType) List(java.util.List) BooleanDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType) Map(java.util.Map) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 4 with BooleanDataType

use of io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType in project automatiko-engine by automatiko-io.

the class AbstractNodeHandler method getDataType.

protected DataType getDataType(String itemSubjectRef, Map<String, ItemDefinition> itemDefinitions, ClassLoader cl) {
    DataType dataType = new ObjectDataType();
    if (itemDefinitions == null) {
        return dataType;
    }
    ItemDefinition itemDefinition = itemDefinitions.get(itemSubjectRef);
    if (itemDefinition != null) {
        String structureRef = itemDefinition.getStructureRef();
        if ("java.lang.Boolean".equals(structureRef) || "Boolean".equals(structureRef)) {
            dataType = new BooleanDataType();
        } else if ("java.lang.Integer".equals(structureRef) || "Integer".equals(structureRef)) {
            dataType = new IntegerDataType();
        } else if ("java.lang.Float".equals(structureRef) || "Float".equals(structureRef)) {
            dataType = new FloatDataType();
        } else if ("java.lang.String".equals(structureRef) || "String".equals(structureRef)) {
            dataType = new StringDataType();
        } else if ("java.lang.Object".equals(structureRef) || "Object".equals(structureRef)) {
            dataType = new ObjectDataType(constructClass(structureRef), structureRef);
        } else {
            dataType = new ObjectDataType(constructClass(structureRef, cl), structureRef);
        }
    }
    return dataType;
}
Also used : StringDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType) FloatDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.FloatDataType) IntegerDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType) ItemDefinition(io.automatiko.engine.workflow.bpmn2.core.ItemDefinition) DataType(io.automatiko.engine.api.workflow.datatype.DataType) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) FloatDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.FloatDataType) IntegerDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType) BooleanDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType) StringDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) BooleanDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType)

Aggregations

BooleanDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType)4 ObjectDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType)4 DataType (io.automatiko.engine.api.workflow.datatype.DataType)3 FloatDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.FloatDataType)3 IntegerDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType)3 StringDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType)3 ItemDefinition (io.automatiko.engine.workflow.bpmn2.core.ItemDefinition)3 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)2 DmnDecisionModel (io.automatiko.engine.decision.dmn.DmnDecisionModel)1 ContextContainer (io.automatiko.engine.workflow.base.core.ContextContainer)1 VariableScope (io.automatiko.engine.workflow.base.core.context.variable.VariableScope)1 UndefinedDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.UndefinedDataType)1 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)1 RuleSetNode (io.automatiko.engine.workflow.process.core.node.RuleSetNode)1 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)1 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)1