How to include pre/postconditions in generated document

Hi

Is there a way of including the pre- and postconditions of system capabilities into the generated word document? I didn’t found an example and I’ve tried myself to enhance the template, but without any success.

I’m using Capella4Teams 1.3.1 with M2doc

Kind regards, Peter

Hi,

If you already have the Capability object you can use something like:
{m:capability.preCondition.name}
or
{m:capability.postCondition.name}

To get the capability in the first place if you are on a System object and want capabilitys from the SystemAnalysis you can use:
{m:system.ownedArchitectures->filter(ctx::SystemAnalysis)->at(1).ownedAbstractCapabilityPkg.oclAsType(ctx::CapabilityPkg).ownedCapabilities.postCondition.name}

Note there are other places where you can find Capabilities:
{m:system.ownedArchitectures->filter(la::LogicalArchitecture)->at(1).ownedAbstractCapabilityPkg.oclAsType(la::CapabilityRealizationPkg).ownedCapabilityRealizations}

{m:system.ownedArchitectures->filter(pa::PhysicalArchitecture)->at(1).ownedAbstractCapabilityPkg.oclAsType(la::CapabilityRealizationPkg).ownedCapabilityRealizations}

{m:system.ownedArchitectures->filter(epbs::EPBSArchitecture)->at(1).ownedAbstractCapabilityPkg.oclAsType(la::CapabilityRealizationPkg).ownedCapabilityRealizations}

Yvan.

Hi Yvan, thanks for your help. Unfortunately it doesn’t seem to work as aql query and in the m2doc template. Despite there are pre- and postconditions defined on a system capability the string generated is empty. See my screenshots below:



I’m able to access the pre- and postconditions with this aql query:
aql:self.preCondition.ownedSpecification.bodies

But in m2doc it is not possible to access bodies:

Any ideas, how to solve this problem?

Hi,

After looking at The Capella metamodels I found that the object referenced by a Capability.preCondition or .postCondition is a Constraint and it can be of different natures, so I looked in the definition of the odesign and found a service that can represent those objects in a human readable way. But the service seems to reference an editor and I’m not sure if it will work with M2Doc, anyway you can try by importing the service class in your template (using the template properties wizard):

org.polarsys.capella.core.sirius.analysis.CapellaServices

Then you can call:

{m:capability.preCondition.getConstraintLabel()}

The returned text will be the same as in the property view so you might need to change it a bit to fit your needs.

For the second point, the error happens because the Constraint.ownedSpecification can be diffent kinds of objects for instance an OpaqueExpression with a feature body or a ValueSpecification that don’t have a feaure body.

Hope it help,
Yvan.

Hello

I’m still struggling to import the service class. The template properties wizard, doesn’t offer any service to choose. I’ve tried to follow the instructions on the refered reference documentation. However I hadn’t any success. Are there any prerequisites for using the CapellaServices?

Kind regards, Peter

This dialog is using the JDT and is only populated if a plugin project is opened in the workspace. This project should have dependencies to Capella plugins. To make things easier in the future, I’ll add those classes to the Capella token accessible in the template properties wizard:

That was the missing piece! Thank you for your help.

Short recap about the steps that I needed to do:

1.) Installing m2doc plugin (https://www.m2doc.org/capella/)

2.) Create a plugin project in capella. Added org.polarsys.capella.core.sirius.analysis to the depencies

3.) Add the CapellaServices to the Capella project

4.) Enhance the m2doc template

1 Like
Copyright © Eclipse Capella, the Eclipse Capella logo, Eclipse and the Eclipse logo are Trademarks of The Eclipse Foundation.