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