Class CDOMigrator


  • public class CDOMigrator
    extends Object
    Migrator to migrate a model from a previous to the current release.
    Author:
    Christophe Bouhier
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static org.eclipse.emf.common.util.URI cdoCanonicalURI​(org.eclipse.emf.common.util.URI sourceURI, String repo)
      Converts a 'regular' resource URI to a CDO Resource URI.
      static org.eclipse.emf.common.util.URI cdoConnectionAwareURI​(String host, String port, String repo, String resourceName)
      Get a connection aware URI for specified arguments.
      static org.eclipse.emf.common.util.URI cdoConnectionAwareURI​(org.eclipse.emf.common.util.URI canonicalURI, String authority)
      Get a connection aware URI for original canonical URI and specified arguments.
      static org.eclipse.emf.common.util.URI cdoConnectionAwareURI​(org.eclipse.emf.common.util.URI sourceURI, String host, String port, String repo)
      Converts a 'regular' resource URI to a CDO Resource URI.
      static org.eclipse.emf.common.util.URI cdoConnectionAwareURI​(org.eclipse.emf.common.util.URI canonicalURI, org.eclipse.emf.cdo.util.CDOURIData data)
      Get a connection aware URI for original canonical URI and specified source CDOURIData.
      static org.eclipse.emf.cdo.eresource.CDOResource cdoCreateResource​(org.eclipse.emf.ecore.resource.ResourceSet set, org.eclipse.emf.common.util.URI cdoResourceURI, Metamodel mmmeta)
      Create a CDOResource from a URI the MMMeta will be used to register the corresponding EPackage by the CDOViewProvider.
      static void clear​(List<org.eclipse.emf.common.util.URI> cdoSourceURIs, ResourceSetFactoryImpl resourceSetFactoryImpl)
      Clear a CDOResource from the CDO Repository.
      void clearCDORepositories​(String host, String port, String repo)
      clear the specified CDO Repository.
      static List<org.eclipse.emf.common.util.URI> collectConnectionAwareURIs​(org.eclipse.emf.cdo.util.CDOURIData data, List<org.eclipse.emf.cdo.eresource.CDOResource> cdoResCollection, org.eclipse.emf.cdo.eresource.CDOResourceNode node)
      Converts regular CDOResource URI's to connection aware URI's.
      static void collectResources​(List<org.eclipse.emf.cdo.eresource.CDOResource> cdoResCollection, org.eclipse.emf.cdo.eresource.CDOResourceNode node)
      Collect all CDOResource for a root resource.
      static boolean commitTransaction​(org.eclipse.emf.cdo.transaction.CDOTransaction t)
      Commit a CDO Transaction.
      static void copy​(Metamodel metamodel, org.eclipse.emf.ecore.resource.ResourceSet sourceModels, List<org.eclipse.emf.common.util.URI> cdoURIs, IResourceSetFactory resourceSetFactory)
      Construct CDO URI from a given source models, create target models and copy the source content to the target content.
      EdaptCDOViewProvider getEdaptCDOViewProvider()
      Get the CDOViewProvider.
      Metamodel getMetamodel​(Release release)
      Returns the metamodel for a release.
      Set<String> getNsURIs()
      Get set of namespace URIs.
      Release getRelease​(int number)
      Get the release with a certain number.
      Set<Release> getRelease​(org.eclipse.emf.cdo.eresource.CDOResource resource)  
      Set<Release> getRelease​(org.eclipse.emf.common.util.URI modelURI)
      Get the release of a model based on URI.
      List<Release> getReleases()
      Get all releases.
      IResourceSetFactory getResourceSetFactory()
      Get the factory to create ResourceSets for custom serialization.
      static org.eclipse.emf.ecore.EPackage loadEPackageFromEcore​(org.eclipse.emf.common.util.URI expectedTargetMetamodelURI)  
      static void main​(String[] args)
      Main method to perform migrations.
      void migrateAndCopy​(List<org.eclipse.emf.common.util.URI> modelURIs, Release sourceRelease, Release targetRelease, org.eclipse.core.runtime.IProgressMonitor monitor, List<org.eclipse.emf.common.util.URI> list)  
      void migrateAndCopy​(org.eclipse.emf.cdo.util.CDOURIData sourceURIData, org.eclipse.emf.cdo.util.CDOURIData targetURIData, org.eclipse.core.runtime.IProgressMonitor monitor)  
      org.eclipse.emf.ecore.resource.ResourceSet migrateAndLoad​(List<org.eclipse.emf.common.util.URI> modelURIs, Release sourceRelease, Release targetRelease, org.eclipse.core.runtime.IProgressMonitor monitor)
      Migrate a model based on a set of URIs and load it afterwards.
      void setLevel​(ValidationLevel level)
      Set the validation level.
      void setResourceSetFactory​(IResourceSetFactory resourceSetFactory)
      Set the factory to create ResourceSets for custom serialization.
    • Method Detail

      • getEdaptCDOViewProvider

        public EdaptCDOViewProvider getEdaptCDOViewProvider()
        Get the CDOViewProvider.
        Returns:
        the view provider
      • migrateAndCopy

        public void migrateAndCopy​(org.eclipse.emf.cdo.util.CDOURIData sourceURIData,
                                   org.eclipse.emf.cdo.util.CDOURIData targetURIData,
                                   org.eclipse.core.runtime.IProgressMonitor monitor)
                            throws MigrationException
        Parameters:
        sourceURIData - the source uri data
        targetURIData - the target uri data
        monitor - the progress monitor
        Throws:
        MigrationException
      • migrateAndCopy

        public void migrateAndCopy​(List<org.eclipse.emf.common.util.URI> modelURIs,
                                   Release sourceRelease,
                                   Release targetRelease,
                                   org.eclipse.core.runtime.IProgressMonitor monitor,
                                   List<org.eclipse.emf.common.util.URI> list)
                            throws MigrationException
        Throws:
        MigrationException
      • migrateAndLoad

        public org.eclipse.emf.ecore.resource.ResourceSet migrateAndLoad​(List<org.eclipse.emf.common.util.URI> modelURIs,
                                                                         Release sourceRelease,
                                                                         Release targetRelease,
                                                                         org.eclipse.core.runtime.IProgressMonitor monitor)
                                                                  throws MigrationException
        Migrate a model based on a set of URIs and load it afterwards.
        Parameters:
        modelURIs - The set of URI
        sourceRelease - Release to which the model conforms
        targetRelease - Release to which the model should be migrated (use null for the newest release)
        monitor - Progress monitor
        Returns:
        The model in a ResourceSet
        Throws:
        MigrationException
      • getRelease

        public Set<Release> getRelease​(org.eclipse.emf.common.util.URI modelURI)
        Get the release of a model based on URI.
      • getRelease

        public Set<Release> getRelease​(org.eclipse.emf.cdo.eresource.CDOResource resource)
      • getRelease

        public Release getRelease​(int number)
        Get the release with a certain number.
      • getReleases

        public List<Release> getReleases()
        Get all releases.
      • getNsURIs

        public Set<String> getNsURIs()
        Get set of namespace URIs.
      • getMetamodel

        public Metamodel getMetamodel​(Release release)
        Returns the metamodel for a release.
      • setLevel

        public void setLevel​(ValidationLevel level)
        Set the validation level.
      • main

        public static void main​(String[] args)
        Main method to perform migrations.
      • setResourceSetFactory

        public void setResourceSetFactory​(IResourceSetFactory resourceSetFactory)
        Set the factory to create ResourceSets for custom serialization.
      • getResourceSetFactory

        public IResourceSetFactory getResourceSetFactory()
        Get the factory to create ResourceSets for custom serialization.
      • clearCDORepositories

        public void clearCDORepositories​(String host,
                                         String port,
                                         String repo)
        clear the specified CDO Repository.
        Parameters:
        host -
        port -
        repo -
      • copy

        public static void copy​(Metamodel metamodel,
                                org.eclipse.emf.ecore.resource.ResourceSet sourceModels,
                                List<org.eclipse.emf.common.util.URI> cdoURIs,
                                IResourceSetFactory resourceSetFactory)
        Construct CDO URI from a given source models, create target models and copy the source content to the target content. Note: this will only work with a configured CDOViewProvider.
        Parameters:
        metamodel -
        sourceModels -
        resourceSetFactory -
      • cdoCreateResource

        public static org.eclipse.emf.cdo.eresource.CDOResource cdoCreateResource​(org.eclipse.emf.ecore.resource.ResourceSet set,
                                                                                  org.eclipse.emf.common.util.URI cdoResourceURI,
                                                                                  Metamodel mmmeta)
        Create a CDOResource from a URI the MMMeta will be used to register the corresponding EPackage by the CDOViewProvider.
        Parameters:
        set -
        cdoResourceURI -
        mmmeta -
        Returns:
        the cdo resource
      • cdoConnectionAwareURI

        public static org.eclipse.emf.common.util.URI cdoConnectionAwareURI​(String host,
                                                                            String port,
                                                                            String repo,
                                                                            String resourceName)
        Get a connection aware URI for specified arguments. The schema is set to TCP.
        Parameters:
        host -
        port -
        repo -
        resourceName -
        Returns:
        the uri
      • cdoConnectionAwareURI

        public static org.eclipse.emf.common.util.URI cdoConnectionAwareURI​(org.eclipse.emf.common.util.URI canonicalURI,
                                                                            String authority)
        Get a connection aware URI for original canonical URI and specified arguments. The schema is set to TCP.
        Parameters:
        canonicalURI - uri for creating a CDOURIData
        authority - authority for creating a CDOURIData
        Returns:
        the uri
      • cdoConnectionAwareURI

        public static org.eclipse.emf.common.util.URI cdoConnectionAwareURI​(org.eclipse.emf.common.util.URI canonicalURI,
                                                                            org.eclipse.emf.cdo.util.CDOURIData data)
        Get a connection aware URI for original canonical URI and specified source CDOURIData. (Setting the authority, user name and password from this source).
        The schema is set to TCP.
        Parameters:
        canonicalURI -
        data -
        Returns:
        the uri
      • clear

        public static void clear​(List<org.eclipse.emf.common.util.URI> cdoSourceURIs,
                                 ResourceSetFactoryImpl resourceSetFactoryImpl)
        Clear a CDOResource from the CDO Repository. The CDOResource should be active (Have an active CDOTransaction).
        Parameters:
        cdoSourceURIs -
        resourceSetFactoryImpl -
      • cdoConnectionAwareURI

        public static org.eclipse.emf.common.util.URI cdoConnectionAwareURI​(org.eclipse.emf.common.util.URI sourceURI,
                                                                            String host,
                                                                            String port,
                                                                            String repo)
        Converts a 'regular' resource URI to a CDO Resource URI.
        Parameters:
        sourceURI -
        Returns:
        the uri
      • collectConnectionAwareURIs

        public static List<org.eclipse.emf.common.util.URI> collectConnectionAwareURIs​(org.eclipse.emf.cdo.util.CDOURIData data,
                                                                                       List<org.eclipse.emf.cdo.eresource.CDOResource> cdoResCollection,
                                                                                       org.eclipse.emf.cdo.eresource.CDOResourceNode node)
        Converts regular CDOResource URI's to connection aware URI's.
        Parameters:
        data -
        cdoResCollection -
        node -
        Returns:
        the uris
      • collectResources

        public static void collectResources​(List<org.eclipse.emf.cdo.eresource.CDOResource> cdoResCollection,
                                            org.eclipse.emf.cdo.eresource.CDOResourceNode node)
        Collect all CDOResource for a root resource. (Works best if the initial CDOResourceNode is of type CDOResource and this is the root resource for the repository.
        Parameters:
        cdoResCollection -
        node -
      • commitTransaction

        public static boolean commitTransaction​(org.eclipse.emf.cdo.transaction.CDOTransaction t)
        Commit a CDO Transaction.
        Parameters:
        t -
        Returns:
        true if commit failed, false otherwise
      • loadEPackageFromEcore

        public static org.eclipse.emf.ecore.EPackage loadEPackageFromEcore​(org.eclipse.emf.common.util.URI expectedTargetMetamodelURI)
      • cdoCanonicalURI

        public static org.eclipse.emf.common.util.URI cdoCanonicalURI​(org.eclipse.emf.common.util.URI sourceURI,
                                                                      String repo)
        Converts a 'regular' resource URI to a CDO Resource URI.
        Parameters:
        sourceURI -
        Returns:
        the uri