Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » includesAll fails
includesAll fails [message #1771187] Tue, 22 August 2017 17:45 Go to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 90
Registered: March 2015
Member
I'm trying to fix models to fit to OCL constraints coming after creation but a constraint keep complaining when models look valid.

Here is the constraint :
context TransactionReport
inv cycle__5 :
self.card.transactions->includesAll(self.lines.transaction)


Here are the objects involved:
  <RandL:TransactionReport id="TransactionReport_109" lines="TransactionReportLine_103" card="CustomerCard_100"/>

  <RandL:CustomerCard id="CustomerCard_100" valid="false"  transactions="Transaction_112" Membership="Membership_99"/>

 <RandL:Earning id="Transaction_112" amount="0.9586428515996764" points="29" account="LoyaltyAccount_121" generatedBy="Service_124" card="CustomerCard_100"/>

Thus self.card.transactions = { Transaction_112 }

And

<RandL:TransactionReportLine id="TransactionReportLine_103" transaction="Transaction_112" report="TransactionReport_109"/>

Thus self.lines.transaction = { Transaction_112 }

When calling :
helper.setContext(ecClass); //ecClass is TransactionReport
query = helper.createQuery("self.card.transactions->asSet()->includesAll(self.lines.transaction)");
boolean valid = ocl.check(eo, query);


"eo" is an EObject with the following values :
(
- id : TransactionReport_109
- lines : {TransactionReportLine_103} 1 objets [TransactionReportLine]
- card : CustomerCard_100 (ID:id) [CustomerCard]
)

Why do I get a false return from the check ?
Is it possible that some conflicts in references definition makes it fail ?
(Like, if an other object TransactionReport has a transaction field filled with the same "Transaction_112")

Thanks for your help.
Edouard

[Edit: the complete XMI is attached]

[Updated on: Tue, 22 August 2017 17:57]

Report message to a moderator

Re: includesAll fails [message #1771188 is a reply to message #1771187] Tue, 22 August 2017 17:50 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
HI

If you want me to look at something, please post a project that I can work with, rather than snippets that I have to erroneously assemble.

Regards

Ed Willink
Re: includesAll fails [message #1771189 is a reply to message #1771188] Tue, 22 August 2017 17:53 Go to previous messageGo to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 90
Registered: March 2015
Member
That is why I attached the xmi.
I'll add the ecore too, and the ocl.
Thanks.
Re: includesAll fails [message #1771192 is a reply to message #1771189] Tue, 22 August 2017 18:20 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Sorry. Blind.
Re: includesAll fails [message #1771194 is a reply to message #1771192] Tue, 22 August 2017 19:19 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

I see much some minor problems

model_00303.xmi has no schemaLocation making it hard to use. Add xsi:schemaLocation="http://de.tuhh.sts.octopus/octopus2emfatic/2006/RandL RoyalAndLoyal.ecore"

model_00303.xmi has one EMF validation problem for a duplicate Date_113 id.

RoyalAndLoyal_noString+-+Copie.ocl has 4 null navigation hazards.

And one much more serious problem...

When I try to load the OCL document it takes ages and has many StackOverflow failures.

How are you observing what you comment on? What OCL / EMF versions are you using?

Regards

Ed Willink
Re: includesAll fails [message #1771197 is a reply to message #1771194] Tue, 22 August 2017 19:35 Go to previous messageGo to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 90
Registered: March 2015
Member
Thanks.

Added the schemaLocation with no improvements.
I've seen the Duplicate Date id, I've fixed it.
I don't know what the " StackOverflow failures" are, sorry, they don't show up.

I'm using the libs as depicted in attached images.

I am observing what I comment on with homemade tooling, attached is a screenshot of the output too.

I also observe the same behavior with other models (generated from the same tool).

  • Attachment: libs.JPG
    (Size: 57.24KB, Downloaded 73 times)
  • Attachment: libs2.JPG
    (Size: 24.58KB, Downloaded 64 times)
  • Attachment: screenshot_exedit.JPG
    (Size: 174.46KB, Downloaded 66 times)
Re: includesAll fails [message #1771198 is a reply to message #1771197] Tue, 22 August 2017 19:48 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

You appear to have a Neon installation with Neon Classic OCL, but Mars Pivot OCL and a really really vintage UML2. The UML2 mismatch will almost certainly cause trouble if using UML. The OCL mismatch is very unwise, but perhaps not the source of the problems. Mars OCL has no null navigation warnings.

Regards

Ed Willink
Re: includesAll fails [message #1771200 is a reply to message #1771198] Tue, 22 August 2017 20:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

The stack overflow seems tio be a nasty UI bug whereby a DND erroneously opens the editor and captures the drop target. Different issue.

Once loaded successfully I see one validation error, which the Validity View allows me to debug, clearly showing different Earning instances.

Unfortunately FUDforum (heap of ***) does not allow me to / I am too stupid to attach a screen shot. So no debugger screen shot. How did you attach your files? (I have no Browse button as described in the help.)

Regards

Ed Willink
Re: includesAll fails [message #1771290 is a reply to message #1771200] Wed, 23 August 2017 17:29 Go to previous messageGo to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 90
Registered: March 2015
Member
I will try to clean the libs, hopefully it will still work with more recent versions. Thanks for your insight.

Quote:
The stack overflow seems tio be a nasty UI bug whereby a DND erroneously opens the editor and captures the drop target. Different issue.

Oh ok, not sure I get it... but sounds like it doesn't concern me. Correct me if I'm wrong.

Quote:
Once loaded successfully I see one validation error, which the Validity View allows me to debug, clearly showing different Earning instances.

DIfferent Earning instances ? Yes, I would like to see what your debug screen shows !
I attached the files with the "Browse" button below this text pane... No rocket science (when available !).
You can also drop the picture on flickr (or the like) and paste here the link (but I'll understand it's a burden).

What do you use to debug ? I've opened first time the "Validity View" yesterday and I got lost. I'll try to find a tuto.

(Note also that the "Darkest Dark Theme" plugin does not fit with that perspective : dark blue on black is not legidible. FYI)

Thanks again.
Edouard
Re: includesAll fails [message #1771297 is a reply to message #1771290] Wed, 23 August 2017 18:17 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

The stackoverflow is a wierd one. Happens regularly in my development workspace but not when I run a nested Eclipse to debug it.

See "Debugging a Validation failure" in the "Debugger tutorial".

No "Browse" for me!

Regards

Ed
Re: includesAll fails [message #1771700 is a reply to message #1771297] Tue, 29 August 2017 16:07 Go to previous messageGo to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 90
Registered: March 2015
Member
I did run the Debugger.
What I can see, is that the "Transaction_112" doesn't appear in the "variables" of "CustomerCard_100" shown in the debug perspective.

I don't understand what is wrong. The XMI file is loaded via EMF plugins and Eclipse Ecore views successfully ; other rules (not less neither more complicated) are applied successfully too (in Eclipse debug and programmatic checking) ; but OCL fails on this constraint (when applied on other models: same issue).

Could the problem be the multi root-objects characteristic of the model ?
Re: includesAll fails [message #1771710 is a reply to message #1771700] Tue, 29 August 2017 18:57 Go to previous messageGo to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 90
Registered: March 2015
Member
More generally, it sounds like all
self.references->includesAll(self.indirections.reference2) (ex: self.levels->includesAll(self.memberships.currentLevel ) )
don't work.

Same with
self.indirects.reference->includes(self.reference)
( ex : self.programs.levels->includes(self.currentLevel) ) in the RandL example.

And also:
self.participants.cards.Membership->includes(self) (two indirections)


I am confused. Does anyone encounter the same kind of issue ? Is there a test suite on that matter ?
Could it be because the self is a root object and references point out to other root objects ?

Maybe an inconsistency in the EOpposite could generate this behavior ? (The XMI in the Notepad show filled up field but the Recursive Ecore model view don't...)

[Updated on: Tue, 29 August 2017 19:15]

Report message to a moderator

Re: includesAll fails [message #1771714 is a reply to message #1771710] Tue, 29 August 2017 19:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

Isolated snippets and doesn't work comments are very difficult to comment on. You need to provide a repro and a clear observation/expectation.

For the one repro you provided earlier, I investigated and the results was correct since your model content was perhaps not what you expected.

I suspect that you may be getting unhelpful 'help' from an implicit collect. Use the hover text over operators to see whether you expressions are what you expect.

[I have now discovered how to attach. Use Reply, rather than Post Quick Reply. What a confusing tool!]

Regards

Ed Willink
Re: includesAll fails [message #1771716 is a reply to message #1771714] Tue, 29 August 2017 19:52 Go to previous messageGo to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 90
Registered: March 2015
Member
Quote:
For the one repro you provided earlier, I investigated and the results was correct since your model content was perhaps not what you expected.

Quote:
Once loaded successfully I see one validation error, which the Validity View allows me to debug, clearly showing different Earning instances.


I still don't know what the "different Earning instances" means..
If the model is not what I expect, I gave here all the material I have : metamodel in Ecore, OCL rules, and specific model with the precise error showing up.

What I did next is to mention that this is not an isolated case and that I am concern about how EMF/OCL deals with references when there is more than one root object. Which might be caused by my mistake. The "earning instances" comment gave me some hope though.

Quote:
Use the hover text over operators to see whether you expressions are what you expect.
The hover I could get points out sometimes a "null" when the text behind (the actual file) shows a value (a id-reference).

If you have the screenshot of the debugger you mentionned, I'd appreciate seeing it.

Sorry if it is nebulous, I am stuck right now, any hint might help.

Thanks for your consideration,
Edouard
Re: includesAll fails [message #1771759 is a reply to message #1771716] Wed, 30 August 2017 08:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

Attached: the screenshots that I didn't know how to post earlier.

You can see that the two Earning instances are different: Transaction 112/113.

Regards

Ed Willink

index.php/fa/30538/0/

index.php/fa/30539/0/
  • Attachment: Batot1.png
    (Size: 64.74KB, Downloaded 187 times)
  • Attachment: Batot2.png
    (Size: 114.88KB, Downloaded 194 times)
Re: includesAll fails [message #1771762 is a reply to message #1771759] Wed, 30 August 2017 08:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

"Could it be because the self is a root object and references point out to other root objects ? "

I notice that $container is null in the debugger screenshot. There is a Container_RandL that is intended as the root.

Flat EMF models are often regarded as very poor practice, but it shouldn't make a functional difference. Possibly slower because of a single long list for linear searches.

Regards

Ed Willink
Re: includesAll fails [message #1771775 is a reply to message #1771762] Wed, 30 August 2017 10:14 Go to previous messageGo to next message
German Vega is currently offline German VegaFriend
Messages: 51
Registered: December 2015
Member
Hello

Edoaurd Batot wrote on Tue, 29 August 2017 16:07

I did run the Debugger.
What I can see, is that the "Transaction_112" doesn't appear in the "variables" of "CustomerCard_100" shown in the debug perspective.
I don't understand what is wrong.


I think you have a problem with your xmi file.

In the ecore metamodel you specified that CustomerCard.transactions is the opposite of Transaction.card

But if you look carefully at your xmi file you have (I kept only the relevant attributes) :

<RandL:CustomerCard id="CustomerCard_100" transactions="Transaction_112">
<RandL:CustomerCard id="CustomerCard_105" transactions="Transaction_112">

<RandL:Earning id="Transaction_112" card="CustomerCard_105">
<RandL:Earning id="Transaction_113" card="CustomerCard_100">

You can notice that for objects CustomerCard_100 and Transaction_113 the opposites do not match.

Because of this error, when the xmi file is loaded, and the Transaction_113 object is created in memory, setting its "card" attribute to reference the existing CustomerCard_100 object will also modify corresponding opposite attribute (transactions) in the CustomerCard object.

This is the reason why even if you specified <RandL:CustomerCard id="CustomerCard_100" transactions="Transaction_112"> in the xmi file, the corresponding object in memory (as shown in the debugger) is referencing Transaction_113 instead.

And you do not get what you would expect for self.card.transactions

I can not comment on the other errors

Hope it helps

German Vega
Re: includesAll fails [message #1771785 is a reply to message #1771775] Wed, 30 August 2017 11:30 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

I've raised https://bugs.eclipse.org/bugs/show_bug.cgi?id=521593 for the failure of the EMF XMI loader to detect the bad XMI. It's only an enhancement request and will probably be WONTFIX since the cost of detecting the bad XMI is hard to justify for legitimate XMI. The Bugzilla is therefore just there for searches to find.

Regards

Ed Willink
Re: includesAll fails [message #1771815 is a reply to message #1771785] Wed, 30 August 2017 20:18 Go to previous messageGo to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 90
Registered: March 2015
Member
Thank you very much.

It doesn't solve my problem, but it shone some precious light on the engineering happening behind the "Eclipse" tooling.
Detecting bad XMI is too broad to be the descrpton here. But focusing on detecting inconsistency in the EOpposites could be usefull because it is then hdden when manipulating the models. [edit: My bad, this is exactly what is on the bug report ! Good job :) ]

Thanks again !!

[Updated on: Wed, 30 August 2017 20:19]

Report message to a moderator

Re: includesAll fails [message #1771881 is a reply to message #1771815] Thu, 31 August 2017 15:20 Go to previous messageGo to next message
Edoaurd Batot is currently offline Edoaurd BatotFriend
Messages: 90
Registered: March 2015
Member
Oh, and thank you Ed, I didn't see the screenshots yesterday. Thanks a lot.

Quote:
Flat EMF models are often regarded as very poor practice, but it shouldn't make a functional difference. Possibly slower because of a single long list for linear searches.

This is interesting too: how much gets involved in the arbitrary and tacit constraint of a unique root container? I don't blame it, sometimes there are choices to be taken, but it this is an interesting one, conceptually as well as functionally.

To be continued :)
Re: includesAll fails [message #1771888 is a reply to message #1771881] Thu, 31 August 2017 16:15 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

EMF mostly uses EList so finding something often involves a list search.

Suppose you have a tree structured model. N ancestors, N siblings.

A local search will examine N siblings.
A scoped search will examine N siblings and their ancestors; N*N candidates.
A global search will examine everywhere; N*N*N.

Most searches are local/scoped often terminating prematurely with a local or near-local hit.

If you have the same information in a flat model, all searches are global; N*N*N possibilities. Typically half will be examined before a hit.

If the siblings are further classified by different roles, hierarchy gets even better.

In a sensible editor, a hierarchical presentation can be folded. Flat is just huge.

Regards

Ed Willink
Previous Topic:How to run OCL in Eclipse?
Next Topic:OCL constraints on dependency Metaclass and enumeration issues
Goto Forum:
  


Current Time: Fri Nov 16 01:10:12 GMT 2018

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

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

Back to the top