@Test public void testLoadDataObjects_ResolvedCustomProperty() { final Maps.Builder<String, ModelField[]> modelFieldsBuilder = new Maps.Builder<>(); modelFieldsBuilder.put(APerson.class.getName(), new ModelField[]{ newModelField(DataType.TYPE_THIS, APerson.class.getName(), APerson.class.getSimpleName()) }); modelFieldsBuilder.put(CFamily.class.getName(), new ModelField[]{ newModelField(DataType.TYPE_THIS, CFamily.class.getName(), CFamily.class.getSimpleName()), newModelField("mother", APerson.class.getName(), APerson.class.getSimpleName()) }); final Map<String, ModelField[]> modelFields = modelFieldsBuilder.build(); dataModelOracle.addModuleModelFields(modelFields); final List<DataObject> dataObjects = service.loadDataObjects(workspaceProject); assertThat(dataObjects).isNotEmpty(); assertThat(dataObjects).hasSize(2); assertThat(dataObjects.get(0).getClassType()).isEqualTo(APerson.class.getName()); assertThat(dataObjects.get(0).getProperties()).isEmpty(); assertThat(dataObjects.get(1).getClassType()).isEqualTo(CFamily.class.getName()); assertThat(dataObjects.get(1).getProperties()).hasSize(1); assertThat(dataObjects.get(1).getProperties().get(0).getProperty()).isEqualTo("mother"); assertThat(dataObjects.get(1).getProperties().get(0).getType()).isEqualTo(APerson.class.getName()); }
@Override public List<DataObject> loadDataObjects(final WorkspaceProject workspaceProject) { final KieModule module = moduleService.resolveModule(workspaceProject.getRootPath()); final ClassLoader classLoader = moduleClassLoaderHelper.getModuleClassLoader(module); final ModuleDataModelOracle dmo = dataModelService.getModuleDataModel(workspaceProject.getRootPath()); final String[] types = DataModelOracleUtilities.getFactTypes(dmo); final Map<String, ModelField[]> typesModelFields = dmo.getModuleModelFields(); final Map<String, String> parametersType = dmo.getModuleFieldParametersType(); final List<DataObject> dataObjects = Arrays.stream(types).map(DataObject::new).collect(Collectors.toList()); dataObjects.forEach(dataObject -> convertProperties(dataObject, dataObjects, typesModelFields, classLoader, parametersType)); return dataObjects; }
DataObjectsServiceImpl implements DataObjectsService { @Override public List<DataObject> loadDataObjects(final WorkspaceProject workspaceProject) { final KieModule module = moduleService.resolveModule(workspaceProject.getRootPath()); final ClassLoader classLoader = moduleClassLoaderHelper.getModuleClassLoader(module); final ModuleDataModelOracle dmo = dataModelService.getModuleDataModel(workspaceProject.getRootPath()); final String[] types = DataModelOracleUtilities.getFactTypes(dmo); final Map<String, ModelField[]> typesModelFields = dmo.getModuleModelFields(); final Map<String, String> parametersType = dmo.getModuleFieldParametersType(); final List<DataObject> dataObjects = Arrays.stream(types).map(DataObject::new).collect(Collectors.toList()); dataObjects.forEach(dataObject -> convertProperties(dataObject, dataObjects, typesModelFields, classLoader, parametersType)); return dataObjects; } }
DataObjectsServiceImpl implements DataObjectsService { @Override public List<DataObject> loadDataObjects(final WorkspaceProject workspaceProject) { final KieModule module = moduleService.resolveModule(workspaceProject.getRootPath()); final ClassLoader classLoader = moduleClassLoaderHelper.getModuleClassLoader(module); final ModuleDataModelOracle dmo = dataModelService.getModuleDataModel(workspaceProject.getRootPath()); final String[] types = DataModelOracleUtilities.getFactTypes(dmo); final Map<String, ModelField[]> typesModelFields = dmo.getModuleModelFields(); final Map<String, String> parametersType = dmo.getModuleFieldParametersType(); final List<DataObject> dataObjects = Arrays.stream(types).map(DataObject::new).collect(Collectors.toList()); dataObjects.forEach(dataObject -> convertProperties(dataObject, dataObjects, typesModelFields, classLoader, parametersType)); return dataObjects; } protected  DataObjectsServiceImpl(); @Inject  DataObjectsServiceImpl(final DataModelService dataModelService,
                                  final ModuleClassLoaderHelper moduleClassLoaderHelper,
                                  final KieModuleService moduleService); }
DataObjectsServiceImpl implements DataObjectsService { @Override public List<DataObject> loadDataObjects(final WorkspaceProject workspaceProject) { final KieModule module = moduleService.resolveModule(workspaceProject.getRootPath()); final ClassLoader classLoader = moduleClassLoaderHelper.getModuleClassLoader(module); final ModuleDataModelOracle dmo = dataModelService.getModuleDataModel(workspaceProject.getRootPath()); final String[] types = DataModelOracleUtilities.getFactTypes(dmo); final Map<String, ModelField[]> typesModelFields = dmo.getModuleModelFields(); final Map<String, String> parametersType = dmo.getModuleFieldParametersType(); final List<DataObject> dataObjects = Arrays.stream(types).map(DataObject::new).collect(Collectors.toList()); dataObjects.forEach(dataObject -> convertProperties(dataObject, dataObjects, typesModelFields, classLoader, parametersType)); return dataObjects; } protected  DataObjectsServiceImpl(); @Inject  DataObjectsServiceImpl(final DataModelService dataModelService,
                                  final ModuleClassLoaderHelper moduleClassLoaderHelper,
                                  final KieModuleService moduleService); @Override List<DataObject> loadDataObjects(final WorkspaceProject workspaceProject); }
DataObjectsServiceImpl implements DataObjectsService { @Override public List<DataObject> loadDataObjects(final WorkspaceProject workspaceProject) { final KieModule module = moduleService.resolveModule(workspaceProject.getRootPath()); final ClassLoader classLoader = moduleClassLoaderHelper.getModuleClassLoader(module); final ModuleDataModelOracle dmo = dataModelService.getModuleDataModel(workspaceProject.getRootPath()); final String[] types = DataModelOracleUtilities.getFactTypes(dmo); final Map<String, ModelField[]> typesModelFields = dmo.getModuleModelFields(); final Map<String, String> parametersType = dmo.getModuleFieldParametersType(); final List<DataObject> dataObjects = Arrays.stream(types).map(DataObject::new).collect(Collectors.toList()); dataObjects.forEach(dataObject -> convertProperties(dataObject, dataObjects, typesModelFields, classLoader, parametersType)); return dataObjects; } protected  DataObjectsServiceImpl(); @Inject  DataObjectsServiceImpl(final DataModelService dataModelService,
                                  final ModuleClassLoaderHelper moduleClassLoaderHelper,
                                  final KieModuleService moduleService); @Override List<DataObject> loadDataObjects(final WorkspaceProject workspaceProject);  }