Search in sources :

Example 11 with NodeEntity

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

the class NodeDAOImpl method selectParentAssocs.

@Override
protected List<ChildAssocEntity> selectParentAssocs(Long childNodeId) {
    ChildAssocEntity assoc = new ChildAssocEntity();
    // Child
    NodeEntity childNode = new NodeEntity();
    childNode.setId(childNodeId);
    assoc.setChildNode(childNode);
    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 12 with NodeEntity

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

the class NodeDAOImpl method countChildAssocsByParent.

public int countChildAssocsByParent(Long parentNodeId, boolean isPrimary) {
    NodeEntity parentNode = new NodeEntity();
    parentNode.setId(parentNodeId);
    ChildAssocEntity childAssoc = new ChildAssocEntity();
    childAssoc.setParentNode(parentNode);
    childAssoc.setPrimary(Boolean.valueOf(isPrimary));
    return template.selectOne(COUNT_CHILD_ASSOC_BY_PARENT_ID, childAssoc);
}
Also used : ChildAssocEntity(org.alfresco.repo.domain.node.ChildAssocEntity) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 13 with NodeEntity

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

the class NodeDAOImpl method selectChildAssocs.

@Override
protected void selectChildAssocs(Long parentNodeId, QName assocTypeQName, Collection<String> childNames, ChildAssocRefQueryCallback resultsCallback) {
    if (childNames.size() == 0) {
        resultsCallback.done();
        return;
    } else if (childNames.size() > 1000) {
        throw new IllegalArgumentException("Unable to process more than 1000 child names in getChildAssocs");
    }
    // Work out the child names to query on
    final Set<String> childNamesShort = new HashSet<String>(childNames.size());
    final List<Long> childNamesCrc = new ArrayList<Long>(childNames.size());
    for (String childName : childNames) {
        String childNameLower = childName.toLowerCase();
        String childNameShort = ChildAssocEntity.getChildNodeNameShort(childNameLower);
        Long childNameCrc = ChildAssocEntity.getChildNodeNameCrc(childNameLower);
        childNamesShort.add(childNameShort);
        childNamesCrc.add(childNameCrc);
    }
    // Create a filter that checks that the name CRC is present
    ChildAssocResultHandlerFilter filter = new ChildAssocResultHandlerFilter() {

        public boolean isResult(ChildAssocEntity assoc) {
            return childNamesShort.contains(assoc.getChildNodeName());
        }
    };
    ChildAssocEntity assoc = new ChildAssocEntity();
    // Parent
    NodeEntity parentNode = new NodeEntity();
    parentNode.setId(parentNodeId);
    assoc.setParentNode(parentNode);
    // Type QName
    if (assocTypeQName != null) {
        if (!assoc.setTypeQNameAll(qnameDAO, assocTypeQName, false)) {
            resultsCallback.done();
            // Shortcut
            return;
        }
    }
    // Child names
    assoc.setChildNodeNameCrcs(childNamesCrc);
    // Ordered
    assoc.setOrdered(resultsCallback.orderResults());
    ChildAssocResultHandler resultHandler = new ChildAssocResultHandler(filter, resultsCallback);
    template.select(SELECT_CHILD_ASSOCS_OF_PARENT, assoc, resultHandler);
    resultsCallback.done();
}
Also used : ChildAssocEntity(org.alfresco.repo.domain.node.ChildAssocEntity) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 14 with NodeEntity

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

the class NodeDAOImpl method selectChildNodeIds.

@Override
protected List<ChildAssocEntity> selectChildNodeIds(Long nodeId, Boolean isPrimary, Long minChildNodeIdInclusive, int maxResults) {
    ChildAssocEntity assoc = new ChildAssocEntity();
    NodeEntity parentNode = new NodeEntity();
    parentNode.setId(nodeId);
    NodeEntity childNode = new NodeEntity();
    childNode.setId(minChildNodeIdInclusive);
    assoc.setParentNode(parentNode);
    assoc.setPrimary(isPrimary);
    assoc.setChildNode(childNode);
    RowBounds rowBounds = new RowBounds(0, maxResults);
    return template.selectList(SELECT_CHILD_NODE_IDS, assoc, rowBounds);
}
Also used : ChildAssocEntity(org.alfresco.repo.domain.node.ChildAssocEntity) RowBounds(org.apache.ibatis.session.RowBounds) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 15 with NodeEntity

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

the class NodeDAOImpl method updatePrimaryParentAssocs.

@Override
protected int updatePrimaryParentAssocs(Long childNodeId, Long parentNodeId, QName assocTypeQName, QName assocQName, String childNodeName) {
    ChildAssocEntity assoc = new ChildAssocEntity();
    // Parent
    NodeEntity parentNode = new NodeEntity();
    parentNode.setId(parentNodeId);
    assoc.setParentNode(parentNode);
    // Child
    NodeEntity childNode = new NodeEntity();
    childNode.setId(childNodeId);
    assoc.setChildNode(childNode);
    // Type QName
    if (assocTypeQName != null) {
        assoc.setTypeQNameAll(qnameDAO, assocTypeQName, true);
        // Have to recalculate the crc values for the association
        assoc.setChildNodeNameAll(dictionaryService, assocTypeQName, childNodeName);
    }
    // QName
    if (assocQName != null) {
        assoc.setQNameAll(qnameDAO, assocQName, true);
    }
    // Primary
    assoc.setPrimary(Boolean.TRUE);
    return template.update(UPDATE_PARENT_ASSOCS_OF_CHILD, assoc);
}
Also used : ChildAssocEntity(org.alfresco.repo.domain.node.ChildAssocEntity) 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