Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF Query] Using EMF Query outside Eclipse (with OCL)
[EMF Query] Using EMF Query outside Eclipse (with OCL) [message #1368800] Tue, 20 May 2014 09:26 Go to next message
Bertrand Quenin is currently offline Bertrand Quenin
Messages: 70
Registered: July 2009
Member
Hi,

I'm using EMF Query and OCL conditions and it works fine except when I provide a malformed OCL expression.

Basically, when I provided a malformed OCL expression, the OCLPlugin is catching the error and tries to process it but since i'm outside the eclipse platform, it leads to the following NPE:

java.lang.ExceptionInInitializerError
	at org.eclipse.emf.query.ocl.internal.OCLPlugin.catching(OCLPlugin.java:480)
	at org.eclipse.emf.query.ocl.conditions.AbstractOCLCondition.getOCLQueryRecord(AbstractOCLCondition.java:366)
	at org.eclipse.emf.query.ocl.conditions.AbstractOCLCondition.isSatisfied(AbstractOCLCondition.java:289)
	at org.eclipse.emf.query.ocl.conditions.BooleanOCLCondition.isSatisfied(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.java:95)
	at org.eclipse.emf.query.internal.statements.QueryStatement.execute(QueryStatement.java:77)
	at org.eclipse.emf.query.statements.SELECT.execute(SELECT.java:172)
	at com.axway.mda.framework.ModelSingleton.freeQuery(ModelSingleton.java:412)
	at com.axway.mda.flowrepository.participant.ParticipantTest.testQuery(ParticipantTest.java:182)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NullPointerException
	at org.eclipse.emf.query.ocl.internal.OCLDebugOptions.<clinit>(OCLDebugOptions.java:29)
	... 36 more



After debugging, it seems that the OCLPlugin.getPlugin() returns null.

Is there a way to enable this plugin or maybe my analysis is wrong?

Regards,
BQ.

[Updated on: Tue, 20 May 2014 09:26]

Report message to a moderator

Re: [EMF Query] Using EMF Query outside Eclipse (with OCL) [message #1369188 is a reply to message #1368800] Tue, 20 May 2014 13:14 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. Damus
Messages: 809
Registered: July 2009
Senior Member
Hi, BQ,

If I recall correctly, this plug-in was not designed for use except in
the Eclipse Platform run-time, so I don't expect there's a work-around
for you. Perhaps EMF Query 2 (of which I know nothing) supports
stand-alone execution? Certainly OCL, itself, does and it could be
sufficient on its own for your querying needs.

Cheers,

Christian

On 2014-05-20 09:26:23 +0000, Bertrand Quenin said:

> Hi,
>
> I'm using EMF Query and OCL conditions and it works fine except when I
> provide a malformed OCL expression.
>
> Basically, when I provided a malformed OCL expression, the OCLPlugin is
> catching the error and tries to process it but since i'm outside the
> eclipse platform, it leads to the following NPE:
>
>
> java.lang.ExceptionInInitializerError
> at org.eclipse.emf.query.ocl.internal.OCLPlugin.catching(OCLPlugin.java:480)
> at
> org.eclipse.emf.query.ocl.conditions.AbstractOCLCondition.getOCLQueryRecord(AbstractOCLCondition.java:366)
>
> at
> org.eclipse.emf.query.ocl.conditions.AbstractOCLCondition.isSatisfied(AbstractOCLCondition.java:289)
>
> at
> org.eclipse.emf.query.ocl.conditions.BooleanOCLCondition.isSatisfied(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.java:95)
> at
> org.eclipse.emf.query.internal.statements.QueryStatement.execute(QueryStatement.java:77)
>
> at org.eclipse.emf.query.statements.SELECT.execute(SELECT.java:172)
> at com.axway.mda.framework.ModelSingleton.freeQuery(ModelSingleton.java:412)
> at
> com.axway.mda.flowrepository.participant.ParticipantTest.testQuery(ParticipantTest.java:182)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:483)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
>
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
>
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>
> at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
>
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
> at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>
> at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
>
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>
> Caused by: java.lang.NullPointerException
> at
> org.eclipse.emf.query.ocl.internal.OCLDebugOptions.<clinit>(OCLDebugOptions.java:29)
>
> ... 36 more
>
>
>
> After debugging, it seems that the OCLPlugin.getPlugin() returns null.
>
> Is there a way to enable this plugin or maybe my analysis is wrong?
>
> Regards,
> BQ.
Re: [EMF Query] Using EMF Query outside Eclipse (with OCL) [message #1369269 is a reply to message #1369188] Tue, 20 May 2014 13:55 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4110
Registered: July 2009
Senior Member
Hi

EMF has evolved so that EcorePlugin.ExtensionProcessor is now able to
start things up much better in a standalone environment.

This improves the capability of EMF-based appliocations tyo also run
standalone, burt as Christian syas, only if desifgned top do so.

Every OCL release occurs only after over a thousand tests have passed in
a standalone environment, so again as Christian says, try using just OCL.

Regards

Ed Willink


On 20/05/2014 14:14, Christian W. Damus wrote:
> Hi, BQ,
>
> If I recall correctly, this plug-in was not designed for use except in
> the Eclipse Platform run-time, so I don't expect there's a work-around
> for you. Perhaps EMF Query 2 (of which I know nothing) supports
> stand-alone execution? Certainly OCL, itself, does and it could be
> sufficient on its own for your querying needs.
>
> Cheers,
>
> Christian
>
> On 2014-05-20 09:26:23 +0000, Bertrand Quenin said:
>
>> Hi,
>>
>> I'm using EMF Query and OCL conditions and it works fine except when
>> I provide a malformed OCL expression.
>>
>> Basically, when I provided a malformed OCL expression, the OCLPlugin
>> is catching the error and tries to process it but since i'm outside
>> the eclipse platform, it leads to the following NPE:
>>
>>
>> java.lang.ExceptionInInitializerError
>> at
>> org.eclipse.emf.query.ocl.internal.OCLPlugin.catching(OCLPlugin.java:480)
>> at
>> org.eclipse.emf.query.ocl.conditions.AbstractOCLCondition.getOCLQueryRecord(AbstractOCLCondition.java:366)
>>
>> at
>> org.eclipse.emf.query.ocl.conditions.AbstractOCLCondition.isSatisfied(AbstractOCLCondition.java:289)
>>
>> at
>> org.eclipse.emf.query.ocl.conditions.BooleanOCLCondition.isSatisfied(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.java:95)
>> at
>> org.eclipse.emf.query.internal.statements.QueryStatement.execute(QueryStatement.java:77)
>>
>> at org.eclipse.emf.query.statements.SELECT.execute(SELECT.java:172)
>> at
>> com.axway.mda.framework.ModelSingleton.freeQuery(ModelSingleton.java:412)
>> at
>> com.axway.mda.flowrepository.participant.ParticipantTest.testQuery(ParticipantTest.java:182)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>
>> at java.lang.reflect.Method.invoke(Method.java:483)
>> at
>> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
>>
>> at
>> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>>
>> at
>> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
>>
>> at
>> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>>
>> at
>> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
>> at
>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
>>
>> at
>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>>
>> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
>> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
>> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
>> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
>> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
>> at
>> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>>
>> at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
>> at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>>
>> Caused by: java.lang.NullPointerException
>> at
>> org.eclipse.emf.query.ocl.internal.OCLDebugOptions.<clinit>(OCLDebugOptions.java:29)
>>
>> ... 36 more
>>
>>
>>
>> After debugging, it seems that the OCLPlugin.getPlugin() returns null.
>>
>> Is there a way to enable this plugin or maybe my analysis is wrong?
>>
>> Regards,
>> BQ.
>
>
Re: [EMF Query] Using EMF Query outside Eclipse (with OCL) [message #1369388 is a reply to message #1369269] Tue, 20 May 2014 15:06 Go to previous messageGo to next message
Bertrand Quenin is currently offline Bertrand Quenin
Messages: 70
Registered: July 2009
Member
Ok, Thanks for your feedback.

I'll try to use OCL only, do you have any idea how I could transpose the following code snippet (using EMF Query) to OCL only, I'm not sure how?

    def Set<EObject> boundQuery(EClass eClass, String oclQuery) {
        val query = oclQuery ?: '''self.oclIsKindOf(«eClass.name»)'''
        val condition = new BooleanOCLCondition<EClassifier, EClass, EObject>(ocl.environment, query, eClass)
        val statement = new SELECT(SELECT.UNBOUNDED, false, new FROM(resource.contents), new WHERE(condition))
        statement.execute.EObjects as Set<EObject>
    }

    def Set<EObject> freeQuery(String oclQuery) {
        log.info("freeQuery: oclQuery = [" + oclQuery + "]")
        val condition = new BooleanOCLCondition<EClassifier, EClass, EObject>(ocl.environment, oclQuery, null)
        val statement = new SELECT(SELECT.UNBOUNDED, false, new FROM(resource.contents), new WHERE(condition))
        statement.execute.EObjects as Set<EObject>
    }



Regards
Re: [EMF Query] Using EMF Query outside Eclipse (with OCL) [message #1369618 is a reply to message #1369388] Tue, 20 May 2014 17:17 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4110
Registered: July 2009
Senior Member
Hi

Not easily. With EMF Query you seem to get to use three languages at
once; Java+SQL+OCL; really confusing.

Try expressing your intent in clear logical words then you can transpose
to OCL.

Regards

Ed Willink


On 20/05/2014 16:06, Bertrand Quenin wrote:
> Ok, Thanks for your feedback.
>
> I'll try to use OCL only, do you have any idea how I could transpose
> the following code snippet (using EMF Query) to OCL only, I'm not sure
> how?
>
>
> def Set<EObject> boundQuery(EClass eClass, String oclQuery) {
> val query = oclQuery ?: '''self.oclIsKindOf(«eClass.name»)'''
> val condition = new BooleanOCLCondition<EClassifier, EClass,
> EObject>(ocl.environment, query, eClass)
> val statement = new SELECT(SELECT.UNBOUNDED, false, new
> FROM(resource.contents), new WHERE(condition))
> statement.execute.EObjects as Set<EObject>
> }
>
> def Set<EObject> freeQuery(String oclQuery) {
> log.info("freeQuery: oclQuery = [" + oclQuery + "]")
> val condition = new BooleanOCLCondition<EClassifier, EClass,
> EObject>(ocl.environment, oclQuery, null)
> val statement = new SELECT(SELECT.UNBOUNDED, false, new
> FROM(resource.contents), new WHERE(condition))
> statement.execute.EObjects as Set<EObject>
> }
>
>
>
> Regards
>
Previous Topic:[CDO/Hibernate]Import data from XMI files to an existing repository - Unresolved proxy
Next Topic:[EMF] Validation framework: constrain instances (instead of classes)
Goto Forum:
  


Current Time: Fri Oct 31 05:55:15 GMT 2014

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

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