Mentions légales du service

Skip to content
Snippets Groups Projects
Commit f1f126cb authored by Nabila's avatar Nabila
Browse files

fix ocl to verify rule

parent bf77346b
No related branches found
No related tags found
2 merge requests!64Develop,!62Release/3.2.2
......@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -412,11 +413,31 @@ public class OCLGenerator {
ImportElementHandler.handleAddingElement(typeName);
}
} else {
res = "(not " + res + ".oclIsUndefined()) and " + res + "=" + valueDPathModified;
res = "(not (" + verifyAndModifyStructure(res) + ".oclIsUndefined())) and " + res + "=" + valueDPathModified;
}
return res;
}
// res = "(not (" + verifyAndModifyStructure(res) + ".oclIsUndefined())) and " + res + "=" + valueDPathModified;
// fix for the case where the path give a nullPointerException: observation.code.code
public static String verifyAndModifyStructure(String input) {
String[] attributeParts = input.split("\\.");
if (attributeParts.length == 0) {
return input;
}
StringBuilder modifiedStructure = new StringBuilder();
String currentObject = "";
for (int i = 0; i < attributeParts.length-1; i++) {
currentObject += (i == 0 ? "" : ".") + attributeParts[i];
modifiedStructure.append(currentObject).append(".oclIsUndefined()");
if (i < attributeParts.length - 1) {
modifiedStructure.append(" or ");
}
}
return modifiedStructure + input ;
}
public String generateRuleToParentFromPath(ChoiceDefinition choiceDefinition) {
DParent dparent = RuleDefinitionUtil.getDParentOfRuleDefinition((RuleDefinition) choiceDefinition.getParentObject());
return this.generateRuleFromPath(dparent, (RuleDefinition) choiceDefinition.getParentObject());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment