Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Re: [OCL-ECORE-JAVA] OCL Queries on Ecore model from Java code.
Re: [OCL-ECORE-JAVA] OCL Queries on Ecore model from Java code. [message #633890] Tue, 19 October 2010 16:53
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi Dave

> Regarding the use of the Interactive OCL Console, I've tested the
execution of several OCL queries and it obviously works.

Well, this is the MDT/OCL newsgroup so MDT/OCL seems to be working.

Your problems are with the EMF Query project; copying to EMFT newsgroup.

> Exception in thread "main" java.lang.ExceptionInInitializerError

often indicates a classpath/startup problem.

> Caused by: java.lang.NullPointerException
at
org.eclipse.emf.query.ocl.internal.OCLDebugOptions.<clinit>(OCLDebugOptions.java:29)

would occur if you are running standalone, since plugins are not
initialised.

Perhaps EMF Query does not support standalone operation.

Perhaps you would be alright if it weren't for yet another exception
that you haven't shown. What you show is what happens after a failure,
not what the first failure was.

You might try commenting out

OCLPlugin.catching(getClass(), "getOCLQueryRecord",
ex); //$NON-NLS-1$

in AbstractOCLCondition since that seems to be the only external
reference that causes OCLPlugin and OCLDebugOptions to be initialized.
It looks as if standalone initialization of some debug code is causing a
failure that then fails to be debugged successfully.

Regards

Ed Willink


On 19/10/2010 15:44, Dave wrote:
> Hi Edward,
>
> Thanks for your reply.
>
> I precise that NotInstalledPackage doesn't generalize
> InstalledPackage, so returning also that kind of elements is wrong.
>
> However, after several efforts, I've done a little progress. In fact,
> with the following statement
>
> IQueryResult res = QueryExecutor.execute(resource,
> "self.oclIsTypeOf(mancoosi::InstalledPackage)");
>
> it returns all the InstalledPackageImpl elements. Moreover, I can
> obtain NotInstalledPackage elements adding "Not" at the beginning of
> the previous statement.
> Unfortunately, I cannot manage more complex queries. For example,
> trying to obtain all the InstalledPackage elements having
> installedSize < 85, I've written the following line:
>
> IQueryResult res = QueryExecutor.execute(resource,
> " self.oclIsTypeOf(mancoosi::InstalledPackage).getInstalledSiz e() < 85");
>
> but the program throws the exception
>
> Exception in thread "main" java.lang.ExceptionInInitializerError
> at
> org.eclipse.emf.query.ocl.internal.OCLPlugin.catching(OCLPlu gin.java:480)
> at
> org.eclipse.emf.query.ocl.conditions.AbstractOCLCondition.ge tOCLQueryRecord(AbstractOCLCondition.java:366)
> at
> org.eclipse.emf.query.ocl.conditions.AbstractOCLCondition.is Satisfied(AbstractOCLCondition.java:289)
> at
> org.eclipse.emf.query.ocl.conditions.BooleanOCLCondition.isS atisfied(BooleanOCLCondition.java:230)
> at org.eclipse.emf.query.statements.WHERE.matches(WHERE.java:46 )
> at org.eclipse.emf.query.statements.SELECT.doResume(SELECT.java :131)
> at org.eclipse.emf.query.statements.SELECT.doExecute(SELECT.jav a:95)
> at
> org.eclipse.emf.query.internal.statements.QueryStatement.exe cute(QueryStatement.java:77)
> at org.eclipse.emf.query.statements.SELECT.execute(SELECT.java: 172)
> at
> mancoosi.failuresdetector.QueryExecutor.execute(QueryExecuto r.java:75)
> at
> mancoosi.failuresdetector.QueryExecutor.main(QueryExecutor.j ava:149)
> Caused by: java.lang.NullPointerException
> at
> org.eclipse.emf.query.ocl.internal.OCLDebugOptions.<clinit>(OCLDebugOptions.java:29)
> ... 11 more
>
> I've not so clear how to structure my queries...think that also the
> allInstances() operation seems to be not available...
>
> Regarding the use of the Interactive OCL Console, I've tested the
> execution of several OCL queries and it obviously works.
> For example, for obtaining the InstalledPackage(s) having
> installedSize < 85, it's sufficient to write the following OCL query:
>
> mancoosi::InstalledPackage.allInstances()->select(p | p.installedSize
> < 85)
>
> that is, among other things, what I would like to pass as query in my
> Java code...
>
> I hope you could help me. Thamks for your consideration.
>
> Dave.
Previous Topic:accessing ecore model content
Next Topic:[EMF Refactor] Reference searches
Goto Forum:
  


Current Time: Mon Dec 22 10:05:12 GMT 2014

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

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