0

I´m currently working on a flutter web project which uses DMN for the more complicated decision tables. However that whole part was already pretty much done when I joined the project and it hasn´t been touched for a while, so it´s all legacy code to me.

Now some minor changes to the texts and properties needed to be done, which caused the whole application to simply not load anymore, no error thrown. So I took a look in the old code and found out, that the reader class used a link to a DMN model as a namespace.

http://www.omg.org/spec/DMN/20180521/MODEL/

This link is no longer available and my working theory with my limited knowledge is that as soon as any change is made, the DMN files are validated against a model that no longer exists, so making any minor change breaks the whole project.

Here´s the reader class, the namespace is listed as optional, however removing it causes the same problem

class DMNReader {
  static const String defaultNullString = "null";
  static const namespace = "http://www.omg.org/spec/DMN/20180521/MODEL/";
  XmlDocument document;

  DMNReader._(String data) : document = XmlDocument.parse(data);

  static Future<DMNReader> forDocument(String path) async {
    String data = await rootBundle.loadString(path);
    return DMNReader._(data);
  }

  List<DMNInputData> getAllInputs() {
    List<DMNInputData> inputs = [];
    document
        .findAllElements("inputData", namespace: namespace)
        .forEach((element) {
      inputs.add(DMNInputData.fromElement(element));
    });
    inputs.sort((a, b) => a.questionId - b.questionId);
    return inputs;
  }

  List<DMNDecision> getAllDecisions() {
    List<DMNDecision> decisions = [];
    document
        .findAllElements("decision", namespace: namespace)
        .forEach((element) {
      decisions.add(DMNDecision.fromElement(element));
    });
    return decisions;
  }

  static String? getAnnotation(String sourceId, XmlDocument document) {
    String? targetId = document
        .findAllElements("association", namespace: namespace)
        .firstWhere((element) =>
            element
                .getElement("sourceRef", namespace: namespace)
                ?.getAttribute("href")
                ?.substring(1) ==
            sourceId)
        .getElement("targetRef", namespace: namespace)
        ?.getAttribute("href")
        ?.substring(1);
    String? annotationText = document
        .findAllElements("textAnnotation", namespace: namespace)
        .firstWhere((element) => element.getAttribute("id") == targetId)
        .getElement("text", namespace: namespace)
        ?.text;
    return annotationText;
  }
}

I´ve searched the page from the link above for alternative DMN models that could maybe work, without success this far. Also none of them had the http://www.omg.org/spec/DMN/'number'/MODEL/"format. I´m also not sure how the correct model looked like in the first place, so recognizing a valid alternative might prove difficult.

Thank you in advance

njco
  • 1
  • 1

0 Answers0