Search in sources :

Example 21 with FieldConstraint

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

the class FactPatternWidget method drawConstraints.

/**
 * Render a hierarchy of constraints, hierarchy here means constraints that
 * may themselves depend on members of constraint objects. With this code,
 * the GUI enables clicking rules of the form: $result = RoutingResult(
 * NerOption.types contains "arzt" )
 * @param sortedConst a sorted list of constraints to display.
 */
protected void drawConstraints(List<FieldConstraint> sortedConst, HasConstraints hasConstraints) {
    final FlexTable table = new FlexTable();
    layout.setWidget(1, 0, table);
    List<FieldConstraint> parents = new ArrayList<FieldConstraint>();
    for (int i = 0; i < sortedConst.size(); i++) {
        traverseSingleFieldConstraints(sortedConst, table, parents, hasConstraints, i);
        // now the clear icon
        final int currentRow = i;
        Image clear = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
        clear.setTitle(GuidedRuleEditorResources.CONSTANTS.RemoveThisWholeRestriction());
        clear.addClickHandler(createClickHandlerForClearImageButton(currentRow));
        if (!this.readOnly) {
            // This used to be 5 and Connectives were not rendered
            table.setWidget(currentRow, 6, clear);
        }
    }
}
Also used : FlexTable(com.google.gwt.user.client.ui.FlexTable) ArrayList(java.util.ArrayList) Image(com.google.gwt.user.client.ui.Image) 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)

Example 22 with FieldConstraint

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

the class FactPatternWidget method traverseSingleFieldConstraints.

private void traverseSingleFieldConstraints(List<FieldConstraint> sortedConst, final FlexTable table, List<FieldConstraint> parents, HasConstraints hasConstraints, int i) {
    int tabs = -1;
    FieldConstraint current = sortedConst.get(i);
    if (current instanceof SingleFieldConstraint) {
        SingleFieldConstraint single = (SingleFieldConstraint) current;
        FieldConstraint parent = single.getParent();
        for (int j = 0; j < parents.size(); j++) {
            FieldConstraint storedParent = parents.get(j);
            if (storedParent != null && storedParent.equals(parent)) {
                tabs = j + 1;
                traverseForRemoval(parents, j);
                parents.add(current);
                break;
            }
        }
        if (tabs < 0) {
            tabs = 0;
            parents.add(current);
        }
    }
    renderFieldConstraint(table, i, current, hasConstraints, true, tabs);
}
Also used : 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) 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 23 with FieldConstraint

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

the class GuidedRuleTemplateIndexVisitor method visitFactPattern.

private void visitFactPattern(final FactPattern pattern) {
    String fullyQualifiedClassName = getFullyQualifiedClassName(pattern.getFactType());
    addResourceReference(fullyQualifiedClassName, ResourceType.JAVA);
    for (FieldConstraint fc : pattern.getFieldConstraints()) {
        visit(fc);
    }
}
Also used : 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

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