Model Validation from Java Code [message #1843465] |
Sat, 31 July 2021 01:17 |
Miguel Fernandes Messages: 7 Registered: July 2021 |
Junior Member |
|
|
Hello!
I was working with the Epsilon languages, doing a Validation (of UML Activity Diagrams) followed by a Generation, which was working perfectly from a build.xml (using the epsilon ant tasks) but when I put it into code it gives me unexpected errors in the Validations, and if I skip validating, in the Generation also throws unexpected errors. I will only tackle the Validation problem for now, to make it more simple.
The code related to the validations in the build.xml file was this:
<target name="validateModel" depends="loadModel">
<epsilon.evl src="${basedir}/validateActivity.evl" failOnErrors="true" failOnWarnings="false">
<model ref="loadedModel"/>
</epsilon.evl>
<record name="${basedir}/checkreport.txt" action="stop"/>
</target>
<target name="loadModel">
<record name="${basedir}/checkreport.txt" action="start"/>
<epsilon.loadModel name="loadedModel" type="UML">
<parameter name="modelFile" value="${basedir}/modelact.uml"/>
<parameter name="metamodelFile" value="${basedir}/UML.ecore"/>
<parameter name="isMetamodelFileBased" value="true"/>
</epsilon.loadModel>
</target>
This was working perfectly. The way I now do this and that gives me these errors is the following:
String filename = "src/main/activity/modelact.uml";
String res = "";
EvlModule module = new EvlModule();
UmlModel model = new UmlModel();
model.setModelFile(filename);
model.load();
module.getContext().getModelRepository().addModel(model);
File fileEvl = new File("src/main/activity/validateActivity.evl");
module.parse(fileEvl);
module.execute();
Collection<UnsatisfiedConstraint> unsatisfiedList = module.getContext().getUnsatisfiedConstraints();
for (UnsatisfiedConstraint constraint : unsatisfiedList) {
res+=constraint.getMessage()+"\n";
}
This gives me the persistent error: "Called feature 'name' on undefined object", an exception which did not appear when I did this via the build.xml file.
This error basically is saying that, on the code below, "type()" is not defined, but the thing is that a Control Flow source is an Activity Node, and if it is defined, it always has a type, so the error is nonsensical.
context ControlFlow{
constraint HasOnlyBasicNodes{
guard : self.source.isDefined() and self.target.isDefined()
check : isValidType(self.source.type().name.toString()) and isValidType(self.target.type().name.toString())
message : 'Control Flow target and source are reduced to the subset: {Opaque Actions + Initial, Decision, Fork, Join, Merge, and Final activity nodes}'
}
Can someone help me with this?
Thanks in advance
Bests,
Miguel
|
|
|
|
Powered by
FUDForum. Page generated in 0.03240 seconds