Search in sources :

Example 6 with NodeEntity

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

the class NodeDAOImpl method selectChildAssocsByChildTypes.

@Override
protected void selectChildAssocsByChildTypes(Long parentNodeId, Set<QName> childNodeTypeQNames, ChildAssocRefQueryCallback resultsCallback) {
    ChildAssocEntity assoc = new ChildAssocEntity();
    // Parent
    NodeEntity parentNode = new NodeEntity();
    parentNode.setId(parentNodeId);
    assoc.setParentNode(parentNode);
    // Child Node Type QNames
    Set<Long> childNodeTypeQNameIds = qnameDAO.convertQNamesToIds(childNodeTypeQNames, false);
    if (childNodeTypeQNameIds.size() == 0) {
        resultsCallback.done();
        // Shortcut as they don't exist
        return;
    }
    assoc.setChildNodeTypeQNameIds(new ArrayList<Long>(childNodeTypeQNameIds));
    // Ordered
    assoc.setOrdered(resultsCallback.orderResults());
    ChildAssocResultHandler resultHandler = new ChildAssocResultHandler(resultsCallback);
    template.select(SELECT_CHILD_ASSOCS_OF_PARENT, assoc, resultHandler);
    resultsCallback.done();
}
Also used : ChildAssocEntity(org.alfresco.repo.domain.node.ChildAssocEntity) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 7 with NodeEntity

use of org.alfresco.repo.domain.node.NodeEntity 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)

Example 8 with NodeEntity

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

the class NodeDAOImpl method selectNodeByNodeRef.

@Override
protected NodeEntity selectNodeByNodeRef(NodeRef nodeRef) {
    StoreEntity store = new StoreEntity();
    StoreRef storeRef = nodeRef.getStoreRef();
    store.setProtocol(storeRef.getProtocol());
    store.setIdentifier(storeRef.getIdentifier());
    NodeEntity node = new NodeEntity();
    // Store
    node.setStore(store);
    // UUID
    String uuid = nodeRef.getId();
    if (uuid.length() > 36) {
        // Avoid query failure if someone passes in a made-up UUID.
        return null;
    // Originally for DB2 which has been EOLed, but might now be used by other databases.
    }
    node.setUuid(uuid);
    return template.selectOne(SELECT_NODE_BY_NODEREF, node);
}
Also used : StoreRef(org.alfresco.service.cmr.repository.StoreRef) StoreEntity(org.alfresco.repo.domain.node.StoreEntity) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 9 with NodeEntity

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

the class NodeDAOImpl method selectPrimaryParentAssocs.

@Override
protected List<ChildAssocEntity> selectPrimaryParentAssocs(Long childNodeId) {
    ChildAssocEntity assoc = new ChildAssocEntity();
    // Child
    NodeEntity childNode = new NodeEntity();
    childNode.setId(childNodeId);
    assoc.setChildNode(childNode);
    // Primary
    assoc.setPrimary(Boolean.TRUE);
    return template.selectList(SELECT_PARENT_ASSOCS_OF_CHILD, assoc);
}
Also used : ChildAssocEntity(org.alfresco.repo.domain.node.ChildAssocEntity) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 10 with NodeEntity

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

the class NodeDAOImpl method deleteNodeById.

@Override
protected int deleteNodeById(Long nodeId) {
    NodeEntity node = new NodeEntity();
    node.setId(nodeId);
    return template.delete(DELETE_NODE_BY_ID, node);
}
Also used : NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Aggregations

NodeEntity (org.alfresco.repo.domain.node.NodeEntity)29 ChildAssocEntity (org.alfresco.repo.domain.node.ChildAssocEntity)16 NodeAssocEntity (org.alfresco.repo.domain.node.NodeAssocEntity)5 ArrayList (java.util.ArrayList)4 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 Serializable (java.io.Serializable)3 HashMap (java.util.HashMap)3 Random (java.util.Random)3 CannedQueryDAOTest (org.alfresco.repo.domain.query.CannedQueryDAOTest)3 QName (org.alfresco.service.namespace.QName)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 NodeDAO (org.alfresco.repo.domain.node.NodeDAO)2 Pair (org.alfresco.util.Pair)2 DefaultResultContext (org.apache.ibatis.executor.result.DefaultResultContext)2 RowBounds (org.apache.ibatis.session.RowBounds)2 IdsEntity (org.alfresco.ibatis.IdsEntity)1 StoreEntity (org.alfresco.repo.domain.node.StoreEntity)1 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1