use of org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle in project drools-wb by kiegroup.
the class TestTestScenarioFileIndexer method getModuleDataModelOracle.
@Override
protected ModuleDataModelOracle getModuleDataModelOracle(final Path path) {
final ModuleDataModelOracle dmo = new ModuleDataModelOracleImpl();
dmo.addModuleModelFields(new HashMap<String, ModelField[]>() {
{
put("org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Applicant", new ModelField[] { new ModelField("age", "java.lang.Integer", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER) });
put("org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Mortgage", new ModelField[] { new ModelField("amount", "java.lang.Integer", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER) });
put("java.util.Date", new ModelField[] { new ModelField("minutes", "java.lang.Integer", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER) });
}
});
return dmo;
}
use of org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle in project drools-wb by kiegroup.
the class TestScenarioFileIndexer method fillIndexBuilder.
@Override
public DefaultIndexBuilder fillIndexBuilder(final Path path) throws Exception {
final String content = ioService.readAllString(path);
final Scenario model = ScenarioXMLPersistence.getInstance().unmarshal(content);
final ModuleDataModelOracle dmo = getModuleDataModelOracle(path);
final Module project = moduleService.resolveModule(Paths.convert(path));
final Package pkg = moduleService.resolvePackage(Paths.convert(path));
final DefaultIndexBuilder builder = new DefaultIndexBuilder(Paths.convert(path).getFileName(), project, pkg);
final TestScenarioIndexVisitor visitor = new TestScenarioIndexVisitor(dmo, builder, model);
visitor.visit();
addReferencedResourcesToIndexBuilder(builder, visitor);
return builder;
}
use of org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle in project drools-wb by kiegroup.
the class TestGuidedDecisionTableFileIndexer method getModuleDataModelOracle.
@Override
protected ModuleDataModelOracle getModuleDataModelOracle(final Path path) {
final ModuleDataModelOracle dmo = new ModuleDataModelOracleImpl();
dmo.addModuleModelFields(new HashMap<String, ModelField[]>() {
{
put(Applicant.class.getCanonicalName(), new ModelField[] { new ModelField("age", Integer.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER) });
put(Mortgage.class.getCanonicalName(), new ModelField[] { new ModelField("amount", Integer.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER), new ModelField("applicant", Applicant.class.getCanonicalName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, Applicant.class.getCanonicalName()) });
}
});
return dmo;
}
use of org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle in project drools-wb by kiegroup.
the class EnumFileIndexer method fillIndexBuilder.
@Override
public DefaultIndexBuilder fillIndexBuilder(final Path path) throws Exception {
final String enumDefinition = ioService.readAllString(path);
final DataEnumLoader enumLoader = new DataEnumLoader(enumDefinition, mvelEvaluator);
if (enumLoader.hasErrors()) {
logger.info("Unable to index '" + path.toUri().toString() + "'. Related errors follow:");
for (String e : enumLoader.getErrors()) {
logger.info(e);
}
}
final ModuleDataModelOracle dmo = getModuleDataModelOracle(path);
final DefaultIndexBuilder builder = getIndexBuilder(path);
if (builder == null) {
return null;
}
final EnumIndexVisitor visitor = new EnumIndexVisitor(dmo, path, enumLoader);
visitor.visit();
addReferencedResourcesToIndexBuilder(builder, visitor);
return builder;
}
use of org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle in project drools-wb by kiegroup.
the class EnumIndexVisitorCDITest method testDependentEnumIndexing.
@Test
public void testDependentEnumIndexing() throws Exception {
final String carFQN = "com.myteam.repro.Car";
final Path testedPath = Paths.get(getClass().getResource("cars/src/main/resources/com/myteam/repro/cars.enumeration").toURI());
final Set<KProperty<?>> properties = indexer.fillIndexBuilder(testedPath).build();
final ModuleDataModelOracle oracle = indexer.getModuleDataModelOracle(testedPath);
Assertions.assertThat(oracle.getModuleModelFields().keySet()).contains(carFQN);
final AbstractListAssert carFields = Assertions.assertThat(properties).filteredOn("name", "ref:field:" + carFQN);
carFields.filteredOn("value", "price").hasSize(1);
carFields.filteredOn("value", "color").hasSize(1);
final AbstractListAssert javaClasses = Assertions.assertThat(properties).filteredOn("name", "ref:java");
javaClasses.filteredOn("value", carFQN).hasSize(1);
}
Aggregations