use of org.kie.soup.project.datamodel.oracle.TypeSource in project kie-wb-common by kiegroup.
the class AsyncPackageDataModelOracleImpl method getTypeSource.
/**
* Return where a given FactType was defined
* @param factType
* @return
*/
@Override
public void getTypeSource(final String factType, final Callback<TypeSource> callback) {
final TypeSource typeSource = filteredTypeSources.get(factType);
// Load incremental content
if (typeSource == null) {
service.call(new RemoteCallback<PackageDataModelOracleIncrementalPayload>() {
@Override
public void callback(final PackageDataModelOracleIncrementalPayload dataModel) {
AsyncPackageDataModelOracleUtilities.populateDataModelOracle(AsyncPackageDataModelOracleImpl.this, dataModel);
final TypeSource typeSource = filteredTypeSources.get(factType);
callback.callback(typeSource);
}
}).getUpdates(resourcePath, imports, factType);
} else {
callback.callback(typeSource);
}
}
use of org.kie.soup.project.datamodel.oracle.TypeSource in project kie-wb-common by kiegroup.
the class PackageDataModelDeclaredTypesTest method testPackageDeclaredTypes.
@Test
public void testPackageDeclaredTypes() throws Exception {
final Bean dataModelServiceBean = (Bean) beanManager.getBeans(DataModelService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(dataModelServiceBean);
final DataModelService dataModelService = (DataModelService) beanManager.getReference(dataModelServiceBean, DataModelService.class, cc);
final URL packageUrl = this.getClass().getResource("/DataModelBackendDeclaredTypesTest1/src/main/java/t1p1");
final org.uberfire.java.nio.file.Path nioPackagePath = fs.getPath(packageUrl.toURI());
final Path packagePath = paths.convert(nioPackagePath);
final PackageDataModelOracle packageLoader = dataModelService.getDataModel(packagePath);
// Emulate server-to-client conversions
final Caller<IncrementalDataModelService> service = new MockIncrementalDataModelServiceCaller(packageLoader);
final AsyncPackageDataModelOracle oracle = new AsyncPackageDataModelOracleImpl(service, validatorInstance);
final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
dataModel.setPackageName("t1p1");
dataModel.setModelFields(packageLoader.getModuleModelFields());
dataModel.setTypeSources(new HashMap<String, TypeSource>() {
{
put("t1p1.Bean1", TypeSource.JAVA_PROJECT);
put("t1p1.DRLBean", TypeSource.DECLARED);
put("t1p2.Bean2", TypeSource.JAVA_PROJECT);
put("java.lang.String", TypeSource.JAVA_PROJECT);
put("int", TypeSource.JAVA_PROJECT);
}
});
PackageDataModelOracleTestUtils.populateDataModelOracle(mock(Path.class), new MockHasImports(), oracle, dataModel);
assertNotNull(dataModel);
assertEquals(2, oracle.getFactTypes().length);
PackageDataModelOracleTestUtils.assertContains("Bean1", oracle.getFactTypes());
PackageDataModelOracleTestUtils.assertContains("DRLBean", oracle.getFactTypes());
assertEquals(2, oracle.getExternalFactTypes().length);
PackageDataModelOracleTestUtils.assertContains("t1p2.Bean2", oracle.getExternalFactTypes());
PackageDataModelOracleTestUtils.assertContains("java.lang.String", oracle.getExternalFactTypes());
oracle.getTypeSource("Bean1", new Callback<TypeSource>() {
@Override
public void callback(final TypeSource result) {
assertEquals(TypeSource.JAVA_PROJECT, result);
}
});
oracle.getTypeSource("DRLBean", new Callback<TypeSource>() {
@Override
public void callback(final TypeSource result) {
assertEquals(TypeSource.DECLARED, result);
}
});
}
Aggregations