Search in sources :

Example 1 with AsyncPackageDataModelOracleImpl

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

the class FieldTypeProducer method getFactTypes.

public FactTypes getFactTypes() {
    final FactTypes factTypes = new FactTypes();
    final Map<String, ModelField[]> filteredFactTypes = ((AsyncPackageDataModelOracleImpl) oracle).getFilteredFactTypes();
    for (final String factTypeName : filteredFactTypes.keySet()) {
        final Set<FactTypes.Field> fields = new HashSet<>();
        for (final ModelField modelField : filteredFactTypes.get(factTypeName)) {
            fields.add(new FactTypes.Field(modelField.getName(), modelField.getType()));
        }
        factTypes.add(new FactTypes.FactType(factTypeName, fields));
    }
    return factTypes;
}
Also used : ModelField(org.kie.soup.project.datamodel.oracle.ModelField) AsyncPackageDataModelOracleImpl(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleImpl) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) FactTypes(org.drools.workbench.services.verifier.plugin.client.api.FactTypes) HashSet(java.util.HashSet)

Example 2 with AsyncPackageDataModelOracleImpl

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

the class FactPatternConstraintsPageTest method setUp.

@Before
public void setUp() throws Exception {
    incrementalDataModelServiceCaller = new CallerMock<>(incrementalDataModelService);
    oracle = new AsyncPackageDataModelOracleImpl(incrementalDataModelServiceCaller, null);
    page.oracle = oracle;
    page.model = model;
    page.validator = validator;
    when(pattern.getFactType()).thenReturn("org.Address");
    when(conditionCol.getFactField()).thenReturn("street");
    when(model.getPatterns()).thenReturn(Arrays.asList(pattern, secondPattern));
    modelFields = new ModelField[] { modelField("this", DataType.TYPE_THIS), modelField("street", DataType.TYPE_STRING), modelField("homeAddress", DataType.TYPE_BOOLEAN), modelField("number", DataType.TYPE_NUMERIC_INTEGER) };
    Map<String, ModelField[]> fields = new HashMap<>();
    fields.put("org.Address", modelFields);
    oracle.addModelFields(fields);
    conditions = new ArrayList<>();
    conditions.add(mock(ConditionCol52.class));
    when(pattern.getChildColumns()).thenReturn(conditions);
    when(secondPattern.getChildColumns()).thenReturn(conditions);
}
Also used : AsyncPackageDataModelOracleImpl(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleImpl) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) HashMap(java.util.HashMap) Before(org.junit.Before)

Example 3 with AsyncPackageDataModelOracleImpl

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

the class ConstraintValueEditorHelperTest method testEvents_BoundTypeIsNotEvent.

@Test
public void testEvents_BoundTypeIsNotEvent() throws Exception {
    AsyncPackageDataModelOracle oracle = new AsyncPackageDataModelOracleImpl(serviceCaller, validatorInstance);
    oracle.setPackageName("org.test");
    oracle.addModelFields(new HashMap<String, ModelField[]>() {

        {
            put("org.test.Event1", new ModelField[] { modelField("this", "org.test.Event1") });
            put("org.test.Event2", new ModelField[] { modelField("this", "org.test.Event2") });
        }
    });
    oracle.addEventTypes(new HashMap<String, Boolean>() {

        {
            put("org.test.Event1", false);
            put("org.test.Event2", true);
        }
    });
    oracle.addSuperTypes(new HashMap<String, List<String>>() {

        {
            put("org.test.Event1", Collections.EMPTY_LIST);
            put("org.test.Event2", Collections.EMPTY_LIST);
        }
    });
    oracle.filter();
    FactPattern pattern1 = new FactPattern();
    pattern1.setFactType("Event1");
    pattern1.setBoundName("$e");
    SingleFieldConstraint constraint = new SingleFieldConstraint();
    constraint.setFactType("Event1");
    constraint.setFieldName("this");
    constraint.setFieldType("Event1");
    constraint.setOperator(OperatorsOracle.SIMPLE_CEP_OPERATORS[0]);
    pattern1.addConstraint(constraint);
    model.addLhsItem(pattern1);
    ConstraintValueEditorHelper helper = new ConstraintValueEditorHelper(model, oracle, "Event2", "this", constraint, "Event2", new DropDownData());
    helper.isApplicableBindingsInScope("$e", new Callback<Boolean>() {

        @Override
        public void callback(Boolean result) {
            assertFalse(result);
        }
    });
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ConstraintValueEditorHelper(org.drools.workbench.screens.guided.rule.client.editor.util.ConstraintValueEditorHelper) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) AsyncPackageDataModelOracleImpl(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleImpl) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) List(java.util.List) Test(org.junit.Test)

Example 4 with AsyncPackageDataModelOracleImpl

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

the class OperatorsBaseTest method setUp.

@Before
public void setUp() throws Exception {
    ApplicationPreferences.setUp(new HashMap() {

        {
            put(ApplicationPreferences.DATE_FORMAT, "dd/MM/YYYY");
        }
    });
    serviceCaller = new CallerMock<>(service);
    oracle = new AsyncPackageDataModelOracleImpl(serviceCaller, null);
    final ModelField[] modelFields = new ModelField[] { modelField("street", DataType.TYPE_STRING), modelField("number", DataType.TYPE_NUMERIC_INTEGER) };
    Map<String, ModelField[]> fields = new HashMap<>();
    fields.put("org.Address", modelFields);
    oracle.addModelFields(fields);
    connectives = spy(new Connectives(modeller, eventBus, pattern, false));
    doReturn(oracle).when(connectives).getDataModelOracle();
    doReturn(oracle).when(modeller).getDataModelOracle();
    doReturn(Stream.of(connectiveConstraint).toArray(ConnectiveConstraint[]::new)).when(singleFieldConstraint).getConnectives();
}
Also used : Connectives(org.drools.workbench.screens.guided.rule.client.editor.factPattern.Connectives) AsyncPackageDataModelOracleImpl(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleImpl) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) HashMap(java.util.HashMap) ConnectiveConstraint(org.drools.workbench.models.datamodel.rule.ConnectiveConstraint) Before(org.junit.Before)

Example 5 with AsyncPackageDataModelOracleImpl

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

the class ConstraintValueEditorHelperTest method testEvents_BothTypesAreEvents.

@Test
public void testEvents_BothTypesAreEvents() throws Exception {
    AsyncPackageDataModelOracle oracle = new AsyncPackageDataModelOracleImpl(serviceCaller, validatorInstance);
    oracle.setPackageName("org.test");
    oracle.addModelFields(new HashMap<String, ModelField[]>() {

        {
            put("org.test.Event1", new ModelField[] { modelField("this", "org.test.Event1") });
            put("org.test.Event2", new ModelField[] { modelField("this", "org.test.Event2") });
        }
    });
    oracle.addEventTypes(new HashMap<String, Boolean>() {

        {
            put("org.test.Event1", true);
            put("org.test.Event2", true);
        }
    });
    oracle.filter();
    FactPattern pattern1 = new FactPattern();
    pattern1.setFactType("Event1");
    pattern1.setBoundName("$e");
    SingleFieldConstraint constraint = new SingleFieldConstraint();
    constraint.setFactType("Event1");
    constraint.setFieldName("this");
    constraint.setFieldType("Event1");
    constraint.setOperator(OperatorsOracle.SIMPLE_CEP_OPERATORS[0]);
    pattern1.addConstraint(constraint);
    model.addLhsItem(pattern1);
    ConstraintValueEditorHelper helper = new ConstraintValueEditorHelper(model, oracle, "Event2", "this", constraint, "Event2", new DropDownData());
    helper.isApplicableBindingsInScope("$e", new Callback<Boolean>() {

        @Override
        public void callback(Boolean result) {
            assertTrue(result);
        }
    });
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ConstraintValueEditorHelper(org.drools.workbench.screens.guided.rule.client.editor.util.ConstraintValueEditorHelper) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) AsyncPackageDataModelOracleImpl(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleImpl) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) Test(org.junit.Test)

Aggregations

AsyncPackageDataModelOracleImpl (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleImpl)7 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)6 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)3 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)3 ConstraintValueEditorHelper (org.drools.workbench.screens.guided.rule.client.editor.util.ConstraintValueEditorHelper)3 Before (org.junit.Before)3 Test (org.junit.Test)3 DropDownData (org.kie.soup.project.datamodel.oracle.DropDownData)3 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)3 HashMap (java.util.HashMap)2 List (java.util.List)2 HashSet (java.util.HashSet)1 ConnectiveConstraint (org.drools.workbench.models.datamodel.rule.ConnectiveConstraint)1 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)1 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)1 Connectives (org.drools.workbench.screens.guided.rule.client.editor.factPattern.Connectives)1 FactTypes (org.drools.workbench.services.verifier.plugin.client.api.FactTypes)1 Import (org.kie.soup.project.datamodel.imports.Import)1 Imports (org.kie.soup.project.datamodel.imports.Imports)1 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)1