diff --git a/plugins/org.etsi.mts.tdl.standalone/src/org/etsi/mts/tdl/standalone/Standalone.java b/plugins/org.etsi.mts.tdl.standalone/src/org/etsi/mts/tdl/standalone/Standalone.java index 275e9f72c1b4f672746a396fa1b23e6bf15f11a6..d956cb35cf37bfd729c1c099548a871c959b8c5e 100644 --- a/plugins/org.etsi.mts.tdl.standalone/src/org/etsi/mts/tdl/standalone/Standalone.java +++ b/plugins/org.etsi.mts.tdl.standalone/src/org/etsi/mts/tdl/standalone/Standalone.java @@ -28,6 +28,7 @@ import org.eclipse.ocl.pivot.utilities.OCL; import org.eclipse.ocl.pivot.utilities.ParserException; import org.eclipse.ocl.pivot.utilities.Query; import org.eclipse.xtext.EcoreUtil2; +import org.eclipse.xtext.nodemodel.util.NodeModelUtils; import org.etsi.mts.tdl.ComponentInstance; import org.etsi.mts.tdl.ComponentInstanceRole; import org.etsi.mts.tdl.Extension; @@ -48,6 +49,7 @@ import org.etsi.mts.tdl.tdlPackage; import org.etsi.mts.tdl.asn2tdl.ASN2TDLTranslator; import org.etsi.mts.tdl.constraints.evl.Validator; import org.etsi.mts.tdl.helper.TDLHelper; +import org.etsi.mts.tdl.impl.CompoundBehaviourImpl; import org.etsi.mts.tdl.json2tdl.JSON2TDLTranslator; import org.etsi.mts.tdl.json2tdl.TDL2JSONTranslator; import org.etsi.mts.tdl.openapi2tdl.next.OpenAPI2TDLTranslatorNext; @@ -434,6 +436,7 @@ public class Standalone { e1 = e0; e0 = e; } + //TODO: ports need to be configuration prefixed if only one diagram String c = ""+e0.getComponent().getName()+"_"+e0.getGate().getName()+"" +" <--> " +""+e1.getComponent().getName()+"_"+e1.getGate().getName()+"" @@ -456,11 +459,11 @@ public class Standalone { private void generateBehaviour(String path, EObject model) { List<TestDescription> testDescriptions = EcoreUtil2.getAllContentsOfType(model, TestDescription.class); - + String d = ""; for (TestDescription td : testDescriptions) { - String d = "@startuml\n"; - d+="hide footbox\n"; - d+="title Foot Box removed\n"; + d += "@startuml\n"; + d += "hide footbox\n"; + d += "title "+td.getName()+"\n"; TestConfiguration tc = td.getTestConfiguration(); for (var i : tc.getComponentInstance()) { if (i.getRole() == ComponentInstanceRole.TESTER) { @@ -487,23 +490,19 @@ public class Standalone { if (td.getBehaviourDescription()!= null) { var b = td.getBehaviourDescription().getBehaviour(); - try { - d += processBehaviour(castObject(b.getClass(), b)); - } catch (Exception e) { - System.out.println("Error: "+e.getMessage()); - } + d += processBehaviour(b); } - d += "@enduml"; + d += "@enduml\n"; //TODO: need to split behaviours.. - System.out.println(d); - try { - //TODO: make configurable - Files.writeString(Path.of(path+"-"+td.getName()+"-behaviour.md"), d); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + } + System.out.println(d); + try { + //TODO: make configurable + Files.writeString(Path.of(path+"-behaviour.md"), d); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } @@ -512,15 +511,24 @@ public class Standalone { } private String processBehaviour(Behaviour b) { - String d = "' Not supported yet: "+b.getClass().getName(); - System.out.println(d); - return d+"\n"; + String d = "' Not supported yet: "+b.getClass().getName(); + switch (b.eClass().getClassifierID()) { + case tdlPackage.COMPOUND_BEHAVIOUR: + d = processBehaviour((CompoundBehaviour)b); + break; + case tdlPackage.MESSAGE: + d = processBehaviour((Message)b); + break; + default: + break; + } + return d; } private String processBehaviour(CompoundBehaviour b) { String d = ""; for (var nested : b.getBlock().getBehaviour()) { - d+=processBehaviour(castObject(nested.getClass(), nested)); + d += processBehaviour(nested); } //TODO: handle prefixes and indentation? return d; @@ -533,8 +541,9 @@ public class Standalone { var t = tc.container().getName()+"_"+tc.getName(); var a = b.getArgument(); String d = ""; + String at = NodeModelUtils.findActualNodeFor(a).getText(); //TODO: use node model untils to get text (needs processing) - d += c+" -> "+t+" : "+b.toString()+"\n"; + d += c+" -> "+t+" : "+at.replaceAll("\n", "\\n")+"\n"; return d; }