Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Static profile OCL expressions referring to enumeration literals cause "contains a bad value&qu(Papyrus static profile issue)
Static profile OCL expressions referring to enumeration literals cause "contains a bad value&qu [message #1837352] Thu, 28 January 2021 09:36 Go to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi,

A problem has been found when referencing enumeration literals within OCL expressions for static profiles.

Attached is tar file ValidationProblem.tar.gz containing the example static profile wrapped in a Git repo called "com.validationproblem.profile" and an application Papyrus model project called "ValidationProblemApp".

Testing was done with 2020-06 Eclipse release - Papyrus 4.8.0 (version installed when installing Papyrus SysML 1.6 Feature through the Marketplace).

Firstly to demonstrate the problem, the following profile has been created:
index.php/fa/39843/0/

Stereotype "Stereotype1" extends a UML NamedElement metamodel element and contains 2 derived properties "depends" and "enum1". It also contains operations with same names that contain OCL instructions to set the values of these derived and read-only attributes.

Stereotype "Depends" extends a UML Dependency metamodel element and has 2 constraints - created to show that normal constraints are working fine during model validation checks.

Stereotype1 operation enum1 contains the problematic constraint "enum1_derived_property_evaluator" with OCL expression:

Set(Enumeration1){Enumeration1::EnumerationLiteral2}


Somehow specifying the profile enumeration literal in an OCL expression results in the reported issue.

To replicate the problem, you must create a Run Configuration within Eclipse after building the profile com.validationproblem.profile, making sure the Run Configuration will register this built profile plugin. Then within the Run Configuration instance of Eclipse that starts during runtime, you must configure OCL/Pivot by clicking Windows -> Preferences -> OCL and make sure the Executor targeted by the default OCL delegate is set to http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot.

Within the Run Configuration test instances of Eclipse open the test application model ValidationProblemApp and open the Papyrus model:

index.php/fa/39844/0/

When you click on Class1 and using the properties view click on Profile and check the tagged values of the Stereotype1 stereotype you will see the tagged value of "depends" is [Class3, Class2] and "enum1" is [EnumerationLiteral2]. All fine so far. You can also check Class2 and Class3 stereotype tagged values and they should all show correctly according to the "Depends" dependencies. Anyway, all the "enum1" values should be EnumerationLiteral2 as specified by the OCL expression discussed above.

Now if you right-click on the ValidationProblemApp Model element of the application model and click Validation -> Validate model you will see 3 errors in the Model Validation view:

Severity	Description	Element	Parent	Type
Error	The feature 'validationproblem::Stereotype1::enum1' of 'Stereotype1' contains a bad value	<<Stereotype1>> <Class> Class1	ValidationProblemApp	EMF Problem

Severity	Description	Element	Parent	Type
Error	The feature 'validationproblem::Stereotype1::enum1' of 'Stereotype1' contains a bad value	<<Stereotype1>> <Class> Class2	ValidationProblemApp	EMF Problem

Severity	Description	Element	Parent	Type
Error	The feature 'validationproblem::Stereotype1::enum1' of 'Stereotype1' contains a bad value	<<Stereotype1>> <Class> Class3	ValidationProblemApp	EMF Problem


All corresponding to the "enum1" derived property with the static reference to the profile enumeration literal. Notice that the other derived property referencing the "Depends" element shows perfectly fine.

I have narrowed down this issue to only happen for enumeration literals that are specified by OCL expressions.

Any ideas what is going wrong? Is this a bug found and should I create a Bugzilla ticket?



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837365 is a reply to message #1837352] Thu, 28 January 2021 14:35 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

This appears to be another EnumerationLiteral problem. Unfortunately both UML and Ecore variants co-exist at run-time requiring careful conversion. Seems ok with a single EnumerationLiteral , but not with a Set of EnumerationLiteral . https://bugs.eclipse.org/bugs/show_bug.cgi?id=570717 raised.

You seem to have been badly influenced by the UML spec. There is no need for a "x" to redirect to "x()" to a Constraint. You can add an OCL-valued OpaqueExpression directly as the default value of a Property (or the Body Condition of an Operation.).

You are still using the interpreted execution rather than the Java. The Java version has a very similar problem with Set(EnumerationLiteral) but now it is a compiler error rather than a validation problem.

Regards

Ed Willink
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837366 is a reply to message #1837352] Thu, 28 January 2021 15:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The attached has:

- a simpler *.uml defining Property default values and a enum0 to demonstrate correct declarations for a non-Set EnumerationLiteral
- a genmodel that enforces code generation
- a Stereotype1.java with the manual declaration fix for the compiler error.
- MANIFEST.MF/plugin.xml simplifications so that I don't need Papyrus

With this Java generated static profile, validation is ok.

So - just need to fix the bad Set<EnumerationLiteral> in both CG and interpreter.

Regards

Ed
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837382 is a reply to message #1837366] Fri, 29 January 2021 02:59 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

Much appreciated thank you! I've learnt quite a few things from you now, and thank you for raising the bug ticket also.

After downloading your modifications, here is my breakdown.

Initially I had a missing bundle org.eclipse.ocl.examples.codegen; resolved by installing all OCL packages, perhaps some where missing (later discovered this is added to the META-INF/MANIFEST.MF during code generation when "Use Delegates" is enabled):

  • OCL Build Support
  • OCL Build Support Developer Resources
  • OCL Classic SDK: Ecore/UML Parsers, Evaluator, Edit
  • OCL Classic SDK: Ecore/UML Parsers, Evaluator, Edit Developer Resources
  • OCL Examples and Editors SDK
  • OCL Examples and Editors SDK Developer Resources


There was a missing file com.validationproblem.profile.validationproblem.ValidationProblemTables; this is a generated file also (only when "Use Delegates" is enabled) and is missing from my generated code because I was still using the interpreted execution rather than the Java. Well only because I didn't know how to make it generate the Java one until I reverse engineered the changes you did in your posted version!

It seems your version of the genmodel has the following, which I suspect is how we specify we want to generate Java code from OCL rather than use interpreted OCL:
  <genAnnotations source="http://www.eclipse.org/OCL/GenModel">
    <details key="Use Delegates" value="false"/>
  </genAnnotations>


I then opened the file "ValidationProblem.profile.genmodel in the Eclipse editor (I even opened the previous version side-by-side to see if I am failing to see the option), but I could not see any of the options showing "Use Delegates". So the Eclipse genmodel editor UI does not show this option! Is it an invisible option? To help future people, in hindsight, where should I have looked to see this is even an option?!? Looking at the other genAnnotations in the genmodel file I'm inclined to believe it should be one of the options you tick when ReLoading the model importer (same location where the "Camel Case Names" option is) but even there I cannot see "Use Delegates" option. This is definitely something that will plague future people. Currently the only way to enable it as far as I can tell is to manually edit the genmodel file and add the above snippet!

Quote:

You seem to have been badly influenced by the UML spec


YES I have been, here is the specific item in the OMG UML version 2.5.1 specification formal/2017-12-05 states:

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.


Another thing I learnt... Looking at your code and how you have speficied a UML OpaqueExpression (with OCL expression body) for the defaultValue of an ownedAttribute of a Property is something I did not know was possible! However, the defaultValue is a UML ValueSpecification element, so nothing stops it from being specified with an OpaqueExpression! Brilliant and it seems to be compliant with UML spec also; however I'm a little worried with the UML specification wording implying the defaultValue is only for the initial value of the Property "The evaluated default then becomes the initial value (or values) of the Property" it does however also say "The derivation for a derived Property may be specified by a constraint" however that doesn't say it's the defaultValue attribute of the property, but since it was talking about the defaultValue attribute just in the previous paragraph and I cannot see any other way of specifing a derived property with a constraint other than the defaultValue! OMG UML version 2.5.1 specification formal/2017-12-05 states:
Quote:

If there is a defaultValue specified for a Property, this default is evaluated when an instance of the Property is created in the absence of a specific setting for the Property or a constraint in the model that requires the Property to have a specificvalue. The evaluated default then becomes the initial value (or values) of the Property.

If a Property has isDerived = true, it is derived and its value or values may be computed from other information. Actions involving a derived Property behave the same as for a nonderived Property. Derived Properties are often specified to be read-only (i.e., clients may not directly change values). But where a derived Property is changeable, an implementation is expected to make appropriate changes to the model in order for all the constraints to be met, in particular the derivation constraint for the derived Property. The derivation for a derived Property may be specified by a constraint.


Thus quasi-uneasily I accept OCL in defaultValue for derived properties as a better way forward over same name operations after consulting the gospels of OMG :)

Quote:

There is no need for a "x" to redirect to "x()" to a Constraint.


I agree, however I often get worried if OCL will refer to the correct object (trust issues), for example, given StereotypeX extends NamedElement and self is a Stereotype that extends Dependency, if I have an OCL expression:

self.base_Dependency->forAll(StereotypeX.allInstances()->select(base_NamedElement = client)->notEmpty())


OCL must therefore know that within the "select" scope, the "base_NamedElement" refers to the StereotypeX iterator element and the "client" refers to the "base_Dependency" iterator element from the "forAll". What if both those iterators contained something that is called "client" or "base_NamedElement"?? Thus my insecurities and comfort in being explicit:

self.base_Dependency.client->forAll(aNamedElement : UML::NamedElement | StereotypeX.allInstances()->select(base_NamedElement = aNamedElement)->notEmpty())


I guess if there was a clash, then OCL would detect that ambiguity I am worried about?

After importing your posted changes my model generated the following Java code:
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EList<Enumeration1> getEnum1() {
    /**
    * Set{Enumeration1::EnumerationLiteral2}
    */
    final /*@NonInvalid*/ Executor executor = PivotUtil.getExecutor(this);
    final /*@NonInvalid*/ IdResolver idResolver = executor.getIdResolver();
    final /*@NonInvalid*/ List<EnumerationLiteralId> ECORE_Set = ((IdResolverExtension)idResolver).ecoreValueOfAll(Enumeration1.class, ValidationProblemTables.Set);
    return (EList<EnumerationLiteralId>)ECORE_Set;
}


Looks like the returned "EnumerationLiteralId" should be a "Enumeration1" as per your description of the problem in the Bug 570717 ticket?

After I generate the code gives Java Problems in Stereotype1Impl.java as expected and apparent from your bug report:
Type mismatch: cannot convert from EList<Enumeration1> to List<EnumerationLiteralId> Stereotype1Impl.java
Type mismatch: cannot convert from EList<EnumerationLiteralId> to EList<Enumeration1>


Your posted code changes looks to have been manually edited as follows (I guess this is your workaround for the bug you have reported?):
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EList<Enumeration1> getEnum1() {
    /**
    * Set{Enumeration1::EnumerationLiteral2}
    */
    final /*@NonInvalid*/ Executor executor = PivotUtil.getExecutor(this);
    final /*@NonInvalid*/ IdResolver idResolver = executor.getIdResolver();
//  final /*@NonInvalid*/ List<EnumerationLiteralId> ECORE_Set = ((IdResolverExtension)idResolver).ecoreValueOfAll(Enumeration1.class, ValidationProblemTables.Set);
//  return (EList<EnumerationLiteralId>)ECORE_Set;
    final /*@NonInvalid*/ List<Enumeration1> ECORE_Set = ((IdResolverExtension)idResolver).ecoreValueOfAll(Enumeration1.class, ValidationProblemTables.Set);
    return (EList<Enumeration1>)ECORE_Set;
}


When I replace my generated getEnum1 function with this one (seeming to be a manually edited workaround) the Validation checks and all other OCL expressions work!

Once again thank you for all your help!


Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837385 is a reply to message #1837382] Fri, 29 January 2021 05:20 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

One new problem appears with this Java version as apposed to the interpreted OCL version, and that is the constraints "client_is_Stereotype1" and "supplier_is_Stereotype1" applied to the Depends stereotype never fail.

To test you can open the ValidationProblemApp and add a new class without applying the "Stereotype1" stereotype, link using a Dependency with the "Depends" stereotype applied, then do "Validation" -> "Validate model" and the above mentioned constraints do not fail when they should.

Worse, note that this worked with the interpreted OCL version previously.

Besides this validation check, the other OCL items seem to still be working with the Java version. I did however find another issue similar to the bug you reported regarding UML::Integer Sets; I might need to elaborate on that one later.

But do you see why the constraints would be always passing even when they should fail?



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837394 is a reply to message #1837385] Fri, 29 January 2021 09:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You fall foul of many secrets. It seems i need to review the Papyrus help since not everything is appropriate.

The OMG policy of a Property x redirecting to an x() Operation is good if you need polymorphism since an Operation can be overridden but a Property cannot. The perverse non-use of the Operation Body Condition is just stupid, particularly when it mandates a manual fixup.

Sadly the OMG OCL, and the OCL aspects of the OMG UML, specifications are a disgrace. You can read how/why the OCL specification is so bad in "Reflections on OCL 2" [1]. There has never been anyone with genuine OCL understanding actively contributing to the UML 2.x spec. You will find that the UML 2.5 credits me with contributions, but they were limited to reducing the hundreds of OCL syntax errors to just 4 and ensuring that the explanatory note that you quote on x redirects to x() was added. I failed to get the missing default value expressions added so that the default for x would be an invocation of x(). The UML specification model therefore has a gaping hole filled only by an explanatory note. UML has also not come to terms with the concept of an OCL expression, insisting that OCL only has Constraints consequently the Body Condition of an operation cannot legally specify a non-Boolean return value. In UML 2.5 at last there is a consistent XMI exposition using the "result = x" idiom to express the x result in Boolean form. The Pivot OCL loader for UML strips the idiom to allow operations to return values. This lack of support for OCL expressions perhaps correlates with the reticence to endorse the idea that the default value specification of a Property might do something useful.

GenModel annotations are editable once you select Show Annotations from the Generator tool bar menu. It was years before I discovered that some EMF / UML functionality was available by the toolbar and nowhere else. The GenAnnotation that I added manually should be provided automatically by whatever tool synthesizes your *.genmodel. You don't have to have it but then you fall back on project/workspace settings.

Your original "UML" problem is now mitigated by a better error message redirecting to the Wiki.

I'm working on your new Set<EnumerationLiteral> problem. It seems that although I have JUnit tests that use static UML profiles and tests that generate compile and execute Ecore models, no tests generate compile and execute UML models so a bit more test technology is required first.

In principle, compiled and interpreted should always give the same results, subject to classpath magic allowing models to be loaded. Your distinction seems like another bug to investigate.

Regards

Ed Willink

[1] https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwid7vCG5cDuAhUPZcAKHVSIB0gQFjABegQIBRAC&url=http%3A%2F%2Fwww.jot.fm%2Fissues%2Fissue_2020_03%2Farticle17.pdf&usg=AOvVaw3jLR9VPJwPPuTGPWCkiCvF

Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837397 is a reply to message #1837394] Fri, 29 January 2021 10:22 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

Nice! There you are! -> OMG UML spec 6.5.2 Technical Support:
Quote:

The following people provided technical support for this specification, including writing tools to generate portions of the document and to validate the OCL:Peter Denno, Maged Elaasar, Nicolas Rouquette, Ed Willink


I definitely noticed some issues in the UML metamodel also, but I wasn't sure if I'm wrong - I was wondering how I can report it back to OMG but never looked into it yet - perhaps you have pointers? For example in UML machine consumable xmi 2.5.1 xmi-id "Namespace-excludeCollisions" has OCL:
result = (imps->reject(imp1  | imps->exists(imp2 | not imp1.isDistinguishableFrom(imp2, self))))


But it should have "imp1 <> imp2" like this:
result = (imps->reject(imp1  | imps->exists(imp2 | imp1 <> imp2 and not imp1.isDistinguishableFrom(imp2, self))))


There was a couple others I noticed, can't seem to remember at the moment.

Anyway, regarding this new problem, from what I can tell the stereotype "Depends" constraints supplier_is_Stereotype1 and client_is_Stereotype1 do not get called at all when you right-click the test application model and select Validation -> Validate model.

I'm uploading the updated Git ValidationProblem2.tar.gz (containing also your changes) and I've added some System.out.println to show that these constraint functions are not called by the Papyrus framework during model validation!

I have also checked that genmodel contains the "Model Plug-in Class" - if that makes a difference?

Otherwise, all the other OCL functions such as derived properties are working much better with the Java version as you have indicated. As per your earlier comments, the Java version is far more responsive and clearly faster to execute when navigating the Papyrus model - very happy with this decision to move to Java.

I know you are busy with the previous bugs, any quick pointers you have for me to try to get the validation calls working?



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837403 is a reply to message #1837397] Fri, 29 January 2021 12:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The direct Java code, although a bit verbose and only 'half-readable' is also much better for debugging. Many optimisation opportunities remain for my next model-driven rewrite.

I'm not 100% sure what the Model Plug-in Class is; probably its just the Activator that you don't need for a boring model but may need if you start elaborating with manual code that uses the ResourceLoader to intemationalize error messages.

OMG bugs may be reported at https://issues.omg.org/issues/create-new-issue

Prior to UML 2.5, the OCL in the UML specification was open loop best endeavours and had many hundreds of errors since it had never been though a tool that checked syntax. How good would your coding be in a new language without any tooling support? For UML 2.5, I fixed all syntax errors and all semantic errors, but when I improved Eclipse OCL tooling four new semantic errors were detected just too late to go into 2.5. AFAIAA there has never been any comprehensive execution of the OCL so there are no doubt hundreds of functional errors to be resolved. Sadly no implementer, such as the Eclipse UML2, fed back the discrepancies they uncovered when transcribing from specification OCL to their preferred implementation language (Java for Eclipse UML2). While developing the Validity View I accidentally found that I was executing the OCL for the UML and it was really really slow so I guess the main class structure constraints are right, but direct use needs some significant optimization in regard to rewriting allInstances as package constraints and avoiding naive cascaded collections.

What Papyrus calls during model validation doesn't particularly interest me. When investigating defective tooling, you should load your model in the UML Model Editor and (EMF->)Validate there and if you're not happy try OCL->Validate. Anything that works in the UML Model Editor but doesn't work in Papyrus is a Papyrus bug.

(EMF has a clear validate API that applies to all EObjects in a model. Unfortunately the OMG specification decided that a Stereotype application did not merit a StereotypeApplication class and so there is XMI magic for some dynamic/reflective content. The UML2 representation is faithfully irregular and outwits the EMF API. The better OCL->Validate remedies the missing UML validation, and Papyrus picked up the OCL fix, but the developers forgot why they had one bit of irregular code and yet another for the wierd EMFv Constraint capability; the OCL validation got lost for a while. Meanwhile UML2 improved its validation and Papyrus changed. Just remember that OCL->Validate is there in case the other tools are not doing their job properly.)

Regards

Ed Willink

Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837406 is a reply to message #1837403] Fri, 29 January 2021 12:50 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

I agree, it does seem the Java code is much better for debugging - even for a C++ programmer! I guess when you know a couple languages it's all the same.
Did I understand correctly that you implemented this Java code generator and in the process of doing a rewrite? Is there some way I can get involved or help?

Quote:

What Papyrus calls during model validation doesn't particularly interest me.

I am happy to comply with this opinion - I tried opening the uml model file of the model using the UML Editor instead of Papyrus and the Validate instruction worked perfectly! To be honest Papyrus is only important to me for diagrams, the actual model and it's contents can be managed through UML Editor directly just fine. Do you have another Eclipse based tool you prefer for diagram construction?

I created the OMG bug at https://issues.omg.org/issues/lists/unclassified#issue-47355, to me it's important to share what I can to contribute.

I really think OMG should work even closer with EMF/Eclipse based modelling tools, they are clearly a perfect match. OMG can definitely benefit from the practical experience from Eclipse Modelling tools/community and it's open source culture aligns with what OMG stands for.



Once again thank you for all your help,

Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837413 is a reply to message #1837406] Fri, 29 January 2021 14:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The current code generator is my third version. It suffers from using an inadequate conversion chain; OCL-model->CG-model->Java-text. This leaves considerable complexity in the type descriptions for actual/future Java types; when contributing to genmodel, the Java classes may not yet exist. The multi-enumeration future declaration is almost certainly where your Set<EnumerationLiteral> is going wrong.

My next rewrite, (my stack of TODOs is huge) will be OCL-model->CG-model->Abstract-OO-model->Java-model->Java-text. Abstract CG-model and Abstract-OO-model might merge. I hope to find a credible Java-model so that the pain of irregular primitive type code in Java-model->Java-text is done for me. Generating C/C++ is also on my wish list since particularly for model transformation, while the warm Java speed may not be that much slower than C, once you allow for warming up the JVM for each application in a transformation chain, C is much much faster. (IMHO C++ is invaluable to stop a team of programmers playing with each other's 'private parts' but almost totally redundant for auto-generated code.)

I am happy to devote quite a bit of time to mentoring genuine modeling enthusiasts. I can easily partition off one of the many areas that I do not have time for to such an enthusiast.

In principle I am a fan of Papyrus. It is my first choice when I need to draw UML diagrams, but usually I want something different and Sirius is more appropriate, but very hard to use - another of my TODOs. Day to day I try to avoid installing too much so I do not use Papyrus or Sirius at all.

Please raise a Papyrus bug for the validation that 'fails' in Papyrus but 'works' in the UML Model Editor.

Regards

Ed Willink
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837442 is a reply to message #1837413] Sat, 30 January 2021 02:32 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

I created the Papyrus bug ticket for the validation problem:
Bug 570771: https://bugs.eclipse.org/bugs/show_bug.cgi?id=570771



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837443 is a reply to message #1837442] Sat, 30 January 2021 02:55 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

I posted another Papyrus bug I came across when I was creating a single Integer typed Property, Bug #570772: https://bugs.eclipse.org/bugs/show_bug.cgi?id=570772

Attached updated profile with the Integer issue ValidationProblem4.tar.gz

Anyway, the actual problem I was replicating is this Integer Set issue when generating Java static profile "EList<IntegerValue> -> EList<Integer>" problem.
Perhaps I'm hitting my Java knowledge limit as it now seems to deal with a literal int value using ValueUtil.intValueOf but we need to somehow turn that back into EList<Integer> - I tried seemed to have fixed it, but can you please verify that fix is OK?

Anyway, it's definitely a special case of the previous problem we identified:

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EList<Integer> getIntegerSet() {
    /**
    * Set{101}
    */
    final /*@NonInvalid*/ Executor executor = PivotUtil.getExecutor(this);
    final /*@NonInvalid*/ IdResolver idResolver = executor.getIdResolver();
    final int ECORE_Set_0 = ValueUtil.intValueOf(ValidationProblemTables.Set_0);
    return (EList<IntegerValue>)ECORE_Set_0;
}


Here is my manual workaround fix:
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EList<Integer> getIntegerSet() {
		/**
		 * Set{101}
		 */
		final /*@NonInvalid*/ Executor executor = PivotUtil.getExecutor(this);
		final /*@NonInvalid*/ IdResolver idResolver = executor.getIdResolver();

//		final int ECORE_Set_0 = ValueUtil.intValueOf(ValidationProblemTables.Set_0);
//		return (EList<IntegerValue>)ECORE_Set_0;
		final /*@NonInvalid*/ List<Integer> ECORE_Set_0 = ((IdResolverExtension)idResolver).ecoreValueOfAll(Integer.class, ValidationProblemTables.Set_0);
		return (EList<Integer>)ECORE_Set_0;
	}


Should I create another Bugzilla ticket for this case or will you handle it as part of the previous generator issue?



Best regards,
Deniz

[Updated on: Sat, 30 January 2021 03:06]

Report message to a moderator

Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837446 is a reply to message #1837443] Sat, 30 January 2021 06:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I've extended the existing Bugzilla; it's almost certainly demonstrating that the Set<EnumerationLiteral> problem is more generally Collection<T>.

You're not hitting your Java knowledge limit; you are starting to see the practical difficulties.

Java has a mutable and an immutable Integer type; int and Integer with inconsistent equality behaviours.
Ecore has three mutable IntegerEDataTypes; EInt, EInteger, EIntegerObject with no functional behaviour.
OCL has one unbounded immutable Integer type called Integer but implemented in the PIvot OCL by a polymorphic IntegerValue hierarchy of IntIntegerValue, LongIntegerValue, BigIntegerValue with consistent value equality, numerical growth.

Each of Java/Ecore/OCL again has its own Collection system with OCL again offering the uniformity appropriate to a specification rather than implementation language.

Consequently an OCL evaluation may acquire an Ecore value from a model using a Java representation and then convert it to an OCL value for computation. And the reverse for a result. Avoiding needless conversions is desirable.

Along the way any function calls must respect the appropriate EMF / Java / OCL library calling conventions.

And just to make life more fun an EEnumLiteral is not contained by its EEnum so there are distinct Java, Ecore, UML, Pivot variants of the seemingly trivial value to be used appropriately.

Regards

Ed Willink
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837448 is a reply to message #1837446] Sat, 30 January 2021 07:12 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

Thanks for the pointers.

It seems one can come up with many complex OCL expressions that fail to parse to Java. I already fixed some, but to share I'll have to come up with simplified versions that replicate the problem. Would it help if I keep posting them here?



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837451 is a reply to message #1837448] Sat, 30 January 2021 09:08 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

I've again attached the replication profile/application projects.

I'm getting another Java generation error that is different to ones we've discussed. This time an exception is thrown:
org.eclipse.ocl.pivot.values.InvalidValueException: Unknown enumeration EnumerationLiteral1
    at org.eclipse.ocl.pivot.internal.library.executor.AbstractIdResolver.boxedValueOfEnumerator(AbstractIdResolver.java:516)
    at org.eclipse.ocl.pivot.internal.library.executor.AbstractIdResolver.boxedValueOf(AbstractIdResolver.java:439)
    at org.eclipse.ocl.pivot.internal.library.executor.AbstractIdResolver.createSetOfAll(AbstractIdResolver.java:653)
    at com.validationproblem.profile.validationproblem.impl.Stereotype1Impl.getVal1(Stereotype1Impl.java:464)
    at com.validationproblem.profile.validationproblem.impl.Stereotype1Impl.eGet(Stereotype1Impl.java:508)


So basically I added 2 properties to the Steroetype1 stereotype called "pin" and "val1". "val1" is a derived property that is set to "pin" if "pin" (which is of type Enumeration1) is not set to enumeration literal "unrestricted", or if it's set to "unrestricted" it takes the value of the parent Class that has the stereotype applied, or else the default value of "EnumerationLiteral1".

In OCL the property defaultValue looks like this:
let allStereotype1 : Set(Stereotype1) = Stereotype1.allInstances() in if self.pin <> Enumeration1::unrestricted then Set(Enumeration1){self.pin} else if self.base_NamedElement.owner.oclIsKindOf(UML::Class) then allStereotype1->select(self.base_NamedElement.owner.oclAsType(UML::Class)->includes(base_NamedElement)).val1->asSet() else Set(Enumeration1){Enumeration1::EnumerationLiteral1} endif endif


I had to put a "let" expression to house the "Stereotype2.allInstances()" because when I use that value as an expression I get another problem - which I intend to demonstrate with "val2" property implemented in that way soon.

So looking at the source of the exception Stereotype1Impl.java:464 where the exception is thrown looks like this:
final /*@NonInvalid*/ SetValue BOXED_val1 = idResolver.createSetOfAll(ValidationProblemTables.SET_ENUMid_Enumeration1, val1);


Since the exception said "Unknown enumeration EnumerationLiteral1" it seems the instance is being searched from the name, so I changed it to the following and it seems to work now:
final /*@NonInvalid*/ SetValue BOXED_val1 = ValueUtil.createSetOfEach(ValidationProblemTables.SET_ENUMid_Enumeration1, val1.get(0).toString());


However I'm not happy that the string value is used to look up the instance; I mean it works, but there clearly is a Java generation bug here and I'm not sure if my workaround fix is good enough?

Here is the full function showing comments where I modified it with the workaround:
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EList<Enumeration1> getVal1() {
    /**
    *
    * let
    *   allStereotype1 : Set(ValidationProblem::Stereotype1) = Stereotype1.allInstances()
    * in
    *   if self.pin <> Enumeration1::unrestricted
    *   then Set{self.pin}
    *   else
    *     if self.base_NamedElement.owner.oclIsKindOf(UML::Class)
    *     then
    *       allStereotype1->select(
    *         self.base_NamedElement.owner.oclAsType(UML::Class)
    *         ->includes(base_NamedElement))
    *       .val1->asSet()
    *     else Set{Enumeration1::EnumerationLiteral1}
    *     endif
    *   endif
    */
    final /*@NonInvalid*/ Executor executor = PivotUtil.getExecutor(this);
    final /*@NonInvalid*/ IdResolver idResolver = executor.getIdResolver();
    final /*@NonInvalid*/ org.eclipse.ocl.pivot.Class TYP_ValidationProblem_c_c_Stereotype1_0 = idResolver.getClass(ValidationProblemTables.CLSSid_Stereotype1, null);
    final /*@NonInvalid*/ SetValue allStereotype1 = ClassifierAllInstancesOperation.INSTANCE.evaluate(executor, ValidationProblemTables.SET_CLSSid_Stereotype1, TYP_ValidationProblem_c_c_Stereotype1_0);
    final /*@NonInvalid*/ Enumeration1 pin_0 = this.getPin();
    final /*@NonInvalid*/ EnumerationLiteralId BOXED_pin = ValidationProblemTables.ENUMid_Enumeration1.getEnumerationLiteralId(ClassUtil.nonNullState(pin_0.getName()));
    final /*@NonInvalid*/ boolean ne = BOXED_pin != ValidationProblemTables.ELITid_unrestricted;
    /*@Thrown*/ SetValue symbol_1;
    if (ne) {
        final /*@NonInvalid*/ SetValue Set = ValueUtil.createSetOfEach(ValidationProblemTables.SET_ENUMid_Enumeration1, pin_0);
        symbol_1 = Set;
    }
    else {
        final /*@NonInvalid*/ org.eclipse.ocl.pivot.Class TYP_UML_c_c_Class_0 = idResolver.getClass(ValidationProblemTables.CLSSid_Class_0, null);
        final /*@NonInvalid*/ NamedElement base_NamedElement = this.getBase_NamedElement();
        if (base_NamedElement == null) {
            throw new InvalidValueException("Null source for \'\'http://www.eclipse.org/uml2/5.0.0/UML\'::Element::owner\'");
        }
        final /*@Thrown*/ Element owner = base_NamedElement.getOwner();
        final /*@Thrown*/ boolean oclIsKindOf = OclAnyOclIsKindOfOperation.INSTANCE.evaluate(executor, owner, TYP_UML_c_c_Class_0).booleanValue();
        /*@Thrown*/ SetValue symbol_0;
        if (oclIsKindOf) {
            /*@Thrown*/ Accumulator accumulator = ValueUtil.createSetAccumulatorValue(ValidationProblemTables.SET_CLSSid_Stereotype1);
            Iterator<Object> ITERATOR__1 = allStereotype1.iterator();
            /*@Thrown*/ SetValue select;
            while (true) {
                if (!ITERATOR__1.hasNext()) {
                    select = accumulator;
                    break;
                }
                /*@NonInvalid*/ Stereotype1 _1 = (Stereotype1)ITERATOR__1.next();
                /**
                *
                * self.base_NamedElement.owner.oclAsType(UML::Class)
                * ->includes(base_NamedElement)
                */
                final /*@Thrown*/ org.eclipse.uml2.uml.Class oclAsType = (org.eclipse.uml2.uml.Class)OclAnyOclAsTypeOperation.INSTANCE.evaluate(executor, owner, TYP_UML_c_c_Class_0);
                final /*@Thrown*/ SetValue oclAsSet = OclAnyOclAsSetOperation.INSTANCE.evaluate(executor, ValidationProblemTables.SET_CLSSid_Class, oclAsType);
                final /*@NonInvalid*/ NamedElement base_NamedElement_1 = _1.getBase_NamedElement();
                final /*@Thrown*/ boolean includes = CollectionIncludesOperation.INSTANCE.evaluate(oclAsSet, base_NamedElement_1).booleanValue();
                //
                if (includes == ValueUtil.TRUE_VALUE) {
                    accumulator.add(_1);
                }
            }
            /*@Thrown*/ org.eclipse.ocl.pivot.values.BagValue.Accumulator accumulator_0 = ValueUtil.createBagAccumulatorValue(ValidationProblemTables.BAG_ENUMid_Enumeration1);
            Iterator<Object> ITERATOR__1_0 = select.iterator();
            /*@Thrown*/ BagValue collect;
            while (true) {
                if (!ITERATOR__1_0.hasNext()) {
                    collect = accumulator_0;
                    break;
                }
                /*@NonInvalid*/ Stereotype1 _1_0 = (Stereotype1)ITERATOR__1_0.next();
                /**
                * val1
                */
                // Build Error -> final /*@NonInvalid*/ List<EnumerationLiteralId> val1 = _1_0.getVal1();
                final /*@NonInvalid*/ List<Enumeration1> val1 = _1_0.getVal1();
                // Exception thrown -> final /*@NonInvalid*/ SetValue BOXED_val1 = idResolver.createSetOfAll(ValidationProblemTables.SET_ENUMid_Enumeration1, val1);
                final /*@NonInvalid*/ SetValue BOXED_val1 = ValueUtil.createSetOfEach(ValidationProblemTables.SET_ENUMid_Enumeration1, val1.get(0).toString());
                //
                for (Object value : BOXED_val1.flatten().getElements()) {
                    accumulator_0.add(value);
                }
            }
            final /*@Thrown*/ SetValue asSet = CollectionAsSetOperation.INSTANCE.evaluate(collect);
            symbol_0 = asSet;
        }
        else {
            symbol_0 = ValidationProblemTables.Set_1;
        }
        symbol_1 = symbol_0;
    }
    // Build Error -> final /*@Thrown*/ List<EnumerationLiteralId> ECORE_symbol_1 = ((IdResolverExtension)idResolver).ecoreValueOfAll(Enumeration1.class, symbol_1);
    // Build Error -> return (EList<EnumerationLiteralId>)ECORE_symbol_1;
    final /*@Thrown*/ List<Enumeration1> ECORE_symbol_1 = ((IdResolverExtension)idResolver).ecoreValueOfAll(Enumeration1.class, symbol_1);
    return (EList<Enumeration1>)ECORE_symbol_1;
}
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837452 is a reply to message #1837451] Sat, 30 January 2021 09:37 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

No. Just post the OCL expression in a comment to https://bugs.eclipse.org/bugs/show_bug.cgi?id=570717 and if non-trivial attach an updated xxx.profile.uml too. But don't bother with any that might be regarded as Collection<T> since I've found a generic issue. I'm puzzled that it has escaped attention for so long.

Regards

Ed
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837453 is a reply to message #1837452] Sat, 30 January 2021 10:13 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

Could this latest "idResolver.createSetOfAll" exception issue also be linked to the Collection issue somehow?



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837454 is a reply to message #1837453] Sat, 30 January 2021 10:36 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Probably. While generating code there is an action to perform, such as "add" and a type on which to perform it such as "Short". A simple traversal of the CG AST traverses actions and each action does something 'sensible'. Unfortunately once the diversity of 'sensible' results in an unwieldy if-tree it makes sense to redirect the if-tree-branch of the action via a polymorphic call to a type-specific handler. The convert-to-Ecore action had been only partially redirected leading to bad treatment of at least convert-collection-to-Ecore.

Feel free to add more examples to the Bugzilla; they all make for good JUnit tests.

Regards

Ed Willink
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837455 is a reply to message #1837454] Sat, 30 January 2021 11:44 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
No problem, thanks Ed, I can retest when you release the bug fix versions anyway.



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837470 is a reply to message #1837455] Sun, 31 January 2021 01:40 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

I found a different problem not related to this topic (at least I think it's different) so I created a new forum topic to handling is separately: https://www.eclipse.org/forums/index.php?t=msg&th=1106785&goto=1837469&#msg_1837469
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837508 is a reply to message #1837470] Mon, 01 February 2021 10:23 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You should find that your EList and EnumerationLiteral issues are resolved by installing from https://ci.eclipse.org/ocl/job/ocl-branch-tests/238/artifact/targetPlatform/

Regards

Ed Willink
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837511 is a reply to message #1837508] Mon, 01 February 2021 12:05 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Edi,

Looking good, the collection issue is fixed!

However, I still get this exception thrown as I've described in this message earlier:
https://www.eclipse.org/forums/index.php?t=msg&th=1106761&goto=1837451&#msg_1837451

The code that throws the exception is this one as outlined in the above message:
/**
 * val1
 */
final /*@NonInvalid*/ List<Enumeration1> val1 = _1_0.getVal1();
final /*@NonInvalid*/ SetValue BOXED_val1 = idResolver.createSetOfAll(ValidationProblemTables.SET_ENUMid_Enumeration1, val1);


If I manually change this to the following code it all works:
/**
 * val1
 */
final /*@NonInvalid*/ List<Enumeration1> val1 = _1_0.getVal1();
final /*@NonInvalid*/ SetValue BOXED_val1 = ValueUtil.createSetOfEach(ValidationProblemTables.SET_ENUMid_Enumeration1, val1.get(0));


This one is clearly a different bug to the collection issue.

As a side note, I've been using your OCL Java generator with quite complex OCL expression lately and I am quite impressed how well it works! When it comes to this collection issue, I can verify it is now fixed in this version you present. When it comes to this enumeration exception throwing issue, I fix those by hand, and the UnlimitedNatural issue I avoid altogether. Besides these, really complex OCL expressions are working nicely!

What's your view about why this enumeration exception is happening?



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837516 is a reply to message #1837511] Mon, 01 February 2021 13:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

It's a bug. As I indicated earlier non-trivial synthesis is redirected from actions to TypeDescriptors which come in far far too many flavours that should simplify dramatically given a rethink and a clean Java/OO model.

What you are seeing is a straightforward bug; hopefully localized to a particular style of EnumerationLiteral reference. Once I put the offending OCL expression into a Junit test case it should be an easy fix.

I'm glad that the CG is mostly good for you. More bad bugs have appeared in the last three days than the last year so I was getting a bit depressed.

Regards

Ed Willink
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837544 is a reply to message #1837516] Tue, 02 February 2021 06:04 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

The generator you have developed is truly brilliant!

It's only human nature to focus on a couple of issue, as they draw the attention of the user upon themselves, however the silent mammoths of working features seamlessly operate and make no noise for us to hear them. Now that I am getting more experience playing with your generator via some really complex OCL expressions, I can really appreciate how truly powerful it is!

I really like Papyrus also, and to me it is the only true graphical modelling tool (being open-source is very important), however it seems to suffer from a handful of really unfortunate user interface issues, which I'm sure can be fixed really easily. What actions would you propose to at least get some Papyrus UI experts to check and comment on some of these sore spots that impact on model development effort?

Besides those Papyrus issues, the static profile development workflow you have recommended to me, using your generator, in the last few weeks is now really efficient. It involves designing the Papyrus profile with embedded OCL expressions inside derived property defaultValue fields, then save and click "No" on the "Would you like to define it?" question - always testing to see if I want to critically break my project :) Simple question to bypass but as you get more and more tired during the night...

Then I reload the genmodel and generate the Model Code - and now thanks to your latest fix I do not need to edit the generated code at all. The example code I gave has that enumeration issue but that was a special case I can develop around.

Another good thing, is that when generating the Model Code any OCL expression errors are reported nicely! Papyrus checks OCL expressions during editing also however with gliches such as:


  • Often it says there is an error by giving red underling on the OCL expression, but when you click to other elements and then click back to the OCL expression editor box the error reporting is mysteriously gone!
  • Of course when you click back to the OCL expression you need to scroll around horizontally trying to read the OCL expression in the editor because Papyrus loses the nice wrapped display of the OCL expression when you click out of the editor right after creating it!


Once again thank you for all your help and recent fixes, it's truly amazing software you are developing! Also worth mentioning, thanks to your pointers and mentoring, even though I started off as a fairly new user to Papyrus (although familiar with UML) within a couple of weeks only I am now able to design static profiles with serious power.



Best regards,
Deniz

[Updated on: Tue, 02 February 2021 06:05]

Report message to a moderator

Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837550 is a reply to message #1837544] Tue, 02 February 2021 09:40 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

It seems I can span my OCL Expressions to multiple lines in Papyrus without it effecting the resultant generated code - so I guess that aspect is OK now.



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837554 is a reply to message #1837550] Tue, 02 February 2021 10:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Thank you for your nice kind words; always nice to feel appreciated.

I am perhaps fortunate in that I can pursue my enthusiasms without undue financial concerns. Few other committers can afford to do this, so the one thing you can do to really help Papyrus is to arrange funding from your company / clients / .... Almost equally as helpful is to become really familiar with the Papyrus code so that you can contribute solutions to the pain points.

While your learning experiences are fresh in your mind, it could be helpful to review the documentation that you found hard to find and the documentation that you found of poor quality.

Regards

Ed Willink
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837559 is a reply to message #1837554] Tue, 02 February 2021 11:43 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

Good ideas, I will do what I can.

An interesting issue I came across - when referring to a sub-profile stereotype in an OCL expression such as "StereotypeX.allInstance()" the generator seems to fail when StereotypeX is in a different sub-profile than the Stereotype property which the OCL expression is applied to.

Should I make and post an example project or is this a limitation that is known or expected?

I also have PackageImport elements importing the necessary sub-profiles, still no luck.



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837560 is a reply to message #1837559] Tue, 02 February 2021 11:50 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

It seems it only works when you name sub-profile types with the full qualified names even though Papyrus is happy with the OCL expression after using package-import or element-imports, the Java generator is only happy when you give full qualified-names of Stereotype types that are in other sub-profiles.

Let me know if this is an expected limitation or if you would like an example project that demonstrates it.



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837562 is a reply to message #1837560] Tue, 02 February 2021 13:03 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Quite apart from allInstances being probably the worst way to solve a problem given that implicit opposites can nearly always do the same job with out a global model search ...

The boundary of the global model search for allInstances is undefined. In Eclipse OCL it should be the prevailing ResourceSet, but not all static entities are in a ResourceSet.

I'm not sure that UML's Package/ElementImports actually do anything for Eclipse OCL, since everything is always referenced in some other way already.

But as always, if you have a reasonable problem please attach it to a Bugzilla so that I can review.

Regards

Ed Willink
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837565 is a reply to message #1837562] Tue, 02 February 2021 13:38 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

When you implicit opposites do you mean for example the use of "extension_Requirement" in the following OCL expression:

DeriveReqt.allInstances()->select(base_Abstraction.supplier=self).base_Abstraction.client.extension_Requirement


Where DeriveReqt and Requirement are custom stereotypes from earlier examples I was discussing with you and Christian.
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837571 is a reply to message #1837565] Tue, 02 February 2021 14:34 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Yes and No. Given "base_Abstraction.supplier=self" the inverse of supplier should take you direct from self to the candidate instances. No need to search the world. NB All navigations have an opposite in OMG OCL and Pivot OCL. In some cases it is necessary to use the X[y] qualified form, but they are all there. Some of my QVTd tests need them.

Regards

Ed Willink
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837608 is a reply to message #1837516] Wed, 03 February 2021 06:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I have created Bugzillas from a number of your comments and I think these are all fixed (apart from UnlimitedNatural), but I'm far from clear which residual concern applies to which repro. I have gone back to ValidationProblem4 and that seems fine once I fixup the package 'names' to suit my test harness. Please raise a Bugzilla for each distinct concern. For similar problems I am now familiar with your project structure so do not need a full repro. The *.profile.uml and possibly the *.uml is all that I actually copy to my test harness.

Regards

Ed
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837626 is a reply to message #1837608] Wed, 03 February 2021 12:08 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Thank you Ed!

If ValidationProblem4.tar.gz works then all currently reported bugs regarding static profile generation should be covered.

There is a new and interesting case brewing, I will upload and describe after I verify it's not something I'm doing wrong. I think these will form good test cases like you said and anything else found should be minor things anyway.



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837634 is a reply to message #1837626] Wed, 03 February 2021 13:35 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

I created this new topic:
https://www.eclipse.org/forums/index.php/m/1837633/#msg_1837633



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837636 is a reply to message #1837634] Wed, 03 February 2021 14:01 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

I created another case:
https://www.eclipse.org/forums/index.php/m/1837635/#msg_1837635



Best regards,
Deniz
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837641 is a reply to message #1837636] Wed, 03 February 2021 14:35 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Please use Bugzilla. it provides sensible tracking and searching. Eclipse forums are fragile, links sometimes don't work a few years later, messages are sometimes not even sent. If you keep extending messages I get very confused by the number of issues and once I create the Bugzillas myself half the discussion in one place and half in another. GIT comments can sensibly be prefixed with [570809] but not [msg_1837634].

Currently I am aware that your recent messages have directly prompted a UnlimitedNatural conversion issue in https://bugs.eclipse.org/bugs/show_bug.cgi?id=570809 and indirectly an EChar wraparound issue in https://bugs.eclipse.org/bugs/show_bug.cgi?id=570800

Please raise Bugzilla for anything else.

Regards

Ed Willink
Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837667 is a reply to message #1837641] Wed, 03 February 2021 23:23 Go to previous messageGo to next message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

Apologies I didn't realise Bugzilla works better for Git, etc, noted.
I created the Bugzilla tickets:





Best regards,
Deniz

[Updated on: Wed, 03 February 2021 23:29]

Report message to a moderator

Re: Static profile OCL expressions referring to enumeration literals cause "contains a bad valu [message #1837677 is a reply to message #1837667] Thu, 04 February 2021 05:45 Go to previous message
Deniz Eren is currently offline Deniz ErenFriend
Messages: 68
Registered: March 2014
Member
Hi Ed,

I created another ticket, here is all the Bugzilla tickets created today:

Bug 570891 https://bugs.eclipse.org/bugs/show_bug.cgi?id=570891 [Work around possible: extend different types (bad hack but workaround)]
Bug 570892 https://bugs.eclipse.org/bugs/show_bug.cgi?id=570892 [Work around possible: use allInstances() instead of extension_*]
Bug 570894 https://bugs.eclipse.org/bugs/show_bug.cgi?id=570894 [NO workaround!]



Best regards,
Deniz

[Updated on: Thu, 04 February 2021 05:57]

Report message to a moderator

Previous Topic:Papyrus static profile Java does not detect stereotypes applied to imported package element
Next Topic:Trouble making conditional block
Goto Forum:
  


Current Time: Thu Apr 25 16:46:19 GMT 2024

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

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

Back to the top