Class CDOMigrator
- java.lang.Object
-
- org.eclipse.emf.edapt.cdo.migration.execution.CDOMigrator
-
public class CDOMigrator extends Object
Migrator to migrate a model from a previous to the current release.- Author:
- Christophe Bouhier
-
-
Constructor Summary
Constructors Constructor Description CDOMigrator(org.eclipse.emf.common.util.URI historyURI, IClassLoader classLoader)
Constructor.CDOMigrator(History history, IClassLoader classLoader)
Constructor.
-
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 aconnection aware URI
for specified arguments.static org.eclipse.emf.common.util.URI
cdoConnectionAwareURI(org.eclipse.emf.common.util.URI canonicalURI, String authority)
Get aconnection 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 aconnection 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 aCDOResource
from aURI
theMMMeta
will be used to register the correspondingEPackage
by theCDOViewProvider
.static void
clear(List<org.eclipse.emf.common.util.URI> cdoSourceURIs, ResourceSetFactoryImpl resourceSetFactoryImpl)
Clear aCDOResource
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 allCDOResource
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 CDOURI
from a givensource models
, createtarget models
and copy the source content to the target content.EdaptCDOViewProvider
getEdaptCDOViewProvider()
Get theCDOViewProvider
.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 onURI
.List<Release>
getReleases()
Get all releases.IResourceSetFactory
getResourceSetFactory()
Get the factory to createResourceSet
s 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 ofURI
s and load it afterwards.void
setLevel(ValidationLevel level)
Set the validation level.void
setResourceSetFactory(IResourceSetFactory resourceSetFactory)
Set the factory to createResourceSet
s for custom serialization.
-
-
-
Constructor Detail
-
CDOMigrator
public CDOMigrator(org.eclipse.emf.common.util.URI historyURI, IClassLoader classLoader) throws MigrationException
Constructor.- Throws:
MigrationException
-
CDOMigrator
public CDOMigrator(History history, IClassLoader classLoader)
Constructor.
-
-
Method Detail
-
getEdaptCDOViewProvider
public EdaptCDOViewProvider getEdaptCDOViewProvider()
Get theCDOViewProvider
.- 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 datatargetURIData
- the target uri datamonitor
- 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 ofURI
s and load it afterwards.- Parameters:
modelURIs
- The set ofURI
sourceRelease
- Release to which the model conformstargetRelease
- 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 onURI
.
-
getRelease
public Release getRelease(int number)
Get the release with a certain number.
-
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 createResourceSet
s for custom serialization.
-
getResourceSetFactory
public IResourceSetFactory getResourceSetFactory()
Get the factory to createResourceSet
s 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 CDOURI
from a givensource models
, createtarget models
and copy the source content to the target content. Note: this will only work with a configuredCDOViewProvider
.- 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 aCDOResource
from aURI
theMMMeta
will be used to register the correspondingEPackage
by theCDOViewProvider
.- 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 aconnection 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 aconnection aware URI
for original canonical URI and specified arguments. The schema is set to TCP.- Parameters:
canonicalURI
- uri for creating aCDOURIData
authority
- authority for creating aCDOURIData
- 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 aconnection 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 aCDOResource
from the CDO Repository. The CDOResource should be active (Have an activeCDOTransaction
).- 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 allCDOResource
for a root resource. (Works best if the initialCDOResourceNode
is of typeCDOResource
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
-
-