Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Class.allInstances() does not work
Class.allInstances() does not work [message #824233] Mon, 19 March 2012 12:24 Go to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 529
Registered: June 2011
Senior Member
Hi,

I have created Ecore programmatically and i am trying to instantiate it programmatically as well. I am using OCLSettingDelegateFactory.Global() delegates. But OCL expression 'TestClass.allInstances()' does not give instances of Type TestClass, it is always empty, do you have any idea why it is like that?

Do i need to use extentMap? if yes then how to to integrate extentMap?

Note: every OCL statement works perfectly except allInstances() operation.


Regards,

[Updated on: Mon, 19 March 2012 16:48]

Report message to a moderator

Re: Class.allInstances() does not work [message #824464 is a reply to message #824233] Mon, 19 March 2012 17:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4150
Registered: July 2009
Senior Member
Hi

allInstances() operates in some finite scope; which is the ExtentMap
passed to the constructor of EvaluatiinVisitorImpl. Check whether wht
you expect is in that ExtentMap and that it has the correct EClass.

Regards

Ed Willink

On 19/03/2012 08:24, ModelGeek Mising name wrote:
> Hi,
>
> I have created Ecore programmatically and i am trying to instantiate
> it programmatically as well, but OCL expression
> 'TestClass.allInstances()' does not give instances of Type TestClass,
> it is always empty, do you have any idea why it is like that?
>
> Note: every OCL statement works perfectly except allInstances()
> operation.
>
>
> Regards,
>
>
Re: Class.allInstances() does not work [message #824560 is a reply to message #824464] Mon, 19 March 2012 20:28 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 529
Registered: June 2011
Senior Member
At what scope allInstances() works? I am using it in an attribute derivation statement
currently, i am evaluating using setting delegates, i am not using OCL facade.
Do i still need extent map?
As in documentation, example of OCL evaluation with OCL facade uses OCL.setExtentMap(map);

thanks for help.
Re: Class.allInstances() does not work [message #824584 is a reply to message #824560] Mon, 19 March 2012 21:04 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4150
Registered: July 2009
Senior Member
Hi

As I wrote before (with typos)

allInstances() operates in some finite scope; which is the ExtentMap
passed to the constructor of EvaluationVisitorImpl. Check whether what
you expect is in that ExtentMap and that it has the correct EClass.

So yes you need the ExtentMap to provide all possible instances of all
possible classes, where 'all possible' is bounded by what you consider
appropriate for your application.

You are using the OCL facade, or rather the OCLSettingDelegate is using
it for you. It should be creating a LazyExtentMap that will use all
EObjects within the Resource of the EObject for which you use an
OCLSettingDelegate.

Have you ensured that all your EObjects are contained by a Resource,
which is contained by a ResourceSet? Many things in EMF go wrong if
EObjects are not fully contained.

Regards

Ed Willink


On 19/03/2012 16:28, ModelGeek Mising name wrote:
> At what scope allInstances() works? I am using it in an attribute
> derivation statement
> currently, i am evaluating using setting delegates, i am not using OCL
> facade.
> Do i still need extent map? As in documentation, example of OCL
> evaluation with OCL facade uses OCL.setExtentMap(map);
> thanks for help.
Re: Class.allInstances() does not work [message #824932 is a reply to message #824584] Tue, 20 March 2012 08:55 Go to previous messageGo to next message
Axel Uhl is currently offline Axel UhlFriend
Messages: 40
Registered: July 2009
Member
You may also want to take a look at org.eclipse.ocl.examples.impactanalyzer.util.EcoreEnvironmentFactoryWithScopedExtentMap and the related OppositeEndFinder from the examples area. It may give you more fine-grained control of your scope definitions for the allInstances() operation.
Re: Class.allInstances() does not work [message #824955 is a reply to message #824932] Tue, 20 March 2012 09:33 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 529
Registered: June 2011
Senior Member
Hi,

EObjects were not contained by a Resource, now i update my code to have resource containing EObjects and it seems to work fine.

Actually i am also looking for minimum processing time as i have to make large number of instances for ecore and to save resource for each instance(xmi) of ecore to hard drive and to delete it afterwards will take processing time. Is there any way to do it without saving the resource?

Thanks for assistance!

Regards,

Re: Class.allInstances() does not work [message #824992 is a reply to message #824955] Tue, 20 March 2012 10:25 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 529
Registered: June 2011
Senior Member
Hi,

I have figured it out and it is working fine.

thanks for assitance!

regards
Re: Class.allInstances() does not work [message #825056 is a reply to message #824955] Tue, 20 March 2012 12:02 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4150
Registered: July 2009
Senior Member
Hi

I'm not sure I understand your comment; perhaps the subsequent message
supersedes it.

Putting all your EObjects in a Resource does not require you to actually
save the Resource to your hard drive.

Regards

Ed Willink

On 20/03/2012 05:33, ModelGeek Mising name wrote:
> Hi,
>
> EObjects were not contained by a Resource, now i update my code to
> have resource containing EObjects and it seems to work fine.
>
> Actually i am also looking for minimum processing time as i have to
> make large number of instances for ecore and to save resource for each
> instance(xmi) of ecore to hard drive and to delete it afterwards will
> take processing time. Is there any way to do it without saving the
> resource?
>
> Thanks for assistance!
>
> Regards,
>
>
Re: Class.allInstances() does not work [message #825113 is a reply to message #825056] Tue, 20 March 2012 13:40 Go to previous message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 529
Registered: June 2011
Senior Member
Yes thats what i figured out and it is working fine now.

Thanks!
Previous Topic:[Announce] Eclipse OCL Core 4.0.0 (Juno) M6 is now available
Next Topic:Method OCL.parse(OCLInput input) in pivot
Goto Forum:
  


Current Time: Sun Nov 23 12:39:49 GMT 2014

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

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