use of org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleIncrementalPayload 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.workbench.common.services.datamodel.model.PackageDataModelOracleIncrementalPayload in project kie-wb-common by kiegroup.
the class AsyncPackageDataModelOracleImplTest method createGiantPayload.
private PackageDataModelOracleIncrementalPayload createGiantPayload() {
PackageDataModelOracleIncrementalPayload payload = new PackageDataModelOracleIncrementalPayload();
HashMap<String, ModelField[]> addressModelFields = new HashMap<String, ModelField[]>();
addressModelFields.put("org.globals.GiantContainerOfInformation", new ModelField[] { new ModelField("this", "org.globals.GiantContainerOfInformation", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.SELF, FieldAccessorsAndMutators.ACCESSOR, "this") });
payload.setModelFields(addressModelFields);
return payload;
}
use of org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleIncrementalPayload in project kie-wb-common by kiegroup.
the class IncrementalDataModelServiceImpl method getUpdates.
@Override
public PackageDataModelOracleIncrementalPayload getUpdates(final Path resourcePath, final Imports imports, final String factType) {
PortablePreconditions.checkNotNull("resourcePath", resourcePath);
PortablePreconditions.checkNotNull("imports", imports);
PortablePreconditions.checkNotNull("factType", factType);
final PackageDataModelOracleIncrementalPayload dataModel = new PackageDataModelOracleIncrementalPayload();
try {
// Check resource was within a Module structure
final KieModule project = resolveModule(resourcePath);
if (project == null) {
return dataModel;
}
// Check resource was within a Package structure
final Package pkg = resolvePackage(resourcePath);
if (pkg == null) {
return dataModel;
}
// Get the fully qualified class name of the fact type
String fullyQualifiedClassName = factType;
// Retrieve (or build) oracle and populate incremental content
final PackageDataModelOracle oracle = cachePackages.assertPackageDataModelOracle(project, pkg);
// Check if the FactType is already known to the DataModelOracle, otherwise we need to find the FQCN
if (oracle.getModuleModelFields().get(fullyQualifiedClassName) == null) {
for (Import imp : imports.getImports()) {
if (imp.getType().endsWith(factType)) {
fullyQualifiedClassName = imp.getType();
break;
}
}
}
// If the FactType isn't recognised try using the Package Name
if (oracle.getModuleModelFields().get(fullyQualifiedClassName) == null) {
fullyQualifiedClassName = pkg.getPackageName() + "." + factType;
}
// If the FactType still isn't recognised return an empty payload
if (oracle.getModuleModelFields().get(fullyQualifiedClassName) == null) {
return dataModel;
}
DataModelOracleUtilities.populateDataModel(oracle, dataModel, fullyQualifiedClassName);
return dataModel;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleIncrementalPayload in project kie-wb-common by kiegroup.
the class AsyncPackageDataModelOracleImplTest method createStringPayload.
private PackageDataModelOracleIncrementalPayload createStringPayload() {
PackageDataModelOracleIncrementalPayload payload = new PackageDataModelOracleIncrementalPayload();
HashMap<String, ModelField[]> addressModelFields = new HashMap<String, ModelField[]>();
addressModelFields.put("java.lang.String", new ModelField[] { new ModelField("this", "java.lang.String", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.SELF, FieldAccessorsAndMutators.ACCESSOR, "this") });
payload.setModelFields(addressModelFields);
return payload;
}
use of org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleIncrementalPayload in project kie-wb-common by kiegroup.
the class AsyncPackageDataModelOracleImplTest method createAddressPayload.
private PackageDataModelOracleIncrementalPayload createAddressPayload() {
PackageDataModelOracleIncrementalPayload payload = new PackageDataModelOracleIncrementalPayload();
HashMap<String, ModelField[]> addressModelFields = new HashMap<String, ModelField[]>();
addressModelFields.put("org.Address", new ModelField[] { new ModelField("this", "org.Address", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.SELF, FieldAccessorsAndMutators.ACCESSOR, "this"), new ModelField("street", "String", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_STRING), new ModelField("homeAddress", "Boolean", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_BOOLEAN), new ModelField("number", Integer.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_NUMERIC_INTEGER) });
payload.setModelFields(addressModelFields);
return payload;
}
Aggregations