M2Doc diagrams insertion

once you have the DRepresentation you can get the name with:
rep.name
or the image if its a diagram:
rep.asImage()

Hello Yvan,
I think I have some trouble with the eInverse method.
I wrote the following template:
but in the generated file I have the following error message:
eInverse(org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore .EClassifier) with arguments [ org.polarsys.capella.core.data.oa.impl.OperationalContextImp l @3b5771e7 (id: 6182ceb8-b72f-4e32-a710-fc1307b393e0, sid: null) (name: Operational Context) (visibleInDoc: true, visibleInLM: true, summary: null, review: null) (abstract: false), org.eclipse.emf.ecore.impl.EClassImpl@54ae1240 (name: DRepresentation) (instanceClassName: null) (abstract: true, interface: false)] failed: null java.lang.NullPointerException at org.eclipse.acceleo.query.services.EObjectServices.eInverse( EObjectServices.java:1416) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.acceleo.query.runtime.impl.JavaMethodService.int ernalInvoke(JavaMethodService.java:162) at org.eclipse.acceleo.query.runtime.impl.AbstractService.invok e(AbstractService.java:135) at org.eclipse.acceleo.query.runtime.impl.EvaluationServices.ca llService(EvaluationServices.java:129) at org.eclipse.acceleo.query.runtime.impl.EvaluationServices.ca ll(EvaluationServices.java:172) at org.eclipse.acceleo.query.runtime.impl.EvaluationServices.ca llOrApply(EvaluationServices.java:208) at org.eclipse.acceleo.query.runtime.impl.EvaluationServices.ap plyCallOnSequence(EvaluationServices.java:275) at org.eclipse.acceleo.query.runtime.impl.EvaluationServices.ca llOrApply(EvaluationServices.java:203) at org.eclipse.acceleo.query.parser.AstEvaluator.caseCall(AstEv aluator.java:192) at org.eclipse.acceleo.query.ast.util.AstSwitch.doSwitch(AstSwi tch.java:119) at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53) at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69) at org.eclipse.acceleo.query.parser.AstEvaluator.caseCall(AstEv aluator.java:183) at org.eclipse.acceleo.query.ast.util.AstSwitch.doSwitch(AstSwi tch.java:119) at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53) at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69) at org.eclipse.acceleo.query.parser.AstEvaluator.eval(AstEvalua tor.java:112) at org.eclipse.acceleo.query.runtime.impl.QueryEvaluationEngine .eval(QueryEvaluationEngine.java:52) at org.obeonetwork.m2doc.generator.M2DocEvaluator.caseRepetitio n(M2DocEvaluator.java:831) at org.obeonetwork.m2doc.generator.M2DocEvaluator.caseRepetitio n(M2DocEvaluator.java:1) at org.obeonetwork.m2doc.template.util.TemplateSwitch.doSwitch( TemplateSwitch.java:139) at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53) at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69) at org.obeonetwork.m2doc.generator.M2DocEvaluator.doSwitch(M2Do cEvaluator.java:865) at org.obeonetwork.m2doc.generator.M2DocEvaluator.caseBlock(M2D ocEvaluator.java:1063) at org.obeonetwork.m2doc.generator.M2DocEvaluator.caseBlock(M2D ocEvaluator.java:1) at org.obeonetwork.m2doc.template.util.TemplateSwitch.doSwitch( TemplateSwitch.java:183) at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53) at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69) at org.obeonetwork.m2doc.generator.M2DocEvaluator.doSwitch(M2Do cEvaluator.java:865) at org.obeonetwork.m2doc.generator.M2DocEvaluator.caseTemplate( M2DocEvaluator.java:298) at org.obeonetwork.m2doc.generator.M2DocEvaluator.caseTemplate( M2DocEvaluator.java:1) at org.obeonetwork.m2doc.template.util.TemplateSwitch.doSwitch( TemplateSwitch.java:201) at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53) at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69) at org.obeonetwork.m2doc.generator.M2DocEvaluator.doSwitch(M2Do cEvaluator.java:865) at org.obeonetwork.m2doc.generator.M2DocEvaluator.caseDocumentT emplate(M2DocEvaluator.java:260) at org.obeonetwork.m2doc.generator.M2DocEvaluator.caseDocumentT emplate(M2DocEvaluator.java:1) at org.obeonetwork.m2doc.template.util.TemplateSwitch.doSwitch( TemplateSwitch.java:246) at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53) at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69) at org.obeonetwork.m2doc.generator.M2DocEvaluator.doSwitch(M2Do cEvaluator.java:865) at org.obeonetwork.m2doc.generator.M2DocEvaluator.generate(M2Do cEvaluator.java:253) at org.obeonetwork.m2doc.util.M2DocUtils.generate(M2DocUtils.ja va:712) at org.obeonetwork.m2doc.util.M2DocUtils.generate(M2DocUtils.ja va:669) at org.obeonetwork.m2doc.genconf.GenconfUtils.generate(GenconfU tils.java:437) at org.obeonetwork.m2doc.genconf.GenconfUtils.generate(GenconfU tils.java:370) at org.obeonetwork.m2doc.genconf.editor.command.GenerateHandler $1.run(GenerateHandler.java:56) at org.eclipse.jface.operation.ModalContext$ModalContextThread. run(ModalContext.java:119)

Hello all,
For information Yvan Lussaud has developed a new service to get the name of a diagram (
https://github.com/ObeoNetwork/M2Doc/issues/282).
This new service is available in the nightly version of M2Doc (
https://s3-eu-west-1.amazonaws.com/obeo-m2doc-releases/maste r/nightly/repository) and will be included in the next release of M2Doc.
In order to make it work, the syntax is a little bit different.
For example, use:
m:for rep | self.containedSystemAnalysis.ownedSystem.representationByDes criptionName(‘System Architecture Blank’)
m:rep.asImage().fit(500,400)
m:rep.name <- diagram name
m:endfor
Also, additional nsURI packages need to be declared by opening the word template with the M2Doc Template Editor:
http://www.eclipse.org/sirius/1.1.0
http://www.eclipse.org/sirius/diagram/1.1.0
http://www.eclipse.org/sirius/diagram/sequence/2.0.0
http://www.eclipse.org/sirius/table/1.1.0
http://www.eclipse.org/sirius/tree/1.0.0
Enjoy !

Hello,
You can also try the pxDoc document generation tool: it is fully integrated with Eclipse, so you can get all diagram attributes (name, description…) without any restriction:
To get started with the Capella enabler (open source pxDoc connector):
http:// pragmatic-modeling.org/index.php?option=com_content&view =article&id=1&Itemid=142#pxDoc
Let me know if you need further support to start with pxDoc (tutorials available on
https://www.pxdoc.fr).
Regards
Thomas

Hi, related to this is the question how to access e.g. the description of a diagram (Capella: “description” in the properties tab of a diagram), which is stored in the documentation feature (i.e. attribute) of diagram::DRepresentationDescriptor. Even if I have the name of the diagram (representation), how can I get the DRepresentationDescriptor of that name? Or how can I get from DRepresentation to DRepresentationDescriptor. In the Capella metamodell, I have not found so far the tie point between the structure hierarchy and the diagrams/representations…

You can use the following to get the documentation of the representation:

{m:rep.oclAsType(viewpoint::DRepresentation).precedingSiblings(viewpoint::DAnalysis).ownedViews.ownedRepresentationDescriptors->select(descriptor | descriptor.representation = rep).documentation}

If you are using M2Doc 3.0.0 or later you probably also want to use the fromHTMLBodyString() service.

Thank you Yvan! It works (precedingSiblings is probably a not yet documented feature) . Eventually, I have found out, that DRepresentation also has the documentation (of the same contents), so this works too: {rep.documentation.fromHTMLBodyString() } :wink:

Hi, in some generated documents there is a diagram followed by text which must correspond to that diagram in that only elements visible in that diagram are included in that text (e.g. each in its own chapter). In the Capella Interpreter, if that diagram is selected in the Project Explorer, the following statement works:

self.representation.representationElements.elements->select(e | e.visible = true).target

(it can be, of course, further restricted by using select() and filter() )

How this can be achieved in m2doc?

The naive approach to replace “self.representation” with “diagramName.representationByName()” does not work, because the underlying classes are in different subpackages of the Sirius ecore: diagram::DDiagramElement (contains the “visible” attribute) in the aql vs. viewpoint::DRepresentationElement in the m2doc. So how to get the instance of the diagram:: class corresponding to the instance of viewpoint class? Or is there another way?

(This is a question related to the Capella diagram metamodel, actually, so it could be moved to a different thread. )

Hi,

DDiagramElement is a sub type of DRepresentationElement so you can filter the list:

self.representationElements->filter(diagram::DDiagramElement).visible

You will need the nsURI for Sirius diagram in you template if it’s not already present.

Yes, you can downcast (via filter). This resolves my question, thanks. But the question itself was not the right one :wink: I have overreduced my problem: it was to get all visible component exchanges of a logical component visible in a LAB diagram. The contained elements (i.e. also ports etc.) of a diagram node are accessible via the “.elements” attribute of a DDiagramElementContainer. It seems, the interpreters of AQL in M2Doc and Sirius Interpreter in Capella differs:

In M2DOC
“diagramName.representationByName().representationElements->select(e | e.name =‘LKS’)”
returns these types (acc. to the validation error messages):
String.viewpoint::DRepresentation.viewpoint::DRepresentationElement.viewpoint::DRepresentationElement -> NO “elements” attribute

VS.

In the Sirius Interpreter in Capella:
aql: self.representation.representationElements->select(e | e.name =‘LKS’).elements
returns these types:
viewpoint::DRepresentationDescriptor.diagram::DSemanticDiagram->DDiagram.viewpoint::DRepresentationElement.diagram::NodeContainer->diagram::DDiagramElementContainer.diagram::DDiagramElement

So that was my problem. The solution in M2Doc is then:
diagramName.representationByName().representationElements->filter(diagram::DDiagramElementContainer)->select(e | e.name =‘xxx’).elements…