use of org.kie.dmn.core.impl.DMNPackageImpl in project drools by kiegroup.
the class DMNWeaverService method merge.
@Override
public void merge(KiePackage kiePkg, DMNPackage dmnpkg) {
ResourceTypePackageRegistry registry = ((InternalKnowledgePackage) kiePkg).getResourceTypePackages();
DMNPackageImpl existing = registry.computeIfAbsent(ResourceType.DMN, rt -> new DMNPackageImpl(dmnpkg.getNamespace()));
for (Map.Entry<String, DMNModel> entry : dmnpkg.getAllModels().entrySet()) {
existing.addModel(entry.getKey(), entry.getValue());
}
existing.addProfiles(((DMNPackageImpl) dmnpkg).getProfiles());
}
use of org.kie.dmn.core.impl.DMNPackageImpl in project drools by kiegroup.
the class DMNAssemblerService method addResourcesAfterRules.
@Override
public void addResourcesAfterRules(Object kbuilder, Collection<ResourceWithConfiguration> resources, ResourceType type) throws Exception {
EvalHelper.clearGenericAccessorCache();
KnowledgeBuilderImpl kbuilderImpl = (KnowledgeBuilderImpl) kbuilder;
DMNCompilerImpl dmnCompiler = (DMNCompilerImpl) kbuilderImpl.getCachedOrCreate(DMN_COMPILER_CACHE_KEY, () -> getCompiler(kbuilderImpl));
DMNMarshaller dmnMarshaller = dmnCompiler.getMarshaller();
List<DMNResource> dmnResources = new ArrayList<>();
for (ResourceWithConfiguration r : resources) {
Definitions definitions = dmnMarshaller.unmarshal(r.getResource().getReader());
DMNResource dmnResource = new DMNResource(definitions, r);
dmnResources.add(dmnResource);
}
Collection<DMNModel> dmnModels = new ArrayList<>();
// KIE API: KieContainer upgrade using KieContainer#updateToVersion -based DMN Import resolution strategy
if (kbuilderImpl.getKnowledgeBase() != null) {
for (InternalKnowledgePackage pr : kbuilderImpl.getKnowledgeBase().getPackagesMap().values()) {
ResourceTypePackage resourceTypePackage = pr.getResourceTypePackages().get(ResourceType.DMN);
if (resourceTypePackage != null) {
DMNPackageImpl dmnpkg = (DMNPackageImpl) resourceTypePackage;
dmnModels.addAll(dmnpkg.getAllModels().values());
}
}
}
// Workbench: InternalKieBuilder#createFileSet#build -based DMN Import resolution strategy
for (PackageRegistry pr : kbuilderImpl.getPackageRegistry().values()) {
ResourceTypePackage resourceTypePackage = pr.getPackage().getResourceTypePackages().get(ResourceType.DMN);
if (resourceTypePackage != null) {
DMNPackageImpl dmnpkg = (DMNPackageImpl) resourceTypePackage;
dmnModels.addAll(dmnpkg.getAllModels().values());
}
}
enrichDMNResourcesWithImportsDependencies(dmnResources, dmnModels);
List<DMNResource> sortedDmnResources = DMNResourceDependenciesSorter.sort(dmnResources);
for (DMNResource dmnRes : sortedDmnResources) {
DMNModel dmnModel = internalAddResource(kbuilderImpl, dmnCompiler, dmnRes, dmnModels);
dmnModels.add(dmnModel);
}
}
Aggregations