mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fixed SAIL-384: HEAD merge fallout: CMIS TCK
- Implemented NodeService.getAssoc(id) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20939 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -650,6 +650,12 @@
|
|||||||
targetNode.id = #targetNode.id#
|
targetNode.id = #targetNode.id#
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="select_NodeAssocById" parameterClass="NodeAssoc" resultMap="result_NodeAssoc">
|
||||||
|
<include refid="alfresco.node.select_NodeAssoc_Results"/>
|
||||||
|
where
|
||||||
|
assoc.id = #id#
|
||||||
|
</select>
|
||||||
|
|
||||||
<!-- Common results for result_ChildAssoc -->
|
<!-- Common results for result_ChildAssoc -->
|
||||||
<sql id="select_ChildAssoc_Results">
|
<sql id="select_ChildAssoc_Results">
|
||||||
select
|
select
|
||||||
|
@@ -2124,12 +2124,7 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
for (NodeAssocEntity nodeAssocEntity : nodeAssocEntities)
|
for (NodeAssocEntity nodeAssocEntity : nodeAssocEntities)
|
||||||
{
|
{
|
||||||
Long assocId = nodeAssocEntity.getId();
|
Long assocId = nodeAssocEntity.getId();
|
||||||
QName assocTypeQName = qnameDAO.getQName(nodeAssocEntity.getTypeQNameId()).getSecond();
|
AssociationRef assocRef = nodeAssocEntity.getAssociationRef(qnameDAO);
|
||||||
AssociationRef assocRef = new AssociationRef(
|
|
||||||
nodeAssocEntity.getId(),
|
|
||||||
nodeAssocEntity.getSourceNode().getNodeRef(),
|
|
||||||
assocTypeQName,
|
|
||||||
nodeAssocEntity.getTargetNode().getNodeRef());
|
|
||||||
results.add(new Pair<Long, AssociationRef>(assocId, assocRef));
|
results.add(new Pair<Long, AssociationRef>(assocId, assocRef));
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
@@ -2142,17 +2137,23 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
for (NodeAssocEntity nodeAssocEntity : nodeAssocEntities)
|
for (NodeAssocEntity nodeAssocEntity : nodeAssocEntities)
|
||||||
{
|
{
|
||||||
Long assocId = nodeAssocEntity.getId();
|
Long assocId = nodeAssocEntity.getId();
|
||||||
QName assocTypeQName = qnameDAO.getQName(nodeAssocEntity.getTypeQNameId()).getSecond();
|
AssociationRef assocRef = nodeAssocEntity.getAssociationRef(qnameDAO);
|
||||||
AssociationRef assocRef = new AssociationRef(
|
|
||||||
nodeAssocEntity.getId(),
|
|
||||||
nodeAssocEntity.getSourceNode().getNodeRef(),
|
|
||||||
assocTypeQName,
|
|
||||||
nodeAssocEntity.getTargetNode().getNodeRef());
|
|
||||||
results.add(new Pair<Long, AssociationRef>(assocId, assocRef));
|
results.add(new Pair<Long, AssociationRef>(assocId, assocRef));
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Pair<Long, AssociationRef> getNodeAssoc(Long assocId)
|
||||||
|
{
|
||||||
|
NodeAssocEntity nodeAssocEntity = selectNodeAssocById(assocId);
|
||||||
|
if (nodeAssocEntity == null)
|
||||||
|
{
|
||||||
|
throw new ConcurrencyFailureException("Assoc ID does not point to a valid association: " + assocId);
|
||||||
|
}
|
||||||
|
AssociationRef assocRef = nodeAssocEntity.getAssociationRef(qnameDAO);
|
||||||
|
return new Pair<Long, AssociationRef>(assocId, assocRef);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Child assocs
|
* Child assocs
|
||||||
*/
|
*/
|
||||||
@@ -3082,6 +3083,7 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
protected abstract int deleteNodeAssocsToAndFrom(Long nodeId, Set<Long> assocTypeQNameIds);
|
protected abstract int deleteNodeAssocsToAndFrom(Long nodeId, Set<Long> assocTypeQNameIds);
|
||||||
protected abstract List<NodeAssocEntity> selectNodeAssocsBySource(Long sourceNodeId);
|
protected abstract List<NodeAssocEntity> selectNodeAssocsBySource(Long sourceNodeId);
|
||||||
protected abstract List<NodeAssocEntity> selectNodeAssocsByTarget(Long targetNodeId);
|
protected abstract List<NodeAssocEntity> selectNodeAssocsByTarget(Long targetNodeId);
|
||||||
|
protected abstract NodeAssocEntity selectNodeAssocById(Long assocId);
|
||||||
protected abstract Long insertChildAssoc(ChildAssocEntity assoc);
|
protected abstract Long insertChildAssoc(ChildAssocEntity assoc);
|
||||||
protected abstract int deleteChildAssocById(Long assocId);
|
protected abstract int deleteChildAssocById(Long assocId);
|
||||||
protected abstract int updateChildAssocIndex(
|
protected abstract int updateChildAssocIndex(
|
||||||
|
@@ -26,6 +26,10 @@ package org.alfresco.repo.domain.node;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||||
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean for <b>alf_node_assoc</b> table.
|
* Bean for <b>alf_node_assoc</b> table.
|
||||||
*
|
*
|
||||||
@@ -61,6 +65,20 @@ public class NodeAssocEntity
|
|||||||
.append("]");
|
.append("]");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to fetch the association reference
|
||||||
|
*/
|
||||||
|
public AssociationRef getAssociationRef(QNameDAO qnameDAO)
|
||||||
|
{
|
||||||
|
QName assocTypeQName = qnameDAO.getQName(typeQNameId).getSecond();
|
||||||
|
AssociationRef assocRef = new AssociationRef(
|
||||||
|
id,
|
||||||
|
sourceNode.getNodeRef(),
|
||||||
|
assocTypeQName,
|
||||||
|
targetNode.getNodeRef());
|
||||||
|
return assocRef;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId()
|
public Long getId()
|
||||||
{
|
{
|
||||||
|
@@ -284,6 +284,13 @@ public interface NodeDAO extends NodeBulkLoader
|
|||||||
*/
|
*/
|
||||||
public Collection<Pair<Long, AssociationRef>> getTargetNodeAssocs(Long sourceNodeId);
|
public Collection<Pair<Long, AssociationRef>> getTargetNodeAssocs(Long sourceNodeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns a specific node association with the given ID
|
||||||
|
*
|
||||||
|
* @throws ConcurrencyFailureException if the association ID is invalid
|
||||||
|
*/
|
||||||
|
public Pair<Long, AssociationRef> getNodeAssoc(Long assocId);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Child Assocs
|
* Child Assocs
|
||||||
*/
|
*/
|
||||||
|
@@ -101,6 +101,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
|
|||||||
private static final String DELETE_NODE_ASSOCS_TO_AND_FROM = "alfresco.node.delete_NodeAssocsToAndFrom";
|
private static final String DELETE_NODE_ASSOCS_TO_AND_FROM = "alfresco.node.delete_NodeAssocsToAndFrom";
|
||||||
private static final String SELECT_NODE_ASSOCS_BY_SOURCE = "alfresco.node.select_NodeAssocsBySource";
|
private static final String SELECT_NODE_ASSOCS_BY_SOURCE = "alfresco.node.select_NodeAssocsBySource";
|
||||||
private static final String SELECT_NODE_ASSOCS_BY_TARGET = "alfresco.node.select_NodeAssocsByTarget";
|
private static final String SELECT_NODE_ASSOCS_BY_TARGET = "alfresco.node.select_NodeAssocsByTarget";
|
||||||
|
private static final String SELECT_NODE_ASSOC_BY_ID = "alfresco.node.select_NodeAssocById";
|
||||||
private static final String SELECT_NODE_PRIMARY_CHILD_ACLS = "alfresco.node.select_NodePrimaryChildAcls";
|
private static final String SELECT_NODE_PRIMARY_CHILD_ACLS = "alfresco.node.select_NodePrimaryChildAcls";
|
||||||
private static final String INSERT_CHILD_ASSOC = "alfresco.node.insert_ChildAssoc";
|
private static final String INSERT_CHILD_ASSOC = "alfresco.node.insert_ChildAssoc";
|
||||||
private static final String DELETE_CHILD_ASSOC_BY_ID = "alfresco.node.delete_ChildAssocById";
|
private static final String DELETE_CHILD_ASSOC_BY_ID = "alfresco.node.delete_ChildAssocById";
|
||||||
@@ -657,6 +658,15 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
|
|||||||
return (List<NodeAssocEntity>) template.queryForList(SELECT_NODE_ASSOCS_BY_TARGET, assoc);
|
return (List<NodeAssocEntity>) template.queryForList(SELECT_NODE_ASSOCS_BY_TARGET, assoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected NodeAssocEntity selectNodeAssocById(Long assocId)
|
||||||
|
{
|
||||||
|
NodeAssocEntity assoc = new NodeAssocEntity();
|
||||||
|
assoc.setId(assocId);
|
||||||
|
|
||||||
|
return (NodeAssocEntity) template.queryForObject(SELECT_NODE_ASSOC_BY_ID, assoc);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Long insertChildAssoc(ChildAssocEntity assoc)
|
protected Long insertChildAssoc(ChildAssocEntity assoc)
|
||||||
{
|
{
|
||||||
|
@@ -2200,6 +2200,10 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
|||||||
sourceRef,
|
sourceRef,
|
||||||
anotherTargetRef,
|
anotherTargetRef,
|
||||||
ASSOC_TYPE_QNAME_TEST_NEXT);
|
ASSOC_TYPE_QNAME_TEST_NEXT);
|
||||||
|
Long anotherAssocId = anotherAssocRef.getId();
|
||||||
|
assertNotNull("Created association does not have an ID", anotherAssocId);
|
||||||
|
AssociationRef anotherAssocRefCheck = nodeService.getAssoc(anotherAssocId);
|
||||||
|
assertEquals("Assoc fetched by ID is incorrect.", anotherAssocRef, anotherAssocRefCheck);
|
||||||
|
|
||||||
// remove assocs
|
// remove assocs
|
||||||
List<AssociationRef> assocs = nodeService.getTargetAssocs(sourceRef, ASSOC_TYPE_QNAME_TEST_NEXT);
|
List<AssociationRef> assocs = nodeService.getTargetAssocs(sourceRef, ASSOC_TYPE_QNAME_TEST_NEXT);
|
||||||
@@ -2222,6 +2226,12 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
|||||||
List<AssociationRef> targetAssocs = nodeService.getTargetAssocs(sourceRef, qname);
|
List<AssociationRef> targetAssocs = nodeService.getTargetAssocs(sourceRef, qname);
|
||||||
assertEquals("Incorrect number of targets", 1, targetAssocs.size());
|
assertEquals("Incorrect number of targets", 1, targetAssocs.size());
|
||||||
assertTrue("Target not found", targetAssocs.contains(assocRef));
|
assertTrue("Target not found", targetAssocs.contains(assocRef));
|
||||||
|
|
||||||
|
// Check that IDs are present
|
||||||
|
for (AssociationRef targetAssoc : targetAssocs)
|
||||||
|
{
|
||||||
|
assertNotNull("Association does not have ID", targetAssoc.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetSourceAssocs() throws Exception
|
public void testGetSourceAssocs() throws Exception
|
||||||
@@ -2234,6 +2244,12 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
|||||||
List<AssociationRef> sourceAssocs = nodeService.getSourceAssocs(targetRef, qname);
|
List<AssociationRef> sourceAssocs = nodeService.getSourceAssocs(targetRef, qname);
|
||||||
assertEquals("Incorrect number of source assocs", 1, sourceAssocs.size());
|
assertEquals("Incorrect number of source assocs", 1, sourceAssocs.size());
|
||||||
assertTrue("Source not found", sourceAssocs.contains(assocRef));
|
assertTrue("Source not found", sourceAssocs.contains(assocRef));
|
||||||
|
|
||||||
|
// Check that IDs are present
|
||||||
|
for (AssociationRef sourceAssoc : sourceAssocs)
|
||||||
|
{
|
||||||
|
assertNotNull("Association does not have ID", sourceAssoc.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1786,8 +1786,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
|||||||
|
|
||||||
public AssociationRef getAssoc(Long id)
|
public AssociationRef getAssoc(Long id)
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException("TODO: Implement the method for the new DAO implementation.");
|
return nodeDAO.getNodeAssoc(id).getSecond();
|
||||||
// return nodeDaoService.getNodeAssocOrNull(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AssociationRef> getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern)
|
public List<AssociationRef> getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern)
|
||||||
|
Reference in New Issue
Block a user