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);
}
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);
}
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();
}
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;
}
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);
}
Aggregations