Jump to: navigation, search

Difference between revisions of "FAQ for CDO and Net4j"

(CDO)
(CDO)
Line 23: Line 23:
 
There's a good example in [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java?root=Modeling_Project&view=co ImportResourceAction.doRun()]:
 
There's a good example in [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java?root=Modeling_Project&view=co ImportResourceAction.doRun()]:
  
<source type="Java">
+
<source lang="Java">
@Override
+
  @Override
 
   protected void doRun() throws Exception
 
   protected void doRun() throws Exception
 
   {
 
   {

Revision as of 03:04, 23 September 2008


General

How can I enable tracing?

If running as Eclipse launch config it's easy: just turn on tracing on the tracing page of the launch config (plus all net4j and cdo plugins in the list).

If running standalone:

    OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
    OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
    OMPlatform.INSTANCE.setDebugging(true);


CDO

What's the best way to convert an XMIResource to a CDOResource?

You just need to copy/move the root objects over to the CDOResource. There's a good example in ImportResourceAction.doRun():

  @Override
  protected void doRun() throws Exception
  {
    CDOTransaction transaction = getTransaction();
 
    // Source ResourceSet
    ResourceSet sourceSet = new ResourceSetImpl();
    Map<String, Object> map = sourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
    map.put("*", new XMIResourceFactoryImpl());
    sourceSet.setPackageRegistry(transaction.getSession().getPackageRegistry());
 
    // Source Resource
    Resource source = sourceSet.getResource(sourceURI, true);
    List<EObject> sourceContents = new ArrayList<EObject>(source.getContents());
 
    // Target Resource
    Resource target = transaction.createResource(targetPath);
    EList<EObject> targetContents = target.getContents();
 
    // Move contents over
    for (EObject root : sourceContents)
    {
      targetContents.add(root);
    }
  }



Net4j


Wikis: CDO | Net4j | EMF | Eclipse