Package org.eclipse.emf.cdo.server.db.mapping

# Schnittstelle IMappingStrategy

Alle bekannten Unterschnittstellen:
  `IMappingStrategy2`

public interface IMappingStrategy
The mapping strategy acts as a connection between the DBStore and the database management (and OR-mapping) classes. The `DBStore` uses methods of this interface to create and lookup mappings (or mappers, as they could also be named as such) and to get properties and informations about the mappings used. The mapping classes (e.g., instances of IClassMapping and IListMapping) also use this class as a central point of information and as a resource of common functionalities.

Seit:
  2.0
Autor:
  Eike Stepper, Stefan Winkler

## Verschachtelte Klassen - Übersicht

Verschachtelte Klassen
Modifizierer und Typ
Schnittstelle
Beschreibung
`static interface`
`IMappingStrategy.Props`
Contains symbolic constants that specifiy valid keys of `mapping strategy properties`.

## Feldübersicht

Felder
Modifizierer und Typ
Feld
Beschreibung
`static final String`
`PROP_COLUMN_TYPE_MODIFIER`
Veraltet.
As of 4.4 use `IMappingStrategy.Props.COLUMN_TYPE_MODIFIER`.
`static final String`
`PROP_FORCE_NAMES_WITH_ID`
Veraltet.
As of 4.4 use `IMappingStrategy.Props.FORCE_NAMES_WITH_ID`.
`static final String`
`PROP_MAX_FIELD_NAME_LENGTH`
Veraltet.
As of 4.4 use `IMappingStrategy.Props.MAX_FIELD_NAME_LENGTH`.
`static final String`
`PROP_MAX_TABLE_NAME_LENGTH`
Veraltet.
As of 4.4 use `IMappingStrategy.Props.MAX_TABLE_NAME_LENGTH`.
`static final String`
`PROP_OBJECT_TYPE_CACHE_SIZE`
Veraltet.
As of 4.4 use `IMappingStrategy.Props.OBJECT_TYPE_CACHE_SIZE`.
`static final String`
`PROP_QUALIFIED_NAMES`
Veraltet.
As of 4.4 use `IMappingStrategy.Props.QUALIFIED_NAMES`.
`static final String`
`PROP_TABLE_NAME_PREFIX`
Veraltet.
As of 4.4 use `IMappingStrategy.Props.TABLE_NAME_PREFIX`.

## Methodenübersicht

Modifizierer und Typ
Methode
Beschreibung
`IListMapping`
`createListMapping(EClass containingClass, EStructuralFeature feature)`
Factory for value mappings of multi-valued-attributes.
`void`
`createMapping(Connection connection, InternalCDOPackageUnit[] packageUnits, org.eclipse.net4j.util.om.monitor.OMMonitor monitor)`
Create and initialize the mapping infrastructure for the given packages.
`ITypeMapping`
`createValueMapping(EStructuralFeature feature)`
Factory for value mappings of single-valued attributes.
`IClassMapping`
`getClassMapping(EClass eClass)`
Look up an existing class mapping for the given class.
`Map<EClass,IClassMapping>`
`getClassMappings()`
Returns all class mappings of this strategy.
`Map<EClass,IClassMapping>`
`getClassMappings(boolean createOnDemand)`
Returns all class mappings of this strategy.
`String`
`getFieldName(EStructuralFeature feature)`
Create a suitable column name which can be used to map the given element.
`String`
`getListJoin(String attrTable, String listTable)`
`Map<String,String>`
`getProperties()`
Returns the configuration properties of this mapping strategy.
`IDBStore`
`getStore()`
`String`
`getTableName(EClass containingClass, EStructuralFeature feature)`
Create a suitable table name which can be used to map the given element.
`String`
`getTableName(ENamedElement element)`
Create a suitable table name which can be used to map the given element.
`void`
`handleRevisions(IDBStoreAccessor accessor, EClass eClass, CDOBranch branch, long timeStamp, boolean exactTime, CDORevisionHandler handler)`
Passes all revisions of the store to the `handler` if all of the following conditions are met: The `eClass` parameter is `null` or equal to `revision.getEClass()`.
`boolean`
`hasAuditSupport()`
Query if this mapping supports audits.
`boolean`
`hasBranchingSupport()`
Query if this mapping supports branches.
`boolean`
`hasDeltaSupport()`
Query if this mapping supports revision deltas.
`void`
`queryResources(IDBStoreAccessor accessor, IStoreAccessor.QueryResourcesContext context)`
Executes a resource query.
`void`
`queryXRefs(IDBStoreAccessor accessor, IStoreAccessor.QueryXRefsContext context)`
Executes a cross reference query.
`void`
`rawExport(IDBStoreAccessor accessor, CDODataOutput out, int lastReplicatedBranchID, int lastBranchID, long lastReplicatedCommitTime, long lastCommitTime)`
`void`
`rawImport(IDBStoreAccessor accessor, CDODataInput in, long fromCommitTime, long toCommitTime, org.eclipse.net4j.util.om.monitor.OMMonitor monitor)`
`Set<CDOID>`
`readChangeSet(IDBStoreAccessor accessor, org.eclipse.net4j.util.om.monitor.OMMonitor monitor, CDOChangeSetSegment[] segments)`
Returns a set of CDOIDs that have at least one revision in any of the passed branches and time ranges.
`org.eclipse.net4j.util.collection.CloseableIterator<CDOID>`
`readObjectIDs(IDBStoreAccessor accessor)`
Get an iterator over all instances of objects in the store.
`CDOClassifierRef`
`readObjectType(IDBStoreAccessor accessor, CDOID id)`
Read the type (i.e.
`void`
`removeMapping(Connection connection, InternalCDOPackageUnit[] packageUnits)`
Remove the mapping infrastructure for the given packages.
`void`
`repairAfterCrash(org.eclipse.net4j.db.IDBAdapter dbAdapter, Connection connection)`
Return the maximum object id used in the store.
`void`
`setProperties(Map<String,String> properties)`
Set configuration properties for this mapping strategy.
`void`
`setStore(IDBStore dbStore)`
Set the store to which this MappingStrategy instance belongs.

## Felddetails

### PROP_MAX_TABLE_NAME_LENGTH

@Deprecated static final String PROP_MAX_TABLE_NAME_LENGTH
Veraltet.
As of 4.4 use `IMappingStrategy.Props.MAX_TABLE_NAME_LENGTH`.
Name of the integer property that configures the maximum length for table names. A value of zero indicates the value of the `db adapter` to be used.

Siehe auch:
  - Konstantenfeldwerte

### PROP_MAX_FIELD_NAME_LENGTH

@Deprecated static final String PROP_MAX_FIELD_NAME_LENGTH
Veraltet.
As of 4.4 use `IMappingStrategy.Props.MAX_FIELD_NAME_LENGTH`.
Name of the integer property that configures the maximum length for column names. A value of zero indicates the value of the `db adapter` to be used.

Siehe auch:
  - Konstantenfeldwerte

### PROP_TABLE_NAME_PREFIX

@Deprecated static final String PROP_TABLE_NAME_PREFIX
Veraltet.
As of 4.4 use `IMappingStrategy.Props.TABLE_NAME_PREFIX`.
Name of the String property that specifies a common prefix for table names.

Siehe auch:
  - Konstantenfeldwerte

### PROP_QUALIFIED_NAMES

@Deprecated static final String PROP_QUALIFIED_NAMES
Veraltet.
As of 4.4 use `IMappingStrategy.Props.QUALIFIED_NAMES`.
Name of the boolean property that configures whether the table names are made of simple class names or of qualified class names.

Siehe auch:
  - Konstantenfeldwerte

### PROP_FORCE_NAMES_WITH_ID

@Deprecated static final String PROP_FORCE_NAMES_WITH_ID
Veraltet.
As of 4.4 use `IMappingStrategy.Props.FORCE_NAMES_WITH_ID`.
Name of the boolean property that configures whether table names and column names are always suffixed with the internal DBID or only in cases where generated names violate the naming constraints of the underlying backend.

Siehe auch:
  - Konstantenfeldwerte

### PROP_OBJECT_TYPE_CACHE_SIZE

@Deprecated static final String PROP_OBJECT_TYPE_CACHE_SIZE
Veraltet.
As of 4.4 use `IMappingStrategy.Props.OBJECT_TYPE_CACHE_SIZE`.
Name of the integer property that configures the size of the object type in-memory cache. Possible configuration values are:

- 0 (zero). Don't use memory caching.
- >0. Use memory caching with the cache size given.

Default is a memory cache size of 10,000,000.

Seit:
  4.0
Siehe auch:
  - Konstantenfeldwerte

### PROP_COLUMN_TYPE_MODIFIER

@Deprecated static final String PROP_COLUMN_TYPE_MODIFIER
Veraltet.
As of 4.4 use `IMappingStrategy.Props.COLUMN_TYPE_MODIFIER`.
Name of a String property that specifies the name of a `column type modifier`.

Seit:
  4.2
Siehe auch:
  - Konstantenfeldwerte

## Methodendetails

### getStore

IDBStore getStore()

Gibt zurück:
  the store, this MappingStrategy instance belongs to.

### setStore

void setStore(IDBStore dbStore)
Set the store to which this MappingStrategy instance belongs. Should only be called by the `DBStore`, and only once to initialize the connection between `DBStore` and mapping strategy.

Parameter:
  `dbStore` - the DBStore instance to which this MappingStrategy instance belongs.

### createValueMapping

ITypeMapping createValueMapping(EStructuralFeature feature)
Factory for value mappings of single-valued attributes.

Parameter:
  `feature` - the feature for which a mapping should be created. It must hold `feature.isMany() == false`.
Gibt zurück:
  the mapping created.

### createListMapping

IListMapping createListMapping(EClass containingClass, EStructuralFeature feature)
Factory for value mappings of multi-valued-attributes.

Parameter:
  `containingClass` - the class containing the feature.
  `feature` - the feature for which a mapping should be created. It must hold `feature.isMany() == true`.

### getTableName

String getTableName(ENamedElement element)
Create a suitable table name which can be used to map the given element. Should only be called by mapping classes.

Parameter:
  `element` - the element for which the name should be created. It must hold: `element instanceof EClass || element instanceof EPackage`.
Gibt zurück:
  the created table name. It is guaranteed that the table name is compatible with the chosen database.

### getTableName

String getTableName(EClass containingClass, EStructuralFeature feature)
Create a suitable table name which can be used to map the given element. Should only be called by mapping classes. Should only be called by mapping classes.

Parameter:
  `containingClass` - the class containeng the feature.
  `feature` - the feature for which the table name should be created.
Gibt zurück:
  the created table name. It is guaranteed that the table name is compatible with the chosen database.

### getFieldName

String getFieldName(EStructuralFeature feature)
Create a suitable column name which can be used to map the given element. Should only be called by mapping classes.

Parameter:
  `feature` - the feature for which the column name should be created.
Gibt zurück:
  the created column name. It is guaranteed that the name is compatible with the chosen database.

### createMapping

void createMapping(Connection connection, InternalCDOPackageUnit[] packageUnits, org.eclipse.net4j.util.om.monitor.OMMonitor monitor)
Create and initialize the mapping infrastructure for the given packages. Should be called from the DBStore or the DBStoreAccessor.

Parameter:
  `connection` - the connection to use.
  `packageUnits` - the packages whose elements should be mapped.
  `monitor` - the monitor to report progress.

### removeMapping

void removeMapping(Connection connection, InternalCDOPackageUnit[] packageUnits)
Remove the mapping infrastructure for the given packages. Should be called from the DBStore or the DBStoreAccessor.

Parameter:
  `connection` - the connection to use.
  `packageUnits` - the packages for which the mappings should be removed
Seit:
  4.0

### getClassMapping

IClassMapping getClassMapping(EClass eClass)
Look up an existing class mapping for the given class. Before this method is called, the class mapping must have been initialized by calling `createMapping(Connection, InternalCDOPackageUnit[], OMMonitor)` on its containing package.

Parameter:
  `eClass` - the class to look up.
Gibt zurück:
  the class mapping.

### getClassMappings

Map<EClass,IClassMapping> getClassMappings()
Returns all class mappings of this strategy.

Seit:
  4.0

### getClassMappings

Map<EClass,IClassMapping> getClassMappings(boolean createOnDemand)
Returns all class mappings of this strategy.

Seit:
  4.0

### hasDeltaSupport

boolean hasDeltaSupport()
Query if this mapping supports revision deltas.
If this method returns `true`, it is guaranteed that all class mappings returned by `getClassMapping(EClass)` implement `IClassMappingDeltaSupport`.

Gibt zurück:
  `true` if revision deltas are supported, `false` else.

### hasAuditSupport

boolean hasAuditSupport()
Query if this mapping supports audits.
If this method returns `true`, it is guaranteed that all class mappings returned by `getClassMapping(EClass)` implement `IClassMappingAuditSupport`.

Gibt zurück:
  `true` if audits are supported, `false` else.

### hasBranchingSupport

boolean hasBranchingSupport()
Query if this mapping supports branches.

Gibt zurück:
  `true` if branches are supported, `false` else.
Seit:
  3.0

### queryResources

void queryResources(IDBStoreAccessor accessor, IStoreAccessor.QueryResourcesContext context)
Executes a resource query.

Parameter:
  `accessor` - the accessor to use.
  `context` - the context from which the query parameters are read and to which the result is written.

### queryXRefs

void queryXRefs(IDBStoreAccessor accessor, IStoreAccessor.QueryXRefsContext context)
Executes a cross reference query.

Parameter:
  `accessor` - the accessor to use.
  `context` - the context from which the query parameters are read and to which the result is written.
Seit:
  3.0

### readObjectType

CDOClassifierRef readObjectType(IDBStoreAccessor accessor, CDOID id)
Read the type (i.e. class) of the object referred to by a given ID.

Parameter:
  `accessor` - the accessor to use to look up the type.
  `id` - the ID of the object for which the type is to be determined.
Gibt zurück:
  the type of the object.

### readObjectIDs

org.eclipse.net4j.util.collection.CloseableIterator<CDOID> readObjectIDs(IDBStoreAccessor accessor)
Get an iterator over all instances of objects in the store.

Parameter:
  `accessor` - the accessor to use.
Gibt zurück:
  the iterator.

### repairAfterCrash

void repairAfterCrash(org.eclipse.net4j.db.IDBAdapter dbAdapter, Connection connection)
Return the maximum object id used in the store. This is used by the DBStore if a previous crash is discovered during the startup process. Should only be called by the DBStore and only during startup.

Parameter:
  `dbAdapter` - the dbAdapter to use to access the database
  `connection` - the connection to use to access the database
Seit:
  4.0

### getProperties

Map<String,String> getProperties()
Returns the configuration properties of this mapping strategy.

Seit:
  4.0

### setProperties

void setProperties(Map<String,String> properties)
Set configuration properties for this mapping strategy. Should only be called by the factory creating the mapping strategy instance.

Parameter:
  `properties` - the configuration properties to set.

### handleRevisions

void handleRevisions(IDBStoreAccessor accessor, EClass eClass, CDOBranch branch, long timeStamp, boolean exactTime, CDORevisionHandler handler)
Passes all revisions of the store to the `handler` if all of the following conditions are met:

- The `eClass` parameter is `null` or equal to `revision.getEClass()`.
- The `branch` parameter is `null` or equal to `revision.getBranch()`.
- The `timeStamp` parameter is `CDOBranchPoint.UNSPECIFIED_DATE` or equal to `revision.getTimeStamp()`.

Seit:
  4.0

### readChangeSet

Set<CDOID> readChangeSet(IDBStoreAccessor accessor, org.eclipse.net4j.util.om.monitor.OMMonitor monitor, CDOChangeSetSegment[] segments)
Returns a set of CDOIDs that have at least one revision in any of the passed branches and time ranges. DetachedCDORevisions must also be considered!

Seit:
  4.0
Siehe auch:
  - `IStoreAccessor.readChangeSet(OMMonitor, CDOChangeSetSegment...)`

### rawExport

void rawExport(IDBStoreAccessor accessor, CDODataOutput out, int lastReplicatedBranchID, int lastBranchID, long lastReplicatedCommitTime, long lastCommitTime) throws IOException

Löst aus:
  `IOException`
Seit:
  3.0

### rawImport

void rawImport(IDBStoreAccessor accessor, CDODataInput in, long fromCommitTime, long toCommitTime, org.eclipse.net4j.util.om.monitor.OMMonitor monitor) throws IOException

Löst aus:
  `IOException`
Seit:
  4.0

### getListJoin

String getListJoin(String attrTable, String listTable)

Seit:
  4.0