Search in sources :

Example 31 with RuleAttribute

use of org.drools.workbench.models.datamodel.rule.RuleAttribute in project drools-wb by kiegroup.

the class RuleModelCloneVisitor method visitRuleAttribute.

private RuleAttribute visitRuleAttribute(RuleAttribute attr) {
    RuleAttribute clone = new RuleAttribute();
    clone.setAttributeName(attr.getAttributeName());
    clone.setValue(attr.getValue());
    return clone;
}
Also used : RuleAttribute(org.drools.workbench.models.datamodel.rule.RuleAttribute)

Example 32 with RuleAttribute

use of org.drools.workbench.models.datamodel.rule.RuleAttribute in project drools-wb by kiegroup.

the class GuidedRuleTemplateFactory method makeModelWithAttributes.

public static TemplateModel makeModelWithAttributes(final String packageName, final Collection<Import> imports, final String name) {
    final TemplateModel model = new TemplateModel();
    model.getImports().getImports().addAll(imports);
    model.setPackageName(packageName);
    model.name = name;
    model.addAttribute(new RuleAttribute("ruleflow-group", "myRuleFlowGroup"));
    return model;
}
Also used : RuleAttribute(org.drools.workbench.models.datamodel.rule.RuleAttribute) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel)

Example 33 with RuleAttribute

use of org.drools.workbench.models.datamodel.rule.RuleAttribute in project drools-wb by kiegroup.

the class GuidedRuleTemplateIndexVisitor method visitRuleModel.

public void visitRuleModel(final TemplateModel model) {
    // Add Attributes
    if (model.attributes != null) {
        for (int i = 0; i < model.attributes.length; i++) {
            RuleAttribute attr = model.attributes[i];
            visit(attr);
        }
    }
    // Add Types and Fields used by LHS
    if (model.lhs != null) {
        for (int i = 0; i < model.lhs.length; i++) {
            IPattern pattern = model.lhs[i];
            visit(pattern);
        }
    }
    // Add Types and Fields used by RHS
    if (model.rhs != null) {
        for (int i = 0; i < model.rhs.length; i++) {
            IAction action = model.rhs[i];
            if (action instanceof ActionSetField) {
                final ActionSetField asf = (ActionSetField) action;
                final String typeName = getTypeNameForBinding(asf.getVariable());
                if (typeName != null) {
                    final String fullyQualifiedClassName = getFullyQualifiedClassName(typeName);
                    visitActionFieldList(fullyQualifiedClassName, asf);
                }
            } else {
                visit(action);
            }
        }
    }
    // Add rule names
    final String parentRuleName = model.parentName;
    for (int i = 0; i < model.getRowsCount(); i++) {
        final String ruleName = model.name + "_" + i;
        addResourceReference(ruleName, ResourceType.RULE);
        if (parentRuleName != null) {
            addResourceReference(parentRuleName, ResourceType.RULE);
        }
    }
}
Also used : IPattern(org.drools.workbench.models.datamodel.rule.IPattern) ActionSetField(org.drools.workbench.models.datamodel.rule.ActionSetField) IAction(org.drools.workbench.models.datamodel.rule.IAction) RuleAttribute(org.drools.workbench.models.datamodel.rule.RuleAttribute) ConnectiveConstraint(org.drools.workbench.models.datamodel.rule.ConnectiveConstraint) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint)

Aggregations

RuleAttribute (org.drools.workbench.models.datamodel.rule.RuleAttribute)33 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)25 Test (org.junit.Test)24 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)14 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)14 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)12 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)12 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)12 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)11 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)11 ActionInsertFact (org.drools.workbench.models.datamodel.rule.ActionInsertFact)10 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)9 ActionFieldValue (org.drools.workbench.models.datamodel.rule.ActionFieldValue)7 ActionGlobalCollectionAdd (org.drools.workbench.models.datamodel.rule.ActionGlobalCollectionAdd)4 CompositeFieldConstraint (org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint)4 FieldConstraint (org.drools.workbench.models.datamodel.rule.FieldConstraint)4 TemplateModel (org.drools.workbench.models.guided.template.shared.TemplateModel)4 ActionCallMethod (org.drools.workbench.models.datamodel.rule.ActionCallMethod)3 ActionFieldFunction (org.drools.workbench.models.datamodel.rule.ActionFieldFunction)3 ActionRetractFact (org.drools.workbench.models.datamodel.rule.ActionRetractFact)3