use of org.kie.dmn.core.compiler.DMNProfile in project drools by kiegroup.
the class DMNAssemblerService method getCompiler.
private DMNCompiler getCompiler(KnowledgeBuilderImpl kbuilderImpl) {
List<DMNProfile> dmnProfiles = kbuilderImpl.getCachedOrCreate(DMN_PROFILES_CACHE_KEY, () -> getDMNProfiles(kbuilderImpl));
DMNCompilerConfiguration compilerConfig = compilerConfigWithKModulePrefs(kbuilderImpl.getBuilderConfiguration().getChainedProperties(), dmnProfiles);
return DMNFactory.newCompiler(compilerConfig);
}
use of org.kie.dmn.core.compiler.DMNProfile in project drools by kiegroup.
the class DMNAssemblerService method getDMNProfiles.
private List<DMNProfile> getDMNProfiles(KnowledgeBuilderImpl kbuilderImpl) {
ChainedProperties chainedProperties = kbuilderImpl.getBuilderConfiguration().getChainedProperties();
List<DMNProfile> dmnProfiles = new ArrayList<>();
dmnProfiles.addAll(getDefaultDMNProfiles(chainedProperties));
Map<String, String> dmnProfileProperties = new HashMap<>();
chainedProperties.mapStartsWith(dmnProfileProperties, DMN_PROFILE_PREFIX, false);
if (!dmnProfileProperties.isEmpty()) {
try {
for (Map.Entry<String, String> dmnProfileProperty : dmnProfileProperties.entrySet()) {
DMNProfile dmnProfile = (DMNProfile) kbuilderImpl.getRootClassLoader().loadClass(dmnProfileProperty.getValue()).newInstance();
dmnProfiles.add(dmnProfile);
}
return dmnProfiles;
} catch (Exception e) {
kbuilderImpl.addBuilderResult(new DMNKnowledgeBuilderError(ResultSeverity.WARNING, "Trying to load a non-existing Kie DMN profile " + e.getLocalizedMessage()));
logger.error("Trying to load a non-existing Kie DMN profile {}", e.getLocalizedMessage(), e);
kbuilderImpl.addBuilderResult(new DMNKnowledgeBuilderError(ResultSeverity.WARNING, "DMN Compiler configuration contained errors, will fall-back using empty-configuration compiler."));
logger.warn("DMN Compiler configuration contained errors, will fall-back using empty-configuration compiler.");
}
}
return dmnProfiles;
}
use of org.kie.dmn.core.compiler.DMNProfile in project drools by kiegroup.
the class DMNAssemblerService method compilerConfigWithKModulePrefs.
/**
* Returns a DMNCompilerConfiguration with the specified properties set, and applying the explicited dmnProfiles.
* @param chainedProperties applies properties --it does not do any classloading nor profile loading based on these properites, just passes the values.
* @param dmnProfiles applies these DMNProfile(s) to the DMNCompilerConfiguration
* @return
*/
public static DMNCompilerConfiguration compilerConfigWithKModulePrefs(ChainedProperties chainedProperties, List<DMNProfile> dmnProfiles) {
DMNCompilerConfigurationImpl config = (DMNCompilerConfigurationImpl) DMNFactory.newCompilerConfiguration();
Map<String, String> dmnPrefs = new HashMap<>();
chainedProperties.mapStartsWith(dmnPrefs, ORG_KIE_DMN_PREFIX, true);
config.setProperties(dmnPrefs);
for (DMNProfile dmnProfile : dmnProfiles) {
config.addExtensions(dmnProfile.getExtensionRegisters());
config.addDRGElementCompilers(dmnProfile.getDRGElementCompilers());
config.addFEELProfile(dmnProfile);
}
return config;
}
use of org.kie.dmn.core.compiler.DMNProfile in project drools by kiegroup.
the class DMNRuntimeImpl method getProfiles.
public List<DMNProfile> getProfiles() {
// need list to preserve ordering
List<DMNProfile> profiles = new ArrayList<>();
runtime.getKieBase().getKiePackages().forEach(kpkg -> {
DMNPackageImpl dmnPkg = (DMNPackageImpl) ((InternalKnowledgePackage) kpkg).getResourceTypePackages().get(ResourceType.DMN);
if (dmnPkg != null) {
for (DMNProfile p : dmnPkg.getProfiles()) {
if (!profiles.contains(p)) {
profiles.add(p);
}
}
}
});
return profiles;
}
Aggregations