ChinchuAjith commented on code in PR #6267:
URL:
https://github.com/apache/incubator-kie-drools/pull/6267#discussion_r1984530204
##########
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java:
##########
@@ -209,60 +210,82 @@ public DMNModel compile(Definitions dmndefs,
Collection<DMNModel> dmnModels, Res
}
DMNModelImpl model = new DMNModelImpl(dmndefs, resource);
model.setRuntimeTypeCheck(((DMNCompilerConfigurationImpl)
dmnCompilerConfig).getOption(RuntimeTypeCheckOption.class).isRuntimeTypeCheck());
+ DMNCompilerContext ctx = configureDMNCompiler(model.getFeelDialect(),
relativeResolver);
+ if (!dmndefs.getImport().isEmpty()) {
+ iterateImports(dmndefs, dmnModels, model, relativeResolver );
+ }
+ processItemDefinitions(ctx, model, dmndefs);
+ processDrgElements(ctx, model, dmndefs);
+ return model;
+ }
+
+ private DMNCompilerContext configureDMNCompiler(FEELDialect feeldialect,
Function<String, Reader> relativeResolver) {
+
DMNCompilerConfigurationImpl cc = (DMNCompilerConfigurationImpl)
dmnCompilerConfig;
List<FEELProfile> helperFEELProfiles = cc.getFeelProfiles();
- DMNFEELHelper feel = new DMNFEELHelper(cc.getRootClassLoader(),
helperFEELProfiles, model.getFeelDialect());
+ DMNFEELHelper feel = new DMNFEELHelper(cc.getRootClassLoader(),
helperFEELProfiles, feeldialect);
DMNCompilerContext ctx = new DMNCompilerContext(feel);
ctx.setRelativeResolver(relativeResolver);
+ return ctx;
+ }
+
+ private void iterateImports(Definitions dmndefs, Collection<DMNModel>
dmnModels, DMNModelImpl model, Function<String, Reader> relativeResolver ) {
List<DMNModel> toMerge = new ArrayList<>();
- if (!dmndefs.getImport().isEmpty()) {
- for (Import i : dmndefs.getImport()) {
- if (ImportDMNResolverUtil.whichImportType(i) ==
ImportType.DMN) {
- Either<String, DMNModel> resolvedResult =
ImportDMNResolverUtil.resolveImportDMN(i, dmnModels, (DMNModel m) -> new
QName(m.getNamespace(), m.getName()));
- DMNModel located = resolvedResult.cata(msg -> {
- MsgUtil.reportMessage(logger,
- DMNMessage.Severity.ERROR,
- i,
- model,
- null,
- null,
- Msg.IMPORT_NOT_FOUND_FOR_NODE,
- msg,
- i);
- return null;
- }, Function.identity());
- if (located != null) {
- String iAlias =
Optional.ofNullable(i.getName()).orElse(located.getName());
- // incubator-kie-issues#852: The idea is to not treat
the anonymous models as import, but to "merge" them
- // with original one,
- // because otherwise we would have to deal with
clashing name aliases, or similar issues
- if (iAlias != null && !iAlias.isEmpty()) {
- model.setImportAliasForNS(iAlias,
located.getNamespace(), located.getName());
- importFromModel(model, located, iAlias);
- } else {
- toMerge.add(located);
- }
- }
- } else if (ImportDMNResolverUtil.whichImportType(i) ==
ImportType.PMML) {
- processPMMLImport(model, i, relativeResolver);
- model.setImportAliasForNS(i.getName(), i.getNamespace(),
i.getName());
- } else {
- MsgUtil.reportMessage(logger,
- DMNMessage.Severity.ERROR,
- null,
- model,
- null,
- null,
- Msg.IMPORT_TYPE_UNKNOWN,
- i.getImportType());
- }
+ for (Import i : dmndefs.getImport()) {
+ if (ImportDMNResolverUtil.whichImportType(i) == ImportType.DMN) {
Review Comment:
Replaced with switch
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]