Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Relation between model and meta-model.
[CDO] Relation between model and meta-model. [message #761323] Tue, 06 December 2011 09:41 Go to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
Hi,
Can CDO save relation between model and meta-model(Ecore) in repository?

Khosro.
Re: [CDO] Relation between model and meta-model. [message #761343 is a reply to message #761323] Tue, 06 December 2011 10:27 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 06.12.2011 10:41, schrieb Khosro Asgharifard Sharabiani:
> Hi,
> Can CDO save relation between model and meta-model(Ecore) in repository?
Yes, but it requires the used IStore to support external references. Compare
http://download.eclipse.org/modeling/emf/cdo/drops/I20111125-0410/help

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Relation between model and meta-model. [message #761488 is a reply to message #761343] Tue, 06 December 2011 14:43 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
Hi Eike,
Excuse me,i did not find any sample or any doc in http://download.eclipse.org/modeling/emf/cdo/drops/I20111125-0410/help.
Maybe i must dig into source code of CDO.

Khosro.
Re: [CDO] Relation between model and meta-model. [message #761617 is a reply to message #761488] Tue, 06 December 2011 18:49 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 06.12.2011 15:43, schrieb Khosro Asgharifard Sharabiani:
> Hi Eike,
> Excuse me,i did not find any sample or any doc in http://download.eclipse.org/modeling/emf/cdo/drops/I20111125-0410/help.
Because there are none. That's obviously a sore comparison table that tells you what stores support external references.

> Maybe i must dig into source code of CDO.
That's always a good idea. But if you tell me exactly what you want to achieve I may be able to help you.

What do you mean by "Relation between model and meta-model"?

What have you tried so far?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Relation between model and meta-model. [message #761809 is a reply to message #761617] Wed, 07 December 2011 05:00 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
>That's always a good idea. But if you tell me exactly what you want to achieve I may >be able to help you.
>What do you mean by "Relation between model and meta-model"?

Thanks Eike.
I have a Ecore Model that i have attached it to message(Ecore Diagrams.png).
For persisting model to repository i used the following code :
	   CDOTransaction transaction = cdoSession.openTransaction();
			CDOResource resource =         transaction.getOrCreateResource("/myResource");
			Library library = LibraryFactory.eINSTANCE.createLibrary();

			Book book = LibraryFactory.eINSTANCE.createBook();
			book.setTitle("Eclipse Modeling Framework (2nd edition)");
			library.getBooks().add(book);

			Writer writer = LibraryFactory.eINSTANCE.createWriter();
			writer.setName("Ed");
			book.setAuthor(writer);

			resource.getContents().add(library);
			transaction.commit();
			cdoSession.close();


and for persisting Ecore Model to repository i used the following code :
	 EPackage libraryPackage= LibraryPackage.eINSTANCE;
		 cdoSession.getPackageRegistry().putEPackage(libraryPackage);



I want to tell to CDO that these models(book,writer) that i have persisted are related to Ecore Model(LibraryPackage),i think we must use something like foreign key in model's table(There are Book and Write table in Repository.),but i do not know how to achieve this purpose.

I hope that i could explain my goal the best way.

Best Regards.

Khosro.





Re: [CDO] Relation between model and meta-model. [message #761844 is a reply to message #761809] Wed, 07 December 2011 06:54 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 07.12.2011 06:00, schrieb Khosro Asgharifard Sharabiani:
>> That's always a good idea. But if you tell me exactly what you want to achieve I may>be able to help you.
>> What do you mean by "Relation between model and meta-model"?
> Thanks Eike.
> I have a Ecore Model that i have attached it to message(Ecore Diagrams.png).
> For persisting model to repository i used the following code :
>
> CDOTransaction transaction = cdoSession.openTransaction();
> CDOResource resource = transaction.getOrCreateResource("/myResource");
> Library library = LibraryFactory.eINSTANCE.createLibrary();
>
> Book book = LibraryFactory.eINSTANCE.createBook();
> book.setTitle("Eclipse Modeling Framework (2nd edition)");
> library.getBooks().add(book);
>
> Writer writer = LibraryFactory.eINSTANCE.createWriter();
> writer.setName("Ed");
> book.setAuthor(writer);
>
> resource.getContents().add(library);
> transaction.commit();
> cdoSession.close();
That code looks perfect.

>
>
> and for persisting Ecore Model to repository i used the following code :
>
> EPackage libraryPackage= LibraryPackage.eINSTANCE;
> cdoSession.getPackageRegistry().putEPackage(libraryPackage);
This one is not needed if the LibraryPackage plugin is deployed to a running OSGi because the extension registry takes
care of the registration.

>
>
>
> I want to tell to CDO that these models(book,writer)
We use to call these "instances of model classes".

> that i have persisted are related to Ecore Model(LibraryPackage),
All instances are already "related" to their model, e.g.:

book.eClass() ==> LibraryPackage.Literals.BOOK

> i think we must use something like foreign key in model's table(There are Book and Write table in Repository.),but i do not know how to achieve this purpose.
>
> I hope that i could explain my goal the best way.
No, I still have no clue what you want to do, or why.Do you want to add EReferences of type EModelElement (or
descendent) to your own model classes?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Relation between model and meta-model. [message #761858 is a reply to message #761844] Wed, 07 December 2011 07:39 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
Eike,
I really thanks for your patience.
Excuse me.Because i am beginner in EMF and also in CDO,maybe because of that i can not express my goal the best way that i want.
Ok.
Let me to ask my question in another way,and excuse me for that ,i ask such newbie questions here,and also i have googled but not found any answer to my question,and also i have searched forum(Maybe my search keywords do not proper),and read docs in CDO website but not found any answer.

My question is as follow :

I have seen some tables in my repository(MySQL DB) like EPackage and EReference.
I thought that they are related to Ecore Model,and then i thought we can persist Ecore Model to repository.Am i right?
If yes,how we can persist Ecore Model to repository?
In past i thought the following code does persists Ecore Model to repository :
EPackage libraryPackage= LibraryPackage.eINSTANCE;
 cdoSession.getPackageRegistry().putEPackage(libraryPackage);

But it seems i was wrong.

If no,can we extend CDO for that purpose?

Best Regards.
Khosro.


Re: [CDO] Relation between model and meta-model. [message #761874 is a reply to message #761858] Wed, 07 December 2011 08:02 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
When i said Ecore Model ,i mean Ecore itself not model that is generated form *.ecore file.
When i look at *.ecore file there is "ecore:EPackage" element.And i thought we can persists Ecore to repository to "EPackage" table as i said in last message.

Khosro.
Re: [CDO] Relation between model and meta-model. [message #761877 is a reply to message #761858] Wed, 07 December 2011 08:11 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Okay, I start to understand ;-)

CDO is both a model (Resources and EObjects) and a meta model (EModelElements such as EPackages, EClasses, ...)
repository. On the server it maintains two different areas for these types. The meta model area (in the DBStore there
are tables cdo_package_units and cdo_packae_infos) is read-only once a package is *published* and can be referenced from
the model area (internally represented as "external references").

The tables you are referring to are normal model area tables that can be used to store instances of Ecore (i.e.,
EPackages or thelike) in a mutable and versioned manner, usually during software development phases. These tables are
optional and you can prevent them from being created by specifying this in the cdo-server.xml:

<repository name="repo1">
[...]
<property name="supportingEcore" value="false"/>

In CDO 4.1 we've made this the default.

Please note that you'll have to enable the legacy mode when trying to store instances of Ecore in a CDOResource:
http://wiki.eclipse.org/CDO_Legacy_Mode

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 07.12.2011 08:39, schrieb Khosro Asgharifard Sharabiani:
> Eike,
> I really thanks for your patience.
> Excuse me.Because i am beginner in EMF and also in CDO,maybe because of that i can not express my goal the best way
> that i want.
> Ok.
> Let me to ask my question in another way,and excuse me for that ,i ask such newbie questions here,and also i have
> googled but not found any answer to my question,and also i have searched forum(Maybe my search keywords do not
> proper),and read docs in CDO website but not found any answer.
>
> My question is as follow :
>
> I have seen some tables in my repository(MySQL DB) like EPackage and EReference.
> I thought that they are related to Ecore Model,and then i thought we can persist Ecore Model to repository.Am i right?
> If yes,how we can persist Ecore Model to repository?
> In past i thought the following code does persists Ecore Model to repository :
>
> EPackage libraryPackage= LibraryPackage.eINSTANCE;
> cdoSession.getPackageRegistry().putEPackage(libraryPackage);
>
> But it seems i was wrong.
>
> If no,can we extend CDO for that purpose?
>
> Best Regards.
> Khosro.
>
>
>


Re: [CDO] Relation between model and meta-model. [message #761906 is a reply to message #761877] Wed, 07 December 2011 09:08 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
OK,Thanks.
As you said ,i have enabled
<property name="supportingEcore" value="false"/>


for my purpose(Storing Ecore to repository).
How can i store instance of Ecore to DB?
I have used the following code :


		CDOTransaction transaction = cdoSession.openTransaction();
		CDOResource resource = transaction.getOrCreateResource("/res1");
		EPackage libraryPackage = LibraryPackage.eINSTANCE;
		cdoSession.getPackageRegistry().putEPackage(libraryPackage);
		CDOUtil.setLegacyModeDefault(true);
		resource.getContents().add(libraryPackage);
		try {
			transaction.commit();
		} catch (CommitException e) {
			e.printStackTrace();
		}
		cdoSession.close();



but i got "Legacy mode exception".

And also how can i relate instance of Ecore to model instances?Is my purpose clear?

Khosro.



Re: [CDO] Relation between model and meta-model. [message #761924 is a reply to message #761906] Wed, 07 December 2011 09:42 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 07.12.2011 10:08, schrieb Khosro Asgharifard Sharabiani:
> OK,Thanks.
> As you said ,i have enabled
> <property name="supportingEcore" value="false"/>
>
>
> for my purpose(Storing Ecore to repository).
> How can i store instance of Ecore to DB?
> I have used the following code :
>
>
>
> CDOTransaction transaction = cdoSession.openTransaction();
> CDOResource resource = transaction.getOrCreateResource("/res1");
> EPackage libraryPackage = LibraryPackage.eINSTANCE;
> cdoSession.getPackageRegistry().putEPackage(libraryPackage);
> CDOUtil.setLegacyModeDefault(true);
This must be called *before* you open the view/transaction, which must happen on the same htread.

We're working on a better mechanism for enabling the legacy mode:

318816: [Legacy] Legacy mode is unreliable in multi-threaded environments
https://bugs.eclipse.org/bugs/show_bug.cgi?id=318816

> resource.getContents().add(libraryPackage);
> try {
> transaction.commit();
> } catch (CommitException e) {
> e.printStackTrace();
> }
> cdoSession.close();
>
>
>
> but i got "Legacy mode exception".
>
> And also how can i relate instance of Ecore to model instances?Is my purpose clear?
You cannot create/store instances of EClasses that are not released in the immutable meta model area.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Relation between model and meta-model. [message #761932 is a reply to message #761924] Wed, 07 December 2011 10:03 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
Thanks Eike,
I really thanks for your help.

>You cannot create/store instances of EClasses that are not released in the immutable >meta model area.
I do not understand it.Would be please a bit more explanation about it.

I now can understand a bit more about CDO.
I took the following sentence form your last post.
>No, I still have no clue what you want to do, or why.Do you want to add EReferences >of type EModelElement (or
>descendent) to your own model classes?
I think,i want something like that as you said (add EReferences of type EModelElement to your own model classes).How can i achieve that?

Thanks for your patience.
Best Regards.

Khosro.

[Updated on: Wed, 07 December 2011 10:04]

Report message to a moderator

Re: [CDO] Relation between model and meta-model. [message #761946 is a reply to message #761932] Wed, 07 December 2011 10:30 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 07.12.2011 11:03, schrieb Khosro Asgharifard Sharabiani:
> Thanks Eike,
> I really thanks for your help.
>
>> You cannot create/store instances of EClasses that are not released in the immutable >meta model area.
> I do not understand it.Would be please a bit more explanation about it.
I explained the difference between the two areas in my other reply.

>
> I now can understand a bit more about CDO.
> I took the following sentence form your last post.
>> No, I still have no clue what you want to do, or why.Do you want to add EReferences >of type EModelElement (or
>> descendent) to your own model classes?
>
> I think,i want something like that as you said (add EReferences of type EModelElement to your own model classes).How
> can i achieve that?
In your model add a reference of type EAttribute to, e.g., the Library class. Regenerate your model, wipe the DB and
start the repo server. In a client you can then set the new reference to any attribute (instance) in your meta model,
e.g., LibraryPackage.Literals.WRITER_NAME or LibraryPackage.Literals.BOOK_PAGES.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Relation between model and meta-model. [message #762002 is a reply to message #761946] Wed, 07 December 2011 12:12 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
Thanks Eike,
I will try your solution about assign relation between model and meta-model.
But i have a another question about extending CDO.
I do not know whether the following question must be expressed in a separate message?
My question :
Suppose that i want to add some another column to some tables generated by CDO.
Must i extend DBStore or i must implement IStore?
In both cases how i can tell to CDO to use our implementation?

Khosro.
Re: [CDO] Relation between model and meta-model. [message #762082 is a reply to message #761946] Wed, 07 December 2011 14:19 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
>In your model add a reference of type EAttribute to, e.g., the Library class. >Regenerate your model, wipe the DB and
>start the repo server. In a client you can then set the new reference to any >attribute (instance) in your meta model,
>e.g., LibraryPackage.Literals.WRITER_NAME or LibraryPackage.Literals.BOOK_PAGES.

The following is my code :


CDOUtil.setLegacyModeDefault(true);
			CDOTransaction transaction = cdoSession.openTransaction();
			CDOResource resource = transaction.getOrCreateResource("/res3");
			
					
			Library library = LibraryFactory.eINSTANCE.createLibrary();
			library.setMetaModel(LibraryPackage.Literals.LIBRARY__NAME);

			Book book = LibraryFactory.eINSTANCE.createBook();
			book.setTitle("Eclipse Modeling Framework (2nd edition)");
			library.getBooks().add(book);

			resource.getContents().add(library);
			transaction.commit();
			cdoSession.close();


But it does not work.
Because the following exception throws :

Quote:

Caused by: java.io.NotSerializableException: org.eclipse.emf.ecore.impl.EAttribu
teImpl


And this exception is related to
library.setMetaModel(LibraryPackage.Literals.LIBRARY__NAME);

I have created a metaModel EAttribute in Library class and its EType is "EJavaObject [java.lang.Object]".

It seems i must extend EAttributeImpl and make it Serializable.But i do not know,whether it is possible in EMF?

Khosro.






Re: [CDO] Relation between model and meta-model. [message #762120 is a reply to message #762082] Wed, 07 December 2011 15:23 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
Khosro Asgharifard Sharabiani wrote on Wed, 07 December 2011 09:19
>In your model add a reference of type EAttribute to, e.g., the Library class. >Regenerate your model, wipe the DB and
>start the repo server. In a client you can then set the new reference to any >attribute (instance) in your meta model,
>e.g., LibraryPackage.Literals.WRITER_NAME or LibraryPackage.Literals.BOOK_PAGES.

The following is my code :


CDOUtil.setLegacyModeDefault(true);
			CDOTransaction transaction = cdoSession.openTransaction();
			CDOResource resource = transaction.getOrCreateResource("/res3");
			
					
			Library library = LibraryFactory.eINSTANCE.createLibrary();
			library.setMetaModel(LibraryPackage.Literals.LIBRARY__NAME);

			Book book = LibraryFactory.eINSTANCE.createBook();
			book.setTitle("Eclipse Modeling Framework (2nd edition)");
			library.getBooks().add(book);

			resource.getContents().add(library);
			transaction.commit();
			cdoSession.close();


But it does not work.
Because the following exception throws :

Quote:

Caused by: java.io.NotSerializableException: org.eclipse.emf.ecore.impl.EAttribu
teImpl


And this exception is related to
library.setMetaModel(LibraryPackage.Literals.LIBRARY__NAME);

I have created a metaModel EAttribute in Library class and its EType is "EJavaObject [java.lang.Object]".

It seems i must extend EAttributeImpl and make it Serializable.But i do not know,whether it is possible in EMF?

Khosro.








Give it up.I think this is not a solution.Because i do not know how to query the repository to take model of specific meta model.Because in the above code i do not save relation between meta model and model.

Any way. Eike,thanks for your help.

Re: [CDO] Relation between model and meta-model. [message #762162 is a reply to message #762002] Wed, 07 December 2011 16:23 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 07.12.2011 13:12, schrieb Khosro Asgharifard Sharabiani:
> Thanks Eike,
> I will try your solution about assign relation between model and meta-model.
> But i have a another question about extending CDO.
> I do not know whether the following question must be expressed in a separate message?
> My question :
> Suppose that i want to add some another column to some tables generated by CDO.
Who will use these columns? I mean, how are you planning to store data to, or load from these columns?

> Must i extend DBStore or i must implement IStore?
Both is possible. The latter is much more work, though.

> In both cases how i can tell to CDO to use our implementation?
The DBStore is registered through an extension point:

<extension
point="org.eclipse.emf.cdo.server.storeFactories">
<storeFactory
class="org.eclipse.emf.cdo.server.internal.db.DBStoreFactory"
storeType="db">
</storeFactory>
</extension>

You can create your own store implementation, a respective factory and register this factory in your plugin.xml.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Relation between model and meta-model. [message #762166 is a reply to message #762082] Wed, 07 December 2011 16:28 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 07.12.2011 15:19, schrieb Khosro Asgharifard Sharabiani:
>> In your model add a reference of type EAttribute to, e.g., the Library class. >Regenerate your model, wipe the DB and
>> start the repo server. In a client you can then set the new reference to any >attribute (instance) in your meta
>> model, e.g., LibraryPackage.Literals.WRITER_NAME or LibraryPackage.Literals.BOOK_PAGES.
>
> The following is my code :
>
>
> CDOUtil.setLegacyModeDefault(true);
> CDOTransaction transaction = cdoSession.openTransaction();
> CDOResource resource = transaction.getOrCreateResource("/res3");
>
>
> Library library = LibraryFactory.eINSTANCE.createLibrary();
> library.setMetaModel(LibraryPackage.Literals.LIBRARY__NAME);
>
> Book book = LibraryFactory.eINSTANCE.createBook();
> book.setTitle("Eclipse Modeling Framework (2nd edition)");
> library.getBooks().add(book);
>
> resource.getContents().add(library);
> transaction.commit();
> cdoSession.close();
>
>
> But it does not work.
> Because the following exception throws :
>
> Quote:
>> Caused by: java.io.NotSerializableException: org.eclipse.emf.ecore.impl.EAttribu
>> teImpl
Is the complete stack trace missing? That would certainly help me understand.

>
>
> And this exception is related to
> library.setMetaModel(LibraryPackage.Literals.LIBRARY__NAME);
>
> I have created a metaModel EAttribute in Library class and its EType is "EJavaObject [java.lang.Object]".
>
> It seems i must extend EAttributeImpl and make it Serializable.
Definitely not.

> But i do not know,whether it is possible in EMF?
CDO can not persist instances with attributes of type EJavaObject ;-(

If you submit a bugzilla we could try to add this functionality. But it would certainly involve some sort of text/blob
serialization.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Relation between model and meta-model. [message #762453 is a reply to message #762162] Thu, 08 December 2011 05:09 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
Am 07.12.2011 13:12, schrieb Khosro Asgharifard Sharabiani:
>> Thanks Eike,
>> I will try your solution about assign relation between model and meta-model.
>> But i have a another question about extending CDO.
>> I do not know whether the following question must be expressed in a separate >>message?
>> My question :
>> Suppose that i want to add some another column to some tables generated by CDO.
>Who will use these columns? I mean, how are you planning to store data to, or load >from these columns?
I want to store data into these columns.
Maybe this idea(create some another column to table) causes to make some architectural changes in CDO.Suppose that when a user want to store a model instance to DB ,he must say to CDO that this model instance is related to a EClass of meta model.For that purpose, i must to create a column in model instances(for example in Library table) that references to id of EClass table.
But it is a raw idea,and i must think about it more to make it mature.
The basic idea is that maybe in future i want to store some other data to some of tables in database and also query those column to get those data.


>> Must i extend DBStore or i must implement IStore?
>Both is possible. The latter is much more work, though.

>> In both cases how i can tell to CDO to use our implementation?
>The DBStore is registered through an extension point:

><extension
>point="org.eclipse.emf.cdo.server.storeFactories">
><storeFactory
>class="org.eclipse.emf.cdo.server.internal.db.DBStoreFactory"
>storeType="db">
></storeFactory>
></extension>

>You can create your own store implementation, a respective factory and register this >factory in your plugin.xml.

I must explore a bit more about it.


>Cheers
>/Eike

Khosro.
Re: [CDO] Relation between model and meta-model. [message #762457 is a reply to message #762166] Thu, 08 December 2011 05:26 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
>> The following is my code :
>>
>>
>>CDOUtil.setLegacyModeDefault(true);
>> CDOTransaction transaction = cdoSession.openTransaction();
>> CDOResource resource = transaction.getOrCreateResource("/res3");
>>
>>
>> Library library = LibraryFactory.eINSTANCE.createLibrary();
>> library.setMetaModel(LibraryPackage.Literals.LIBRARY__NAME);
>>
>> Book book = LibraryFactory.eINSTANCE.createBook();
>> book.setTitle("Eclipse Modeling Framework (2nd edition)");
>> library.getBooks().add(book);
>>
>> resource.getContents().add(library);
>> transaction.commit();
>> cdoSession.close();
>>
>>
>> But it does not work.
>> Because the following exception throws :
>>
>> Quote:
>>> Caused by: java.io.NotSerializableException: org.eclipse.emf.ecore.impl.EAttribu
>>> teImpl
>Is the complete stack trace missing? That would certainly help me understand.

The complete stack trace is :

Quote:


java.lang.RuntimeException: java.io.NotSerializableException: org.eclipse.emf.ec
ore.impl.EAttributeImpl
at org.eclipse.emf.ecore.impl.EFactoryImpl.convertToString(EFactoryImpl.java:67
Cool
at org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertEJavaObjectToString(Ecore
FactoryImpl.java:943)
at org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertToString(EcoreFactoryImpl
.java:215)
at org.eclipse.emf.ecore.util.EcoreUtil.convertToString(EcoreUtil.java:3294)
at org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl$24.convertToCDO(CDOTyp
eImpl.java:513)
at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertToCDO(CDOStoreImpl.jav
a:589)
at org.eclipse.emf.internal.cdo.CDOObjectImpl.instanceToRevisionFeature(CDOObje
ctImpl.java:1155)
at org.eclipse.emf.internal.cdo.CDOObjectImpl.cdoInternalPostAttach(CDOObjectIm
pl.java:335)
at org.eclipse.emf.internal.cdo.view.CDOStateMachine$AttachTransition.execute(C
DOStateMachine.java:644)
at org.eclipse.emf.internal.cdo.view.CDOStateMachine$AttachTransition.execute(C
DOStateMachine.java:1)
at org.eclipse.net4j.util.fsm.FiniteStateMachine.process(FiniteStateMachine.jav
a:162)
at org.eclipse.emf.internal.cdo.view.CDOStateMachine.attachObject(CDOStateMachi
ne.java:240)
at org.eclipse.emf.internal.cdo.view.CDOStateMachine.attachOrReattach(CDOStateM
achine.java:212)
at org.eclipse.emf.internal.cdo.view.CDOStateMachine.attach(CDOStateMachine.jav
a:193)
at org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl.attached(CDOResourceImpl.
java:1217)
at org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl.access$0(CDOResourceImpl.
java:1215)
at org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl$ContentsCDOList.inverseAd
d(CDOResourceImpl.java:1451)
at org.eclipse.emf.common.notify.impl.DelegatingNotifyingListImpl.addUnique(Del
egatingNotifyingListImpl.java:310)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
at test.TestCdoClient.popola(TestCdoClient.java:76)
at test.TestCdoClient.test(TestCdoClient.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.
java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.j
ava:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.ja
va:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.jav
a:20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunne
r.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.jav
a:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.jav
a:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28
)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestRef
erence.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:3
Cool
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.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.io.NotSerializableException: org.eclipse.emf.ecore.impl.EAttribu
teImpl
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
at org.eclipse.emf.ecore.impl.EFactoryImpl.convertToString(EFactoryImpl.java:67
3)
... 44 more





>If you submit a bugzilla we could try to add this functionality. But it would >certainly involve some sort of text/blob
>serialization.
OK.I will submit it.

>Cheers
>/Eike

Khosro.
Re: [CDO] Relation between model and meta-model. [message #762464 is a reply to message #762453] Thu, 08 December 2011 05:45 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 08.12.2011 06:09, schrieb Khosro Asgharifard Sharabiani:
> Am 07.12.2011 13:12, schrieb Khosro Asgharifard Sharabiani:
>>> Thanks Eike,
>>> I will try your solution about assign relation between model and meta-model.
>>> But i have a another question about extending CDO.
>>> I do not know whether the following question must be expressed in a separate >>message?
>>> My question :
>>> Suppose that i want to add some another column to some tables generated by CDO.
>> Who will use these columns? I mean, how are you planning to store data to, or load >from these columns?
> I want to store data into these columns.
> Maybe this idea(create some another column to table) causes to make some architectural changes in CDO.Suppose that
> when a user want to store a model instance to DB ,he must say to CDO that this model instance is related to a EClass
> of meta model.For that purpose, i must to create a column in model instances(for example in Library table) that
> references to id of EClass table.
> But it is a raw idea,and i must think about it more to make it mature.
> The basic idea is that maybe in future i want to store some other data to some of tables in database and also query
> those column to get those data.
In 8 years of CDO noone has ever asked to fiddle with the database directly. That should serve as an indication that you
may be on the wrong track. You should not care about IDs of EClasses or other things in the DB. If your Library needs
more data you should change the model of that class, regenerate and have CDO ceate the needed schema.

>
>
>>> Must i extend DBStore or i must implement IStore?
>> Both is possible. The latter is much more work, though.
>
>>> In both cases how i can tell to CDO to use our implementation?
>> The DBStore is registered through an extension point:
>
>> <extension
>> point="org.eclipse.emf.cdo.server.storeFactories">
>> <storeFactory
>> class="org.eclipse.emf.cdo.server.internal.db.DBStoreFactory"
>> storeType="db">
>> </storeFactory>
>> </extension>
>
>> You can create your own store implementation, a respective factory and register this >factory in your plugin.xml.
>
> I must explore a bit more about it.
First be very sure that there's no standard way for what you want to achieve.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Relation between model and meta-model. [message #762467 is a reply to message #762457] Thu, 08 December 2011 05:50 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 08.12.2011 06:26, schrieb Khosro Asgharifard Sharabiani:
>>> The following is my code :
>>>
>>>
>>> CDOUtil.setLegacyModeDefault(true);
>>> CDOTransaction transaction = cdoSession.openTransaction();
>>> CDOResource resource = transaction.getOrCreateResource("/res3");
>>>
>>>
>>> Library library = LibraryFactory.eINSTANCE.createLibrary();
>>> library.setMetaModel(LibraryPackage.Literals.LIBRARY__NAME);
>>>
>>> Book book = LibraryFactory.eINSTANCE.createBook();
>>> book.setTitle("Eclipse Modeling Framework (2nd edition)");
>>> library.getBooks().add(book);
>>>
>>> resource.getContents().add(library);
>>> transaction.commit();
>>> cdoSession.close();
>>>
>>>
>>> But it does not work.
>>> Because the following exception throws :
>>>
>>> Quote:
>>>> Caused by: java.io.NotSerializableException: org.eclipse.emf.ecore.impl.EAttribu
>>>> teImpl
>> Is the complete stack trace missing? That would certainly help me understand.
>
> The complete stack trace is :
A pity that the stack trace is in a format that I can't paste it to my console and click the links ;-(

It seems you EJavaObject does not implement Serializeable. Would saving the resource to an XMLResource work?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


>
> Quote:
>> java.lang.RuntimeException: java.io.NotSerializableException: org.eclipse.emf.ec
>> ore.impl.EAttributeImpl
>> at org.eclipse.emf.ecore.impl.EFactoryImpl.convertToString(EFactoryImpl.java:67
>> 8)
>> at org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertEJavaObjectToString(Ecore
>> FactoryImpl.java:943)
>> at org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertToString(EcoreFactoryImpl
>> .java:215)
>> at org.eclipse.emf.ecore.util.EcoreUtil.convertToString(EcoreUtil.java:3294)
>> at org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl$24.convertToCDO(CDOTyp
>> eImpl.java:513)
>> at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertToCDO(CDOStoreImpl.jav
>> a:589)
>> at org.eclipse.emf.internal.cdo.CDOObjectImpl.instanceToRevisionFeature(CDOObje
>> ctImpl.java:1155)
>> at org.eclipse.emf.internal.cdo.CDOObjectImpl.cdoInternalPostAttach(CDOObjectIm
>> pl.java:335)
>> at org.eclipse.emf.internal.cdo.view.CDOStateMachine$AttachTransition.execute(C
>> DOStateMachine.java:644)
>> at org.eclipse.emf.internal.cdo.view.CDOStateMachine$AttachTransition.execute(C
>> DOStateMachine.java:1)
>> at org.eclipse.net4j.util.fsm.FiniteStateMachine.process(FiniteStateMachine.jav
>> a:162)
>> at org.eclipse.emf.internal.cdo.view.CDOStateMachine.attachObject(CDOStateMachi
>> ne.java:240)
>> at org.eclipse.emf.internal.cdo.view.CDOStateMachine.attachOrReattach(CDOStateM
>> achine.java:212)
>> at org.eclipse.emf.internal.cdo.view.CDOStateMachine.attach(CDOStateMachine.jav
>> a:193)
>> at org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl.attached(CDOResourceImpl.
>> java:1217)
>> at org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl.access$0(CDOResourceImpl.
>> java:1215)
>> at org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl$ContentsCDOList.inverseAd
>> d(CDOResourceImpl.java:1451)
>> at org.eclipse.emf.common.notify.impl.DelegatingNotifyingListImpl.addUnique(Del
>> egatingNotifyingListImpl.java:310)
>> at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
>> at test.TestCdoClient.popola(TestCdoClient.java:76)
>> at test.TestCdoClient.test(TestCdoClient.java:51)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
>> )
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
>> .java:25)
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.
>> java:44)
>> at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.j
>> ava:15)
>> at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.ja
>> va:41)
>> at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.jav
>> a:20)
>> at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunne
>> r.java:79)
>> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.jav
>> a:71)
>> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.jav
>> a:49)
>> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
>> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
>> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
>> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
>> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
>> at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28
>> )
>> at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
>> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestRef
>> erence.java:50)
>> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:3
>> 8)
>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
>> nner.java:467)
>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
>> nner.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.io.NotSerializableException: org.eclipse.emf.ecore.impl.EAttribu
>> teImpl
>> at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
>> at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
>> at org.eclipse.emf.ecore.impl.EFactoryImpl.convertToString(EFactoryImpl.java:67
>> 3)
>> ... 44 more
>
>
>
>
>> If you submit a bugzilla we could try to add this functionality. But it would >certainly involve some sort of
>> text/blob serialization.
> OK.I will submit it.
>
>> Cheers
>> /Eike
>
> Khosro.
>


Re: [CDO] Relation between model and meta-model. [message #762514 is a reply to message #762467] Thu, 08 December 2011 08:24 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
>It seems you EJavaObject does not implement Serializeable. Would saving the resource to an XMLResource work?
Excuse me,i do not understand.You mean that i must save to XMLResource?I do not how to do that.EJavaObject is EType of my "metaModel1" EAttribute in my Library model.

Khosro.
Re: [CDO] Relation between model and meta-model. [message #762524 is a reply to message #762514] Thu, 08 December 2011 08:46 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 08.12.2011 09:24, schrieb Khosro Asgharifard Sharabiani:
>> It seems you EJavaObject does not implement Serializeable. Would saving the resource to an XMLResource work?
> Excuse me,i do not understand.You mean that i must save to XMLResource?
I'd like to see if your scenario works in "normal" EMF.

> I do not how to do that.EJavaObject is EType of my "metaModel1" EAttribute in my Library model.
That means that at runtime you can point to any Java object with this attribute. What is this particular Java object and
does its class implement java.io.Serializeable?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Relation between model and meta-model. [message #762568 is a reply to message #762524] Thu, 08 December 2011 10:11 Go to previous messageGo to next message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
>That means that at runtime you can point to any Java object with this attribute. What >is this particular Java object and
>does its class implement java.io.Serializeable?

This particular Java object is "LibraryPackage.Literals.LIBRARY__NAME".And it does not implement java.io.Serializeable.
I think a workaround is creating a EDataType and make it serializeable,and set EType of
"metaModel" attribute(it is EAttribute in my model) to created EDataType .

Re: [CDO] Relation between model and meta-model. [message #762580 is a reply to message #762568] Thu, 08 December 2011 10:35 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 08.12.2011 11:11, schrieb Khosro Asgharifard Sharabiani:
>> That means that at runtime you can point to any Java object with this attribute. What >is this particular Java object
>> and does its class implement java.io.Serializeable?
>
> This particular Java object is "LibraryPackage.Literals.LIBRARY__NAME".And it does not implement java.io.Serializeable.
> I think a workaround is creating a EDataType and make it serializeable,and set EType of "metaModel" attribute(it is
> EAttribute in my model) to created EDataType .
Sorry, I think you're completely misled. Why are you trying to store an EAttribute instance in an EAttribute? Didn't you
say you want to *point* to it? Pointing should be done through EReferences, not EAttributes.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Relation between model and meta-model. [message #762621 is a reply to message #762580] Thu, 08 December 2011 12:02 Go to previous message
Khosro Asgharifard Sharabiani is currently offline Khosro Asgharifard SharabianiFriend
Messages: 35
Registered: December 2011
Member
>Sorry, I think you're completely misled. Why are you trying to store an EAttribute >instance in an EAttribute? Didn't you
>say you want to *point* to it? Pointing should be done through EReferences, not >EAttributes.
oh, Rolling Eyes .Yes.I made a big mistake.You are right.Thanks for your help.

Khosro.
Previous Topic:Looking for org.eclipse.core.runtime_3.1.0.jar file
Next Topic:[Teneo] Do I understand OneToOne correctly?
Goto Forum:
  


Current Time: Fri Apr 26 22:50:07 GMT 2024

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

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

Back to the top