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