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