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