Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » CDO server and client usage
CDO server and client usage [message #426084] Tue, 16 December 2008 08:33 Go to next message
Toni is currently offline ToniFriend
Messages: 5
Registered: July 2009
Junior Member
Hi, I've to create a CDO server and store inside it metamodels ecore
compliant and models created starting from previous metamodels. I've
created using code and following examples on eclipse site a CDO server.
I've used the code below for launch it,and it seems run.

public class TestCdoServerOk {
private static final String DATABASE = "c:\\test\\cdotest";
public static void main(String[] args) throws Exception {
OMPlatform.INSTANCE.setDebugging(true);
OMPlatform.INSTANCE .addLogHandler(org.eclipse.net4j.util.om.log.PrintLogHandler .CONSOLE);
OMPlatform.INSTANCE .addTraceHandler(org.eclipse.net4j.util.om.trace.PrintTraceH andler.CONSOLE);

IManagedContainer container = ContainerUtil.createContainer();
Net4jUtil.prepareContainer(container);
TCPUtil.prepareContainer(container);
CDOServerUtil.prepareContainer(container);
LifecycleUtil.activate(container);

// prepare store parameters
IMappingStrategy strategy = CDODBUtil.createHorizontalMappingStrategy();

Map<String, String> mappingProps = new HashMap<String, String>();
mappingProps.put(MappingStrategy.PROP_TO_MANY_REFERENCE_MAPP ING,
"MODEL");
mappingProps.put(MappingStrategy.PROP_TO_ONE_REFERENCE_MAPPI NG,
"LIKE_ATTRIBUTES");
mappingProps.put(MappingStrategy.PROP_TO_MANY_REFERENCE_MAPP ING,
"ONE_TABLE_PER_REFERENCE");


strategy.setProperties(mappingProps);

IDBAdapter adapter = new EmbeddedDerbyAdapter();

DataSource dataSource = createEmbeddedDataSource(DATABASE);
// DataSource dataSource = createClientDataSource(DATABASE);
IDBConnectionProvider provider = DBUtil
.createConnectionProvider(dataSource);

// Create a DBStore
IDBStore store = CDODBUtil.createStore(strategy, adapter, provider);
strategy.setStore(store);

// Create a repository
Map<String, String> props = new HashMap<String, String>();
props.put(Props.PROP_SUPPORTING_AUDITS, "true");
props.put(Props.PROP_SUPPORTING_REVISION_DELTAS, "false");// true does
// not work
// for
// DBStore
props.put(Props.PROP_VERIFYING_REVISIONS, "false");
props.put(Props.PROP_CURRENT_LRU_CAPACITY, "10000");
props.put(Props.PROP_REVISED_LRU_CAPACITY, "10000");

//ITCPAcceptor tcpAcceptor =
TCPUtil.getAcceptor(container,"0.0.0.0:2036");

IRepository repository = CDOServerUtil.createRepository("repo1", store,
props);
CDOServerUtil.addRepository(container, repository);

container.getElement("org.eclipse.net4j.acceptors", "tcp", null);

}

After that I've try to crate a client that read from the filesystem an
*.ecore file and store it inside the database. I've used the following
code:

public class ClientCDO {
public static void main(String[] argj){
IManagedContainer container = ContainerUtil.createContainer();

IConnector connector;

Net4jUtil.prepareContainer(container);
CDOUtil.prepareContainer(container, true);
IAcceptor acceptor = null;
int kind =0;
if (kind == 0) {
TCPUtil.prepareContainer(container);

// Start the TCP transport
acceptor = TCPUtil.getAcceptor(container, "127.0.0.1:2036");


// Open a TCP connection
connector = TCPUtil.getConnector(container,"127.0.0.1:2036");

} else {

JVMUtil.prepareContainer(container);

// Start the JVM transport
acceptor = JVMUtil.getAcceptor(container, "default");

// Open a JVM connection
connector = JVMUtil.getConnector(container, "default");
}

// Create configuration
CDOSessionConfiguration configuration =
CDOUtil.createSessionConfiguration();
configuration.setConnector(connector);
configuration.setRepositoryName("repo1");

// Open session
CDOSession session = configuration.openSession();

session.getPackageRegistry().putEPackage(Model1Package.eINST ANCE);

// Open transaction
CDOTransaction transaction = session.openTransaction();
System.out.println("prima di creare la risorsa");
// Get or create resource
CDOResource resource =
transaction.createResource("c:/test/test.ecore");
System.out.println("risorsa creata");
// Work with the resource and commit the transaction
//EObject object = Model1Factory.eINSTANCE.createCompany();
//resource.getContents().add(object);
transaction.commit();
System.out.println("dopo commit");
// Cleanup
transaction.close();
session.close();
connector.disconnect();

}
}

When I run the client the following exception appears:
[ERROR] SQL Exception: Column 'PATH' cannot accept a NULL value.
org.eclipse.net4j.db.DBException: SQL Exception: Column 'PATH' cannot
accept a NULL value.
at
org.eclipse.emf.cdo.server.internal.db.ClassMapping.sqlUpdat e(ClassMapping.java:178)
at
org.eclipse.emf.cdo.server.internal.db.ClassMapping.writeAtt ributes(ClassMapping.java:494)
at
org.eclipse.emf.cdo.server.internal.db.ClassMapping.writeRev ision(ClassMapping.java:450)
at
org.eclipse.emf.cdo.server.internal.db.HorizontalClassMappin g.writeRevision(HorizontalClassMapping.java:37)
at
org.eclipse.emf.cdo.server.internal.db.DBStoreWriter.writeRe vision(DBStoreWriter.java:201)
at
org.eclipse.emf.cdo.internal.server.StoreAccessor.writeRevis ions(StoreAccessor.java:197)
at
org.eclipse.emf.cdo.internal.server.StoreAccessor.commit(Sto reAccessor.java:116)
at
org.eclipse.emf.cdo.server.internal.db.DBStoreWriter.commit( DBStoreWriter.java:52)
at
org.eclipse.emf.cdo.internal.server.Transaction.commit(Trans action.java:181)
at
org.eclipse.emf.cdo.internal.server.protocol.CommitTransacti onIndication.indicating(CommitTransactionIndication.java:109 )
at
org.eclipse.net4j.signal.IndicationWithResponse.execute(Indi cationWithResponse.java:46)
at org.eclipse.net4j.signal.Signal.runSync(Signal.java:143)
at org.eclipse.net4j.signal.Signal.run(Signal.java:124)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unkno wn Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: SQL Exception: Column 'PATH' cannot accept a NULL value.
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unkno wn Source)
at
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQL Exception(Unknown
Source)
at
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleExc eption(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(U nknown
Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(U nknown
Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(U nknown
Source)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(Unkn own Source)
at
org.eclipse.emf.cdo.server.internal.db.ClassMapping.sqlUpdat e(ClassMapping.java:174)
... 15 more

Can anybody help me? This is the way for store a model or metamodel
starting from a file or I'm totally wrong!?
Thanks for the support!
Toni
Re: CDO server and client usage [message #426090 is a reply to message #426084] Tue, 16 December 2008 09:43 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6483
Registered: July 2009
Senior Member
Toni,

Comments below...



Toni schrieb:
> Hi, I've to create a CDO server and store inside it metamodels ecore
> compliant and models created starting from previous metamodels. I've
> created using code and following examples on eclipse site a CDO
> server. I've used the code below for launch it,and it seems run.
>
> public class TestCdoServerOk {
> private static final String DATABASE = "c:\\test\\cdotest";
> public static void main(String[] args) throws Exception {
> OMPlatform.INSTANCE.setDebugging(true);
> OMPlatform.INSTANCE
> .addLogHandler(org.eclipse.net4j.util.om.log.PrintLogHandler .CONSOLE);
> OMPlatform.INSTANCE
> .addTraceHandler(org.eclipse.net4j.util.om.trace.PrintTraceH andler.CONSOLE);
>
Don't forget to disable console tracing in production. It consumes
between 30% and 50% of the overall load!

>
> IManagedContainer container = ContainerUtil.createContainer();
> Net4jUtil.prepareContainer(container);
> TCPUtil.prepareContainer(container);
> CDOServerUtil.prepareContainer(container);
> LifecycleUtil.activate(container);
>
> // prepare store parameters
> IMappingStrategy strategy =
> CDODBUtil.createHorizontalMappingStrategy();
>
> Map<String, String> mappingProps = new HashMap<String, String>();
> mappingProps.put(MappingStrategy.PROP_TO_MANY_REFERENCE_MAPP ING,
> "MODEL");
This is wrong, but overwritten two calls below.

> mappingProps.put(MappingStrategy.PROP_TO_ONE_REFERENCE_MAPPI NG,
> "LIKE_ATTRIBUTES");
> mappingProps.put(MappingStrategy.PROP_TO_MANY_REFERENCE_MAPP ING,
> "ONE_TABLE_PER_REFERENCE");
>
>
> strategy.setProperties(mappingProps);
>
> IDBAdapter adapter = new EmbeddedDerbyAdapter();
>
> DataSource dataSource = createEmbeddedDataSource(DATABASE);
> // DataSource dataSource = createClientDataSource(DATABASE);
> IDBConnectionProvider provider = DBUtil
> .createConnectionProvider(dataSource);
>
> // Create a DBStore
> IDBStore store = CDODBUtil.createStore(strategy, adapter,
> provider);
> strategy.setStore(store);
>
> // Create a repository
> Map<String, String> props = new HashMap<String, String>();
> props.put(Props.PROP_SUPPORTING_AUDITS, "true");
> props.put(Props.PROP_SUPPORTING_REVISION_DELTAS, "false");//
> true does
> //
> not work
> //
> for
> //
> DBStore
> props.put(Props.PROP_VERIFYING_REVISIONS, "false");
> props.put(Props.PROP_CURRENT_LRU_CAPACITY, "10000");
> props.put(Props.PROP_REVISED_LRU_CAPACITY, "10000");
>
> //ITCPAcceptor tcpAcceptor =
> TCPUtil.getAcceptor(container,"0.0.0.0:2036");
> IRepository repository =
> CDOServerUtil.createRepository("repo1", store,
> props);
> CDOServerUtil.addRepository(container, repository);
>
> container.getElement("org.eclipse.net4j.acceptors", "tcp", null);
>
> }
>
> After that I've try to crate a client that read from the filesystem an
> *.ecore file and store it inside the database. I've used the following
> code:
>
> public class ClientCDO {
> public static void main(String[] argj){
> IManagedContainer container = ContainerUtil.createContainer();
>
> IConnector connector;
>
> Net4jUtil.prepareContainer(container);
> CDOUtil.prepareContainer(container, true);
> IAcceptor acceptor = null;
> int kind =0;
> if (kind == 0) {
> TCPUtil.prepareContainer(container);
>
> // Start the TCP transport
> acceptor = TCPUtil.getAcceptor(container, "127.0.0.1:2036");
You should not start an TCP acceptor on the client!!

>
>
> // Open a TCP connection
> connector = TCPUtil.getConnector(container,"127.0.0.1:2036");
> } else {
>
> JVMUtil.prepareContainer(container);
>
> // Start the JVM transport
> acceptor = JVMUtil.getAcceptor(container, "default");
Here the acceptor would be ok, because client == server ;-)

>
> // Open a JVM connection
> connector = JVMUtil.getConnector(container, "default");
> }
>
> // Create configuration
> CDOSessionConfiguration configuration =
> CDOUtil.createSessionConfiguration();
> configuration.setConnector(connector);
> configuration.setRepositoryName("repo1");
>
> // Open session
> CDOSession session = configuration.openSession();
>
> session.getPackageRegistry().putEPackage(Model1Package.eINST ANCE);
>
> // Open transaction
> CDOTransaction transaction = session.openTransaction();
> System.out.println("prima di creare la risorsa");
> // Get or create resource
> CDOResource resource =
> transaction.createResource("c:/test/test.ecore");
This looks like a problem. The path of the *repository* resource should
not start with "c:". It should start with "/".
If you think we shold have better argument checking here, please file a
bugzilla and mention the CDO version you're using.

> System.out.println("risorsa creata");
> // Work with the resource and commit the transaction
> //EObject object = Model1Factory.eINSTANCE.createCompany();
> //resource.getContents().add(object);
> transaction.commit();
> System.out.println("dopo commit");
> // Cleanup
> transaction.close();
> session.close();
> connector.disconnect();
>
> }
> }
>
> When I run the client the following exception appears: [ERROR] SQL
> Exception: Column 'PATH' cannot accept a NULL value.
> org.eclipse.net4j.db.DBException: SQL Exception: Column 'PATH' cannot
> accept a NULL value.
> at
> org.eclipse.emf.cdo.server.internal.db.ClassMapping.sqlUpdat e(ClassMapping.java:178)
>
> at
> org.eclipse.emf.cdo.server.internal.db.ClassMapping.writeAtt ributes(ClassMapping.java:494)
>
> at
> org.eclipse.emf.cdo.server.internal.db.ClassMapping.writeRev ision(ClassMapping.java:450)
>
> at
> org.eclipse.emf.cdo.server.internal.db.HorizontalClassMappin g.writeRevision(HorizontalClassMapping.java:37)
>
> at
> org.eclipse.emf.cdo.server.internal.db.DBStoreWriter.writeRe vision(DBStoreWriter.java:201)
>
> at
> org.eclipse.emf.cdo.internal.server.StoreAccessor.writeRevis ions(StoreAccessor.java:197)
>
> at
> org.eclipse.emf.cdo.internal.server.StoreAccessor.commit(Sto reAccessor.java:116)
>
> at
> org.eclipse.emf.cdo.server.internal.db.DBStoreWriter.commit( DBStoreWriter.java:52)
>
> at
> org.eclipse.emf.cdo.internal.server.Transaction.commit(Trans action.java:181)
>
> at
> org.eclipse.emf.cdo.internal.server.protocol.CommitTransacti onIndication.indicating(CommitTransactionIndication.java:109 )
>
> at
> org.eclipse.net4j.signal.IndicationWithResponse.execute(Indi cationWithResponse.java:46)
>
> at org.eclipse.net4j.signal.Signal.runSync(Signal.java:143)
> at org.eclipse.net4j.signal.Signal.run(Signal.java:124)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unkno wn
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
> Caused by: SQL Exception: Column 'PATH' cannot accept a NULL value.
> at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unkno wn
> Source)
> at
> org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQL Exception(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.TransactionResourceImpl.handleExc eption(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.EmbedConnection.handleException(U nknown
> Source)
> at
> org.apache.derby.impl.jdbc.ConnectionChild.handleException(U nknown
> Source)
> at
> org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(U nknown
> Source)
> at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
> at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(Unkn own
> Source)
> at
> org.eclipse.emf.cdo.server.internal.db.ClassMapping.sqlUpdat e(ClassMapping.java:174)
>
> ... 15 more
>
> Can anybody help me? This is the way for store a model or metamodel
> starting from a file or I'm totally wrong!?
No, I would say your code basically looks fine.
Except that I can not see where objects are attached to the resource.
But CDO usually does not care where the objects come from that are
attached to a CDO resource.

Does fixing the resource path value, i.e. the
transaction.createResource(path) call, solve your problem?

Cheers
/Eike

----
http://thegordian.blogspot.com


> Thanks for the support!
> Toni
>


Re: CDO server and client usage [message #426093 is a reply to message #426090] Tue, 16 December 2008 10:06 Go to previous messageGo to next message
Toni is currently offline ToniFriend
Messages: 5
Registered: July 2009
Junior Member
A question that may be stupid.. ;) the path of the repository resource
refers to the path inside the repository that is inside the CDO server?
because I've understand that the path is the one that refers to a model
file into the filesystem and this file is "converted" in a CDOResource and
then I can put it insde the CDO server. If I'm wrong, which is the way for
load a *.ecore file and transform it into a CDOResource that I can Store
inside the repo Server?
thanks.
Re: CDO server and client usage [message #426095 is a reply to message #426093] Tue, 16 December 2008 10:16 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6483
Registered: July 2009
Senior Member
Toni schrieb:
> A question that may be stupid.. ;) the path of the repository resource
> refers to the path inside the repository that is inside the CDO server?
Yes.

> because I've understand that the path is the one that refers to a
> model file into the filesystem and this file is "converted" in a
> CDOResource and then I can put it insde the CDO server.
I'd prefer to avoid the term "resource conversion" because it's
technically not correct.
But from a users perspective it might make sense, Maybe that's why I
named this FAQ entry accordingly ;-)
http://wiki.eclipse.org/FAQ_for_CDO_and_Net4j#What.27s_the_b est_way_to_convert_an_XMIResource_to_a_CDOResource.3F

> If I'm wrong, which is the way for load a *.ecore file and transform
> it into a CDOResource that I can Store inside the repo Server?
> thanks.
As shown in the FAQ the steps are basically:
1) Load resource from file (not CDO related!)
2) Create a resource in a CDOTransaction
3) Move the contents from 1) to 2)
4) Commit the CDOTransaction

Does that help?

Cheers
/Eike

----
http://thegordian.blogspot.com


Re: CDO server and client usage [message #426104 is a reply to message #426095] Tue, 16 December 2008 13:35 Go to previous messageGo to next message
Toni is currently offline ToniFriend
Messages: 5
Registered: July 2009
Junior Member
I've try to insert a file inside the repository following the example but
I've this exception:
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
'http://www.eclipse.org/emf/2002/Ecore' not found.
(file:/C:/test/My.ecore, 3, 101)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe mandLoadException(ResourceSetImpl.java:315)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:274)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
at ClientCDO.main(ClientCDO.java:105)
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package
with uri 'http://www.eclipse.org/emf/2002/Ecore' not found.
(file:/C:/test/My.ecore, 3, 101)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X MLHandler.java:2576)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi x(XMLHandler.java:2407)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1285)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1454)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:83)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocume ntParser.emptyElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator. emptyElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$ContentDriver.scanRootElementHook(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$PrologDriver.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
... 2 more

I've see the graphical example for create a model using eclipse directly
and the guide (http://wiki.eclipse.org/Using_the_CDO_User_Interface) says
that the user have to commit some packages..I think one of these pack i
the ecore metamodel definition. Is right? Which are commands for perform
this operation with code?
Thanks
Re: CDO server and client usage [message #426115 is a reply to message #426104] Tue, 16 December 2008 17:54 Go to previous messageGo to next message
Victor Roldan Betancort is currently offline Victor Roldan BetancortFriend
Messages: 524
Registered: July 2009
Senior Member
Toni,

If understand you right, you want to commit an existing model persisted
in a file to CDO Repository. Am I right? We use to know that as "import"
a resource into CDO repository. Could you describe the steps you are
following? What is the "big picture" of what you want to achieve?

> I've try to insert a file inside the repository following the example
> but I've this exception:

Looking at the code you provided in your initial post, you did this:

CDOResource resource = transaction.createResource("c:/test/test.ecore");

CDOTransaction.createResource does not convert an existing XMIResource
into a CDOResource. It creates a new empty resource with the path you
provide. For instance, if you do the following:

CDOResource resource = transaction.createResource("/test/myResource");

You'll be creating a new CDOResource called "myResource" under a
CDOFolder called "test".

Furthermore, that "c:/test/test.ecore" you are trying to "convert" into
a CDOResource, looks like package definition (Ecore model instance). I
believe CDO isn't capable to store instances of the Ecore model. What
you could do is storing instances of your "test.ecore" model.

I'm not sure to be addressing you problem correctly. Does the above
description help you?

> I've see the graphical example for create a model using eclipse directly
> and the guide (http://wiki.eclipse.org/Using_the_CDO_User_Interface)
> says that the user have to commit some packages..I think one of these
> pack i the ecore metamodel definition. Is right? Which are commands for
> perform this operation with code?
> Thanks
>

If you want to register a new package, you can do that through
CDOPackageRegistry:

public EPackage putEPackage(EPackage ePackage) throws
IllegalArgumentException;

You can get it through

org.eclipse.emf.cdo.CDOSession.getPackageRegistry()

HTH,
VĂ­ctor.
Re: CDO server and client usage [message #426140 is a reply to message #426115] Wed, 17 December 2008 08:34 Go to previous messageGo to next message
Toni is currently offline ToniFriend
Messages: 5
Registered: July 2009
Junior Member
Hi, I've understand the usage of method createResource(" "), and I've
correct my code. Yes I want to insert into CDO repo a metamodel (or model
based on it) that is inside an xmi file. Following the graphical example
called "Using the CDO User Interface", there is a description of a package
registration. I think that my application crash because when I try to
insert my metamodel(ecore based)there isn't already the package
http://www.eclipse.org/emf/2002/Ecore and namespaces are not resolved.
I've try using the graphical tool to connect to the repository register
ecore pkg and insert my metamodel and it works, but I cannot insert the
ecore pack using code. I use the following code but nothing happend:
session.getPackageRegistry().putEPackage (EcorePackage.eINSTANCE);
When I browse the repo the isn't the ecore pkg inside.
What is the way for register packages?
Thanks.
Toni
Re: CDO server and client usage [message #426153 is a reply to message #426140] Wed, 17 December 2008 13:13 Go to previous messageGo to next message
Victor Roldan Betancort is currently offline Victor Roldan BetancortFriend
Messages: 524
Registered: July 2009
Senior Member
Toni,

> Hi, I've understand the usage of method createResource(" "), and I've
> correct my code. Yes I want to insert into CDO repo a metamodel (or
> model based on it) that is inside an xmi file. Following the graphical
> example called "Using the CDO User Interface", there is a description of
> a package registration. I think that my application crash because when I
> try to insert my metamodel(ecore based)there isn't already the package
> http://www.eclipse.org/emf/2002/Ecore and namespaces are not resolved.

Yes, for some reason, Ecore model isn't being created dynamically in CDO
Repository. According to Eike, it should work. I've submitted the
following bug:

Ecore model isn't being correctly dinamically registered into the backend
https://bugs.eclipse.org/bugs/show_bug.cgi?id=259090

> I've try using the graphical tool to connect to the repository register
> ecore pkg and insert my metamodel and it works, but I cannot insert the
> ecore pack using code.

I wonder how did you make it work! Going through the UI CDO Session
View, I can't :(

> I use the following code but nothing happend:
> session.getPackageRegistry().putEPackage (EcorePackage.eINSTANCE);
> When I browse the repo the isn't the ecore pkg inside.
> What is the way for register packages?

You were doing it the right way :) But don't forget to commit!

Feel free to give some feedback in the bug :)

Cheers,
Victor.
Re: CDO server and client usage [message #426155 is a reply to message #426153] Wed, 17 December 2008 13:45 Go to previous messageGo to next message
Toni is currently offline ToniFriend
Messages: 5
Registered: July 2009
Junior Member
Hi, I've register the ecore pack inside the repositoy but when I try to
create a new resource and a new root element, for example an EClass, I've
the following error:
Legacy system not available. Is it a problem?

I've others quation for you:

1. with the graphical tool I've register my metamodel using the command
"register workspace packages". After that I can create a new model
(resource) and commit the transaction. My question is: when I register my
package the repo is empty, without the Ecore metamodel pack, but my pack
is inserted anyway. There isn't any check? And if register only my pack
and close connection, when I access again the repo the pack is missing,
but if I create a resource and commit the pack remain registered. Wy?

2.after the registration of a custom pack what is the way for create
resource using the elements of the metamodel just registered? I other
words I want do with code what I do with the graphical tool.

Thanks for the support.
Re: CDO server and client usage [message #426159 is a reply to message #426155] Wed, 17 December 2008 14:02 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6483
Registered: July 2009
Senior Member
Toni, Vik,

In contrast to what' been said here before. It is not possible to
register the *global instance* of Ecore (EcorePackage.eINSTANCE) with a
CDOSession because the Ecore package itself has not been (and can not
be) generated for CDO. It would incur a circular dependency on plugin
level. Instead you must register a dynamic instance of the Ecore.ecore
file. Unfortunately Vik told me that CDO's support for this is currently
broken. He already filed a bugzilla.

I would like to support Ecore as a legacy model when it comes to:

247226: Transparently support legacy models
https://bugs.eclipse.org/bugs/show_bug.cgi?id=247226

But Ed told me that he's not going to support the needed EMF mechanisms
in Ecore due to performance concerns.

Cheers
/Eike

----
http://thegordian.blogspot.com



Toni schrieb:
> Hi, I've register the ecore pack inside the repositoy but when I try
> to create a new resource and a new root element, for example an
> EClass, I've the following error:
> Legacy system not available. Is it a problem?
>
> I've others quation for you:
>
> 1. with the graphical tool I've register my metamodel using the
> command "register workspace packages". After that I can create a new
> model (resource) and commit the transaction. My question is: when I
> register my package the repo is empty, without the Ecore metamodel
> pack, but my pack is inserted anyway. There isn't any check? And if
> register only my pack and close connection, when I access again the
> repo the pack is missing, but if I create a resource and commit the
> pack remain registered. Wy?
>
> 2.after the registration of a custom pack what is the way for create
> resource using the elements of the metamodel just registered? I other
> words I want do with code what I do with the graphical tool.
>
> Thanks for the support.
>
>
>


Previous Topic:.ecore file export as xmi file
Next Topic:[CDO] CDO View throws OutOfMemoryError
Goto Forum:
  


Current Time: Mon Feb 24 09:20:11 GMT 2020

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

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

Back to the top