mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged 5.1-MNT1 (5.1.0) to HEAD (5.1)
115460 adavis: Merged 5.1.N (5.1.1) to 5.1-MNT1 (5.1.0) 113727 amorarasu: Merged 5.0.N (5.0.3) to 5.1.N (5.1.1) 113684 adavis: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.3) (PARTIAL MERGE) 113603 cturlica: Merged DEV to V4.2-BUG-FIX (4.2.6) 113602 cturlica: MNT-14504: Cloud pull process not working after large delete git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@115670 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -823,10 +823,24 @@
|
|||||||
targetNode.id = #{id}
|
targetNode.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="select_NodeAssocsBySource" parameterType="NodeAssoc" resultMap="result_NodeAssoc">
|
<select id="select_NodeAssocsBySourceAndPropertyValue" parameterType="NodeAssoc" resultMap="result_NodeAssoc">
|
||||||
<include refid="alfresco.node.select_NodeAssoc_Results"/>
|
<include refid="alfresco.node.select_NodeAssoc_Results"/>
|
||||||
|
|
||||||
|
<if test="propertyQNameId != null">
|
||||||
|
join alf_node_properties prop on (targetNode.id = prop.node_id)
|
||||||
|
</if>
|
||||||
where
|
where
|
||||||
sourceNode.id = #{sourceNode.id}
|
sourceNode.id = #{sourceNode.id}
|
||||||
|
|
||||||
|
<if test="propertyQNameId != null">
|
||||||
|
and prop.qname_id = #{propertyQNameId}
|
||||||
|
|
||||||
|
<if test="propertyValue.persistedType == 6">and prop.string_value = #{propertyValue.stringValue}</if>
|
||||||
|
<if test="propertyValue.persistedType == 5">and prop.double_value = #{propertyValue.doubleValue}</if>
|
||||||
|
<if test="propertyValue.persistedType == 3">and prop.long_value = #{propertyValue.longValue}</if>
|
||||||
|
<if test="propertyValue.persistedType == 1">and prop.boolean_value = #{propertyValue.booleanValue}</if>
|
||||||
|
</if>
|
||||||
|
|
||||||
<if test="typeQNameId != null">
|
<if test="typeQNameId != null">
|
||||||
<![CDATA[and assoc.type_qname_id = #{typeQNameId}]]>
|
<![CDATA[and assoc.type_qname_id = #{typeQNameId}]]>
|
||||||
<include refid="alfresco.node.select_NodeAssoc_OrderBy"/>
|
<include refid="alfresco.node.select_NodeAssoc_OrderBy"/>
|
||||||
|
@@ -3003,6 +3003,67 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Pair<Long, AssociationRef>> getTargetAssocsByPropertyValue(Long sourceNodeId, QName typeQName, QName propertyQName, Serializable propertyValue)
|
||||||
|
{
|
||||||
|
Long typeQNameId = null;
|
||||||
|
if (typeQName != null)
|
||||||
|
{
|
||||||
|
Pair<Long, QName> typeQNamePair = qnameDAO.getQName(typeQName);
|
||||||
|
if (typeQNamePair == null)
|
||||||
|
{
|
||||||
|
// No such QName
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
typeQNameId = typeQNamePair.getFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
Long propertyQNameId = null;
|
||||||
|
NodePropertyValue nodeValue = null;
|
||||||
|
if (propertyQName != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
Pair<Long, QName> propQNamePair = qnameDAO.getQName(propertyQName);
|
||||||
|
if (propQNamePair == null)
|
||||||
|
{
|
||||||
|
// No such QName
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
propertyQNameId = propQNamePair.getFirst();
|
||||||
|
|
||||||
|
PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName);
|
||||||
|
|
||||||
|
nodeValue = nodePropertyHelper.makeNodePropertyValue(propertyDef, propertyValue);
|
||||||
|
if (nodeValue != null)
|
||||||
|
{
|
||||||
|
switch (nodeValue.getPersistedType())
|
||||||
|
{
|
||||||
|
case 1: // Boolean
|
||||||
|
case 3: // long
|
||||||
|
case 5: // double
|
||||||
|
case 6: // string
|
||||||
|
// no floats due to the range errors testing equality on a float.
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("method not supported for persisted value type " + nodeValue.getPersistedType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<NodeAssocEntity> nodeAssocEntities = selectNodeAssocsBySourceAndPropertyValue(sourceNodeId, typeQNameId, propertyQNameId, nodeValue);
|
||||||
|
|
||||||
|
// Create custom result
|
||||||
|
List<Pair<Long, AssociationRef>> results = new ArrayList<Pair<Long, AssociationRef>>(nodeAssocEntities.size());
|
||||||
|
for (NodeAssocEntity nodeAssocEntity : nodeAssocEntities)
|
||||||
|
{
|
||||||
|
Long assocId = nodeAssocEntity.getId();
|
||||||
|
AssociationRef assocRef = nodeAssocEntity.getAssociationRef(qnameDAO);
|
||||||
|
results.add(new Pair<Long, AssociationRef>(assocId, assocRef));
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pair<Long, AssociationRef> getNodeAssocOrNull(Long assocId)
|
public Pair<Long, AssociationRef> getNodeAssocOrNull(Long assocId)
|
||||||
{
|
{
|
||||||
@@ -4871,6 +4932,7 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
protected abstract int deleteNodeAssocs(List<Long> ids);
|
protected abstract int deleteNodeAssocs(List<Long> ids);
|
||||||
protected abstract List<NodeAssocEntity> selectNodeAssocs(Long nodeId);
|
protected abstract List<NodeAssocEntity> selectNodeAssocs(Long nodeId);
|
||||||
protected abstract List<NodeAssocEntity> selectNodeAssocsBySource(Long sourceNodeId, Long typeQNameId);
|
protected abstract List<NodeAssocEntity> selectNodeAssocsBySource(Long sourceNodeId, Long typeQNameId);
|
||||||
|
protected abstract List<NodeAssocEntity> selectNodeAssocsBySourceAndPropertyValue(Long sourceNodeId, Long typeQNameId, Long propertyQNameId, NodePropertyValue nodeValue);
|
||||||
protected abstract List<NodeAssocEntity> selectNodeAssocsByTarget(Long targetNodeId, Long typeQNameId);
|
protected abstract List<NodeAssocEntity> selectNodeAssocsByTarget(Long targetNodeId, Long typeQNameId);
|
||||||
protected abstract NodeAssocEntity selectNodeAssocById(Long assocId);
|
protected abstract NodeAssocEntity selectNodeAssocById(Long assocId);
|
||||||
protected abstract int selectNodeAssocMaxIndex(Long sourceNodeId, Long assocTypeQNameId);
|
protected abstract int selectNodeAssocMaxIndex(Long sourceNodeId, Long assocTypeQNameId);
|
||||||
|
@@ -39,7 +39,11 @@ public class NodeAssocEntity
|
|||||||
private Long typeQNameId;
|
private Long typeQNameId;
|
||||||
private int assocIndex;
|
private int assocIndex;
|
||||||
private List<Long> typeQNameIds;
|
private List<Long> typeQNameIds;
|
||||||
|
|
||||||
|
// Supplemental query-related parameters
|
||||||
|
private Long propertyQNameId;
|
||||||
|
private NodePropertyValue propertyValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required default constructor
|
* Required default constructor
|
||||||
*/
|
*/
|
||||||
@@ -145,4 +149,25 @@ public class NodeAssocEntity
|
|||||||
{
|
{
|
||||||
this.typeQNameIds = typeQNameIds;
|
this.typeQNameIds = typeQNameIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getPropertyQNameId()
|
||||||
|
{
|
||||||
|
return propertyQNameId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPropertyQNameId(Long propertyQNameId)
|
||||||
|
{
|
||||||
|
this.propertyQNameId = propertyQNameId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodePropertyValue getPropertyValue()
|
||||||
|
{
|
||||||
|
return propertyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPropertyValue(NodePropertyValue propertyValue)
|
||||||
|
{
|
||||||
|
this.propertyValue = propertyValue;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -457,6 +457,17 @@ public interface NodeDAO extends NodeBulkLoader
|
|||||||
*/
|
*/
|
||||||
public Collection<Pair<Long, AssociationRef>> getTargetNodeAssocs(Long sourceNodeId, QName typeQName);
|
public Collection<Pair<Long, AssociationRef>> getTargetNodeAssocs(Long sourceNodeId, QName typeQName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get target associations by type of the association, property name and value.
|
||||||
|
*
|
||||||
|
* @param sourceNodeId the source of the association
|
||||||
|
* @param typeQName the type of the association (<tt>null</tt> allowed)
|
||||||
|
* @param propertyQName property QName (<tt>null</tt> allowed)
|
||||||
|
* @param propertyValue property value (<tt>null</tt> allowed only if the <b>propertyQName</b> is <tt>null</tt>)
|
||||||
|
* @return Returns all the node associations where the node is the <b>source</b>.
|
||||||
|
*/
|
||||||
|
public Collection<Pair<Long, AssociationRef>> getTargetAssocsByPropertyValue(Long sourceNodeId, QName typeQName, QName propertyQName, Serializable propertyValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns a specific node association with the given ID
|
* @return Returns a specific node association with the given ID
|
||||||
* or <tt>null</tt> if it doesn't exist
|
* or <tt>null</tt> if it doesn't exist
|
||||||
|
@@ -109,7 +109,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
|
|||||||
private static final String DELETE_NODE_ASSOC = "alfresco.node.delete_NodeAssoc";
|
private static final String DELETE_NODE_ASSOC = "alfresco.node.delete_NodeAssoc";
|
||||||
private static final String DELETE_NODE_ASSOCS = "alfresco.node.delete_NodeAssocs";
|
private static final String DELETE_NODE_ASSOCS = "alfresco.node.delete_NodeAssocs";
|
||||||
private static final String SELECT_NODE_ASSOCS = "alfresco.node.select_NodeAssocs";
|
private static final String SELECT_NODE_ASSOCS = "alfresco.node.select_NodeAssocs";
|
||||||
private static final String SELECT_NODE_ASSOCS_BY_SOURCE = "alfresco.node.select_NodeAssocsBySource";
|
private static final String SELECT_NODE_ASSOCS_BY_SOURCE_AND_PROPERTY_VALUE = "alfresco.node.select_NodeAssocsBySourceAndPropertyValue";
|
||||||
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_ASSOC_BY_ID = "alfresco.node.select_NodeAssocById";
|
||||||
private static final String SELECT_NODE_ASSOCS_MAX_INDEX = "alfresco.node.select_NodeAssocsMaxId";
|
private static final String SELECT_NODE_ASSOCS_MAX_INDEX = "alfresco.node.select_NodeAssocsMaxId";
|
||||||
@@ -754,9 +754,15 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
|
|||||||
return template.selectList(SELECT_NODE_ASSOCS, node);
|
return template.selectList(SELECT_NODE_ASSOCS, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
protected List<NodeAssocEntity> selectNodeAssocsBySource(Long sourceNodeId, Long typeQNameId)
|
protected List<NodeAssocEntity> selectNodeAssocsBySource(Long sourceNodeId, Long typeQNameId)
|
||||||
|
{
|
||||||
|
return selectNodeAssocsBySourceAndPropertyValue(sourceNodeId, typeQNameId, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
protected List<NodeAssocEntity> selectNodeAssocsBySourceAndPropertyValue(Long sourceNodeId, Long typeQNameId, Long propertyQNameId, NodePropertyValue nodeValue)
|
||||||
{
|
{
|
||||||
NodeAssocEntity assoc = new NodeAssocEntity();
|
NodeAssocEntity assoc = new NodeAssocEntity();
|
||||||
// Source
|
// Source
|
||||||
@@ -765,8 +771,12 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
|
|||||||
assoc.setSourceNode(sourceNode);
|
assoc.setSourceNode(sourceNode);
|
||||||
// Type
|
// Type
|
||||||
assoc.setTypeQNameId(typeQNameId);
|
assoc.setTypeQNameId(typeQNameId);
|
||||||
|
|
||||||
return template.selectList(SELECT_NODE_ASSOCS_BY_SOURCE, assoc);
|
// Property
|
||||||
|
assoc.setPropertyQNameId(propertyQNameId);
|
||||||
|
assoc.setPropertyValue(nodeValue);
|
||||||
|
|
||||||
|
return (List<NodeAssocEntity>) template.selectList(SELECT_NODE_ASSOCS_BY_SOURCE_AND_PROPERTY_VALUE, assoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@@ -2238,6 +2238,41 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
|||||||
return nodeAssocRefs;
|
return nodeAssocRefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AssociationRef> getTargetAssocsByPropertyValue(NodeRef sourceRef, QNamePattern qnamePattern, QName propertyQName, Serializable propertyValue)
|
||||||
|
{
|
||||||
|
Pair<Long, NodeRef> sourceNodePair = getNodePairNotNull(sourceRef);
|
||||||
|
Long sourceNodeId = sourceNodePair.getFirst();
|
||||||
|
|
||||||
|
QName qnameFilter = null;
|
||||||
|
if (qnamePattern instanceof QName)
|
||||||
|
{
|
||||||
|
qnameFilter = (QName) qnamePattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the QName is not one of the "special" system maintained ones.
|
||||||
|
if (getChildAssocsByPropertyValueBannedProps.contains(propertyQName))
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"getTargetAssocsByPropertyValue does not allow search of system maintained properties: " + propertyQName);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection<Pair<Long, AssociationRef>> assocPairs = nodeDAO.getTargetAssocsByPropertyValue(sourceNodeId, qnameFilter, propertyQName, propertyValue);
|
||||||
|
List<AssociationRef> nodeAssocRefs = new ArrayList<AssociationRef>(assocPairs.size());
|
||||||
|
for (Pair<Long, AssociationRef> assocPair : assocPairs)
|
||||||
|
{
|
||||||
|
AssociationRef assocRef = assocPair.getSecond();
|
||||||
|
// check qname pattern, if not already filtered
|
||||||
|
if (qnameFilter == null && !qnamePattern.isMatch(assocRef.getTypeQName()))
|
||||||
|
{
|
||||||
|
continue; // the assoc name doesn't match the pattern given
|
||||||
|
}
|
||||||
|
nodeAssocRefs.add(assocRef);
|
||||||
|
}
|
||||||
|
// done
|
||||||
|
return nodeAssocRefs;
|
||||||
|
}
|
||||||
|
|
||||||
public List<AssociationRef> getSourceAssocs(NodeRef targetRef, QNamePattern qnamePattern)
|
public List<AssociationRef> getSourceAssocs(NodeRef targetRef, QNamePattern qnamePattern)
|
||||||
{
|
{
|
||||||
Pair<Long, NodeRef> targetNodePair = getNodePairNotNull(targetRef);
|
Pair<Long, NodeRef> targetNodePair = getNodePairNotNull(targetRef);
|
||||||
|
@@ -238,4 +238,57 @@ public class Node2ServiceImpl extends NodeServiceImpl implements NodeService, Ve
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* Implementation for version store v2
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AssociationRef> getTargetAssocsByPropertyValue(NodeRef sourceRef, QNamePattern qnamePattern, QName propertyQName, Serializable propertyValue)
|
||||||
|
{
|
||||||
|
// If lightWeightVersionStore call default version store implementation.
|
||||||
|
if (sourceRef.getStoreRef().getIdentifier().equals(VersionModel.STORE_ID))
|
||||||
|
{
|
||||||
|
return super.getTargetAssocsByPropertyValue(sourceRef, qnamePattern, propertyQName, propertyValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the assoc references from the version store.
|
||||||
|
List<ChildAssociationRef> childAssocRefs = this.dbNodeService.getChildAssocs(VersionUtil.convertNodeRef(sourceRef),
|
||||||
|
Version2Model.CHILD_QNAME_VERSIONED_ASSOCS, qnamePattern);
|
||||||
|
|
||||||
|
List<AssociationRef> result = new ArrayList<AssociationRef>(childAssocRefs.size());
|
||||||
|
|
||||||
|
for (ChildAssociationRef childAssocRef : childAssocRefs)
|
||||||
|
{
|
||||||
|
// Get the assoc reference.
|
||||||
|
NodeRef childRef = childAssocRef.getChildRef();
|
||||||
|
NodeRef referencedNode = (NodeRef) this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE);
|
||||||
|
|
||||||
|
if (this.dbNodeService.exists(referencedNode))
|
||||||
|
{
|
||||||
|
Long assocDbId = (Long) this.dbNodeService.getProperty(childRef, Version2Model.PROP_QNAME_ASSOC_DBID);
|
||||||
|
|
||||||
|
// Check if property type validation has to be done.
|
||||||
|
if (propertyQName != null)
|
||||||
|
{
|
||||||
|
Serializable propertyValueRetrieved = this.dbNodeService.getProperty(referencedNode, propertyQName);
|
||||||
|
|
||||||
|
// Check if property value has been retrieved (property
|
||||||
|
// exists) and is equal to the requested value.
|
||||||
|
if (propertyValueRetrieved == null || !propertyValueRetrieved.equals(propertyValue))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build an assoc ref to add to the returned list.
|
||||||
|
AssociationRef newAssocRef = new AssociationRef(assocDbId, sourceRef, childAssocRef.getQName(), referencedNode);
|
||||||
|
result.add(newAssocRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -69,6 +69,8 @@ public class NodeServiceImpl implements NodeService, VersionModel
|
|||||||
*/
|
*/
|
||||||
protected final static String MSG_UNSUPPORTED =
|
protected final static String MSG_UNSUPPORTED =
|
||||||
"This operation is not supported by a version store implementation of the node service.";
|
"This operation is not supported by a version store implementation of the node service.";
|
||||||
|
|
||||||
|
private final static String MSG_UNSUPPORTED_V1 = "Versioning V1 is not implemented or supported. Patches exist to upgrade your data to use Versioning V2. Please contact support.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the spoofed root association
|
* The name of the spoofed root association
|
||||||
@@ -691,6 +693,16 @@ public class NodeServiceImpl implements NodeService, VersionModel
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws UnsupportedOperationException always
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AssociationRef> getTargetAssocsByPropertyValue(NodeRef sourceRef, QNamePattern qnamePattern, QName propertyQName, Serializable propertyValue)
|
||||||
|
{
|
||||||
|
// This operation is not supported for versioning V1
|
||||||
|
throw new UnsupportedOperationException(MSG_UNSUPPORTED_V1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws UnsupportedOperationException always
|
* @throws UnsupportedOperationException always
|
||||||
*/
|
*/
|
||||||
|
@@ -75,6 +75,7 @@ import org.alfresco.service.namespace.RegexQNamePattern;
|
|||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.BaseSpringTest;
|
import org.alfresco.util.BaseSpringTest;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
@@ -2805,7 +2806,79 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
|||||||
setComplete();
|
setComplete();
|
||||||
endTransaction();
|
endTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests get target associations by property value.</p>
|
||||||
|
* See <b>MNT-14504</b> for more details.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void testGetTargetAssocsByPropertyValue() throws Exception
|
||||||
|
{
|
||||||
|
// Create test data.
|
||||||
|
AssociationRef assocRef = createAssociation();
|
||||||
|
NodeRef sourceRef = assocRef.getSourceRef();
|
||||||
|
createAssociation(sourceRef);
|
||||||
|
|
||||||
|
NodeRef targetRef = assocRef.getTargetRef();
|
||||||
|
QName qname = assocRef.getTypeQName();
|
||||||
|
|
||||||
|
/* Positive tests of various types that should be accepted by the query. */
|
||||||
|
|
||||||
|
List<AssociationRef> targetAssocs = nodeService.getTargetAssocsByPropertyValue(sourceRef, qname, null, null);
|
||||||
|
assertEquals("Incorrect number of targets", 2, targetAssocs.size());
|
||||||
|
|
||||||
|
Map<QName, Serializable> checkProperties = new HashMap<QName, Serializable>();
|
||||||
|
checkProperties.put(ContentModel.PROP_ENABLED, Boolean.TRUE);
|
||||||
|
checkProperties.put(ContentModel.PROP_COUNTER, 100);
|
||||||
|
checkProperties.put(ContentModel.PROP_LATITUDE, new Double(51.521));
|
||||||
|
checkProperties.put(ContentModel.PROP_SUBJECT, "Hello World");
|
||||||
|
|
||||||
|
for (QName propertyQName : checkProperties.keySet())
|
||||||
|
{
|
||||||
|
Serializable propertyValue = checkProperties.get(propertyQName);
|
||||||
|
nodeService.setProperty(targetRef, propertyQName, propertyValue);
|
||||||
|
|
||||||
|
targetAssocs = nodeService.getTargetAssocsByPropertyValue(sourceRef, qname, propertyQName, propertyValue);
|
||||||
|
assertEquals("Incorrect number of targets", 1, targetAssocs.size());
|
||||||
|
assertTrue("Target not found", targetAssocs.contains(assocRef));
|
||||||
|
|
||||||
|
AssociationRef targetAssoc = targetAssocs.get(0);
|
||||||
|
|
||||||
|
// Check that ID is present
|
||||||
|
assertNotNull("Association does not have ID", targetAssoc.getId());
|
||||||
|
|
||||||
|
NodeRef targetRefFound = targetAssoc.getTargetRef();
|
||||||
|
|
||||||
|
assertEquals("Incorrect value found", propertyValue, this.nodeService.getProperty(targetRefFound, propertyQName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Negative tests. */
|
||||||
|
|
||||||
|
// Invalid to search on sys:node-dbid
|
||||||
|
try
|
||||||
|
{
|
||||||
|
targetAssocs = nodeService.getTargetAssocsByPropertyValue(sourceRef, qname, ContentModel.PROP_NODE_DBID, "Fail");
|
||||||
|
fail("sys:node-dbid not rejected");
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ie)
|
||||||
|
{
|
||||||
|
// Expect to go here.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invalid to search on type MLText.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Serializable title = (String) nodeService.getProperty(sourceRef, ContentModel.PROP_TITLE);
|
||||||
|
targetAssocs = nodeService.getTargetAssocsByPropertyValue(sourceRef, qname, ContentModel.PROP_NAME, title);
|
||||||
|
fail("MLText type not rejected");
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ie)
|
||||||
|
{
|
||||||
|
// Expect to go here.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testGetSourceAssocs() throws Exception
|
public void testGetSourceAssocs() throws Exception
|
||||||
{
|
{
|
||||||
AssociationRef assocRef = createAssociation();
|
AssociationRef assocRef = createAssociation();
|
||||||
|
@@ -263,7 +263,31 @@ public class NodeServiceImplTest extends BaseVersionStoreTest
|
|||||||
assertNotNull(assocs);
|
assertNotNull(assocs);
|
||||||
assertEquals(origAssocs.size(), assocs.size());
|
assertEquals(origAssocs.size(), assocs.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests get target associations by property value.</p>
|
||||||
|
* See <b>MNT-14504</b> for more details.
|
||||||
|
*/
|
||||||
|
public void testGetTargetAssocsByPropertyValue()
|
||||||
|
{
|
||||||
|
// Create a new versionable node
|
||||||
|
NodeRef versionableNode = createNewVersionableNode();
|
||||||
|
|
||||||
|
QName propertyQName = PROP_1;
|
||||||
|
Serializable propertyValue = VALUE_1;
|
||||||
|
// Store the current details of the target associations
|
||||||
|
List<AssociationRef> origAssocs = this.dbNodeService.getTargetAssocsByPropertyValue(versionableNode, RegexQNamePattern.MATCH_ALL,
|
||||||
|
propertyQName, propertyValue);
|
||||||
|
|
||||||
|
// Create a new version
|
||||||
|
Version version = createVersion(versionableNode, this.versionProperties);
|
||||||
|
|
||||||
|
List<AssociationRef> assocs = this.versionStoreNodeService.getTargetAssocsByPropertyValue(version.getFrozenStateNodeRef(),
|
||||||
|
RegexQNamePattern.MATCH_ALL, propertyQName, propertyValue);
|
||||||
|
assertNotNull(assocs);
|
||||||
|
assertEquals(origAssocs.size(), assocs.size());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test hasAspect
|
* Test hasAspect
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user