Skip to main content



      Home
Home » Modeling » Papyrus » Papyrus profiles with derived stereotype properties defined by same name operations(Papyrus profile issue)
Papyrus profiles with derived stereotype properties defined by same name operations [message #1835775] Fri, 11 December 2020 20:59 Go to next message
Eclipse UserFriend
When I create a simple UML model with 2 classes A and B, with application of SysML.Requirement to both, then link them with an Abstraction relationship with Stereotype DeriveReqt applied, I can see in the profile variables of A and B the properties /derived and /derivedBy get updated with A and B respectively. However when I create a new custom profile and attempt to replicate this bahaviour, the equivalent /derived and /derivedBy Stereotype properties do not update with A and B.

I wasn't able to see any documentation on this topic, but I suspect some additional Java coding is needed to make this possible, am I right? However Papyrus seems to validate and check OCL code embedded in Constraints quite correctly, so I'm worried this should just work but I'm doing something wrong. Can you please review my examples "test", "test_profile" and "test_sysml"?

"test_sysml" works OK, but my version "test" that uses "test_profile" instead of SysML does not work.

In my investigation of how SysML profile is setup to achieve this (given I cannot find any good documentation of Papyrus profile creation that utilizes derived properties) I have investigated SysML.

Snippet from SysML/20181001/SysML.xmi 1.6 (Normative Machine Readable Documents from OMG SysML), after I have done the following for ease of readability:


    - removed ownedComment,
    - edited "->" to simply show "->",
    - replaced "SysML.AbstractRequirement" and "SysML.DeriveReqt" with ".." as they appear in xmi:id fields;


As a result we have the following readable raw specification that probes the magic that makes derived and derivedFrom tick.

Specification of DeriveReqt Stereotype:

  <packagedElement xmi:id="SysML.DeriveReqt" xmi:type="uml:Stereotype" name="DeriveReqt">
    <generalization xmi:id=".._generalization.SysML.Trace" xmi:type="uml:Generalization" isSubstitutable="false">
      <general xmi:idref="SysML.Trace"/>
    </generalization>
    <ownedRule xmi:id=".._rule.1_supplier_is_requirement" xmi:type="uml:Constraint" name="1_supplier_is_requirement">
      <specification xmi:id=".._rule.1_supplier_is_requirement.specification" xmi:type="uml:OpaqueExpression" body="AbstractRequirement.allInstances().base_NamedElement->includesAll(self.base_Abstraction.client)" language="OCL" name="specification">
        <type href="www.omg.org/spec/UML/20161101/PrimitiveTypes.xmi#Boolean"/>
      </specification>
    </ownedRule>
    <ownedRule xmi:id=".._rule.2_client_is_requirement" xmi:type="uml:Constraint" name="2_client_is_requirement">
      <specification xmi:id=".._rule.2_client_is_requirement.specification" xmi:type="uml:OpaqueExpression" body="AbstractRequirement.allInstances().base_NamedElement->includesAll(self.base_Abstraction.supplier)" language="OCL" name="specification">
        <type href="www.omg.org/spec/UML/20161101/PrimitiveTypes.xmi#Boolean"/>
      </specification>
    </ownedRule>
  </packagedElement>


Note: DeriveReqt has generalization relation to SysML.Trace which has Stereotype Extension of Abstraction metamodel type; i.e. has the property "base_Abstraction". So when recreating these structures as closely as possible to the SysML equivalent, this must also be taken into consideration, further below. Similarly SysML.AbstractRequirement has Stereotype Extension of NamedElement metamodel type.

Specification of AbstractRequirement Stereotype:

  <packagedElement xmi:id="SysML.AbstractRequirement" xmi:type="uml:Stereotype" isAbstract="true" name="AbstractRequirement">
    <ownedAttribute xmi:id="..base_NamedElement" xmi:type="uml:Property" name="base_NamedElement">
      <lowerValue xmi:id="..base_NamedElement.lowerValue0" xmi:type="uml:LiteralInteger" name="" value="1"/>
      <type href="www.omg.org/spec/UML/20161101/UML.xmi#NamedElement"/>
      <upperValue xmi:id="..base_NamedElement.upperValue0" xmi:type="uml:LiteralUnlimitedNatural" name="" value="1"/>
    </ownedAttribute>
    <ownedAttribute xmi:id="..derived" xmi:type="uml:Property" isDerived="true" name="derived">
      <lowerValue xmi:id="..derived.lowerValue0" xmi:type="uml:LiteralInteger" name=""/>
      <type xmi:idref="SysML.AbstractRequirement"/>
      <upperValue xmi:id="..derived.upperValue0" xmi:type="uml:LiteralUnlimitedNatural" name="" value="*"/>
    </ownedAttribute>
    <ownedAttribute xmi:id="..derivedFrom" xmi:type="uml:Property" isDerived="true" name="derivedFrom">
      <lowerValue xmi:id="..derivedFrom.lowerValue0" xmi:type="uml:LiteralInteger" name=""/>
      <type xmi:idref="SysML.AbstractRequirement"/>
      <upperValue xmi:id="..derivedFrom.upperValue0" xmi:type="uml:LiteralUnlimitedNatural" name="" value="*"/>
    </ownedAttribute>
    <ownedOperation xmi:id="..getDerived_" xmi:type="uml:Operation" isQuery="true" name="getDerived">
      <bodyCondition xmi:id="..getDerived_._rule.getDerived_body" xmi:type="uml:Constraint" name="getDerived_body">
        <specification xmi:id="..getDerived_._rule.getDerived_body.getDerived_body_specification" xmi:type="uml:OpaqueExpression" body="DeriveReqt.allInstances()->select(base_Abstraction.supplier=self).base_Abstraction.client" language="OCL" name="getDerived_body_specification">
          <type xmi:idref="SysML.AbstractRequirement"/>
        </specification>
      </bodyCondition>
      <ownedParameter xmi:id="..getDerived_.return" xmi:type="uml:Parameter" direction="return" effect="read" name="return">
        <lowerValue xmi:id="..getDerived_.return.lowerValue0" xmi:type="uml:LiteralInteger" name=""/>
        <type xmi:idref="SysML.AbstractRequirement"/>
        <upperValue xmi:id="..getDerived_.return.upperValue0" xmi:type="uml:LiteralUnlimitedNatural" name="" value="*"/>
      </ownedParameter>
      <ownedRule xmi:idref="..getDerived_._rule.getDerived_body"/>
    </ownedOperation>
    <ownedOperation xmi:id="..getDerivedFrom_" xmi:type="uml:Operation" isQuery="true" name="getDerivedFrom">
      <bodyCondition xmi:id="..getDerivedFrom_._rule.getDerivedFrom_body" xmi:type="uml:Constraint" name="getDerivedFrom_body">
        <specification 
        xmi:id="..getDerivedFrom_._rule.getDerivedFrom_body.getDerivedFrom_body_specification" xmi:type="uml:OpaqueExpression" body="DeriveReqt.allInstances()->select(base_Abstraction.client=self).base_Abstraction.supplier" language="OCL" name="getDerivedFrom_body_specification">
          <type xmi:idref="SysML.AbstractRequirement"/>
</specification>
      </bodyCondition>
      <ownedParameter xmi:id="..getDerivedFrom_.return" xmi:type="uml:Parameter" direction="return" effect="read" name="return">
        <lowerValue xmi:id="..getDerivedFrom_.return.lowerValue0" xmi:type="uml:LiteralInteger" name=""/>
        <type xmi:idref="SysML.AbstractRequirement"/>
        <upperValue xmi:id="..getDerivedFrom_.return.upperValue0" xmi:type="uml:LiteralUnlimitedNatural" name="" value="*"/>
      </ownedParameter>
      <ownedRule xmi:idref="..getDerivedFrom_._rule.getDerivedFrom_body"/>
    </ownedOperation>
  </packagedElement>


I had initially named the "test_profile" operations as getDerived and getDerivedBy just like SysML, however Papyrus complains about this because the "isDerived=true" properties "derived" and "derivedBy" don't have any way of deducing their values from same named operations as per UML standard (in section 6.4.1 of formal-17-12-05.pdf OMG UML specification):
Derivation: where an Attribute or Association End is marked as derived and is not a derived union, the derivation is specified by an Operation with the same name and type as the derived Attribute or Association End.

It is also strange that SysML names the operation that derives the values of "dervied" and "derviedBy" as "getDerived" and "getDerivedBy" - but it seems to work in the Papyrus registered profile "SysML". Which leads me to suspect there might be other Java code working in the background and that it might not just be the Papyrus profile...

Anyway, I have created projects "test" and "test_profile" to attempt to replicate this behaviour, however in my version of the "test" project, the derived Stereotype properties \derived and \derivedBy do not show A and B as they do with the "test_sysml" test program I made using SysML profile.

Please take a look and see if I'm doing something obviously wrong?
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1835798 is a reply to message #1835775] Sun, 13 December 2020 10:59 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Your surmise was correct that the Papyrus SysML 1.6 implementation has custom Java code to make the derived properties of the Requirement stereotype work. And that implementation is not based on the UML convention of same-named operations; it is just a customization of the Java code generated for the profile by subclassing and overriding the property getter methods.

A better approach in generated code is actually like the UML convention, but relying on the Eclipse UML2 metamodel's extensions of EMF code generation. As you can see in the UML.merged.uml model in the org.eclipse.uml2.uml bundle, which is the source model for the generation of the Eclipse UML API, there are a great many operations that

- have protected visibility (in UML terms)
- have the same name as the derived property that they compute
- have the «eOperation» stereotype applied
- use the stereotype property to make the method name generated in the corresponding Ecore model be 'getXyz' instead of just 'xyz'
- specify suppressed visibility (an Ecore code generation concept) in that same stereotype

The UML metamodel also provides for generation of operations that require implementation "by hand" in custom code into separate XyzOperations classes to which the generated model classes delegate. This is more flexible than the subclassing technique employed by Papyrus SysML 1.6 and accounts for multiple inheritance as it relies on delegation, not subclassing. Moreover, by specifying Java "getXyz" method names, which actually go into the Ecore model required by the EMF run-time, that makes the base EMF code generation recognize that the operation implements the derivation of the property. All very tidy. But, it requires generating your Profile to Java code using the UML2 code generator.

In the example projects that you attached, the profile is a "dynamic profile" leveraging the dynamic capabilities of EMF. These do actually support the delegation of operation behaviour and feature derivation to "invocation delegates." There is a syntax of EAnnotations that you need to attach to the Ecore EPackage and the features/operations to make this work; that is documented in the Eclipse Wiki. To get those annotations in the dynamic Ecore model generated for your profile by the "profile definition" process, you need to ensure that the "Operation Bodies," "Derived Features," and "Invocation Delegates" options are set to "Process" in the profile definition dialog. It looks like you've done that in your profile definition as I see the relevant annotations on the package. But I don't think that EMF's derived feature delegation recognizes the UML convention of same-named operations. It requires the EStructuralFeature to have an annotation providing the delegation expression. I am not sure how you would specify that in the UML, because properties cannot own constraints at all (much less "body constraints" as operations do) and can only be constrained by owned rules of their owning class, but those must be boolean-valued because only the operation body constraint can actually compute a value. Perhaps you can use the «eReference» stereotype on your derived properties to explicitly model the annotations the EMF needs. I've never tried that.

Ultimately, I think your best bet would be to generate your profile to code in the way that the Papyrus SysML 1.6 profile is generated, but using Eclipse UML2's enhanced code generation capabilities, especially the "operations class" pattern for operations that are difficult to express with OCL. Note that code generation also supports delegation of operations to dynamic evaluation of OCL body constraints using the applicable generator options. So, you should be able to make the same-named-operation pattern that the UML2 metamodel itself uses to factor out custom code into "operations classes" to actually generate their "implementations" by delegation to OCL, so that you won't even have custom code to write. I don't know that I've tried this, myself, but it feels like it should work. Assuming that the code generation templates handling the same-named-operation pattern also understand the invocation delegate pattern.

HTH,
Christian
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1835806 is a reply to message #1835798] Sun, 13 December 2020 13:41 Go to previous messageGo to next message
Eclipse UserFriend
Hi

Delegation of ordinary constraints to OCL should work. But, while testing the OCL validation for Papyrus and the OCL Validity View, I accidentally enabled use of the embedded OMG OCL for UML validation, in place of the hand-crafted Java transliteration. Once bad bugs in the OMG OCL were fixed, the performance was only really terrible, since the OMG OCL does many very inefficient things with cascades of collections of allInstances for which there is very inadequate compiler optimization. I suspect that the SysML embedded OCL may present similar optimization challenges.

Regards

Ed Willink
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1835860 is a reply to message #1835798] Tue, 15 December 2020 05:51 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for the pointers Christian!
Thank you also Ed - at this stage I'm trying this Java option as it might be a little more better in performance.

I'm a little stuck.

First I create a very simple cut down Papyrus UML profile; simply create Papyrus UML profile project called test_profile2.
- Add "Requirement" Stereotype that extends UML Class Metaclass type.

I then created a second project; an EMF Project called test_profile2_emf.

During EMF Project wizard,
- Select "UML Model" in Select a Model Importer dialog.
- Select from workspace the test_profile2 Papyrus profile.uml file.
* Some errors about UML metamodel types are reported but project creates fine.
- Select "Test_profile2" by right-click and select Generate Model Code; Java code appears in src path of project.
* Some minor issue complaining about JDK version in MANIFEST.MF file, fixed by pointing to JavaSE-11.

After this point I have no idea how to "register" this Java project as a Papyrus registered profile similar to what SysML is - i.e. do I need to somehow install this as a plugin to Eclipse? Sorry C++ programmer here, my Java skills are rather new :)

Any pointers will be appreciated greatly.

[Updated on: Tue, 15 December 2020 05:55] by Moderator

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1835878 is a reply to message #1835860] Tue, 15 December 2020 11:10 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

In the properties of the top GenModel element in the EMF generator model for your profile, if you select "11.0" in the "Compliance Level" property, then you won't have to tweak the manifest for JDK versions.

For registration of the profile in Papyrus, to make it easy to apply to models, follow the example of the SysML 1.6 plug-in, below. There is a Papyrus extension point on which you need to register the profile in your bundle's plugin.xml file. Note that SysML 1.6 additional registers a URI mapping in EMF to make abstract pathmap scheme URIs. This is optional, not required by Papyrus.

HTH,
Christian

--

   <extension
        point="org.eclipse.papyrus.uml.extensionpoints.UMLProfile">
     <profile
           description="UML profile for SysML (from OMG SysML V1.6)"
           iconpath="resources/icons/SysMLProfile.gif"
           name="SysML 1.6"
           path="pathmap://SysML16_PROFILES/SysML.profile.uml"
           provider="Eclipse Modeling Project">
     </profile>
  </extension>   
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1835974 is a reply to message #1835878] Thu, 17 December 2020 09:26 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

Thank you for all your help.

I tried different combinations using ecore profile with EOperation stereotype and without, also different combinations of operation names vs derived property names, but the final generated Java code seems to have "TODO" sections.

Is this the expected behaviour? Should I be expecting the OCL automatically get translated to Java as I am?

Here is my "Impl" code with all the TODO's appearing:

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Requirement> getDerived() {
		// TODO: implement this method to return the 'Derived' reference list
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Requirement> getDerivedFrom() {
		// TODO: implement this method to return the 'Derived From' reference list
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Requirement> derived() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Requirement> derivedFrom() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1835988 is a reply to message #1835974] Thu, 17 December 2020 13:57 Go to previous messageGo to next message
Eclipse UserFriend
Hi, Deniz,

Find attached a version of your test_profile project that generates code as I think you are expecting. Compare this with the version that you originally attached to this thread, and you will see several changes:

- URI specified in the Profile element to generate a predictable namespace URI in the Ecore EPackage
- constraint names fixed to be valid Java identifiers (removing the leading numeric digits)
- derived properties made read-only (I think this is key to having the right code generated for them)
- derived-property shadow operations made
-- protected in the UML definition
-- renamed for Java in the «eOperation» stereotype
-- suppressed visibility (an Ecore concept) in the «eOPeration» stereotype
- body expressions fixed to navigate to the «requirement» stereotype application of the related elements, to conform to the operation return type (not to mention the derived property type)

In the generator model, I enabled the UML2 "operations" class generation pattern, although in this case they are not needed (and so not generated) because there are no operations that need to be filled in (no "TODO"s). You will see that the delegation to the modeled OCL constraints is generated in the RequirementImpl class.

HTH,
Christian

[Updated on: Thu, 17 December 2020 13:59] by Moderator

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836136 is a reply to message #1835988] Tue, 22 December 2020 05:45 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

I am very close and once I am done I'll put up a detailed set of instructions here for future readers, which are struggling as I did, to follow.

One final item I'm stuck with is perhaps this suppressed visibility concept. I cannot see this visibility option in the Papyrus profile application of «EOperation» as shown in the capture image1.png

I do however I see an option in ecore file itself as seen in image2.png but that one is a boolean check "Suppressed Visibility" field. However I'm a little confused as the ecore file is generated from the Papyrus profile is it not? So this suppressed visibility should be set at the Papyrus profile level somehow, which I cannot see in the «EOperation» profile in image1.png

Thank you once again for your help.



Best regards,
Deniz
  • Attachment: image2.png
    (Size: 132.58KB, Downloaded 108 times)
  • Attachment: image1.png
    (Size: 219.10KB, Downloaded 141 times)
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836147 is a reply to message #1836136] Tue, 22 December 2020 09:06 Go to previous messageGo to next message
Eclipse UserFriend
Hi, Deniz,

Right, sorry, the mapping from the Ecore Profile (UML) to "suppressed visibility" in the GenModel isn't as direct as my phrasing seemed to make it. Your attachment "image1.png" has it right: it is the "none" visibility kind in the Ecore stereotypes for properties and operations. This attribute of the stereotype is picked up by the UML importer when it creates the GenModel element for the operation, to set the property that you show in "image2.png". There is no representation of this visibility concept in Ecore, unless perhaps it be via a codegen-specific annotation.

So, I think you have the complete picture here.

Best,
Christian

[Updated on: Tue, 22 December 2020 09:07] by Moderator

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836168 is a reply to message #1836147] Tue, 22 December 2020 22:36 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

Thank you for all this help, this is getting close...

When I define the plugin.xml file as per the default generated version as shown below, there are issues:

<plugin>
   <extension point="org.eclipse.emf.ecore.generated_package">
      <!-- @generated Requirements -->
      <package
            uri="http://www.eclipse.org/model/requirements"
            class="requirements.RequirementsPackage"
            genModel="model/Requirements.genmodel"/>
   </extension>
</plugin>


Papyrus registered profile application doesn't list the custom created "Requirements" profile as shown in image4.png.

When I define additional entension point for org.eclipse.papyrus.uml.extensionpoints.UMLProfile as shown below, I can access the registered profile application in Papyrus, however I cannot apply the "Requirement" Stereotype to any Class:

<plugin>
   <extension point="org.eclipse.emf.ecore.uri_mapping">
     <mapping
           source="pathmap://resources/model/"
           target="platform:/plugin/Requirements_1.0.0/model/">
     </mapping>
   </extension>
   <extension point="org.eclipse.papyrus.uml.extensionpoints.UMLProfile">
     <profile
           description="Basic example requirements profile"
           name="Requirements 1.0"
           path="pathmap://resources/model/Requirements.profile.uml"
           provider="Deniz Eren">
     </profile>
   </extension>
   <extension point="org.eclipse.emf.ecore.generated_package">
      <!-- @generated Requirements -->
      <package
            uri="http://www.eclipse.org/model/requirements"
            class="requirements.RequirementsPackage"
            genModel="model/Requirements.genmodel"/>
   </extension>
</plugin>


Papyrus registered profile application does list the custom created "Requirements" profile, but it cannot be applied to any of the classes A or B as shown in image5.png, image6.png and image7.png. After applying the Stereotype the "Applied Stereotypes" section of the class Profile is empty and later I get error messages reporting detached Stereotypes.

The only version I can get working is when I remove the generated extension org.eclipse.emf.ecore.generated_package, but that's just the same as applying Requirements.profile.uml as a non-registered profile and I suspect it isn't even using the Java generated code, as all the Constraints supplier_is_requirement and client_is_requirement behave as they would when you just apply non-registered profile Requirements.profile.uml:

<plugin>
   <extension point="org.eclipse.emf.ecore.uri_mapping">
     <mapping
           source="pathmap://resources/model/"
           target="platform:/plugin/Requirements_1.0.0/model/">
     </mapping>
   </extension>
   <extension point="org.eclipse.papyrus.uml.extensionpoints.UMLProfile">
     <profile
           description="Basic example requirements profile"
           name="Requirements 1.0"
           path="pathmap://resources/model/Requirements.profile.uml"
           provider="Deniz Eren">
     </profile>
   </extension>
</plugin>


Any pointers where the issue might be and how the plugin.xml should be configured?

I have also attached the experimental "Requirements" project as-is.
  • Attachment: image4.png
    (Size: 159.23KB, Downloaded 116 times)
  • Attachment: image5.png
    (Size: 158.86KB, Downloaded 125 times)
  • Attachment: image6.png
    (Size: 127.43KB, Downloaded 93 times)
  • Attachment: image7.png
    (Size: 130.82KB, Downloaded 105 times)
  • Attachment: Requirements.tar.gz
    (Size: 97.91KB, Downloaded 92 times)

[Updated on: Wed, 23 December 2020 06:39] by Moderator

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836200 is a reply to message #1836168] Wed, 23 December 2020 21:10 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

Actually looking at the SysML jar file plugin.xml there are other extensions missing in my one, I will try adding those and see.

Thanks for your help, and I will post update when I get it working.



Best regards,
Deniz
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836235 is a reply to message #1836200] Fri, 25 December 2020 08:57 Go to previous messageGo to next message
Eclipse UserFriend
Hi, Deniz,

I suspect that one problem with the run-time behaviour of your profile is that it includes several dynamic definitions in addition to being generated. A profile should be either statically defined (generated), or dynamically defined, not both. I think the UML API is finding the dynamic definition in some cases, and so not looking for the static definition, leading to unexpected results because the dynamic definition is less capable.

You should delete the UML annotation in the profile that contains all of its dynamic EPackage definitions and always ignore the prompt to define the profile when saving it. And, really, Papyrus ought to detect that the profile has an accompanying GenModel and never prompt to define it dynamically. That would be worth raising in Bugzilla.

HTH,
Christian
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836361 is a reply to message #1836235] Wed, 30 December 2020 02:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

Happy to raise any bug reports once the issue is resolved, but I now tried with and without the dynamic profile definition with no luck.

So I went back to the drawing board to eliminate any unknowns, I re-installed eclipse (the new eclipse/modeling-2020-12). I stopped trying to get the fancy derived property working and just have a simple Stereotype extending an Abstraction, with no other contents. I followed the text book description of static profiles from documentation:

https://help.eclipse.org/2020-12/topic/org.eclipse.papyrus.uml.diagram.profile.doc/target/generated-eclipse-help/users/generatingStaticProfiles.html?cp=74_0_1_8_5

But when I try to create a Papyrus UML model to apply this registered profile, it allows me to find and apply it to the package, but when I try to apply it to an Abstraction element it doesn't display the Stereotype. I looked in the Test.uml file and see:

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:testplugin="http://www.mycompany.com/Testplugin/1" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML">
  <uml:Model xmi:id="_slOegEpsEeu6tYPtsHWdHw" name="Test">
    <packageImport xmi:type="uml:PackageImport" xmi:id="_srHEEEpsEeu6tYPtsHWdHw">
      <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
    </packageImport>
    <packagedElement xmi:type="uml:Class" xmi:id="_BozpMEpxEeuASrB-BFX7sQ" name="A"/>
    <packagedElement xmi:type="uml:Class" xmi:id="_CSxzQEpxEeuASrB-BFX7sQ" name="B"/>
    <packagedElement xmi:type="uml:Abstraction" xmi:id="_C_GtwEpxEeuASrB-BFX7sQ" client="_BozpMEpxEeuASrB-BFX7sQ" supplier="_CSxzQEpxEeuASrB-BFX7sQ"/>
    <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_A4bVIEpxEeuASrB-BFX7sQ">
      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_A4fmkEpxEeuASrB-BFX7sQ" source="http://www.eclipse.org/uml2/2.0.0/UML">
        <references xmi:type="ecore:EPackage" href="http://www.mycompany.com/Testplugin/1#/"/>
      </eAnnotations>
      <appliedProfile xmi:type="uml:Profile" href="pathmap://MYLANG_PROFILE/testplugin.profile.uml#_wMd84EpqEeuF1anrashfZA"/>
    </profileApplication>
  </uml:Model>
  <testplugin:Stereotype4 xmi:id="_DwEQoEpxEeuASrB-BFX7sQ"/>
  <testplugin:Stereotype4 xmi:id="_aopK4EpxEeuASrB-BFX7sQ"/>
</xmi:XMI>


The Stereotype application segment references unknown xmi:id's also as expected, being reported as dangling stereotypes by Papyrus:

  <testplugin:Stereotype4 xmi:id="_DwEQoEpxEeuASrB-BFX7sQ"/>
  <testplugin:Stereotype4 xmi:id="_aopK4EpxEeuASrB-BFX7sQ"/>


So as you can see I'm just trying to get a simple static profile working now and no luck. I've attached the profile and model I tried to replicate from the documentation link above.

I also tried to experiment with the location I'm installing the plugin, i.e. /home/deniz/eclipse/modeling-2020-12/eclipse

The way I'm installing the plugin to my workspace is by clicking on File -> Export -> Select Plug-in Development [Deployable plug-ins and fragments] -> Install into host. Repository: /home/deniz/eclipse/modeling-2020-12/eclipse

Is there something obviously wrong with what I'm doing? Because I'm just after getting a "hello world" Papyrus static profile plug-in working now ONLY ....

Your help is appreciated!



Best regards,
Deniz
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836363 is a reply to message #1836361] Wed, 30 December 2020 05:01 Go to previous messageGo to next message
Eclipse UserFriend
Perhaps I need to look into plug-in's more generally first - my example doesn't even have an "Activator" for example - not sure it it's needed for Papyrus static profile plug-ins though...
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836369 is a reply to message #1836363] Wed, 30 December 2020 15:50 Go to previous messageGo to next message
Eclipse UserFriend
Hi, Deniz,

The "xmi:id" attributes in the second XMI snippet in your previous message are not the IDs of referenced elements. They are the IDs of the stereotype applications, themselves. The unknown references are elided when saving, so they do not appear in the XMI. You would have to look at them in memory (perhaps in the debugger) to see what UML elements they reference and why those are not in any resource.

The EPackage reference in your profile application looks strange: "http://www.mycompany.com/Testplugin/1#/" is not a namespace URI as I would expect in a reference to a generated (statically defined) profile's Ecore representation. There should not be any fragment portion in this URI. I would expect this reference to match the XML namespace declaration for "testplugin" in the root XML element. So, it seems that there is one copy of your profile's Ecore representation that is used to instantiate stereotypes and another copy of the same EPackage that is referenced as the profile definition. This can only lead to inconsistencies and unexpected/bad results such as you are witnessing, because objects created from the "same" EClasses in two in-memory copies of the "same" EPackage are different and incompatible; they are like instances of the same Java class loaded twice in separate class loaders.

As for testing all of this, I do not recommend installing the plug-in that you are developing into the configuration of your host (development) instance of Eclipse. It is best to test it in a run-time workbench via a PDE launch configuration. This ensures that the latest state of your code is always deployed at run-time and makes it much easier to debug problems.

Bundle activators have nothing to do with anything here.

Cheers,
Christian
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836375 is a reply to message #1836369] Wed, 30 December 2020 23:42 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

Firstly happy new year!

I started using PDE launch configuration - must say much faster workflow and yes it isolates changes from the host installation - thank you for the advise!

Trying to solve this issue I created another static profile + test papyrus model following the standard static Papyrus profile documentation and checking the file Test/Test.uml I still see the strange fragment # in the href:

<references xmi:type="ecore:EPackage" href="http://www.mycompany.com/MyLanguage#/"/>

This time I tried the URI "http://www.mycompany.com/MyLanguage" instead of "http://www.mycompany.com/MyLanguage/1" as per the Papyrus documentation example, but same/equivalent strange fragment issue appeared.

Full files attached.

I tried playing with the mylanguage.profile.uml model URI's both in the parent profile metamodel element and the applied EPackage stereotype with no luck - the strange fragment still appears when you apply the registered model in the PDE launch environment Papyrus Test model.

I also played with the plugin.xml Extensions by trying different uri entries, with and without fragments, since I do not have direct influence on the final registered uri containing the strange fragment. I'm guessing some configuration in the plugin.xml or the profile model is causing the eventual issue at the registered environment.

I tried using org.eclipse.uml2.uml.dynamic_package instead of org.eclipse.uml2.uml.generated_package with no luck - same strange fragment issue.

It's just very strange that the most simplest case of a Papyrus static profile doesn't work after following the documentation itself. Something must have changed that broke it? Should I try with an older version of Eclipse? What version do you use?
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836378 is a reply to message #1836375] Thu, 31 December 2020 00:42 Go to previous messageGo to next message
Eclipse UserFriend
Tried also with version 4.8 (Photon) with same outcome.
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836380 is a reply to message #1836378] Thu, 31 December 2020 01:19 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian

Quote:
The EPackage reference in your profile application looks strange: "http://www.mycompany.com/Testplugin/1#/" is not a namespace URI as I would expect in a reference to a generated (statically defined) profile's Ecore representation.


Are you sure? It looks a but strange but seems correct to me. It is an EPackage URI just as expected by an ecore:EPackage href. It looks just like a test file for the pretty simple OCLforUML profile.

Quote:
<profileApplication xmi:id="_FxIeIP-ZEeSlRrtw3TnjrQ">
<eAnnotations xmi:id="_FxMvkP-ZEeSlRrtw3TnjrQ" source="http://www.eclipse.org/uml2/2.0.0/UML">
<references xmi:type="ecore:EPackage" href="http://www.eclipse.org/ocl/2015/OCLforUML/1#/"/>
</eAnnotations>
<appliedProfile href="pathmap://OCL_PROFILES/OCLforUML.profile.uml#_0"/>
</profileApplication>


Installing in your development wokspace can indeed be very dangerous, since you create an opportunity for metamodel schizophrenia between the tow copies.

When totally baffled, I find it sometimes helps to gradually narrow the differences between my new not-working functionality and some old working functionality. The OCLforUML is sufficiently simple that you might try using it as a 'working' example.

Regards

Ed Willink
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836382 is a reply to message #1836380] Thu, 31 December 2020 02:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

Good plan, I've been looking at SysML profile but that is quite complex! Where can I get the source code for OCLforUML?



Best regards,
Deniz
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836383 is a reply to message #1836382] Thu, 31 December 2020 05:09 Go to previous messageGo to next message
Eclipse UserFriend
Ed,

Found it here (for other readers):
git clone https://git.eclipse.org/r/ocl/org.eclipse.ocl

Can be found here:
$ find org.eclipse.ocl/ -iname "*OCLforUML*"
org.eclipse.ocl/plugins/org.eclipse.ocl.pivot.uml/model/OCLforUML.profile.genmodel
org.eclipse.ocl/plugins/org.eclipse.ocl.pivot.uml/model/OCLforUML.ecore
org.eclipse.ocl/plugins/org.eclipse.ocl.pivot.uml/model/OCLforUML.profile.uml

I'll get this installing and working from my copy, and see if it generates the same, and if yes, I'll check why mine isn't working in comparison.



Best regards,
Deniz
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836384 is a reply to message #1836380] Thu, 31 December 2020 07:27 Go to previous messageGo to next message
Eclipse UserFriend
Ed Willink wrote on Thu, 31 December 2020 01:19
Hi Christian

Are you sure? It looks a but strange but seems correct to me. It is an EPackage URI just as expected by an ecore:EPackage href. It looks just like a test file for the pretty simple OCLforUML profile.


No, I'm not sure. I expect you're right that the reference to the package meta-object needs to have a fragment because otherwise I suppose the namespace URI only indicates the resource. I'm just baffled as to what is making it so difficult to make a consistent profile deployment, and as I'm staying away from my computer and code these days, my guesses are unlikely to help.



Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836390 is a reply to message #1836384] Thu, 31 December 2020 21:48 Go to previous messageGo to next message
Eclipse UserFriend
Ed,

Testing with OCLforUML seems problematic also, because generating the code from the OCLforUML genmodel with zero changes yields a huge amount of differences with the java code in the repository. Also there doesn't seem to be any major differences from what I've already tried in terms of genmodel, profile.uml and plugin.xml changes.

Here is a question, after "Generate Model Code" is there any need to modify the generated code for the Papyrus static profile to work?



Best regards,
Deniz
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836391 is a reply to message #1836390] Fri, 01 January 2021 01:58 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed, Christian,

I flooded the generated java code with System.out.print() statements to see what's going on. Seems all the functions get called when I apply the profile, except for the following when I apply the test stereotype on a Class element:

public void setBaseClass(org.eclipse.uml2.uml.Class newBaseClass) {


I'm guessing the Papyrus framework is meant to call this - but it isn't...



Best regards,
Deniz
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836392 is a reply to message #1836391] Fri, 01 January 2021 05:21 Go to previous messageGo to next message
Eclipse UserFriend
Ed, Christian,

One problem I've found, regarding fact that setBaseClass isn't called by the framework, is that the default generated code has this:

		// Initialize classes, features, and operations; add parameters
		initEClass(testStereotypeEClass, TestStereotype.class, "TestStereotype", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEReference(getTestStereotype_BaseClass(), theUMLPackage.getClass_(), null, "baseClass", null, 0, 1, TestStereotype.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);


But notice "baseClass" should be "base_Class" - when I make this change the setBaseClass routine does get called by the framework, and the uml file looks better:

  <mylanguage:TestStereotype xmi:id="_8-evgEwaEeu4fux5zoKFGQ" base_Class="_mx6RYEvzEeuPDv5Fd9D50A"/>


Before it was:
  <mylanguage:TestStereotype xmi:id="_hb5kQEwaEeuwKZLS0lr_fA"/>


However it's still not showing the applied stereotype after application - there must be more things wrong with the generated code?

[Updated on: Fri, 01 January 2021 05:25] by Moderator

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836395 is a reply to message #1836390] Fri, 01 January 2021 12:02 Go to previous messageGo to next message
Eclipse UserFriend
Deniz Eren wrote on Thu, 31 December 2020 21:48

Testing with OCLforUML seems problematic also, because generating the code from the OCLforUML genmodel with zero changes yields a huge amount of differences with the java code in the repository.


The autogeneration is launched by:

/org.eclipse.ocl.examples.build/.launches/Generate OCL OCLforUML Model.launch

which invokes

/org.eclipse.ocl.examples.build/src/org/eclipse/ocl/examples/build/GenerateOCLforUMLModel.mwe2

which looks pretty boring apart from fixing the support for @NonNull in generated Adapter/SWitch.

However running it gives a silently bad OCLforUMLPackage. Looks like some bit rot has set in.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=570012 raised.

Regards

Ed Willink
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836396 is a reply to message #1836392] Fri, 01 January 2021 12:24 Go to previous messageGo to next message
Eclipse UserFriend
Deniz Eren wrote on Fri, 01 January 2021 05:21

But notice "baseClass" should be "base_Class"


Well done you are practically there.

Tweaking the generated code might work but as you've discovered only partly.

Presumably whatever causes the 'misspelling' of the reference name may have effects in other places too. You will have to get to the root cause.

You haven't identified what versions of UML or EMF or platform you are using.

I recall that [1] identified that UML's JET had failed to re-clone changes to EMF's JET. This could well be the problem. You might try a version of UML post the bug fix except that there are currently no regular UML builds of master. There is a maintenance build at [2] else you'll need to check it out in your workspace. Or go back to an EMF from perhaps 2020-03 when UML2 was released and perhaps worked, but you may need to take EMF back even further.

Regards

Ed Willink

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=547424
[2] https://ci.eclipse.org/uml2/job/mdt-uml2-maintenance/29/artifact/targetPlatform/
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836402 is a reply to message #1836396] Fri, 01 January 2021 20:16 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

I'm currently testing with UML2 version 5.5.0.v20200302-1312 which installs from the very latest Eclipse release repository for 2020-12. The EMF - Eclipse Modeling Framework SDK is version 2.24.0.v20200917-1439 also from the latest 2012-12.

However keep in mind I went back all the way to Photon version release of Eclipse and that too had not worked in the same way (however I didn't try to flood with prints to console to check exactly what's happening with that one).

I will continue comparing with SysML model to see if I can find the other issues with the generated code.

Is there a way to install older versions of UML2 and EMF? To check if the generator has broken in some particular version? I'm happy to do a manual log-N search to find the version that broke it, if you can tell me a way to get and install older versions?



Best regards,
Deniz
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836406 is a reply to message #1836402] Sat, 02 January 2021 01:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi

Installing an old version of EMF + UML2 is not too hard. Download the basic Eclipse SDK ZIP, unzip. the install UML from the Install New Software ... this should pull in the necessary bits of EMF, but i Usually install the EMF SDK and XSD SDK too to get all the sources. Do NOT install all of EMF since the extras such as RAP seem to fight each other. You might just use Install New .. for Papyrus and let it pull in UML and EMF - should work never tried.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=570012 is making me wonder how OCLforUML generation ever worked. GIT suggests that OCLforUML may not have been regenerated since built in 2016. My suspicion is that the UML generator has been broken for quite some time, but until I actually find the broken code lines I cannot be sure; suspicions are often very wrong and very prejudiced.

Regards

Ed Willink

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836408 is a reply to message #1836406] Sat, 02 January 2021 06:25 Go to previous messageGo to next message
Eclipse UserFriend
Quote:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=570012 is making me wonder how OCLforUML generation ever worked.


My favourite trick of obfuscating the original problem behind new diagnostic problems.

Quote:
Testing with OCLforUML seems problematic also, because generating the code from the OCLforUML genmodel with zero changes yields a huge amount of differences with the java code in the repository.


When I regenerate I see two prolific cosmetic source changes.

a) EMF has finally got round to using StringBuilder rather than StringBuffer which gives many changes. OCLforUML has not been regenerated since this improvement.

b) the OCL auto-generation occurs in a standalone context for which JDT's code formatting is not (yet) supported. In contrast, the Generate Model editor action occurs while Eclipse is running and so code is prettified and significantly different whitespace-wise.

You should therefore be good to go by just emulating OCLforUML and using the Generate Model editor action.

(The auto-generation is desirable since OCLforUML is packaged in org.eclipse.ocl.pivot.uml along with other UML-dependent OCL functionality. The OCL development uses org.eclipse.jdt.annotation.NonNull and friends to improve code integrity which is often beneficial but can be challenging since it is not adequately supported by EMF. The auto-generation should use a variant code template to avoid spurious @NonNull warnings. Just delete all @NonNull / @Nullable when you copy the code and don't copy the external annotations in the .classpath.)

Regards

Ed Willink
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836416 is a reply to message #1836408] Sat, 02 January 2021 21:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

Of course I want to get my static profile working, but I it's also very important that we communicate this issue to be fixed in the next release. In that sense, do you now have enough information to get this needed fix communicated? Or should I go through this exercise I suggested to figure out exactly which version broke it?

My plan was to test older and older versions until the most simplest example of a static profile actually works - let me know if this is still a worthwhile exercise so that we can communicate it as bug?



Best regards,
Deniz
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836418 is a reply to message #1836416] Sun, 03 January 2021 01:03 Go to previous messageGo to next message
Eclipse UserFriend
Hi

I think we're back at the suggestion that narrowing the differences wrt OCLforUML might enable you to make progress. I have resolved the problem with the auto-generation of OCLforUML; if you use the Generate Model action in situ, you get one error from the @NonNull EEA on EFactory.create; easily fixed manually. If you clone OCLforUML in a separate project free from org.eclipse.jdt.annotation 'help' the Generate Model action should work fine. This demonstrates that for a simple profile the UML2Ecore2Java path can be fine, so your problem is either a user error or a tooling bug awaiting investigation.

Skimming this thread, I'm not clear how the original user coding problem morphed via a missing OCL code into an inconsistent UML versions problem and baseClass spelling issue.

I recall that getting the declarations right for OCLforUML was not easy so I strongly suspect that we have a number of misunderstandings clouding the issue.

You/we might find it helpful to enumerate the evolving issues to determine how each was resolved or overtaken by a further problem. If nothing else this list of gotchas might assist a future profile developer or motivate better diagnostics in the tooling.

Regards

Ed Willink

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836419 is a reply to message #1836418] Sun, 03 January 2021 01:43 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

Quote:

You should therefore be good to go by just emulating OCLforUML and using the Generate Model editor action.

(The auto-generation is desirable since OCLforUML is packaged in org.eclipse.ocl.pivot.uml along with other UML-dependent OCL functionality. The OCL development uses org.eclipse.jdt.annotation.NonNull and friends to improve code integrity which is often beneficial but can be challenging since it is not adequately supported by EMF. The auto-generation should use a variant code template to avoid spurious @NonNull warnings. Just delete all @NonNull / @Nullable when you copy the code and don't copy the external annotations in the .classpath.)


I think I understand, but please accept my apologies since I am new to Eclipse (and intruder in Java-land); C++ spy here - I interpret this comment/quote as (please verify if I understood correctly):


  • I clone and import the projects of Git repo https://git.eclipse.org/r/ocl/org.eclipse.ocl
  • Build the org.eclipse.ocl.pivot.uml project (build giving errors, trying to get past these currently)
  • Once built use "Run Configuration" with "Eclipse Application" with "Plug-ins" configured to use the custom built version of org.eclipse.ocl.pivot.uml instead of the version that comes with the Eclipse environment.
  • Within the inception Eclipse running within the "Run Configuration" I then import the projects of the org.eclipse.ocl Git repo once again and try to generate the OCLforUML and see less differences.


Am I correct in my understanding of what you meant?



Best regards,
Deniz
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836421 is a reply to message #1836419] Sun, 03 January 2021 04:02 Go to previous messageGo to next message
Eclipse UserFriend
Hi

Basically you want to find a simple example that works and gradually evolve it to have the important characteristics of your requirement. At some point inspiration will stroke and you will see what you did wrong.

Since there have been many problems and red herrings in this thread, I have no idea what your real problem is; I just know that static profiles can be hard.

Provided OCL is not part of your problem, I recommend uninstalling OCL, and checking out org.eclipse.ocl.pivot.uml and deleting everything that is nothing to do with the profile especially all uses of org.eclipse.jdt.annotation in *.src / *.MF/ classpath so that you have a boring profile that genmodels warning-free and for which you can write a JUnit test to demonstrate that it is useful; tedious to start with but ultimately much quicker than continually starting a nested Eclipse and remembering the UI actions required. Then practice changing names to something completely new so that you discover all places that e.g. http://www.eclipse.org/ocl/2015/OCLforUML/1 is used. This will avoid possible metamodel schizophrenia wrt your many experiments and the standard installation. You can now reinstall OCL and elaborate the simple example to use the semantic constructs that are interesting for your real application. At some point you will realize what the user problem is or identify the tooling bug.

In so far as possible I recommend doing everything with the UML Model editor and GenModel Editor. Using the Papyrus UI just provides extra opportunities for confusion. Wait till UML works before using the extra UI abstraction.

Regards

Ed Willink

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836422 is a reply to message #1836421] Sun, 03 January 2021 04:36 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Ed, I'll give it a go and report back how it goes.
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836844 is a reply to message #1836422] Fri, 15 January 2021 08:50 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed, hi Christian,

The issue of getting a basic Papyrus static profile working is now SOLVED!

Next step is for me to return to the original issue of getting the derived property magic working as discussed early on with Christian (will post future comment to summarise that when I get it working). However, in this comment I'm summarising the findings of getting the basic static profile working and how to get past the "base_Class" to "baseClass" naming issue and resultant static profile failure as discussed above.

Firstly on an unrelated note, because I want to also use the SysML 1.6 profile (for purposes other than the items discussed in this thread), I installed Eclipse Modelling Version 2020-06. Looking at the SysML 1.6 Git repository the last officially tested version seems to be 2020-06 as of this date. Also I tried 2020-12 and it gives some strange string error, so for the time being I'm using 2020-06.

Then using the Eclipse Marketplace I installed SysML 1.6 and via the dependencies it installed Papyrus for UML 4.8.0. Just mentioning versions for future reference just in case it is important to future readers, however the features discussed are common for a long time. I am also not sure if the issues discussed are bugs or expected behaviour. Anyway, I am writing this comment for future readers that have come across the same issues.

Firstly I followed the Generating Static Profiles section of the Papyrus Guide:
https://help.eclipse.org/2020-12/topic/org.eclipse.papyrus.uml.diagram.profile.doc/target/generated-eclipse-help/users/generatingStaticProfiles.html?cp=73_0_1_8_5

UML Import Options seemed unimportant/irrelevant to me and at least the Papyrus Guide didn't have any further documentation on what exactly these Options do. In short - do NOT overlook or underestimate these options! Here are my findings...

In the UML Import section after clicking on your profile.uml model or clicking "Load" with the default Options as shown also in the Papyrus Guide, there will be a number of warnings given such as: "Feature 'UML::Element::ownedElement' should be annotated as a union and made non-changeable".

Originally I was clicking on "Process All" to make these warnings go away, however I stopped doing that and instead ignored the warnings and clicked Next.

Then followed the rest of the Papyrus Guide and set the Extensions etc...

To test (most would know this but thanks to Christian this was a good learning for me) - from the menu click on "Run" -> "Run Configurations" then under the tab "Eclipse Application" create a new configuration. If you check the "Plug-ins" tab you will see the default settings "all workspace and enabled target plug-ins" will mean your test profile "com.mylanguage.profile" will be installed to the test workspace instance that will start when you Run the configuration.

Inside the Run configuration Eclipse environment create a simple Papyrus UML model and apply your registered profiled and it will all work as expected!

Now to analyse which UML Import Option broke the generated code, I did the following tests...

Firstly I created a simple Git repository and committed the working copy. This is useful to track what will change when we generate static profile code with different UML Import Options.

Next I attempted UML Import once again and changed Options to firstly get rid of all the UML metamodel warnings to satisfy my OCD and to get all the minimum features/options needed to get a warning free generation. To achieve this I had to activate (set to Process) the following options:


  • Union Properties,
  • redefining Operations,
  • redefining Properties,
  • Subsetting Properties,
  • Duplicate Operations,
  • Duplicate Features.


This makes sense since UML metamodel uses all these UML concepts - amazing how UML defines UML :)

After these changes the model continues to work fine and there are no warnings during UML Import.

Next aim at this stage was to identify which UML Import Option is actually causing the "base_Class" to become "baseClass" and thus breaking the generated static profile code. So one by one I turned on the remaining Options to "Process" mode and generated the code until the "base_Class" became "baseClass":


  • Duplicate Feature Inheritance -> still OK,
  • Duplicate Operation Inheritance -> still OK,
  • Validate Delegates -> still OK,
  • Non-API Invariants -> still OK,
  • Operation Bodies -> still OK,
  • Invocation Delegates -> still OK,
  • Property Default Expressions -> still OK,
  • Camel Case Names -> BROKEN! "base_Class" became "baseClass" !!!


The UML Import option "Camel Case Names" seems to be the cause of the failure! Make sure this is set to "Ignore". In hindsight the name of this option is quite a clue, but like said, if only there was some documentation explaining these options and what they do! :)

Further, I noticed "Opposite Role Names" is also something that causes some difference in code - in particular function createEmofAnnotations appears in the Java generated code, which seems to annotate some base_Class related functionality. Anyway, when this option is set to "Process" the resultant static profile still works fine.

Next I will go back and try to get derived property feature working, like I was trying in the very beginning.
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836859 is a reply to message #1836844] Fri, 15 January 2021 13:18 Go to previous messageGo to next message
Eclipse UserFriend
HI

Thanks for providing this feedback. As a 'struggling' user, your perspective can be much more relevant than that of a bored 'expert' developer.

Please raise a Bugzilla identifying specific sentences/paragraphs that you wish to rephrase and/or textual annotations that emphasize the significance of certain options. A patch or replacement will make the developer's job much easier.

"Camel Case Names" seems like a separate bug. Since base_xxx has special semantics, it should not be gratuitously beautified. (IMHO the beautification is almost always a recipe for bugs.)

Regards

Ed Willink
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836865 is a reply to message #1836859] Fri, 15 January 2021 20:30 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

Created the following bugs:





Best regards,
Deniz

[Updated on: Sat, 16 January 2021 01:19] by Moderator

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836961 is a reply to message #1836865] Wed, 20 January 2021 05:29 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

For future readers that are also interested in static profiles, attached is my now working solution. It contains the static profile within a small Git repo and a "Test" UML model that utilises it.

I have not been able to get the EOperation auto-generated derived property method to work, however I prefer to use the same way SysML solves this problem, by manually coding the desired behaviour in Java.

In the example here, check the class RequirementImpl for the hand coded Java for getDerived and getDerivedFrom functions. For example:
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public EList<NamedElement> getDerived() {
    // This should return the Requirement(s) derived from current
    EList<NamedElement> derived = new BasicEList<>();
    if (getBase_NamedElement() != null) {
        Iterator<DirectedRelationship> itDep = getBase_NamedElement().getTargetDirectedRelationships().iterator();

        // Find DeriveReqt link
        while (itDep.hasNext()) {
            DirectedRelationship currentDirectedRelationship = itDep.next();
            DeriveReqt currentDeriveReqt = UMLUtil.getStereotypeApplication(currentDirectedRelationship, DeriveReqt.class);

            if (currentDeriveReqt != null) {
                EList<NamedElement> clients = currentDeriveReqt.getBase_Abstraction().getClients();
                Iterator<NamedElement> it = clients.iterator();
                while (it.hasNext()) {
                    derived.add(it.next());
                }
            }
        }
    }

    return new UnmodifiableEList<>(this, MyRequirementsPackage.eINSTANCE.getRequirement_Derived(), derived.size(), derived.toArray());
}


This code blocked replaced the auto-generated code:
    // TODO: implement this method to return the 'Derived' reference list
    // Ensure that you remove @generated or mark it @generated NOT
    throw new UnsupportedOperationException();


P.S. you must also set "@generated" in the function comment block to "@generated NOT" to prevent auto-generation overriding the handwritten code.
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836973 is a reply to message #1836961] Wed, 20 January 2021 07:21 Go to previous messageGo to next message
Eclipse UserFriend
Hi

Use of allInstances() as in
DeriveReqt.allInstances()->select(base_Abstraction.supplier=self).base_Abstraction.client
should be avoided wherever possible. It generally contributes to very inefficient code that performs redundant repeated model searches.

You may find that something like
self.base_Abstraction->selectByKind(DeriveReqt).client
is much more efficient.

You haven't identified why the OCL code generation doesn't work.

Once I reload the genmodel I can generate code with plenty of OCL-derived code. The Requirement::derived() operation has code, but the getDerived() does not since it derives from a Property without any initializer to define its functionality.

If you want to use the crazy UML idiom that X == X() you need an enhanced CG or a modified UML loader. There is a fudge along these lines to support the CG of the UML metamodel, but I'm afraid I forget where. I recommend that you use a sensible policy of defining a property behaviour on the property rather than relying on a non-standard redirection to a conicidentally same-named operation.

The UML 2.5 6.4 commentary:

Quote:
Derivation: where an Attribute or Association End is marked as derived and is not a derived union, the
derivation is specified by an Operation with the same name and type as the derived Attribute or Association
End.


This was added at my instigation, but it only describes how a UML implementer may join up the dots for the UML metamodel. It does not impose a requirement that this crazy lack of clarity is supported for user models. (Sadly OCL has always been an afterthought for UML and so the integration is poor. The UML metamodel could so easily define the initializer of derived property X as a call of X(). Or mandate the idiom by moving the 6.4 commentary to the 9.5 Property specification.)

Regards

Ed Willink
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1836983 is a reply to message #1836973] Wed, 20 January 2021 09:50 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

Thank you for the reply! I actually didn't realise the functions generated named "derived()" and "derivedFrom" are actually the OCL constraints I've created within the same named operations.

The OCL now works! Greatly appreciated! See further how I got it working...

I just made the simple change where I invoke derived() from getDerived() and derivedFrom() from within getDerivedFrom() instead of custom Java code, and it all works fine:
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	@Override
	public EList<NamedElement> getDerived() {
		// TODO: implement this method to return the 'Derived' reference list
		// Ensure that you remove @generated or mark it @generated NOT
		//throw new UnsupportedOperationException();
		// This should return the Requirement(s) derived from current
		return derived();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	@Override
	public EList<NamedElement> getDerivedFrom() {
		// TODO: implement this method to return the 'Derived From' reference list
		// Ensure that you remove @generated or mark it @generated NOT
		//throw new UnsupportedOperationException();
		// This should return the Requirement(s) this Requirement is derived from
		return derivedFrom();
	}


It's still a mystery to me why the generated code wouldn't do this anyway, instead it calls "throw new UnsupportedOperationException()" - but I'm happy adding this by hand if that's what I need to do.

Well this all worked after I fixed the OCL expressions I had to:
DeriveReqt.allInstances()->select(base_Abstraction.supplier->includes(self.base_NamedElement)).base_Abstraction.client

DeriveReqt.allInstances()->select(base_Abstraction.client->includes(self.base_NamedElement)).base_Abstraction.supplier


Ed, the only problem I see in your proposed OCL expression is that the base_Abstraction doesn't generalise the stereotypes DerivedReqt (or even vice-versa) so oclIsKindOf will not work. UML appends the stereotype applications at the end of the model for that reason and the stereotypes have "base_XXX" properties to link back to the metamodel elements - no generalization occurs to those elements. I think this is why we can see many instances of "allInstances" within the UML OCL expressions even. If you know of a way to bypass the need for "allInstances" that would be greatly appreciated, but I couldn't figure out anyway to.

I've attached the latest working copy with the OCL fixed and working instead of custom Java code.

[Updated on: Wed, 20 January 2021 09:53] by Moderator

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837098 is a reply to message #1836983] Fri, 22 January 2021 01:13 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Found another problem.

When your model contains OCL that refers to a UML type for example something like self.base_Element.oclIsKindOf(UML::Comment) the generated static profile Java code gives an exception when it runs, saying:

org.eclipse.ocl.ecore.delegate.OCLDelegateException: Unknown type ([UML, Comment])


On closer examination, when for example an OCL expression as mentioned exists Papyrus is happy with this expression. However the static profile generated Java code looks like this:

addAnnotation
  (getDocumentSection__WordWrapAt(),
   source,
   new String[] {
        "body", "self.base_Element.oclIsKindOf(UML::Comment)"
   });


This when run give the exception as previously mensioned.

However, after generating the Java code if I manually modify the code by changing the "UML::" to lowercase "uml::" (as I suspected from other expressions I've seen in ecore Java usage), then everything works fine. Like said I have to manually edit generated code to look like this for it to work:

addAnnotation
  (getDocumentSection__WordWrapAt(),
   source,
   new String[] {
        "body", "self.base_Element.oclIsKindOf(uml::Comment)"
   });


On the same token however, when dealing with UML PrimitiveTypes such as UML::Boolean, UML::String, UML::UnlimitedNatural, UML::Integer and UML::Real - they work fine with "UML" or "uml" from EMF Java perspective without exceptions being thrown. However Papyrus profile model only accepts the upper case "UML" as valid OCL.

This is less than ideal - is there something I've missed or should I create yet another bugzilla item? If yes, then which product would this bug fall under, Papyrus Core or EMF or is there a separate category for UML? Those bugzilla categories are quite confusing.



Best regards,
Deniz

[Updated on: Fri, 22 January 2021 01:19] by Moderator

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837102 is a reply to message #1837098] Fri, 22 January 2021 03:53 Go to previous messageGo to next message
Eclipse UserFriend
Hi

Definitely an OCL bug. But I see
org.eclipse.ocl.ecore.delegate.OCLDelegateException
This suggests that although you are using the Pivot OCL parser within Papyrus, you are using the Classic OCL parser when executing. The default for the OCL preference for delegate support was changed to Pivot moderately recently. Perhaps you have an old project with an old setting. Perhaps something is still helping you use the wrong setting. Please attach a full repro project and tool versions to the Bugzilla so that the culprit can be resolved.

"UML" is the package name which should always work as the first part of a qualified name.

"uml" is the model name - an alias for e.g. http://www.omg.org/spec/UML/20131001 - it often works but depends on import declaration aliasing.

In so far as possible the Pivot OCL used by Papyrus works with OMG UML models, i.e. with http://www.omg.org/spec/UML/20131001 rather than http://www.eclipse.org/uml2/5.0.0/UML, which is in principle identical, however all your models use http://www.eclipse.org/uml2/5.0.0/UML and so both metamodels co-exist as an overlay to avoid having two variants of Class etc. The co-existence is particularly troublesome for Stereotypes whose metaclasses are the wrong classes and whose persistence in a UML file involves a plethora of embedded Ecore versions. Pivot OCL ignores the Ecore except in so far as the nsURI must be examined to resolve profile applications. (Defining a profile makes no difference to OCL functionality - you only have the latest version as specified by the only UML content).

In contrast the Classic OCL endeavours to work with the Ecore UML content where it is a user responsibility to declare an adequate suite of package registrations.

Unfortunately with all this complexity, things sometimes are not perfect. Please submit a repro so that I can fix it /explain it.

This should not be happening at all since your OCL code could have been realized as Java embedded with your Ecore Java so that you have no need to waste time parsing OCL and then interpreting it at run-time. Check that you have selected Generate Java Code impl classes in your OCL preferences.

Regards

Ed Willink
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837128 is a reply to message #1837102] Fri, 22 January 2021 08:51 Go to previous messageGo to next message
Eclipse UserFriend
Thank you Ed!

I've been using 2020-06 (4.16.0) together with the Papyrus which automatically installs when I install SysML 1.6 from the Marketplace; because I want to play with SysML 1.6.

Reason I use this version and not the latest 2020-12 is because SysML 1.6 has strange issues out of the box.

I think I will need to bite the bullet and install 2020-12 and build SysML myself from the Git repository.

Anyway, I will re-try this latest OCL issue with the latest 2020-12 install and if it continues to happen I will post a simplified test project to Bugzilla.



Best regards,
Deniz
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837152 is a reply to message #1837128] Fri, 22 January 2021 15:29 Go to previous messageGo to next message
Eclipse UserFriend
Hi

There was no 2020-09 release of OCL.

https://wiki.eclipse.org/OCL/New_and_Noteworthy/2020-12 doesn't list anything that makes me suspect your problem is fixed.

Feel free to submit a 2020-06 repro preferably without requiring me to install SysML which I always find remarkably hard.

Regards

Ed Willink

[Updated on: Fri, 22 January 2021 15:37] by Moderator

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837191 is a reply to message #1837152] Sat, 23 January 2021 21:41 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

I created a minimal profile + application model projects that demonstrate the bug and submitted the following Bugzilla ticket (using my existing 2020-06 environment with SysML 1.6 installed Papyrus 4.8 version):

Bug 570598: https://bugs.eclipse.org/bugs/show_bug.cgi?id=570598



Best regards,
Deniz

[Updated on: Sat, 23 January 2021 21:42] by Moderator

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837245 is a reply to message #1837191] Tue, 26 January 2021 01:51 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

Another problem I ran into - this time relating to model element Constraints that are tested within Papyrus with right-click on model element, Validation -> Validate model command.

To demo the issue as simply as possible I created a stereotype called Stereotype1 that extends UML metamodel element UML::Element and have a simple constraint called Constraint1 that has OCL expression simply "true".

The attached tar file contains the static profile Git repository instance and the application model.

After generating the code (I did not modify the static profile Java code at all), and I applied the stereotype in the application model to a Class, Enumeration and Comment to randomly test.

In the application Papyrus model, after clicking on the root model element and then Validation -> Validate model, I get the following error message:

Severity	Description	Element	Parent	Type
Error	An exception occurred while delegating evaluation of the 'Constraint1' constraint on 'Stereotype1': java.lang.IllegalStateException: No 'http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot' ValidationDelegate for 'Stereotype1'	<<Stereotype1>> <Class> Class1	BugDemoApp	EMF Problem

Severity	Description	Element	Parent	Type
Error	An exception occurred while delegating evaluation of the 'Constraint1' constraint on 'Stereotype1': java.lang.ClassCastException: class org.eclipse.ocl.ecore.delegate.OCLValidationDelegateFactory$Global cannot be cast to class org.eclipse.ocl.pivot.internal.delegate.ValidationDelegate$Factory (org.eclipse.ocl.ecore.delegate.OCLValidationDelegateFactory$Global is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @662b7c77; org.eclipse.ocl.pivot.internal.delegate.ValidationDelegate$Factory is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @571cdb6c)	<<Stereotype1>> <Comment>	BugDemoApp	EMF Problem

Severity	Description	Element	Parent	Type
Error	An exception occurred while delegating evaluation of the 'Constraint1' constraint on 'Stereotype1': java.lang.IllegalStateException: No 'http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot' ValidationDelegate for 'Stereotype1'	<<Stereotype1>> <Enumeration> Enumeration1	BugDemoApp	EMF Problem


One thing to note, when I examine the generated validation code that only appears after I add a Constraint to my profile and generate the static profile Java code:

src-gen/com/bugdemo/profile/BugDemo/util/BugDemoValidator.java

In this file there is this "TODO" function generated:

/**
* Returns the resource locator that will be used to fetch messages for this validator's diagnostics.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ResourceLocator getResourceLocator() {
    // TODO
    // Specialize this to return a resource locator for messages specific to this validator.
    // Ensure that you remove @generated or mark it @generated NOT
    return super.getResourceLocator();
}


Am I meant to implement something to this "TODO" section for model element Constraints to work correctly? What am I missing?
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837264 is a reply to message #1837245] Tue, 26 January 2021 07:55 Go to previous messageGo to next message
Eclipse UserFriend
Hi, Deniz,

I cannot comment meaningfully on the delegation of OCL constraints via validation delegates, but the best way to give the BugDemoValidator class its ResourceLocator is to generate the model plug-in class. In the "Model" category of the properties for the root GenModel element in the *.genmodel file is a setting for the name of the plug-in class to generate. Fill that in (the UML project's genmodel shows an example).

HTH,
Christian
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837277 is a reply to message #1837264] Tue, 26 January 2021 20:43 Go to previous messageGo to next message
Eclipse UserFriend
Thank you Christian!

The getResourceLocator function is now generated with your suggestion, however the problem is still happening, so I guess thanks to your advise we now know the problem isn't because of the getResourceLocator.

So the getResourceLocator now looks like this (with no more TODO items):

/**
* Returns the resource locator that will be used to fetch messages for this validator's diagnostics.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ResourceLocator getResourceLocator() {
    return BugDemoPlugIn.INSTANCE;
}


However when I right-click, Validation -> Validate model, I still get the error message:

Severity	Description	Element	Parent	Type
Error	An exception occurred while delegating evaluation of the 'Constraint1' constraint on 'Stereotype1': java.lang.ClassCastException: class org.eclipse.ocl.ecore.delegate.OCLValidationDelegateFactory$Global cannot be cast to class org.eclipse.ocl.pivot.internal.delegate.ValidationDelegate$Factory (org.eclipse.ocl.ecore.delegate.OCLValidationDelegateFactory$Global is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @12f9afd2; org.eclipse.ocl.pivot.internal.delegate.ValidationDelegate$Factory is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @67ba0256)	<<Stereotype1>> <Class> Class1	BugDemoApp	EMF Problem




Best regards,
Deniz
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837279 is a reply to message #1837277] Tue, 26 January 2021 22:27 Go to previous messageGo to next message
Eclipse UserFriend
I first changed the OCL expression to something more interesting such as "self.base_Element.oclIsKindOf(UML::Comment)", then I applied the stereotype to a Class, Enumeration and Comment.

I got it working if I edit the generated code in two functions and change the "String source = "http://www.eclipse.org/emf/2002/Ecore/OCL"" line to "String source = "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot"":

/**
* Initializes the annotations for <b>http://www.eclipse.org/emf/2002/Ecore</b>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void createEcoreAnnotations() {
    String source = "http://www.eclipse.org/emf/2002/Ecore";
    addAnnotation
    (this,
    source,
    new String[] {
            //"validationDelegates", "http://www.eclipse.org/emf/2002/Ecore/OCL"
            "validationDelegates", "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot"
    });
    addAnnotation
    (stereotype1EClass,
    source,
    new String[] {
        "constraints", "Constraint1"
    });
}

/**
* Initializes the annotations for <b>http://www.eclipse.org/emf/2002/Ecore/OCL</b>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void createOCLAnnotations() {
    //String source = "http://www.eclipse.org/emf/2002/Ecore/OCL";
    String source = "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot";
    addAnnotation
    (stereotype1EClass,
    source,
    new String[] {
        "Constraint1", "self.base_Element.oclIsKindOf(UML::Comment)"
    });
}


Now the question; is there a way to tell genmodel to use www.eclipse.org/emf/2002/Ecore/OCL/Pivot in the generated code string "source" rather than www.eclipse.org/emf/2002/Ecore/OCL?

[Updated on: Tue, 26 January 2021 22:29] by Moderator

Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837283 is a reply to message #1837279] Wed, 27 January 2021 01:26 Go to previous messageGo to next message
Eclipse UserFriend
HI

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=570598 again.

This problem is entirely down to your determined use of the http://www.eclipse.org/emf/2002/Ecore/OCL/LPG (Classic OCL) support for the http://www.eclipse.org/emf/2002/Ecore/OCL virtual setting rather than http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot (Pivot OCL).

You can of course fix problems by tweaking all sorts of downstream places. But much easier to just correct either of the primary preferences.

a) delegate mapping so that you do not use the Classic OCL for which case-corrupted model names are not supported

b) use the CG so that you never need to delegate to an OCL parser at all - much faster

Regards

Ed Willink
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837285 is a reply to message #1837283] Wed, 27 January 2021 02:18 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

I definitely am not determined to use LPG, my problems mainly come down to the fact that I am not proficient with Eclipse or Java, so I'm struggling to delegate or configure my Eclipse to use Pivot. It's unfortunate that the default delegate is the LPG when you install Eclipse.



Best regards,
Deniz
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837286 is a reply to message #1837285] Wed, 27 January 2021 02:31 Go to previous messageGo to next message
Eclipse UserFriend
For example my Window->Preferences->OCL globally is and has been setup to Pivot for a long time now and the code is still generating as shown above with the classic OCL.
I'm not sure how to tell Eclipse to default to Pivot only still...
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837296 is a reply to message #1837286] Wed, 27 January 2021 04:08 Go to previous messageGo to next message
Eclipse UserFriend
Hi

The generated code is LPG/Pivot neutral. The LPG delegates always delegate to the use the LPG parser for the eAnnotation bodies. The Pivot may delegate to the precompiled Java or the Pivot parser for the eAnnotation bodies. It is just unfortunate that it has taken so long for someone to try using a static profile with delegated execution, and that that execution has needed to use a corrupted name. NB Corrupted in UMLPackageImpl, not corrupted in the BugDemo profile eAnnotation. So ultimately this bug stems from the crazy UML design decision to make model names more aesthetically pleasing when viewed in Ecore; too late to change now.

It is unfortunate that LPG is still the default but the Pivot is 'only' a prototype that resolves many problems in the OMG OCL specification. It is therefore OCL 'next' rather than OCL 2.4. Since the solutions are still evolving I lack the confidence to impose a new differently standard OCL as the default and cripple my ongoing development with API compatibility issues. Although the Pivot is now so long in the tooth that I do try very hard to keep it as-is too. You might find my recent "Reflections on OCL 2" paper [1] interesting / depressing.

You are obviously failing to set the OCL preference.

Start your nested Eclipse and before you do anything else, check Window->Preferences->OCL, if it shows Pivot then I'm puzzled and may need a copy of your Workspaces. Have you perhaps got some magic clean/reset option configured for your nested Workspace?

But also try BugDemoApp->Properties->OCL which might have a conflicting override.

If both show Pivot, then you should be able to open BugDemoApp.uml in the UML Model Editor and then Validate (the one half way down the menu - oops WTP refuses to fix its bug of inflicting a different Validate). The EMF validate should show no problems (when using Pivot) or three when using LPG.

Regards

Ed Willink

[1] http://www.jot.fm/issues/issue_2020_03/article17.pdf
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837306 is a reply to message #1837296] Wed, 27 January 2021 05:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

Thank you for all your help! It all works now!

I was going to Window -> Preferences -> OCL (Delegate set to Pivot) only in the main Eclipse instance and "assuming" the Run Configuration instance will inherent the settings. I then fell into the rabbit hole testing with .settings which were configured at the eclipse install paths, so again I assumed it would be centrally set.

So to summarise, for future reference to readers also, I needed to set Window -> Preferences -> OCL (Delegate set to Pivot) to the Run Configuration instance of Eclipse.

Both constraints and operation body definitions with OCL work with "UML::" and run OK!

Thank you for all your help, I think this "UML::" bug can be resolved with "won't fix" too. Just not sure how future developers can be helped to transition to this Pivot setting before attempting static profiles. Perhaps the Papyrus user guide instructions should be updated.
https://help.eclipse.org/2020-12/index.jsp?topic=%2Forg.eclipse.papyrus.uml.diagram.profile.doc%2Ftarget%2Fgenerated-eclipse-help%2Fusers%2FgeneratingStaticProfiles.html&cp%3D73_0_1_8_5
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837321 is a reply to message #1837306] Wed, 27 January 2021 08:48 Go to previous messageGo to next message
Eclipse UserFriend
Hi

Thanks for confirming.

I'm not happy about leaving the UML corruption bug as WONTFIX. A genuine user had very real problems that were assisted by poor defaults and for which the poor diagnosis required required real determination to get through. Thank you very much. It would be good if all real users helped to identify the rough spots.

Updating the Papyrus documentation would be good, but few users read documentation ever/at the right time. The code either needs to work or diagnose what fails.

Watch https://bugs.eclipse.org/bugs/show_bug.cgi?id=570598 to see what I come up with.

Regards

Ed Willink
Re: Papyrus profiles with derived stereotype properties defined by same name operations [message #1837345 is a reply to message #1837321] Wed, 27 January 2021 19:28 Go to previous message
Eclipse UserFriend
Excellent, thanks Ed and Christian, much appreciated.
Previous Topic:Can't define a pointer to vector as input parameter.
Next Topic:Impossible run last Mac OS Papyrus release
Goto Forum:
  


Current Time: Sun Jul 27 18:53:03 EDT 2025

Powered by FUDForum. Page generated in 0.37629 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top