Search in sources :

Example 1 with PackageDataModelOracleIncrementalPayload

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);
    }
}
Also used : PackageDataModelOracleIncrementalPayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleIncrementalPayload) TypeSource(org.kie.soup.project.datamodel.oracle.TypeSource) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 2 with PackageDataModelOracleIncrementalPayload

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;
}
Also used : PackageDataModelOracleIncrementalPayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleIncrementalPayload) LazyModelField(org.kie.workbench.common.services.datamodel.model.LazyModelField) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) HashMap(java.util.HashMap)

Example 3 with PackageDataModelOracleIncrementalPayload

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);
    }
}
Also used : PackageDataModelOracleIncrementalPayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleIncrementalPayload) Import(org.kie.soup.project.datamodel.imports.Import) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) Package(org.guvnor.common.services.project.model.Package) KieModule(org.kie.workbench.common.services.shared.project.KieModule)

Example 4 with PackageDataModelOracleIncrementalPayload

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;
}
Also used : PackageDataModelOracleIncrementalPayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleIncrementalPayload) LazyModelField(org.kie.workbench.common.services.datamodel.model.LazyModelField) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) HashMap(java.util.HashMap)

Example 5 with PackageDataModelOracleIncrementalPayload

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;
}
Also used : PackageDataModelOracleIncrementalPayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleIncrementalPayload) LazyModelField(org.kie.workbench.common.services.datamodel.model.LazyModelField) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) HashMap(java.util.HashMap)

Aggregations

PackageDataModelOracleIncrementalPayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleIncrementalPayload)6 HashMap (java.util.HashMap)4 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)4 LazyModelField (org.kie.workbench.common.services.datamodel.model.LazyModelField)4 Package (org.guvnor.common.services.project.model.Package)1 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 Import (org.kie.soup.project.datamodel.imports.Import)1 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)1 TypeSource (org.kie.soup.project.datamodel.oracle.TypeSource)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1