Search in sources :

Example 6 with ChildAssocEntity

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

use of org.alfresco.repo.domain.node.ChildAssocEntity 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 8 with ChildAssocEntity

use of org.alfresco.repo.domain.node.ChildAssocEntity 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 9 with ChildAssocEntity

use of org.alfresco.repo.domain.node.ChildAssocEntity 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 10 with ChildAssocEntity

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

ChildAssocEntity (org.alfresco.repo.domain.node.ChildAssocEntity)20 NodeEntity (org.alfresco.repo.domain.node.NodeEntity)16 Serializable (java.io.Serializable)2 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 QName (org.alfresco.service.namespace.QName)2 RowBounds (org.apache.ibatis.session.RowBounds)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 Node (org.alfresco.repo.domain.node.Node)1 NodeExistsException (org.alfresco.repo.domain.node.NodeExistsException)1 VisitedNode (org.alfresco.repo.node.db.NodeHierarchyWalker.VisitedNode)1 InvalidTypeException (org.alfresco.service.cmr.dictionary.InvalidTypeException)1 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)1 StoreRef (org.alfresco.service.cmr.repository.StoreRef)1 AccessPermission (org.alfresco.service.cmr.security.AccessPermission)1 Extend (org.alfresco.traitextender.Extend)1