Pre-condition and post condition

You gat this error because the ERference preCondition type is Constraint. And Constraint doesn’t have any EStructuralFeature named bodies. You need to cast to the specific sub type OpaqueExpression to access the bodies feature:

oc.preCondition.ownedSpecification.oclAsType(datavalue::OpaqueExpression).bodies

You can find this by looking at the serialized XMI:

          <ownedConstraints xsi:type="org.polarsys.capella.core.data.capellacore:Constraint"
              id="939caad8-95c8-4a42-b36e-e7dc55321b95" name="">
            <ownedSpecification xsi:type="org.polarsys.capella.core.data.information.datavalue:OpaqueExpression"
                id="363368a6-a0e7-4a12-b13a-5cfd4e2cae87">
              <bodies>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</bodies>
              <languages>capella:linkedText</languages>
            </ownedSpecification>

Another solution using the getConstraintLbal() is described here. It will handle any kind of Constraint which is better.

1 Like