Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » EMF Query/OCL beginner question
EMF Query/OCL beginner question [message #523753] Mon, 29 March 2010 08:03
Thomas is currently offline ThomasFriend
Messages: 11
Registered: March 2010
Junior Member
Hello
I'm new to OCL. I have some simple questions
I have an EMF model with shop and owner. The shop has a reference to the owner named "owner"
1. how can I get the owner object via OCL?I expected the OCL String would be "self.owner"
2. the shop has an attribute numberOfWorkers ("self.numberOfWorkers"?)
how can I get the attribute value?or the numberOfWorkers as an EAttribute. Is that even possible?

I tried it with the owner but the results were empty. Here is a code snippet
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() );                            
}

I looked into the eclipse emf ocl tutorial but it only handles query with conditions like self.owner = 'bob' if there are 2 owners
I thought OCL is similar to SQL but I don't get it if I only want simple querys

Thanks for your help

Previous Topic:[EEF] FIXME ERROR INVALID CASE problem
Next Topic:EMF Query/OCL beginner question
Goto Forum:
  


Current Time: Thu Apr 18 12:03:26 GMT 2024

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

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

Back to the top