Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Generating .oclinecore file from Ecore programmatically
Generating .oclinecore file from Ecore programmatically [message #1015147] Wed, 27 February 2013 15:18 Go to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
Hi,

I am creating ecore at run time and i am able to save .ecore file successfully. I would like to generate .oclinecore file programmatically as well.

Once i have tried things like
OCLinEcoreDocumentCS document = Ecore2OCLinEcore.importFromEcore(resourceSet, "test", resource);

now i have updated all components in my eclipse so OCLinEcoreDocumentCS seems missing as well as Ecore2OCLinEcore.

i am trying to explore org.eclipse.ocl.examples.xtext.oclinecore.utilities.OCLinEcoreCSResource as well.

do you have any idea how i can generate .oclinecore programmatically?

thanks!

cheers
Re: Generating .oclinecore file from Ecore programmatically [message #1015171 is a reply to message #1015147] Wed, 27 February 2013 16:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You should be able to find all classes using the Type Hierarchy.

However the CST is not public API so it is likely to change.

If you really want to auto-generate, much better to auto-generate
- the AST, either Pivot or Ecore
- the text

and if you really want the CST you can use one of the concersion
routine. But if you really want the CST, I think you should revisit your
design.

Regards

Ed Willink


On 27/02/2013 15:19, ModelGeek Mising name wrote:
> Hi,
>
> I am creating ecore at run time and i am able to save .ecore file
> successfully. I would like to generate .oclinecore file
> programmatically as well.
>
> Once i have tried things like
> OCLinEcoreDocumentCS document =
> Ecore2OCLinEcore.importFromEcore(resourceSet, "test", resource);
>
> now i have updated all components in my eclipse so
> OCLinEcoreDocumentCS seems missing as well as Ecore2OCLinEcore.
>
> i am trying to explore
> org.eclipse.ocl.examples.xtext.oclinecore.utilities.OCLinEcoreCSResource
> as well.
>
> do you have any idea how i can generate .oclinecore programmatically?
>
> thanks!
>
> cheers
Re: Generating .oclinecore file from Ecore programmatically [message #1015178 is a reply to message #1015171] Wed, 27 February 2013 16:35 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
Sorry i did not understand you..

I just want to generate text from my ecore model. I think Pivot2CS class might be the one i am looking for.

I have tried following

OCLinEcoreStandaloneSetup.doSetup();
Injector injector =OCLinEcoreStandaloneSetup.getInjector();
ResourceSet csRS = injector.getInstance(ResourceSet.class);
Resource r = csRS.createResource(uri1.trimFileExtension().appendFileExtension("oclinecore"));

r.getContents().add(modelPackage);
r.save(null);

and i am getting following exception

java.lang.RuntimeException: The context 'RootPackageCS' is not valid for type 'EPackage'
Recommended contexts for type 'EPackage':
The context 'RootPackageCS' is valid for types: RootPackageCS

Semantic Object: EPackage'temp'
at org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:70)
at org.eclipse.ocl.examples.xtext.oclinecore.serializer.AbstractOCLinEcoreSemanticSequencer.createSequence(AbstractOCLinEcoreSemanticSequencer.java:672)

i hope i am not creating more confusion.

thanks!
Re: Generating .oclinecore file from Ecore programmatically [message #1015201 is a reply to message #1015178] Wed, 27 February 2013 17:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you want text then you need

EcoreXMI->EcoreAST->PivotAST->PivotCS->XtextNodes->text

for which the various converters and loaders are all available. Look at
the SerializeTests.

Regards

Ed Willink


On 27/02/2013 16:35, ModelGeek Mising name wrote:
> Sorry i did not understand you..
>
> I just want to generate text from my ecore model. I think Pivot2CS
> class might be the one i am looking for.
>
> I have tried following
>
> OCLinEcoreStandaloneSetup.doSetup();
> Injector injector
> =OCLinEcoreStandaloneSetup.getInjector();
> ResourceSet csRS =
> injector.getInstance(ResourceSet.class);
> Resource r =
> csRS.createResource(uri1.trimFileExtension().appendFileExtension("oclinecore"));
> r.getContents().add(modelPackage);
> r.save(null);
>
> and i am getting following exception
>
> java.lang.RuntimeException: The context 'RootPackageCS' is not valid
> for type 'EPackage'
> Recommended contexts for type 'EPackage': The context 'RootPackageCS'
> is valid for types: RootPackageCS
>
> Semantic Object: EPackage'temp'
> at
> org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:70)
> at
> org.eclipse.ocl.examples.xtext.oclinecore.serializer.AbstractOCLinEcoreSemanticSequencer.createSequence(AbstractOCLinEcoreSemanticSequencer.java:672)
>
> i hope i am not creating more confusion.
>
> thanks!
Re: Generating .oclinecore file from Ecore programmatically [message #1015313 is a reply to message #1015201] Thu, 28 February 2013 08:13 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
can you please guide me how to access serialization tests... URL? SVN?

thanks for help!

Cheers,
Re: Generating .oclinecore file from Ecore programmatically [message #1015322 is a reply to message #1015313] Thu, 28 February 2013 08:44 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

This information is all availabvle on the OCL project page:
http://projects.eclipse.org/projects/modeling.mdt.ocl

and in the Wiki.

The serialization tests are in the exaamples tests plugin.

Please use a little initiative.

Regards

Ed Willink


On 28/02/2013 08:13, ModelGeek Mising name wrote:
> can you please guide me how to access serialization tests... URL? SVN?
>
> thanks for help!
>
> Cheers,
Re: Generating .oclinecore file from Ecore programmatically [message #1015350 is a reply to message #1015322] Thu, 28 February 2013 10:08 Go to previous message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
thanks!
Previous Topic:OCLinEcore editor hungry? (eats characters)
Next Topic:Using drag'n'drop results in exception when loading CompleteOCL resource
Goto Forum:
  


Current Time: Thu Mar 28 17:34:03 GMT 2024

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

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

Back to the top