diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml index d3b63f4467..1f64806621 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml @@ -20,22 +20,21 @@ - - select - count( distinct assoc.child_node_id ) + distinct childProp.string_value from - alf_child_assoc assoc - left join alf_node_properties childProp on assoc.child_node_id = childProp.node_id + alf_child_assoc assoc + left join alf_node_properties childProp on assoc.child_node_id = childProp.node_id where - assoc.parent_node_id = #{parentId} - and childProp.qname_id = #{propertyQnameId} - and childProp.string_value in - - '${item}' - + assoc.parent_node_id = #{parentId} and + childProp.qname_id = #{propertyQnameId} + + + \ No newline at end of file diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/ChildrenWithPropertyValuesQueryParams.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/PropertyValuesOfChildrenQueryParams.java similarity index 79% rename from rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/ChildrenWithPropertyValuesQueryParams.java rename to rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/PropertyValuesOfChildrenQueryParams.java index aacc945557..b83377cf77 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/ChildrenWithPropertyValuesQueryParams.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/PropertyValuesOfChildrenQueryParams.java @@ -26,19 +26,16 @@ */ package org.alfresco.module.org_alfresco_module_rm.query; -import java.util.Collection; - /** - * Select parameter for select_CountChildrenWithPropertyValues. + * Select parameter for select_GetPropertyValuesOfChildren. * * @author Ana Manolache * @since 2.6 */ -public class ChildrenWithPropertyValuesQueryParams +public class PropertyValuesOfChildrenQueryParams { private Long parentId; private Long propertyQnameId; - private Collection propertyValues; public Long getParentId() { @@ -60,14 +57,5 @@ public class ChildrenWithPropertyValuesQueryParams this.propertyQnameId = propertyQnameId; } - public Collection getPropertyValues() - { - return propertyValues; - } - - public void setPropertyValues(Collection propertyValues) - { - this.propertyValues = propertyValues; - } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java index 04f7313ed4..7750e045ef 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java @@ -28,7 +28,9 @@ package org.alfresco.module.org_alfresco_module_rm.query; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; @@ -50,7 +52,7 @@ import org.mybatis.spring.SqlSessionTemplate; public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, RecordsManagementModel { private static final String COUNT_IDENTIFIER = "alfresco.query.rm.select_CountRMIndentifier"; - private static final String COUNT_CHILDREN_WITH_PROPERTY_VALUES = "select_CountChildrenWithPropertyValues"; + private static final String GET_CHILDREN_PROPERTY_VALUES = "select_GetPropertyValuesOfChildren"; /** SQL session template */ protected SqlSessionTemplate template; @@ -118,12 +120,12 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, @Override public boolean hasChildrenWithPropertyValues(NodeRef parent, QName property, Collection propertyValues) { - if(propertyValues.isEmpty()) + if (propertyValues.isEmpty()) { return false; } - ChildrenWithPropertyValuesQueryParams queryParams = new ChildrenWithPropertyValuesQueryParams(); + PropertyValuesOfChildrenQueryParams queryParams = new PropertyValuesOfChildrenQueryParams(); // Set the parent node id Pair nodePair = nodeDAO.getNodePair(tenantService.getName(parent)); @@ -142,12 +144,11 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, } queryParams.setPropertyQnameId(pair.getFirst()); - - // Set the property values - queryParams.setPropertyValues(propertyValues); - // Perform the query - Long count = template.selectOne(COUNT_CHILDREN_WITH_PROPERTY_VALUES, queryParams); - return count > 0; + List childrenPropertyValues = template.selectList(GET_CHILDREN_PROPERTY_VALUES, queryParams); + + //check if any propertyValues is in the childrenPropertyValues + return !Collections.disjoint(propertyValues, childrenPropertyValues); + } }