Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Programmatically run OCL queries with multiple meta-models produces unknown type errors
Programmatically run OCL queries with multiple meta-models produces unknown type errors [message #1773787] Wed, 04 October 2017 15:52 Go to next message
Thibault beziers la fosse is currently offline Thibault beziers la fosseFriend
Messages: 10
Registered: February 2017
Junior Member
Hi,
I just started using OCL within Java and I'm encountering some issues.
I'm creating models using MoDisco, which conform to multiple meta-models (java, javaapplication, kdmSourceExtension, and kdm), and I'm trying to request those models for some specific data.

So, when I'm requesting the model conforming to the MoDisco java meta-model, things are working fine. But when requesting the JavaApplication one, where the elements inherit from the kdmSourceExtension one, it won't work, and I'm having exceptions during the parsing, such as:

org.eclipse.ocl.SemanticException: Unknown type (ASTNodeSourceRegion)

My Java code is the following:

ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
OCL_HELPER = ocl.createOCLHelper();
OCL_HELPER.setContext(JavaapplicationPackage.eINSTANCE.getEClassifier("Java2File"));
OCLExpression query = OCL_HELPER.createQuery("self.children -> collect(n : ASTNodeSourceRegion | n.node)");
Object o = ocl.evaluate(java2File, query);


What can I do to collect those nodes ? Here is a sample of the metamodel:
http://i68.tinypic.com/2e2duo8.png

An other example:
JavaNodeSourceRegion.allInstances() -> collect (node) ---> works 

ASTNodeSourceRegion.allInstances() -> collect (node) ---> Does not work
Despite the fact that JavaNodeSourceRegion inherits from ASTNodeSourceRegion.

Thank you, for any advice you could give me
Re: Programmatically run OCL queries with multiple meta-models produces unknown type errors [message #1773792 is a reply to message #1773787] Wed, 04 October 2017 16:22 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6038
Registered: July 2009
Senior Member
Hi

You'll probably need to provide a complete repro project since your snippets only reveal 10% of the opportunities for mistakes.

IIRC the old "OCL" requires you to specify a registry with the EPackages you use. I don''t see that.

(The new Pivot OCL will find them on the classpath.)

Regards

Ed Willink
Re: Programmatically run OCL queries with multiple meta-models produces unknown type errors [message #1773826 is a reply to message #1773792] Thu, 05 October 2017 07:41 Go to previous messageGo to next message
Thibault beziers la fosse is currently offline Thibault beziers la fosseFriend
Messages: 10
Registered: February 2017
Junior Member
Hi, thank you for your answer.

I'm running this inside a standalone maven project, using the OCL libraries available on mvnrepository (so, outside of Eclipse).

Quote:
the old "OCL" requires you to specify a registry with the EPackages you use. I don''t see that.


I probably have not did that. The only configuration I have written before evaluating my query on the Java2File object is the following:

JavaPackage.eINSTANCE.eClass();
JavaapplicationPackage.eINSTANCE.eClass();
ExtensionPackage.eINSTANCE.eClass();
KdmPackage.eINSTANCE.eClass();

Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());


How can I specify a registry with the ePackages I use, to OCL ?
If this does not help I'll provide some samples of my project.

Thank you


Re: Programmatically run OCL queries with multiple meta-models produces unknown type errors [message #1773836 is a reply to message #1773826] Thu, 05 October 2017 09:50 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6038
Registered: July 2009
Senior Member
See https://help.eclipse.org/neon/topic/org.eclipse.ocl.doc/help/ParsingDocuments.html
Previous Topic:OCL with a profile applied to itself
Next Topic:OCL generator and EMF super types
Goto Forum:
  


Current Time: Fri Sep 21 05:37:18 GMT 2018

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

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

Back to the top