Search in sources :

Example 16 with FieldConstraint

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

the class GuidedRuleModelVisitor method visitFactPattern.

private Set<String> visitFactPattern(FactPattern pattern) {
    final Set<String> factTypes = new HashSet<String>();
    factTypes.add(pattern.getFactType());
    for (FieldConstraint fc : pattern.getFieldConstraints()) {
        factTypes.addAll(visit(fc));
    }
    return factTypes;
}
Also used : HashSet(java.util.HashSet) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)

Example 17 with FieldConstraint

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

the class GuidedRuleModelVisitor method visitCompositeFieldConstraint.

private Set<String> visitCompositeFieldConstraint(CompositeFieldConstraint cfc) {
    final Set<String> factTypes = new HashSet<String>();
    if (cfc.getConstraints() != null) {
        for (int i = 0; i < cfc.getConstraints().length; i++) {
            FieldConstraint fc = cfc.getConstraints()[i];
            factTypes.addAll(visit(fc));
        }
    }
    return factTypes;
}
Also used : ConnectiveConstraint(org.drools.workbench.models.datamodel.rule.ConnectiveConstraint) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) HashSet(java.util.HashSet) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)

Example 18 with FieldConstraint

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

the class ActionValueEditor method getApplicableBindings.

private List<String> getApplicableBindings() {
    List<String> bindings = new ArrayList<String>();
    // Examine LHS Fact and Field bindings and RHS (new) Fact bindings
    for (String v : modeller.getModel().getAllVariables()) {
        // LHS FactPattern
        FactPattern fp = modeller.getModel().getLHSBoundFact(v);
        if (fp != null) {
            if (isLHSFactTypeEquivalent(v)) {
                bindings.add(v);
            }
        }
        // LHS FieldConstraint
        FieldConstraint fc = modeller.getModel().getLHSBoundField(v);
        if (fc != null) {
            if (isLHSFieldTypeEquivalent(v)) {
                bindings.add(v);
            }
        }
        // RHS ActionInsertFact
        ActionInsertFact aif = modeller.getModel().getRHSBoundFact(v);
        if (aif != null) {
            if (isRHSFieldTypeEquivalent(v)) {
                bindings.add(v);
            }
        }
    }
    return bindings;
}
Also used : ActionInsertFact(org.drools.workbench.models.datamodel.rule.ActionInsertFact) ArrayList(java.util.ArrayList) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint)

Example 19 with FieldConstraint

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

the class ConstraintValueEditor method getDropDownData.

DropDownData getDropDownData() {
    // Set applicable flags and reference data depending upon type
    if (DataType.TYPE_BOOLEAN.equals(this.fieldType)) {
        this.isDropDownDataEnum = false;
        this.dropDownData = DropDownData.create(new String[] { "true", "false" });
    } else {
        this.isDropDownDataEnum = true;
        final Map<String, String> currentValueMap = new HashMap<String, String>();
        if (constraintList != null && constraintList.getConstraints() != null) {
            for (FieldConstraint con : constraintList.getConstraints()) {
                if (con instanceof SingleFieldConstraint) {
                    SingleFieldConstraint sfc = (SingleFieldConstraint) con;
                    String fieldName = sfc.getFieldName();
                    currentValueMap.put(fieldName, sfc.getValue());
                }
            }
        }
        this.dropDownData = oracle.getEnums(this.factType, fieldName, currentValueMap);
    }
    return dropDownData;
}
Also used : SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) HashMap(java.util.HashMap) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)

Example 20 with FieldConstraint

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

the class FactPatternWidget method sortConstraints.

/**
 * Sort the rule constraints such that parent rules are inserted directly
 * before their child rules.
 * @param constraints the list of inheriting constraints to sort.
 * @return a sorted list of constraints ready for display.
 */
private List<FieldConstraint> sortConstraints(FieldConstraint[] constraints) {
    List<FieldConstraint> sortedConst = new ArrayList<FieldConstraint>(constraints.length);
    for (int i = 0; i < constraints.length; i++) {
        FieldConstraint current = constraints[i];
        if (current instanceof SingleFieldConstraint) {
            SingleFieldConstraint single = (SingleFieldConstraint) current;
            int index = sortedConst.indexOf(single.getParent());
            if (single.getParent() == null) {
                sortedConst.add(single);
            } else if (index >= 0) {
                sortedConst.add(index + 1, single);
            } else {
                insertSingleFieldConstraint(single, sortedConst);
            }
        } else {
            sortedConst.add(current);
        }
    }
    return sortedConst;
}
Also used : SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) ArrayList(java.util.ArrayList) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)

Aggregations

FieldConstraint (org.drools.workbench.models.datamodel.rule.FieldConstraint)23 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)23 CompositeFieldConstraint (org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint)18 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)10 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)7 ConnectiveConstraint (org.drools.workbench.models.datamodel.rule.ConnectiveConstraint)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)3 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)3 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)3 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)3 IFactPattern (org.drools.workbench.models.datamodel.rule.IFactPattern)3 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)3 FlexTable (com.google.gwt.user.client.ui.FlexTable)2 Image (com.google.gwt.user.client.ui.Image)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LHSGeneratorContextFactory (org.drools.workbench.models.commons.backend.rule.context.LHSGeneratorContextFactory)2 RHSGeneratorContextFactory (org.drools.workbench.models.commons.backend.rule.context.RHSGeneratorContextFactory)2