Package org.eclipse.emf.cdo.server.db.evolution.phased

# Class Context

java.lang.Object
org.eclipse.emf.cdo.server.db.evolution.phased.Context

All Implemented Interfaces:
  `CDOTimeProvider`, `org.eclipse.net4j.util.properties.IPropertiesContainer`

public final class Context extends Object implements CDOTimeProvider, org.eclipse.net4j.util.properties.IPropertiesContainer
The context for model evolution.

Provides access to the models being evolved, their old and new EPackages, element mappings, and utilities for logging and statement batching.

Instances of this class are created per model evolution operation and passed to the various phases and handlers. If model changes are detected, a Context instance is created and used throughout the evolution process. It is saved to the `evolution folder` and loaded from there when resuming an evolution operation.

Since:
  4.14
Author:
  Eike Stepper
No Implement
  This package is currently considered provisional.
No Extend
  This package is currently considered provisional.
No Reference
  This package is currently considered provisional.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`Context.Manager`
A manager for creating, loading, and saving contexts.
`static final class`
`Context.Model`
A model stored in the DB store.

## Constructor Summary

Constructors
Constructor
Description
`Context(PhasedModelEvolutionSupport support, Collection<Context.Model> models)`
Creates a context for model evolution with the given models.

## Method Summary

Modifier and Type
Method
Description
`void`
`addChangeInfo(Context.Model model, Object changeInfo)`
Adds the given changed model along with its change info.
`org.eclipse.net4j.db.StatementBatcher`
`createStatementBatcher(Connection connection)`
Creates a statement batcher for the given connection that logs batch and result events to the evolution log and accumulates the total update count.
`Map<Context.Model,Object>`
`getChangeInfos()`
Returns the changed models along with their change infos.
`EMFUtil.TreeMapping<EObject>`
`getElementMappings()`
Returns the element mappings from old to new EObjects.
`Map<Integer,Integer>`
`getEnumLiteralChanges(EEnum oldEnum)`
Returns a map of old to new literal IDs for the given old enum.
`Map<String,Context.Model>`
`getModels()`
Returns the models being evolved in this context.
`<T extends EObject>
T`
`getNewElement(T oldElement)`
Returns the new element corresponding to the given old element, or `null` if there is no such mapping.
`Map<String,EPackage>`
`getOldPackages()`
Returns the old EPackages mapped by their URIs as returned by `EcoreUtil.getURI(EObject)`.
`PhasedModelEvolutionSupport`
`getSupport()`
Returns the model evolution support associated with this context.
`long`
`getTimeStamp()`
Returns the timestamp of this context.
`int`
`getTotalUpdateCount()`
Returns the total update count accumulated during this evolution.
`<F extends EStructuralFeature>
void`
`handleFeatureIDChanges(EClass oldClass, Function<EClass,Collection<F>> featureProvider, BiConsumer<Integer,Integer> handler)`
Handles feature ID changes for the given old class by applying the given feature provider and invoking the given handler for each detected feature ID change.
`int`
`incrementTotalUpdateCount()`
`int`
`incrementTotalUpdateCount(int delta)`
`void`
`log(Object message)`
Logs the given message to the evolution log.
`org.eclipse.net4j.util.registry.IRegistry<String,Object>`
`properties()`
Returns the properties container for this context.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Context

public Context(PhasedModelEvolutionSupport support, Collection<Context.Model> models)
Creates a context for model evolution with the given models.

## Method Details

### getSupport

public PhasedModelEvolutionSupport getSupport()
Returns the model evolution support associated with this context.

### properties

public org.eclipse.net4j.util.registry.IRegistry<String,Object> properties()
Returns the properties container for this context.

Can be used by phases and handlers to store and retrieve arbitrary named objects.

Specified by:
  `properties` in interface `org.eclipse.net4j.util.properties.IPropertiesContainer`

### log

public void log(Object message)
Logs the given message to the evolution log.

Can be used by phases and handlers to log messages during model evolution.

The evolution log is typically located in the `evolution folder`.

### getTimeStamp

public long getTimeStamp()
Returns the timestamp of this context.

Specified by:
  `getTimeStamp` in interface `CDOTimeProvider`

### getModels

public Map<String,Context.Model> getModels()
Returns the models being evolved in this context.

Includes both changed and unchanged models.

### getChangeInfos

public Map<Context.Model,Object> getChangeInfos()
Returns the changed models along with their change infos.

### addChangeInfo

public void addChangeInfo(Context.Model model, Object changeInfo)
Adds the given changed model along with its change info.

### getOldPackages

public Map<String,EPackage> getOldPackages()
Returns the old EPackages mapped by their URIs as returned by `EcoreUtil.getURI(EObject)`.

### getElementMappings

public EMFUtil.TreeMapping<EObject> getElementMappings()
Returns the element mappings from old to new EObjects.

Most of the mappings are between EModelElements, but there can also be mappings between arbitrary EObjects, e.g., for contents in EAnnotations.

### getNewElement

public <T extends EObject> T getNewElement(T oldElement)
Returns the new element corresponding to the given old element, or `null` if there is no such mapping.

### getEnumLiteralChanges

public Map<Integer,Integer> getEnumLiteralChanges(EEnum oldEnum)
Returns a map of old to new literal IDs for the given old enum.

### handleFeatureIDChanges

public <F extends EStructuralFeature> void handleFeatureIDChanges(EClass oldClass, Function<EClass,Collection<F>> featureProvider, BiConsumer<Integer,Integer> handler)
Handles feature ID changes for the given old class by applying the given feature provider and invoking the given handler for each detected feature ID change.

### createStatementBatcher

public org.eclipse.net4j.db.StatementBatcher createStatementBatcher(Connection connection) throws SQLException
Creates a statement batcher for the given connection that logs batch and result events to the evolution log and accumulates the total update count.

Throws:
  `SQLException`

### getTotalUpdateCount

public int getTotalUpdateCount()
Returns the total update count accumulated during this evolution.

### incrementTotalUpdateCount

public int incrementTotalUpdateCount()

### incrementTotalUpdateCount

public int incrementTotalUpdateCount(int delta)