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