Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO]How the Ecore dynamic model with cdos, saved to the database, thank you????
[CDO]How the Ecore dynamic model with cdos, saved to the database, thank you???? [message #1154417] Fri, 25 October 2013 07:24 Go to next message
wang songbai is currently offline wang songbaiFriend
Messages: 27
Registered: October 2013
Junior Member
How the Ecore dynamic model with cdos, saved to the database, thank you????

// Create the Workflow Package
EPackage workflowPackage = EcoreFactory.eINSTANCE.createEPackage();
//create the Port class
EClass portClass = EcoreFactory.eINSTANCE.createEClass();
portClass.setName("Port");
EClass inputPortClass = EcoreFactory.eINSTANCE.createEClass();
inputPortClass.setName("InputPort");
//set up inheritance
inputPortClass.getESuperTypes().add(portClass);
//create the Task class
EClass taskClass = EcoreFactory.eINSTANCE.createEClass();
taskClass.setName("Task");

// add name attribute to Task
EAttribute taskNameAttr = EcoreFactory.eINSTANCE.createEAttribute();
taskNameAttr.setName("name");
taskNameAttr.setEType(EcorePackage.eINSTANCE.getEString());
taskClass.getEAttributes().add(taskNameAttr);
// set up the reference between Task and InputPort
EReference taskToInputPortRef = EcoreFactory.eINSTANCE.createEReference();
taskToInputPortRef.setUpperBound(-1);
taskToInputPortRef.setLowerBound(1);
taskToInputPortRef.setEType(inputPortClass);
taskClass.getEReferences().add(taskToInputPortRef);
// add the classes to the package
workflowPackage.getEClassifiers().add(taskClass);
workflowPackage.getEClassifiers().add(portClass);
workflowPackage.getEClassifiers().add(inputPortClass);

EFactory wfFactory = workflowPackage.getEFactoryInstance();
final EObject task1 = wfFactory.create(taskClass);
task1.eSet(taskNameAttr, "Task1");
Re: [CDO]How the Ecore dynamic model with=?UTF-8?B?IGNkb3MsIHNhdmVkIHRvIHRoZSBkYXRhYmFzZSwgdGhhbmsge [message #1154434 is a reply to message #1154417] Fri, 25 October 2013 07:32 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
With cdoSession.getPackageRegistry().putEPackage(workflowPackage);

Cheers
/Eike

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


Re: [CDO]How the Ecore dynamic model with=?UTF-8?B?IGNkb3MsIHNhdmVkIHRvIHRoZSBkYXRhYmFzZSwgdGhhbmsge [message #1154480 is a reply to message #1154434] Fri, 25 October 2013 08:15 Go to previous messageGo to next message
wang songbai is currently offline wang songbaiFriend
Messages: 27
Registered: October 2013
Junior Member
final CDOSession session = openSession();
final CDOTransaction transaction = session.openTransaction();
// get/create a resource
//CDOResource resource = transaction.getOrCreateResource("/res2"); //$NON-NLS-1$

session.getPackageRegistry().putEPackage(workflowPackage);


// clear any previous data
//resource.getContents().clear();
//resource.getContents().add(task1);

transaction.commit();



ECORE dynamic model not persisted to the database,What reason be? thank you!!!
Re: [CDO]How the Ecore dynamic model with [message #1154516 is a reply to message #1154480] Fri, 25 October 2013 08:48 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 25.10.2013 10:15, schrieb wang songbai:
> final CDOSession session = openSession();
> final CDOTransaction transaction = session.openTransaction();
> // get/create a resource
> //CDOResource resource = transaction.getOrCreateResource("/res2"); //$NON-NLS-1$
> session.getPackageRegistry().putEPackage(workflowPackage);
>
>
> // clear any previous data
> //resource.getContents().clear();
> //resource.getContents().add(task1);
>
> transaction.commit();
>
>
>
> ECORE dynamic model not persisted to the database,What reason be? thank you!!!
What store are you using?

Cheers
/Eike

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


Previous Topic:[CDO]I need a CDO detailed tutorial, who can help me. thank you!!!
Next Topic:org.eclipse.emf.databinding problem
Goto Forum:
  


Current Time: Fri Apr 19 14:45:21 GMT 2024

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

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

Back to the top