Search in sources :

Example 1 with DMNPackage

use of org.kie.dmn.api.core.DMNPackage in project drools by kiegroup.

the class DMNRuntimeKBWrappingIKB method getModelById.

@Override
public DMNModel getModelById(String namespace, String modelId) {
    Objects.requireNonNull(namespace, () -> MsgUtil.createMessage(Msg.PARAM_CANNOT_BE_NULL, "namespace"));
    Objects.requireNonNull(modelId, () -> MsgUtil.createMessage(Msg.PARAM_CANNOT_BE_NULL, "modelId"));
    InternalKnowledgePackage kpkg = (InternalKnowledgePackage) knowledgeBase.getKiePackage(namespace);
    if (kpkg == null) {
        return null;
    }
    ResourceTypePackageRegistry map = kpkg.getResourceTypePackages();
    DMNPackage dmnpkg = (DMNPackage) map.get(ResourceType.DMN);
    return dmnpkg != null ? dmnpkg.getModelById(modelId) : null;
}
Also used : DMNPackage(org.kie.dmn.api.core.DMNPackage) ResourceTypePackageRegistry(org.drools.core.definitions.ResourceTypePackageRegistry) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Example 2 with DMNPackage

use of org.kie.dmn.api.core.DMNPackage in project drools by kiegroup.

the class DMNRuntimeKBWrappingIKB method getModels.

@Override
public List<DMNModel> getModels() {
    List<DMNModel> models = new ArrayList<>();
    knowledgeBase.getKiePackages().forEach(kpkg -> {
        DMNPackage dmnPkg = (DMNPackage) ((InternalKnowledgePackage) kpkg).getResourceTypePackages().get(ResourceType.DMN);
        if (dmnPkg != null) {
            dmnPkg.getAllModels().values().forEach(model -> models.add(model));
        }
    });
    return models;
}
Also used : DMNPackage(org.kie.dmn.api.core.DMNPackage) ArrayList(java.util.ArrayList) DMNModel(org.kie.dmn.api.core.DMNModel) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Example 3 with DMNPackage

use of org.kie.dmn.api.core.DMNPackage in project drools by kiegroup.

the class DMNRuntimeImpl method getModel.

@Override
public DMNModel getModel(String namespace, String modelName) {
    InternalKnowledgePackage kpkg = (InternalKnowledgePackage) runtime.getKieBase().getKiePackage(namespace);
    if (kpkg == null) {
        return null;
    }
    Map<ResourceType, ResourceTypePackage> map = kpkg.getResourceTypePackages();
    DMNPackage dmnpkg = (DMNPackage) map.get(ResourceType.DMN);
    return dmnpkg != null ? dmnpkg.getModel(modelName) : null;
}
Also used : DMNPackage(org.kie.dmn.api.core.DMNPackage) ResourceType(org.kie.api.io.ResourceType) ResourceTypePackage(org.kie.api.internal.io.ResourceTypePackage) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Example 4 with DMNPackage

use of org.kie.dmn.api.core.DMNPackage in project drools by kiegroup.

the class DMNRuntimeImpl method getModels.

@Override
public List<DMNModel> getModels() {
    List<DMNModel> models = new ArrayList<>();
    runtime.getKieBase().getKiePackages().forEach(kpkg -> {
        DMNPackage dmnPkg = (DMNPackage) ((InternalKnowledgePackage) kpkg).getResourceTypePackages().get(ResourceType.DMN);
        if (dmnPkg != null) {
            dmnPkg.getAllModels().values().forEach(model -> models.add(model));
        }
    });
    return models;
}
Also used : DMNPackage(org.kie.dmn.api.core.DMNPackage) ArrayList(java.util.ArrayList) DMNModel(org.kie.dmn.api.core.DMNModel) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Example 5 with DMNPackage

use of org.kie.dmn.api.core.DMNPackage in project drools by kiegroup.

the class DMNRuntimeKBWrappingIKB method getModel.

@Override
public DMNModel getModel(String namespace, String modelName) {
    Objects.requireNonNull(namespace, () -> MsgUtil.createMessage(Msg.PARAM_CANNOT_BE_NULL, "namespace"));
    Objects.requireNonNull(modelName, () -> MsgUtil.createMessage(Msg.PARAM_CANNOT_BE_NULL, "modelName"));
    InternalKnowledgePackage kpkg = (InternalKnowledgePackage) knowledgeBase.getKiePackage(namespace);
    if (kpkg == null) {
        return null;
    }
    ResourceTypePackageRegistry map = kpkg.getResourceTypePackages();
    DMNPackage dmnpkg = (DMNPackage) map.get(ResourceType.DMN);
    return dmnpkg != null ? dmnpkg.getModel(modelName) : null;
}
Also used : DMNPackage(org.kie.dmn.api.core.DMNPackage) ResourceTypePackageRegistry(org.drools.core.definitions.ResourceTypePackageRegistry) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Aggregations

InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)5 DMNPackage (org.kie.dmn.api.core.DMNPackage)5 ArrayList (java.util.ArrayList)2 ResourceTypePackageRegistry (org.drools.core.definitions.ResourceTypePackageRegistry)2 DMNModel (org.kie.dmn.api.core.DMNModel)2 ResourceTypePackage (org.kie.api.internal.io.ResourceTypePackage)1 ResourceType (org.kie.api.io.ResourceType)1