Search in sources :

Example 41 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class OperatorPage method getOperatorCompletions.

void getOperatorCompletions(final Callback<String[]> callback) {
    final AsyncPackageDataModelOracle oracle = presenter.getDataModelOracle();
    oracle.getOperatorCompletions(plugin().getFactType(), plugin().getFactField(), callback);
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)

Example 42 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class ActionWorkItemSetFieldPlugin method acceptParameterType.

private boolean acceptParameterType(final PortableParameterDefinition ppd) {
    final AsyncPackageDataModelOracle oracle = presenter.getDataModelOracle();
    if (nil(editingWrapper().getFactField())) {
        return false;
    }
    if (nil(ppd.getClassName())) {
        return false;
    }
    final String fieldClassName = oracle.getFieldClassName(patternWrapper().getFactType(), editingWrapper().getFactField());
    return fieldClassName.equals(ppd.getClassName());
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)

Example 43 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class ActionWorkItemExecuteColumnSynchronizerTest method getOracle.

@Override
protected AsyncPackageDataModelOracle getOracle() {
    final AsyncPackageDataModelOracle oracle = super.getOracle();
    oracle.addModelFields(Collections.singletonMap("Applicant", new ModelField[] { modelField("this", "Applicant"), modelField("age", DataType.TYPE_NUMERIC_INTEGER) }));
    return oracle;
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ModelField(org.kie.soup.project.datamodel.oracle.ModelField)

Example 44 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class ActionInsertFactColumnSynchronizerTest method getOracle.

@Override
protected AsyncPackageDataModelOracle getOracle() {
    final AsyncPackageDataModelOracle oracle = super.getOracle();
    oracle.addModelFields(Collections.singletonMap("Applicant", new ModelField[] { modelField("this", "Applicant"), modelField("age", DataType.TYPE_NUMERIC_INTEGER), modelField("name", DataType.TYPE_STRING), modelField("approved", DataType.TYPE_BOOLEAN) }));
    return oracle;
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ModelField(org.kie.soup.project.datamodel.oracle.ModelField)

Example 45 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class RowExpanderTests method testExpansionWithLimitedEntry.

@Test
@SuppressWarnings("serial")
public void testExpansionWithLimitedEntry() {
    GuidedDecisionTable52 model = new GuidedDecisionTable52();
    model.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
    final ModuleDataModelOracle projectLoader = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()).addFact("Driver").addField(new ModelField("age", Integer.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_NUMERIC_INTEGER)).addField(new ModelField("name", String.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_STRING)).addField(new ModelField("dateOfBirth", Boolean.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_DATE)).addField(new ModelField("approved", Boolean.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_BOOLEAN)).end().build();
    // Emulate server-to-client conversions
    final AsyncPackageDataModelOracle oracle = getOracle();
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    dataModel.setModelFields(projectLoader.getModuleModelFields());
    populateDataModelOracle(mock(Path.class), model, oracle, dataModel);
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("c1");
    p1.setFactType("Driver");
    LimitedEntryConditionCol52 c1 = new LimitedEntryConditionCol52();
    c1.setFactField("name");
    c1.setOperator("==");
    c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    c1.setValue(new DTCellValue52("Mike"));
    p1.getChildColumns().add(c1);
    model.getConditions().add(p1);
    Pattern52 p2 = new Pattern52();
    p2.setBoundName("c2");
    p2.setFactType("Driver");
    LimitedEntryConditionCol52 c2 = new LimitedEntryConditionCol52();
    c2.setFactField("age");
    c2.setOperator("==");
    c2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    c1.setValue(new DTCellValue52(25));
    p2.getChildColumns().add(c2);
    model.getConditions().add(p2);
    LimitedEntryActionSetFieldCol52 a1 = new LimitedEntryActionSetFieldCol52();
    a1.setBoundName("c1");
    a1.setFactField("name");
    a1.setValue(new DTCellValue52("a1name"));
    model.getActionCols().add(a1);
    LimitedEntryActionInsertFactCol52 a2 = new LimitedEntryActionInsertFactCol52();
    a2.setBoundName("a2");
    a2.setFactType("Driver");
    a2.setFactField("name");
    a2.setValue(new DTCellValue52("a2name"));
    model.getActionCols().add(a2);
    RowExpander re = new RowExpander(model, oracle);
    List<RowExpander.ColumnValues> columns = re.getColumns();
    assertEquals(6, columns.size());
    assertEquals(1, columns.get(0).values.size());
    assertEquals(1, columns.get(1).values.size());
    assertEquals(2, columns.get(2).values.size());
    assertEquals(2, columns.get(3).values.size());
    assertEquals(1, columns.get(4).values.size());
    assertEquals(1, columns.get(5).values.size());
    assertEquals(Boolean.TRUE, columns.get(2).values.get(0).getBooleanValue());
    assertEquals(Boolean.FALSE, columns.get(2).values.get(1).getBooleanValue());
    assertEquals(Boolean.TRUE, columns.get(3).values.get(0).getBooleanValue());
    assertEquals(Boolean.FALSE, columns.get(3).values.get(1).getBooleanValue());
    assertEquals(Boolean.FALSE, columns.get(4).values.get(0).getBooleanValue());
    assertEquals(Boolean.FALSE, columns.get(5).values.get(0).getBooleanValue());
    RowExpander.RowIterator i = re.iterator();
    List<List<DTCellValue52>> rows = new ArrayList<List<DTCellValue52>>();
    while (i.hasNext()) {
        List<DTCellValue52> row = i.next();
        rows.add(row);
    }
    assertEquals(4, rows.size());
    assertEquals("", rows.get(0).get(0).getStringValue());
    assertEquals("", rows.get(0).get(1).getStringValue());
    assertEquals(Boolean.TRUE, rows.get(0).get(2).getBooleanValue());
    assertEquals(Boolean.TRUE, rows.get(0).get(3).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(0).get(4).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(0).get(5).getBooleanValue());
    assertEquals("", rows.get(1).get(0).getStringValue());
    assertEquals("", rows.get(1).get(1).getStringValue());
    assertEquals(Boolean.TRUE, rows.get(1).get(2).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(1).get(3).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(1).get(4).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(1).get(5).getBooleanValue());
    assertEquals("", rows.get(2).get(0).getStringValue());
    assertEquals("", rows.get(2).get(1).getStringValue());
    assertEquals(Boolean.FALSE, rows.get(2).get(2).getBooleanValue());
    assertEquals(Boolean.TRUE, rows.get(2).get(3).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(2).get(4).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(2).get(5).getBooleanValue());
    assertEquals("", rows.get(3).get(0).getStringValue());
    assertEquals("", rows.get(3).get(1).getStringValue());
    assertEquals(Boolean.FALSE, rows.get(3).get(2).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(3).get(3).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(3).get(4).getBooleanValue());
    assertEquals(Boolean.FALSE, rows.get(3).get(5).getBooleanValue());
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) Path(org.uberfire.backend.vfs.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) ArrayList(java.util.ArrayList) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ArrayList(java.util.ArrayList) List(java.util.List) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) Test(org.junit.Test)

Aggregations

AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)62 Test (org.junit.Test)36 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)36 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)31 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)29 Path (org.uberfire.backend.vfs.Path)29 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)26 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)26 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)25 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)24 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)19 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)15 List (java.util.List)12 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)12 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)12 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)11 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)10 ArrayList (java.util.ArrayList)9 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)9 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)9