Search in sources :

Example 1 with ModuleDataModelOracleImpl

use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl in project kie-wb-common by kiegroup.

the class DataObjectsServiceImplTest method setup.

@Before
public void setup() {
    service = new DataObjectsServiceImpl(dataModelService, moduleClassLoaderHelper, moduleService);
    dataModelOracle = new ModuleDataModelOracleImpl();
    dataModelOracle.addModulePackageNames(Collections.singletonList(APerson.class.getPackage().getName()));
    when(workspaceProject.getRootPath()).thenReturn(projectRootPath);
    when(dataModelService.getModuleDataModel(projectRootPath)).thenReturn(dataModelOracle);
    when(moduleService.resolveModule(projectRootPath)).thenReturn(kieModule);
    when(moduleClassLoaderHelper.getModuleClassLoader(kieModule)).thenReturn(Thread.currentThread().getContextClassLoader());
}
Also used : APerson(org.kie.workbench.common.dmn.backend.editors.types.classes.APerson) ModuleDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl) Before(org.junit.Before)

Example 2 with ModuleDataModelOracleImpl

use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl in project kie-wb-common by kiegroup.

the class ModuleDataModelFactFieldsAnnotationsTest method testModuleDMOAnnotationAttributes.

@Test
public void testModuleDMOAnnotationAttributes() throws Exception {
    final ModuleDataModelOracleBuilder builder = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator());
    final ModuleDataModelOracleImpl oracle = new ModuleDataModelOracleImpl();
    final ClassFactBuilder cb = new ClassFactBuilder(builder, SmurfHouse.class, false, type -> TypeSource.JAVA_PROJECT);
    cb.build(oracle);
    assertEquals(1, oracle.getModuleModelFields().size());
    assertContains("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.SmurfHouse", oracle.getModuleModelFields().keySet());
    final Map<String, Set<Annotation>> fieldsAnnotations = oracle.getModuleTypeFieldsAnnotations().get("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.SmurfHouse");
    assertNotNull(fieldsAnnotations);
    assertEquals(2, fieldsAnnotations.size());
    testBaseAnnotations(fieldsAnnotations);
}
Also used : Set(java.util.Set) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) ModuleDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl) ClassFactBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ClassFactBuilder) ModuleDataModelOracleBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder) Test(org.junit.Test)

Example 3 with ModuleDataModelOracleImpl

use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl in project kie-wb-common by kiegroup.

the class ModuleDataModelFactFieldsAnnotationsTest method testModuleDMOZeroAnnotationAttributes.

@Test
public void testModuleDMOZeroAnnotationAttributes() throws Exception {
    final ModuleDataModelOracleBuilder builder = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator());
    final ModuleDataModelOracleImpl oracle = new ModuleDataModelOracleImpl();
    final ClassFactBuilder cb = new ClassFactBuilder(builder, Product.class, false, type -> TypeSource.JAVA_PROJECT);
    cb.build(oracle);
    assertEquals(1, oracle.getModuleModelFields().size());
    assertContains("org.kie.workbench.common.services.datamodel.backend.server.testclasses.Product", oracle.getModuleModelFields().keySet());
    final Map<String, Set<Annotation>> fieldAnnotations = oracle.getModuleTypeFieldsAnnotations().get("org.kie.workbench.common.services.datamodel.backend.server.testclasses.Product");
    assertNotNull(fieldAnnotations);
    assertEquals(0, fieldAnnotations.size());
}
Also used : Set(java.util.Set) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) ModuleDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl) ClassFactBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ClassFactBuilder) ModuleDataModelOracleBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder) Test(org.junit.Test)

Example 4 with ModuleDataModelOracleImpl

use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl in project kie-wb-common by kiegroup.

the class DataModelServiceImpl method getModuleDataModel.

@Override
public ModuleDataModelOracle getModuleDataModel(final Path resourcePath) {
    try {
        PortablePreconditions.checkNotNull("resourcePath", resourcePath);
        final KieModule module = resolveModule(resourcePath);
        // Resource was not within a Module structure
        if (module == null) {
            return new ModuleDataModelOracleImpl();
        }
        // Retrieve (or build) oracle
        final ModuleDataModelOracle oracle = cacheModules.assertModuleDataModelOracle(module);
        return oracle;
    } catch (Exception e) {
        e.printStackTrace();
        throw ExceptionUtilities.handleException(e);
    }
}
Also used : ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) KieModule(org.kie.workbench.common.services.shared.project.KieModule) ModuleDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl)

Example 5 with ModuleDataModelOracleImpl

use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl in project kie-wb-common by kiegroup.

the class PackageDataModelOracleBuilder method build.

public PackageDataModelOracle build() {
    // Copy Module DMO into Package DMO
    final ModuleDataModelOracleImpl pd = (ModuleDataModelOracleImpl) moduleOracle;
    packageOracle.addModuleModelFields(pd.getModuleModelFields());
    packageOracle.addModuleFieldParametersType(pd.getModuleFieldParametersType());
    packageOracle.addModuleJavaEnumDefinitions(pd.getModuleJavaEnumDefinitions());
    packageOracle.addModuleMethodInformation(pd.getModuleMethodInformation());
    packageOracle.addModuleCollectionTypes(pd.getModuleCollectionTypes());
    packageOracle.addModuleEventTypes(pd.getModuleEventTypes());
    packageOracle.addModuleTypeSources(pd.getModuleTypeSources());
    packageOracle.addModuleSuperTypes(pd.getModuleSuperTypes());
    packageOracle.addModuleTypeAnnotations(pd.getModuleTypeAnnotations());
    packageOracle.addModuleTypeFieldsAnnotations(pd.getModuleTypeFieldsAnnotations());
    packageOracle.addModulePackageNames(pd.getModulePackageNames());
    // Add Package DMO specifics
    loadEnums();
    loadPackageElements();
    loadGlobals();
    loadModuleOracle();
    return packageOracle;
}
Also used : ModuleDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl)

Aggregations

ModuleDataModelOracleImpl (org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl)37 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)22 Test (org.junit.Test)20 ClassFactBuilder (org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ClassFactBuilder)20 ModuleDataModelOracleBuilder (org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder)20 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)15 Annotation (org.kie.soup.project.datamodel.oracle.Annotation)14 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)14 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)13 Set (java.util.Set)12 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)12 PackageDataModelOracleBuilder (org.kie.workbench.common.services.datamodel.backend.server.builder.packages.PackageDataModelOracleBuilder)12 IncrementalDataModelService (org.kie.workbench.common.services.datamodel.service.IncrementalDataModelService)12 Path (org.uberfire.backend.vfs.Path)12 Map (java.util.Map)4 FactBuilder (org.kie.workbench.common.services.datamodel.backend.server.builder.projects.FactBuilder)2 Applicant (org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant)1 Before (org.junit.Before)1 APerson (org.kie.workbench.common.dmn.backend.editors.types.classes.APerson)1 Product (org.kie.workbench.common.services.datamodel.backend.server.testclasses.Product)1