Search in sources :

Example 21 with NodeEntity

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

the class NodeDAOImpl method insertNodeAssoc.

@Override
protected Long insertNodeAssoc(Long sourceNodeId, Long targetNodeId, Long assocTypeQNameId, int assocIndex) {
    NodeAssocEntity assoc = new NodeAssocEntity();
    assoc.setVersion(1L);
    assoc.setTypeQNameId(assocTypeQNameId);
    // Source
    NodeEntity sourceNode = new NodeEntity();
    sourceNode.setId(sourceNodeId);
    assoc.setSourceNode(sourceNode);
    // Target
    NodeEntity targetNode = new NodeEntity();
    targetNode.setId(targetNodeId);
    assoc.setTargetNode(targetNode);
    // Index
    assoc.setAssocIndex(assocIndex);
    template.insert(INSERT_NODE_ASSOC, assoc);
    return assoc.getId();
}
Also used : NodeAssocEntity(org.alfresco.repo.domain.node.NodeAssocEntity) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 22 with NodeEntity

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

the class NodeDAOImpl method selectNodeAssocMaxIndex.

@Override
protected int selectNodeAssocMaxIndex(Long sourceNodeId, Long assocTypeQNameId) {
    NodeAssocEntity assoc = new NodeAssocEntity();
    // Source
    NodeEntity sourceNode = new NodeEntity();
    sourceNode.setId(sourceNodeId);
    assoc.setSourceNode(sourceNode);
    // Assoc
    assoc.setTypeQNameId(assocTypeQNameId);
    Integer maxIndex = template.selectOne(SELECT_NODE_ASSOCS_MAX_INDEX, assoc);
    return maxIndex == null ? 0 : maxIndex.intValue();
}
Also used : NodeAssocEntity(org.alfresco.repo.domain.node.NodeAssocEntity) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 23 with NodeEntity

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

the class NodeDAOImpl method selectPrimaryChildAcls.

@Override
public List<NodeIdAndAclId> selectPrimaryChildAcls(Long nodeId) {
    ChildAssocEntity assoc = new ChildAssocEntity();
    // Parent
    NodeEntity parentNode = new NodeEntity();
    parentNode.setId(nodeId);
    assoc.setParentNode(parentNode);
    // Primary
    assoc.setPrimary(true);
    return template.selectList(SELECT_NODE_PRIMARY_CHILD_ACLS, assoc);
}
Also used : ChildAssocEntity(org.alfresco.repo.domain.node.ChildAssocEntity) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 24 with NodeEntity

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

the class NodeDAOImpl method selectNodeAssocsBySourceAndPropertyValue.

@Override
protected List<NodeAssocEntity> selectNodeAssocsBySourceAndPropertyValue(Long sourceNodeId, Long typeQNameId, Long propertyQNameId, NodePropertyValue nodeValue) {
    NodeAssocEntity assoc = new NodeAssocEntity();
    // Source
    NodeEntity sourceNode = new NodeEntity();
    sourceNode.setId(sourceNodeId);
    assoc.setSourceNode(sourceNode);
    // Type
    assoc.setTypeQNameId(typeQNameId);
    // Property
    assoc.setPropertyQNameId(propertyQNameId);
    assoc.setPropertyValue(nodeValue);
    return template.selectList(SELECT_NODE_ASSOCS_BY_SOURCE_AND_PROPERTY_VALUE, assoc);
}
Also used : NodeAssocEntity(org.alfresco.repo.domain.node.NodeAssocEntity) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 25 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, Set<QName> assocTypeQNames, ChildAssocRefQueryCallback resultsCallback) {
    ChildAssocEntity assoc = new ChildAssocEntity();
    // Parent
    NodeEntity parentNode = new NodeEntity();
    parentNode.setId(parentNodeId);
    assoc.setParentNode(parentNode);
    // Type QNames
    Set<Long> assocTypeQNameIds = qnameDAO.convertQNamesToIds(assocTypeQNames, false);
    if (assocTypeQNameIds.size() == 0) {
        resultsCallback.done();
        // Shortcut as they don't exist
        return;
    }
    assoc.setTypeQNameIds(new ArrayList<Long>(assocTypeQNameIds));
    // 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)

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