Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.core.storage.sql.jdbc
Class JDBCMapper

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.jdbc.JDBCConnection
      extended by org.nuxeo.ecm.core.storage.sql.jdbc.JDBCRowMapper
          extended by org.nuxeo.ecm.core.storage.sql.jdbc.JDBCMapper
All Implemented Interfaces:
javax.transaction.xa.XAResource, Mapper, RowMapper

public class JDBCMapper
extends JDBCRowMapper
implements Mapper

A JDBCMapper maps objects to and from a JDBC database. It is specific to a given database connection, as it computes statements.

The JDBCMapper does the mapping according to the policy defined by a Model, and generates SQL statements recorded in the SQLInfo.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.storage.sql.Mapper
Mapper.Identification
 
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.storage.sql.RowMapper
RowMapper.CopyHierarchyResult, RowMapper.RowBatch, RowMapper.RowUpdate
 
Field Summary
static java.lang.String TEST_UPGRADE
           
static java.lang.String TEST_UPGRADE_VERSIONS
           
static java.util.Map<java.lang.String,java.io.Serializable> testProps
           
 
Fields inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.JDBCConnection
connection, logger
 
Fields inherited from interface org.nuxeo.ecm.core.storage.sql.Mapper
CLOSE, GET_IDENTIFICATION
 
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Constructor Summary
JDBCMapper(Model model, Session.PathResolver pathResolver, SQLInfo sqlInfo, javax.sql.XADataSource xadatasource, ClusterNodeHandler clusterNodeHandler)
          Creates a new Mapper.
 
Method Summary
 void commit(javax.transaction.xa.Xid xid, boolean onePhase)
           
 void createClusterNode()
          Informs the cluster that this node exists.
 void createDatabase()
          Creates the necessary structures in the database.
 void end(javax.transaction.xa.Xid xid, int flags)
           
 void forget(javax.transaction.xa.Xid xid)
           
 Invalidations getClusterInvalidations()
          Gets the invalidations from other cluster nodes.
 java.io.Serializable getLastVersionId(java.io.Serializable versionSeriesId)
          Gets the id of the last version given a version series id.
 java.io.Serializable getRootId(java.io.Serializable repositoryId)
          Gets the root id for a given repository, if registered.
 int getTableSize(java.lang.String tableName)
           
 int getTransactionTimeout()
           
 java.io.Serializable getVersionIdByLabel(java.io.Serializable versionSeriesId, java.lang.String label)
          Gets the id of a version given a version series id and a label.
 void insertClusterInvalidations(Invalidations invalidations)
          Inserts the invalidation rows for the other cluster nodes.
 boolean isSameRM(javax.transaction.xa.XAResource xares)
           
 int prepare(javax.transaction.xa.Xid xid)
           
 PartialList<java.io.Serializable> query(java.lang.String query, QueryFilter queryFilter, boolean countTotal)
          Makes a NXQL query to the database.
 IterableQueryResult queryAndFetch(java.lang.String query, java.lang.String queryType, QueryFilter queryFilter, java.lang.Object... params)
          Makes a query to the database and returns an iterable (which must be closed when done).
 void rebuildReadAcls()
           
 javax.transaction.xa.Xid[] recover(int flag)
           
 void removeClusterNode()
          Removes this node from the cluster.
 void setRootId(java.io.Serializable repositoryId, java.io.Serializable id)
          Records the newly generated root id for a given repository.
 boolean setTransactionTimeout(int seconds)
           
 void start(javax.transaction.xa.Xid xid, int flags)
           
 void updateReadAcls()
           
 
Methods inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.JDBCRowMapper
clearCache, copyHierarchy, getProxyRows, getVersionRows, read, readChildHierRow, readChildHierRows, readCollectionRowArray, readSimpleRow, receiveInvalidations, rollback, sendInvalidations, write
 
Methods inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.JDBCConnection
close, getIdentification
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nuxeo.ecm.core.storage.sql.Mapper
close, getIdentification
 
Methods inherited from interface org.nuxeo.ecm.core.storage.sql.RowMapper
clearCache, copyHierarchy, getProxyRows, getVersionRows, read, readChildHierRow, readChildHierRows, readCollectionRowArray, readSimpleRow, receiveInvalidations, rollback, sendInvalidations, write
 
Methods inherited from interface javax.transaction.xa.XAResource
rollback
 

Field Detail

testProps

public static java.util.Map<java.lang.String,java.io.Serializable> testProps

TEST_UPGRADE

public static final java.lang.String TEST_UPGRADE
See Also:
Constant Field Values

TEST_UPGRADE_VERSIONS

public static final java.lang.String TEST_UPGRADE_VERSIONS
See Also:
Constant Field Values
Constructor Detail

JDBCMapper

public JDBCMapper(Model model,
                  Session.PathResolver pathResolver,
                  SQLInfo sqlInfo,
                  javax.sql.XADataSource xadatasource,
                  ClusterNodeHandler clusterNodeHandler)
           throws StorageException
Creates a new Mapper.

Parameters:
model - the model
pathResolver - the path resolver (used for startswith queries)
sqlInfo - the sql info
xadatasource - the XA datasource to use to get connections
clusterNodeHandler - the cluster node handler
Throws:
StorageException
Method Detail

getTableSize

public int getTableSize(java.lang.String tableName)
Specified by:
getTableSize in interface Mapper

createDatabase

public void createDatabase()
                    throws StorageException
Description copied from interface: Mapper
Creates the necessary structures in the database.

Specified by:
createDatabase in interface Mapper
Throws:
StorageException

createClusterNode

public void createClusterNode()
                       throws StorageException
Description copied from interface: Mapper
Informs the cluster that this node exists.

Specified by:
createClusterNode in interface Mapper
Throws:
StorageException

removeClusterNode

public void removeClusterNode()
                       throws StorageException
Description copied from interface: Mapper
Removes this node from the cluster.

Specified by:
removeClusterNode in interface Mapper
Throws:
StorageException

insertClusterInvalidations

public void insertClusterInvalidations(Invalidations invalidations)
                                throws StorageException
Description copied from interface: Mapper
Inserts the invalidation rows for the other cluster nodes.

Specified by:
insertClusterInvalidations in interface Mapper
Throws:
StorageException

getClusterInvalidations

public Invalidations getClusterInvalidations()
                                      throws StorageException
Description copied from interface: Mapper
Gets the invalidations from other cluster nodes.

Specified by:
getClusterInvalidations in interface Mapper
Throws:
StorageException

getRootId

public java.io.Serializable getRootId(java.io.Serializable repositoryId)
                               throws StorageException
Description copied from interface: Mapper
Gets the root id for a given repository, if registered.

Specified by:
getRootId in interface Mapper
Parameters:
repositoryId - the repository id, usually 0
Returns:
the root id, or null if not found
Throws:
StorageException

setRootId

public void setRootId(java.io.Serializable repositoryId,
                      java.io.Serializable id)
               throws StorageException
Description copied from interface: Mapper
Records the newly generated root id for a given repository.

Specified by:
setRootId in interface Mapper
Parameters:
repositoryId - the repository id, usually 0
id - the root id
Throws:
StorageException

getVersionIdByLabel

public java.io.Serializable getVersionIdByLabel(java.io.Serializable versionSeriesId,
                                                java.lang.String label)
                                         throws StorageException
Description copied from interface: Mapper
Gets the id of a version given a version series id and a label.

Specified by:
getVersionIdByLabel in interface Mapper
Parameters:
versionSeriesId - the version series id
label - the label
Returns:
the id of the version, or null if not found
Throws:
StorageException

getLastVersionId

public java.io.Serializable getLastVersionId(java.io.Serializable versionSeriesId)
                                      throws StorageException
Description copied from interface: Mapper
Gets the id of the last version given a version series id.

Specified by:
getLastVersionId in interface Mapper
Parameters:
versionSeriesId - the version series id
Returns:
the id of the last version, or null if not found
Throws:
StorageException

query

public PartialList<java.io.Serializable> query(java.lang.String query,
                                               QueryFilter queryFilter,
                                               boolean countTotal)
                                        throws StorageException
Description copied from interface: Mapper
Makes a NXQL query to the database.

Specified by:
query in interface Mapper
Parameters:
query - the query
queryFilter - the query filter
countTotal - if true, count the total size without limit/offset
Returns:
the list of matching document ids
Throws:
StorageException

queryAndFetch

public IterableQueryResult queryAndFetch(java.lang.String query,
                                         java.lang.String queryType,
                                         QueryFilter queryFilter,
                                         java.lang.Object... params)
                                  throws StorageException
Description copied from interface: Mapper
Makes a query to the database and returns an iterable (which must be closed when done).

Specified by:
queryAndFetch in interface Mapper
Parameters:
query - the query
queryType - the query type
queryFilter - the query filter
params - optional query-type-dependent parameters
Returns:
an iterable, which must be closed when done
Throws:
StorageException

updateReadAcls

public void updateReadAcls()
                    throws StorageException
Specified by:
updateReadAcls in interface Mapper
Throws:
StorageException

rebuildReadAcls

public void rebuildReadAcls()
                     throws StorageException
Specified by:
rebuildReadAcls in interface Mapper
Throws:
StorageException

start

public void start(javax.transaction.xa.Xid xid,
                  int flags)
           throws javax.transaction.xa.XAException
Specified by:
start in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

end

public void end(javax.transaction.xa.Xid xid,
                int flags)
         throws javax.transaction.xa.XAException
Specified by:
end in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

prepare

public int prepare(javax.transaction.xa.Xid xid)
            throws javax.transaction.xa.XAException
Specified by:
prepare in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

commit

public void commit(javax.transaction.xa.Xid xid,
                   boolean onePhase)
            throws javax.transaction.xa.XAException
Specified by:
commit in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

forget

public void forget(javax.transaction.xa.Xid xid)
            throws javax.transaction.xa.XAException
Specified by:
forget in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

recover

public javax.transaction.xa.Xid[] recover(int flag)
                                   throws javax.transaction.xa.XAException
Specified by:
recover in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

setTransactionTimeout

public boolean setTransactionTimeout(int seconds)
                              throws javax.transaction.xa.XAException
Specified by:
setTransactionTimeout in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

getTransactionTimeout

public int getTransactionTimeout()
                          throws javax.transaction.xa.XAException
Specified by:
getTransactionTimeout in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

isSameRM

public boolean isSameRM(javax.transaction.xa.XAResource xares)
                 throws javax.transaction.xa.XAException
Specified by:
isSameRM in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.