Search in sources :

Example 1 with IdsEntity

use of org.alfresco.ibatis.IdsEntity in project alfresco-repository by Alfresco.

the class RepoUsageComponentImpl method updateUsers.

/**
 * Update number of users with appropriate locking
 */
private boolean updateUsers(boolean reset) {
    Long userCount = 0L;
    if (!reset) {
        // Count users
        IdsEntity idsParam = new IdsEntity();
        idsParam.setIdOne(qnameDAO.getOrCreateQName(ContentModel.ASPECT_PERSON_DISABLED).getFirst());
        idsParam.setIdTwo(qnameDAO.getOrCreateQName(ContentModel.TYPE_PERSON).getFirst());
        userCount = cannedQueryDAO.executeCountQuery(QUERY_NS, QUERY_SELECT_COUNT_PERSONS_NOT_DISABLED, idsParam);
        // We subtract one to cater for 'guest', which is implicit
        userCount = userCount > 0L ? userCount - 1L : 0L;
    }
    attributeService.setAttribute(new Long(System.currentTimeMillis()), KEY_USAGE_ROOT, KEY_USAGE_CURRENT, KEY_USAGE_LAST_UPDATE_USERS);
    attributeService.setAttribute(userCount, KEY_USAGE_ROOT, KEY_USAGE_CURRENT, KEY_USAGE_USERS);
    // Success
    return true;
}
Also used : IdsEntity(org.alfresco.ibatis.IdsEntity)

Example 2 with IdsEntity

use of org.alfresco.ibatis.IdsEntity in project alfresco-repository by Alfresco.

the class AuthorityDAOImpl method getGroupCount.

@Override
public long getGroupCount() {
    /* Unboxing accepted.  See CannedQueryDAO javadoc and implementation. */
    Pair<Long, QName> qnamePair = qnameDAO.getQName(ContentModel.TYPE_AUTHORITY_CONTAINER);
    if (qnamePair == null) {
        // No results
        return 0L;
    }
    IdsEntity ids = new IdsEntity();
    ids.setIdOne(qnamePair.getFirst());
    Long groupCount = cannedQueryDAO.executeCountQuery("alfresco.query.authorities", "select_AuthorityCount_Groups", ids);
    if (logger.isDebugEnabled()) {
        logger.debug("Counted authorities (groups):" + groupCount);
    }
    return groupCount;
}
Also used : IdsEntity(org.alfresco.ibatis.IdsEntity) QName(org.alfresco.service.namespace.QName)

Example 3 with IdsEntity

use of org.alfresco.ibatis.IdsEntity in project alfresco-repository by Alfresco.

the class ContentDataDAOImpl method deleteContentDataForNode.

@Override
public void deleteContentDataForNode(Long nodeId, Set<Long> qnameIds) {
    if (qnameIds.size() == 0) {
        // There will be no results
        return;
    }
    IdsEntity idsEntity = new IdsEntity();
    idsEntity.setIdOne(nodeId);
    idsEntity.setIds(new ArrayList<Long>(qnameIds));
    List<Long> ids = template.selectList(SELECT_CONTENT_DATA_BY_NODE_AND_QNAME, idsEntity);
    // Delete each one
    for (Long id : ids) {
        try {
            // Delete the ContentData entity
            deleteContentData(id);
        } catch (ConcurrencyFailureException e) {
        // The DB may return results even though the row has just been
        // deleted.  Since we are deleting the row, it doesn't matter
        // if it is deleted here or not.
        }
    }
}
Also used : IdsEntity(org.alfresco.ibatis.IdsEntity) ConcurrencyFailureException(org.springframework.dao.ConcurrencyFailureException)

Example 4 with IdsEntity

use of org.alfresco.ibatis.IdsEntity in project alfresco-repository by Alfresco.

the class NodeDAOImpl method updateNodesInStore.

@Override
protected int updateNodesInStore(Long txnId, Long storeId) {
    IdsEntity ids = new IdsEntity();
    ids.setIdOne(txnId);
    ids.setIdTwo(storeId);
    return template.update(UPDATE_NODES_IN_STORE, ids);
}
Also used : IdsEntity(org.alfresco.ibatis.IdsEntity)

Example 5 with IdsEntity

use of org.alfresco.ibatis.IdsEntity in project alfresco-repository by Alfresco.

the class NodeDAOImpl method selectNodesWithAspects.

@Override
protected void selectNodesWithAspects(List<Long> qnameIds, Long minNodeId, Long maxNodeId, final NodeRefQueryCallback resultsCallback) {
    @SuppressWarnings("rawtypes") ResultHandler resultHandler = new ResultHandler() {

        public void handleResult(ResultContext context) {
            NodeEntity entity = (NodeEntity) context.getResultObject();
            Pair<Long, NodeRef> nodePair = new Pair<Long, NodeRef>(entity.getId(), entity.getNodeRef());
            resultsCallback.handle(nodePair);
        }
    };
    IdsEntity parameters = new IdsEntity();
    parameters.setIdOne(minNodeId);
    parameters.setIdTwo(maxNodeId);
    parameters.setIds(qnameIds);
    template.select(SELECT_NODES_WITH_ASPECT_IDS, parameters, resultHandler);
}
Also used : ResultContext(org.apache.ibatis.session.ResultContext) DefaultResultContext(org.apache.ibatis.executor.result.DefaultResultContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) IdsEntity(org.alfresco.ibatis.IdsEntity) ResultHandler(org.apache.ibatis.session.ResultHandler) NodeEntity(org.alfresco.repo.domain.node.NodeEntity) Pair(org.alfresco.util.Pair)

Aggregations

IdsEntity (org.alfresco.ibatis.IdsEntity)17 QName (org.alfresco.service.namespace.QName)4 DefaultResultContext (org.apache.ibatis.executor.result.DefaultResultContext)3 ResultContext (org.apache.ibatis.session.ResultContext)3 ResultHandler (org.apache.ibatis.session.ResultHandler)3 ArrayList (java.util.ArrayList)2 NodePropertyEntity (org.alfresco.repo.domain.node.NodePropertyEntity)2 HashSet (java.util.HashSet)1 NodeEntity (org.alfresco.repo.domain.node.NodeEntity)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 Pair (org.alfresco.util.Pair)1 ConcurrencyFailureException (org.springframework.dao.ConcurrencyFailureException)1