includesAll fails [message #1771187] |
Tue, 22 August 2017 13:45  |
Eclipse User |
|
|
|
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 13:57] by Moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: includesAll fails [message #1771716 is a reply to message #1771714] |
Tue, 29 August 2017 15:52   |
Eclipse User |
|
|
|
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 #1771888 is a reply to message #1771881] |
Thu, 31 August 2017 12:15  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.06668 seconds