Search in sources :

Example 1 with LimitedEntryConditionCol52

use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools by kiegroup.

the class GuidedDTDRLPersistenceTest method testLimitedEntryLHSIsNullOperator.

@Test
public void testLimitedEntryLHSIsNullOperator() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
    dt.setTableName("limited-entry");
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("p1");
    p1.setFactType("Smurf");
    dt.getConditions().add(p1);
    LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52();
    cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc1.setFieldType(DataType.TYPE_STRING);
    cc1.setFactField("name");
    cc1.setOperator("== null");
    p1.getChildColumns().add(cc1);
    LimitedEntryConditionCol52 cc2 = new LimitedEntryConditionCol52();
    cc2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
    cc2.setFactField("age");
    cc2.setOperator("== null");
    p1.getChildColumns().add(cc2);
    LimitedEntryConditionCol52 cc3 = new LimitedEntryConditionCol52();
    cc3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc3.setFieldType(DataType.TYPE_DATE);
    cc3.setFactField("dateOfBirth");
    cc3.setOperator("== null");
    p1.getChildColumns().add(cc3);
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true, true, true }, new Object[] { 2l, "desc", false, false, false } }));
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dt);
    int index = -1;
    index = drl.indexOf("Smurf( name == null , age == null , dateOfBirth == null )");
    assertTrue(index > -1);
    index = drl.indexOf("Smurf( )", index + 1);
    assertFalse(index > -1);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) Test(org.junit.Test)

Example 2 with LimitedEntryConditionCol52

use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools by kiegroup.

the class GuidedDTDRLPersistenceTest method testLimitedEntryLHSNotInOperator.

@Test
public void testLimitedEntryLHSNotInOperator() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
    dt.setTableName("limited-entry");
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("p1");
    p1.setFactType("Smurf");
    dt.getConditions().add(p1);
    LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52();
    cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc1.setFieldType(DataType.TYPE_STRING);
    cc1.setFactField("name");
    cc1.setOperator("not in");
    cc1.setValue(new DTCellValue52("Pupa, Brains"));
    p1.getChildColumns().add(cc1);
    LimitedEntryConditionCol52 cc2 = new LimitedEntryConditionCol52();
    cc2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
    cc2.setFactField("age");
    cc2.setOperator("not in");
    cc2.setValue(new DTCellValue52("55, 66"));
    p1.getChildColumns().add(cc2);
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true, true }, new Object[] { 2l, "desc", false, false } }));
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dt);
    int index = -1;
    index = drl.indexOf("Smurf( name not in ( \"Pupa\", \"Brains\" ) , age not in ( 55, 66 ) )");
    assertTrue(index > -1);
    index = drl.indexOf("Smurf( )", index + 1);
    assertFalse(index > -1);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) Test(org.junit.Test)

Example 3 with LimitedEntryConditionCol52

use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools-wb by kiegroup.

the class LimitedGuidedDecisionTableBuilder method withIntegerColumn.

public LimitedGuidedDecisionTableBuilder withIntegerColumn(final String boundName, final String factType, final String field, final String operator, final int value) {
    final Pattern52 pattern = findPattern(boundName, factType);
    final LimitedEntryConditionCol52 condition = new LimitedEntryConditionCol52();
    condition.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    condition.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
    condition.setFactField(field);
    condition.setHeader("Some header");
    condition.setOperator(operator);
    condition.setValue(new DTCellValue52() {

        {
            setNumericValue(new Integer(value));
        }
    });
    pattern.getChildColumns().add(condition);
    addPattern(pattern);
    return this;
}
Also used : Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 4 with LimitedEntryConditionCol52

use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools-wb by kiegroup.

the class ConditionColumnPlugin method clone.

ConditionCol52 clone(final ConditionCol52 column) {
    final ConditionCol52 clone;
    if (tableFormat() == LIMITED_ENTRY) {
        clone = new LimitedEntryConditionCol52() {

            {
                setValue(cloneDTCellValue(((LimitedEntryCol) column).getValue()));
            }
        };
    } else {
        clone = new ConditionCol52();
    }
    clone.setConstraintValueType(column.getConstraintValueType());
    clone.setFactField(column.getFactField());
    clone.setFieldType(column.getFieldType());
    clone.setHeader(column.getHeader());
    clone.setOperator(column.getOperator());
    clone.setValueList(column.getValueList());
    clone.setDefaultValue(cloneDTCellValue(column.getDefaultValue()));
    clone.setHideColumn(column.isHideColumn());
    clone.setParameters(column.getParameters());
    clone.setWidth(column.getWidth());
    clone.setBinding(column.getBinding());
    return clone;
}
Also used : LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)

Example 5 with LimitedEntryConditionCol52

use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools-wb by kiegroup.

the class FactPatternConstraintsPageViewImpl method makeNewConditionColumn.

private ConditionCol52 makeNewConditionColumn(final AvailableField f) {
    final GuidedDecisionTable52.TableFormat format = presenter.getTableFormat();
    if (format == GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY) {
        final ConditionCol52 c = new ConditionCol52();
        c.setFactField(f.getName());
        c.setFieldType(f.getType());
        c.setConstraintValueType(f.getCalculationType());
        return c;
    } else {
        final LimitedEntryConditionCol52 c = new LimitedEntryConditionCol52();
        c.setFactField(f.getName());
        c.setFieldType(f.getType());
        c.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
        return c;
    }
}
Also used : LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)

Aggregations

LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)20 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)14 Test (org.junit.Test)14 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)12 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)10 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)10 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)9 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)3 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)2 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1 MultiSelectionModel (com.google.gwt.view.client.MultiSelectionModel)1 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)1 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)1 CEPOperatorsDropdown (org.drools.workbench.screens.guided.rule.client.editor.CEPOperatorsDropdown)1