Search in sources :

Example 1 with TransactionQueryEntity

use of org.alfresco.repo.domain.node.TransactionQueryEntity in project alfresco-repository by Alfresco.

the class NodeDAOImpl method selectNextTxCommitTime.

/**
 * Gets the next commit time from [fromCommitTime]
 *
 * @param fromCommitTime Initial commit time
 * @return next commit time
 */
@Override
public Long selectNextTxCommitTime(Long fromCommitTime) {
    TransactionQueryEntity fromCommitTimeEntity = new TransactionQueryEntity();
    fromCommitTimeEntity.setMinCommitTime(fromCommitTime);
    return template.selectOne(SELECT_TXN_NEXT_TXN_COMMIT_TIME, fromCommitTimeEntity);
}
Also used : TransactionQueryEntity(org.alfresco.repo.domain.node.TransactionQueryEntity)

Example 2 with TransactionQueryEntity

use of org.alfresco.repo.domain.node.TransactionQueryEntity in project alfresco-repository by Alfresco.

the class NodeDAOImpl method deleteNodesByCommitTime.

@Override
protected int deleteNodesByCommitTime(long fromTxnCommitTimeMs, long toTxnCommitTimeMs) {
    // Get the deleted nodes
    Pair<Long, QName> deletedTypePair = qnameDAO.getQName(ContentModel.TYPE_DELETED);
    if (deletedTypePair == null) {
        // Nothing to do
        return 0;
    }
    TransactionQueryEntity query = new TransactionQueryEntity();
    query.setTypeQNameId(deletedTypePair.getFirst());
    query.setMinCommitTime(fromTxnCommitTimeMs);
    query.setMaxCommitTime(toTxnCommitTimeMs);
    // TODO: Fix ALF-16030 Use ON DELETE CASCADE for node aspects and properties
    // First clean up properties
    template.delete(DELETE_NODE_PROPS_BY_TXN_COMMIT_TIME, query);
    // Finally remove the nodes
    return template.delete(DELETE_NODES_BY_TXN_COMMIT_TIME, query);
}
Also used : QName(org.alfresco.service.namespace.QName) TransactionQueryEntity(org.alfresco.repo.domain.node.TransactionQueryEntity)

Example 3 with TransactionQueryEntity

use of org.alfresco.repo.domain.node.TransactionQueryEntity in project alfresco-repository by Alfresco.

the class NodeDAOImpl method deleteTxnsUnused.

@Override
public int deleteTxnsUnused(long fromCommitTime, long toCommitTime) {
    TransactionQueryEntity txnQuery = new TransactionQueryEntity();
    txnQuery.setMinCommitTime(fromCommitTime);
    txnQuery.setMaxCommitTime(toCommitTime);
    int numDeleted = template.delete(DELETE_TXNS_UNUSED, txnQuery);
    return numDeleted;
}
Also used : TransactionQueryEntity(org.alfresco.repo.domain.node.TransactionQueryEntity)

Example 4 with TransactionQueryEntity

use of org.alfresco.repo.domain.node.TransactionQueryEntity in project alfresco-repository by Alfresco.

the class NodeDAOImpl method selectTxns.

@Override
public List<Transaction> selectTxns(Long fromTimeInclusive, Long toTimeExclusive, Integer count, List<Long> includeTxnIds, List<Long> excludeTxnIds, Boolean ascending) {
    TransactionQueryEntity query = new TransactionQueryEntity();
    query.setMinCommitTime(fromTimeInclusive);
    query.setMaxCommitTime(toTimeExclusive);
    if ((includeTxnIds != null) && (includeTxnIds.size() > 0)) {
        query.setIncludeTxnIds(includeTxnIds);
    }
    if ((excludeTxnIds != null) && (excludeTxnIds.size() > 0)) {
        query.setExcludeTxnIds(excludeTxnIds);
    }
    query.setAscending(ascending);
    if (count == null) {
        return template.selectList(SELECT_TXNS, query);
    } else {
        return template.selectList(SELECT_TXNS, query, new RowBounds(0, count));
    }
}
Also used : TransactionQueryEntity(org.alfresco.repo.domain.node.TransactionQueryEntity) RowBounds(org.apache.ibatis.session.RowBounds)

Example 5 with TransactionQueryEntity

use of org.alfresco.repo.domain.node.TransactionQueryEntity in project alfresco-repository by Alfresco.

the class NodeDAOImpl method getNodeIdsIntervalForType.

@Override
@SuppressWarnings("rawtypes")
public Pair<Long, Long> getNodeIdsIntervalForType(QName type, Long startTxnTime, Long endTxnTime) {
    final Pair<Long, Long> intervalPair = new Pair<Long, Long>(LONG_ZERO, LONG_ZERO);
    Pair<Long, QName> typePair = qnameDAO.getQName(type);
    if (typePair == null) {
        // Return default
        return intervalPair;
    }
    TransactionQueryEntity txnQuery = new TransactionQueryEntity();
    txnQuery.setTypeQNameId(typePair.getFirst());
    txnQuery.setMinCommitTime(startTxnTime);
    txnQuery.setMaxCommitTime(endTxnTime);
    ResultHandler resultHandler = new ResultHandler() {

        @SuppressWarnings("unchecked")
        public void handleResult(ResultContext context) {
            Map<Long, Long> result = (Map<Long, Long>) context.getResultObject();
            if (result != null) {
                intervalPair.setFirst(result.get("minId"));
                intervalPair.setSecond(result.get("maxId"));
            }
        }
    };
    template.select(SELECT_NODE_INTERVAL_BY_TYPE, txnQuery, resultHandler);
    return intervalPair;
}
Also used : ResultContext(org.apache.ibatis.session.ResultContext) DefaultResultContext(org.apache.ibatis.executor.result.DefaultResultContext) QName(org.alfresco.service.namespace.QName) TransactionQueryEntity(org.alfresco.repo.domain.node.TransactionQueryEntity) ResultHandler(org.apache.ibatis.session.ResultHandler) HashMap(java.util.HashMap) Map(java.util.Map) Pair(org.alfresco.util.Pair)

Aggregations

TransactionQueryEntity (org.alfresco.repo.domain.node.TransactionQueryEntity)10 QName (org.alfresco.service.namespace.QName)3 RowBounds (org.apache.ibatis.session.RowBounds)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Transaction (org.alfresco.repo.domain.node.Transaction)1 Pair (org.alfresco.util.Pair)1 DefaultResultContext (org.apache.ibatis.executor.result.DefaultResultContext)1 ResultContext (org.apache.ibatis.session.ResultContext)1 ResultHandler (org.apache.ibatis.session.ResultHandler)1