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

## Interface IClassMapping

- All Known Subinterfaces:
    IClassMappingUnitSupport

      public interface IClassMapping

  Basic interface for class mappings.
  Since:
    2.0
  Author:
    Eike Stepper, Stefan Winkler

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.sql.PreparedStatement` | `createObjectIDStatement(IDBStoreAccessor accessor)` Create a prepared statement which returns all IDs of instances of the corresponding class.
    `java.sql.PreparedStatement` | `createResourceQueryStatement(IDBStoreAccessor accessor, CDOID folderId, java.lang.String name, boolean exactMatch, CDOBranchPoint branchPoint)` Create a prepared statement which returns all IDs of instances of the corresponding class.
    `void` | `detachObject(IDBStoreAccessor accessor, CDOID id, int version, CDOBranch branch, long timeStamp, OMMonitor monitor)` Detaches (deletes) a CDO object leaving a "ghost" revision behind.
    `java.util.List<IDBTable>` | `getDBTables()` Returns all DB tables which are used by this class and all its contained features.
    `EClass` | `getEClass()`
    `IListMapping` | `getListMapping(EStructuralFeature feature)` Get the mapping of the many-valued feature.
    `java.util.List<IListMapping>` | `getListMappings()`
    `java.util.List<ITypeMapping>` | `getValueMappings()`
    `void` | `handleRevisions(IDBStoreAccessor accessor, 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 `branch` parameter is `null` or equal to `revision.getBranch()`.
    `boolean` | `queryXRefs(IDBStoreAccessor accessor, IStoreAccessor.QueryXRefsContext context, java.lang.String idString)` Retrieve cross-references from DB
    `java.util.Set<CDOID>` | `readChangeSet(IDBStoreAccessor accessor, CDOChangeSetSegment[] segments)` Returns a set of CDOIDs that have at least one revision in any of the passed branches and time ranges.
    `boolean` | `readRevision(IDBStoreAccessor accessor, InternalCDORevision revision, int listChunk)` Read a revision.
    `void` | `writeRevision(IDBStoreAccessor accessor, InternalCDORevision revision, boolean mapType, boolean revise, OMMonitor monitor)` Write the revision data to the database.

- - ### Method Detail

    - #### getEClass

          EClass getEClass()

      Since:
        3.0

    - #### getDBTables

          java.util.List<IDBTable> getDBTables()

      Returns all DB tables which are used by this class and all its contained features.
      Returns:
        a collection of all tables of this class and all its contained features.
      Since:
        3.0

    - #### getListMapping

          IListMapping getListMapping(EStructuralFeature feature)

      Get the mapping of the many-valued feature.
      Parameters:
        `feature` - the feature for which the mapping should be returned. `feature.isMany()` has to be `true`.
      Returns:
        the list mapping corresponding to the feature.

    - #### getListMappings

          java.util.List<IListMapping> getListMappings()

      Since:
        3.0

    - #### getValueMappings

          java.util.List<ITypeMapping> getValueMappings()

      Since:
        4.0

    - #### readRevision

          boolean readRevision(IDBStoreAccessor accessor,
                               InternalCDORevision revision,
                               int listChunk)

      Read a revision. The branch and timestamp to be read are derived from the branchPoint which is set to the Revision. Note that non-audit stores only support `CDOBranchPoint.UNSPECIFIED_DATE` and non-branching stores only support the main branch.
      Parameters:
        `accessor` - the accessor to use.
        `revision` - the revision object into which the data should be read. The revision has to be have its ID set to the requested object's ID. The version is ignored, as the version parameter is used to determine the version to be read.
        `listChunk` - the chunk size to read attribute lists.
      Returns:
        `true`, if the revision has been found and read correctly. `false` if the revision could not be found. In this case, the content of `revision` is undefined.

    - #### writeRevision

          void writeRevision(IDBStoreAccessor accessor,
                             InternalCDORevision revision,
                             boolean mapType,
                             boolean revise,
                             OMMonitor monitor)

      Write the revision data to the database.
      Parameters:
        `accessor` - the accessor to use.
        `revision` - the revision to write.
        `mapType` - `true` if the type of the object is supposed to be mapped, `false` otherwise.
        `revise` - `true` if the previous revision is supposed to be revised, `false` otherwise.
        `monitor` - the monitor to indicate progress.
      Since:
        4.0

    - #### detachObject

          void detachObject(IDBStoreAccessor accessor,
                            CDOID id,
                            int version,
                            CDOBranch branch,
                            long timeStamp,
                            OMMonitor monitor)

      Detaches (deletes) a CDO object leaving a "ghost" revision behind.
      Parameters:
        `accessor` - the accessor to use.
        `id` - the id to revise.
        `version` - the last valid version.
        `timeStamp` - the timestamp of detach.
        `monitor` - the monitor to indicate progress.
      Since:
        3.0

    - #### createObjectIDStatement

          java.sql.PreparedStatement createObjectIDStatement(IDBStoreAccessor accessor)

      Create a prepared statement which returns all IDs of instances of the corresponding class.
      Parameters:
        `accessor` - the accessor to use to create the statement
      Returns:
        the prepared statement ready to be executed using `result.executeQuery()`.
      Since:
        3.0

    - #### createResourceQueryStatement

          java.sql.PreparedStatement createResourceQueryStatement(IDBStoreAccessor accessor,
                                                                  CDOID folderId,
                                                                  java.lang.String name,
                                                                  boolean exactMatch,
                                                                  CDOBranchPoint branchPoint)

      Create a prepared statement which returns all IDs of instances of the corresponding class.
      Parameters:
        `accessor` - the accessor to use to create the statement
        `folderId` - the ID of the containing folder. `0` means none.
        `name` - the name of the resource node to look up
        `exactMatch` - if `true`, `name` must match exactly, otherwise all resource nodes starting with `name` are returned.
        `branchPoint` - a branchPoint (branch and timestamp). A timestamp in the past if past versions should be looked up. In case of no audit support, this must be `CDOBranchPoint.UNSPECIFIED_DATE`. In case of non branching support the branch id must be equal to `CDOBranch.MAIN_BRANCH_ID`.
      Returns:
        the prepared statement ready to be executed using `result.executeQuery()`.
      Throws:
        `ImplementationError` - if called on a mapping which does not map an `EClass instanceof CDOResourceNode`.
      Since:
        3.0

    - #### handleRevisions

          void handleRevisions(IDBStoreAccessor accessor,
                               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 `branch` parameter is `null` or equal to `revision.getBranch()`.
      - The `timeStamp` parameter is `CDOBranchPoint.UNSPECIFIED_DATE` or equal to `revision.getTimeStamp()`.
      Since:
        4.0
      See Also:
        `IMappingStrategy.handleRevisions(IDBStoreAccessor, org.eclipse.emf.ecore.EClass, CDOBranch, long, boolean, CDORevisionHandler)`

    - #### readChangeSet

          java.util.Set<CDOID> readChangeSet(IDBStoreAccessor accessor,
                                             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!
      Since:
        3.0
      See Also:
        `IStoreAccessor.readChangeSet(OMMonitor, CDOChangeSetSegment...)`

    - #### queryXRefs

          boolean queryXRefs(IDBStoreAccessor accessor,
                             IStoreAccessor.QueryXRefsContext context,
                             java.lang.String idString)

      Retrieve cross-references from DB
      Parameters:
        `idString` - a string of the form "(id1, id2, id3, ...)" which can be used directly in SQL to form the where-part "SELECT * FROM foobar WHERE foobar.target IN [idString]".
      Since:
        4.0
      See Also:
        `IStoreAccessor.queryXRefs(QueryXRefsContext)`

Copyright (c) 2014 Eike Stepper (Berlin, Germany) and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html