Search in sources :

Example 11 with ChildAssocEntity

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

the class NodeDAOImpl method selectChildAssoc.

@Override
protected ChildAssocEntity selectChildAssoc(Long parentNodeId, QName assocTypeQName, String childName) {
    ChildAssocEntity assoc = new ChildAssocEntity();
    // Parent
    NodeEntity parentNode = new NodeEntity();
    parentNode.setId(parentNodeId);
    assoc.setParentNode(parentNode);
    // Type QName
    if (!assoc.setTypeQNameAll(qnameDAO, assocTypeQName, false)) {
        // Shortcut
        return null;
    }
    // Child name
    assoc.setChildNodeNameAll(null, assocTypeQName, childName);
    // Ordered
    assoc.setOrdered(false);
    // Note: This single results was assumed from inception of the original method.  It's correct.
    return template.selectOne(SELECT_CHILD_ASSOC_OF_PARENT_BY_NAME, assoc);
}
Also used : ChildAssocEntity(org.alfresco.repo.domain.node.ChildAssocEntity) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 12 with ChildAssocEntity

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

the class NodeDAOImpl method selectChildAssoc.

@Override
protected List<ChildAssocEntity> selectChildAssoc(Long parentNodeId, Long childNodeId, QName assocTypeQName, QName assocQName) {
    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 (!assoc.setTypeQNameAll(qnameDAO, assocTypeQName, false)) {
        // Shortcut
        return Collections.emptyList();
    }
    // QName
    if (!assoc.setQNameAll(qnameDAO, assocQName, false)) {
        // Shortcut
        return Collections.emptyList();
    }
    // Ordered
    assoc.setOrdered(false);
    return template.selectList(SELECT_CHILD_ASSOCS_OF_PARENT, assoc);
}
Also used : ChildAssocEntity(org.alfresco.repo.domain.node.ChildAssocEntity) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 13 with ChildAssocEntity

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

the class NodeDAOImpl method selectChildAssocsWithoutParentAssocsOfType.

@Override
protected void selectChildAssocsWithoutParentAssocsOfType(Long parentNodeId, QName assocTypeQName, ChildAssocRefQueryCallback resultsCallback) {
    ChildAssocEntity assoc = new ChildAssocEntity();
    // Parent
    NodeEntity parentNode = new NodeEntity();
    parentNode.setId(parentNodeId);
    assoc.setParentNode(parentNode);
    // Type QName
    if (!assoc.setTypeQNameAll(qnameDAO, assocTypeQName, false)) {
        resultsCallback.done();
        // Shortcut
        return;
    }
    // Ordered
    assoc.setOrdered(resultsCallback.orderResults());
    ChildAssocResultHandler resultHandler = new ChildAssocResultHandler(resultsCallback);
    template.select(SELECT_CHILD_ASSOCS_OF_PARENT_WITHOUT_PARENT_ASSOCS_OF_TYPE, assoc, resultHandler);
    resultsCallback.done();
}
Also used : ChildAssocEntity(org.alfresco.repo.domain.node.ChildAssocEntity) NodeEntity(org.alfresco.repo.domain.node.NodeEntity)

Example 14 with ChildAssocEntity

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

the class DbNodeServiceImpl method createNode.

/**
 * {@inheritDoc}
 */
@Extend(traitAPI = NodeServiceTrait.class, extensionAPI = NodeServiceExtension.class)
public ChildAssociationRef createNode(NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName, Map<QName, Serializable> properties) {
    // The node(s) involved may not be pending deletion
    checkPendingDelete(parentRef);
    ParameterCheck.mandatory("parentRef", parentRef);
    ParameterCheck.mandatory("assocTypeQName", assocTypeQName);
    ParameterCheck.mandatory("assocQName", assocQName);
    ParameterCheck.mandatory("nodeTypeQName", nodeTypeQName);
    if (assocQName.getLocalName().length() > QName.MAX_LENGTH) {
        throw new IllegalArgumentException("Localname is too long. Length of " + assocQName.getLocalName().length() + " exceeds the maximum of " + QName.MAX_LENGTH);
    }
    // Get the parent node
    Pair<Long, NodeRef> parentNodePair = getNodePairNotNull(parentRef);
    StoreRef parentStoreRef = parentRef.getStoreRef();
    // null property map is allowed
    if (properties == null) {
        properties = Collections.emptyMap();
    }
    // get an ID for the node
    String newUuid = generateGuid(properties);
    // Invoke policy behaviour
    invokeBeforeCreateNode(parentRef, assocTypeQName, assocQName, nodeTypeQName);
    // check the node type
    TypeDefinition nodeTypeDef = dictionaryService.getType(nodeTypeQName);
    if (nodeTypeDef == null) {
        throw new InvalidTypeException(nodeTypeQName);
    }
    // Ensure child uniqueness
    String newName = extractNameProperty(properties);
    // Get the thread's locale
    Locale locale = I18NUtil.getLocale();
    // create the node instance
    ChildAssocEntity assoc = nodeDAO.newNode(parentNodePair.getFirst(), assocTypeQName, assocQName, parentStoreRef, newUuid, nodeTypeQName, locale, newName, properties);
    ChildAssociationRef childAssocRef = assoc.getRef(qnameDAO);
    Pair<Long, NodeRef> childNodePair = assoc.getChildNode().getNodePair();
    addAspectsAndProperties(childNodePair, nodeTypeQName, null, Collections.<QName>emptySet(), Collections.<QName, Serializable>emptyMap(), Collections.<QName>emptySet(), properties, true, false);
    Map<QName, Serializable> propertiesAfter = nodeDAO.getNodeProperties(childNodePair.getFirst());
    // Propagate timestamps
    propagateTimeStamps(childAssocRef);
    // Invoke policy behaviour
    invokeOnCreateNode(childAssocRef);
    invokeOnCreateChildAssociation(childAssocRef, true);
    Map<QName, Serializable> propertiesBefore = PropertyMap.EMPTY_MAP;
    invokeOnUpdateProperties(childAssocRef.getChildRef(), propertiesBefore, propertiesAfter);
    // Ensure that the parent node has the required aspects
    addAspectsAndPropertiesAssoc(parentNodePair, assocTypeQName, null, null, null, null, false);
    // done
    return childAssocRef;
}
Also used : Locale(java.util.Locale) StoreRef(org.alfresco.service.cmr.repository.StoreRef) Serializable(java.io.Serializable) QName(org.alfresco.service.namespace.QName) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition) NodeRef(org.alfresco.service.cmr.repository.NodeRef) ChildAssocEntity(org.alfresco.repo.domain.node.ChildAssocEntity) InvalidTypeException(org.alfresco.service.cmr.dictionary.InvalidTypeException) Extend(org.alfresco.traitextender.Extend)

Example 15 with ChildAssocEntity

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

the class NodeDAOImpl method updateChildAssocIndex.

@Override
protected int updateChildAssocIndex(Long parentNodeId, Long childNodeId, QName assocTypeQName, QName assocQName, int index) {
    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
    assoc.setTypeQNameAll(qnameDAO, assocTypeQName, true);
    // QName
    assoc.setQNameAll(qnameDAO, assocQName, true);
    // Index
    assoc.setAssocIndex(index);
    return template.update(UPDATE_CHILD_ASSOCS_INDEX, 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