Search in sources :

Example 1 with ModuleDataModelOracle

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;
}
Also used : ModelField(org.kie.soup.project.datamodel.oracle.ModelField) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) ModuleDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl)

Example 2 with ModuleDataModelOracle

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;
}
Also used : ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) Package(org.guvnor.common.services.project.model.Package) DefaultIndexBuilder(org.kie.workbench.common.services.refactoring.backend.server.indexing.DefaultIndexBuilder) Module(org.guvnor.common.services.project.model.Module) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario)

Example 3 with ModuleDataModelOracle

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;
}
Also used : ModelField(org.kie.soup.project.datamodel.oracle.ModelField) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) Applicant(org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant) ModuleDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl)

Example 4 with ModuleDataModelOracle

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;
}
Also used : ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) DefaultIndexBuilder(org.kie.workbench.common.services.refactoring.backend.server.indexing.DefaultIndexBuilder) DataEnumLoader(org.kie.workbench.common.services.datamodel.backend.server.builder.util.DataEnumLoader)

Example 5 with ModuleDataModelOracle

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);
}
Also used : Path(org.uberfire.java.nio.file.Path) KProperty(org.uberfire.ext.metadata.model.KProperty) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) AbstractListAssert(org.assertj.core.api.AbstractListAssert) Test(org.junit.Test)

Aggregations

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