EMF & OCL beginner question [message #523147] |
Thu, 25 March 2010 06:33  |
Eclipse User |
|
|
|
Hello,
i'm new to OCL. I have an simple question
for example: I have an EMF Model with
Shop
Owner
1. A shop has an owner.
so how can i select the owner via OCL?
2. Shop has an attribute numberOfWorkers
how can i asking how many workers there are?
Or is OCL to wrong method
Thanks for your help
|
|
|
|
Re: EMF & OCL beginner question [message #523408 is a reply to message #523147] |
Fri, 26 March 2010 06:48   |
Eclipse User |
|
|
|
Hi,
thanks for ur answer, ur suggestions are kinda like mine but i dont get it, it doesn't work.
I expected that OCl is kinda like SQL.
Why should I need a "where" clause if I only want a select an object.
I googled about OCl and EMF but I didn't see any simple tutorial how to get such simple thinks.
Anyways i tried ur suggestions and the owner, but there were no results
My ocl expression strings are:
for the numberOfWorkers: self.numberOfWorkers
for the owner: self.owner
code snippet for self.owner
EObject shop = getShop();
final OCL ocl = org.eclipse.ocl.ecore.OCL.newInstance();
BooleanOCLCondition<EClassifier, EClass, EObject> condition = null;
try {
condition = new BooleanOCLCondition<EClassifier, EClass, EObject>(ocl.getEnvironment(), "self.owner", null );
} catch( final ParserException ex ) {
log.error( "UNEXPECTED", ex );
}
final SELECT statement = new SELECT( SELECT.UNBOUNDED, false, new FROM( shop), new WHERE( condition ), new NullProgressMonitor() );
final IQueryResult results = statement.execute();
for( final EObject o : results.getEObjects() ) {
log.debug( o.getClass().getName() );
}
Why i dont get the reference (owner)?
Or should I ask in the EMF forum
[Updated on: Fri, 26 March 2010 08:20] by Moderator
|
|
|
Re: EMF & OCL beginner question [message #523669 is a reply to message #523408] |
Sun, 28 March 2010 09:31   |
Eclipse User |
|
|
|
Hi Thomas
The facilities you use are provided by the EMFT/Query framework which
adds value to the MDT/OCL project. You may get a better response from
the emft newsgroup. I have only used EMFq to check for compilation
dependencies.
I Googled too and found
http://help.eclipse.org/help32/topic/org.eclipse.emf.query.d oc/tutorials/oclQueryTutorial.html
Regards
Ed Willink
On 26/03/2010 10:48, Thomas wrote:
> Hi,
> thanks for ur answer, ur suggestions are kinda like mine but i dont get
> it, it doesn't work.
> I expected that OCl is kinda like SQL.
> Why should I need a "where" clause if I only want a select an object. I
> googled about OCl and EMF but I didn't see any simple tutorial how to
> get such simple thinks.
> Anyways i tried ur suggestions and the owner, but there were no results
> My ocl expression strings are:
> for the numberOfWorkers: self.numberOfWorkers
> for the owner: self.owner
>
> code snippet for numberOfWorkers
>
>
> EObject shop = getShop();
> final OCL ocl = org.eclipse.ocl.ecore.OCL.newInstance();
> BooleanOCLCondition<EClassifier, EClass, EObject> condition = null;
> try {
> condition = new BooleanOCLCondition<EClassifier, EClass,
> EObject>(ocl.getEnvironment(), "self.numberOfWorkers", null );
> } catch( final ParserException ex ) {
> log.error( "UNEXPECTED", ex );
> }
> final SELECT statement = new SELECT( SELECT.UNBOUNDED, false, new FROM(
> shop), new WHERE( condition ), new NullProgressMonitor() );
>
> final IQueryResult results = statement.execute();
> for( final EObject o : results.getEObjects() ) {
> log.debug( o.getClass().getName() ); }
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.05211 seconds