Class Context
- All Implemented Interfaces:
CDOTimeProvider,org.eclipse.net4j.util.properties.IPropertiesContainer
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 ClassesModifier and TypeClassDescriptionstatic interfaceA manager for creating, loading, and saving contexts.static final classA model stored in the DB store. -
Constructor Summary
ConstructorsConstructorDescriptionContext(PhasedModelEvolutionSupport support, Collection<Context.Model> models) Creates a context for model evolution with the given models. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeInfo(Context.Model model, Object changeInfo) Adds the given changed model along with its change info.org.eclipse.net4j.db.StatementBatchercreateStatementBatcher(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.Returns the changed models along with their change infos.Returns the element mappings from old to new EObjects.getEnumLiteralChanges(EEnum oldEnum) Returns a map of old to new literal IDs for the given old enum.Returns the models being evolved in this context.<T extends EObject>
TgetNewElement(T oldElement) Returns the new element corresponding to the given old element, ornullif there is no such mapping.Returns the old EPackages mapped by their URIs as returned byEcoreUtil.getURI(EObject).Returns the model evolution support associated with this context.longReturns the timestamp of this context.intReturns the total update count accumulated during this evolution.<F extends EStructuralFeature>
voidhandleFeatureIDChanges(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.intintincrementTotalUpdateCount(int delta) voidLogs the given message to the evolution log.Returns the properties container for this context.
-
Constructor Details
-
Context
Creates a context for model evolution with the given models.
-
-
Method Details
-
getSupport
Returns the model evolution support associated with this context. -
properties
Returns the properties container for this context.Can be used by phases and handlers to store and retrieve arbitrary named objects.
- Specified by:
propertiesin interfaceorg.eclipse.net4j.util.properties.IPropertiesContainer
-
log
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:
getTimeStampin interfaceCDOTimeProvider
-
getModels
Returns the models being evolved in this context.Includes both changed and unchanged models.
-
getChangeInfos
Returns the changed models along with their change infos. -
addChangeInfo
Adds the given changed model along with its change info. -
getOldPackages
Returns the old EPackages mapped by their URIs as returned byEcoreUtil.getURI(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
Returns the new element corresponding to the given old element, ornullif there is no such mapping. -
getEnumLiteralChanges
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)
-