mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
change the old query select_CountChildrenWithPropertyValues to return the list of distinct property values from children
update the implementation were the updated query is used
This commit is contained in:
@@ -20,22 +20,21 @@
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Counts the children that have at least one of the provided property values for a given property qname -->
|
||||
<select id="select_CountChildrenWithPropertyValues"
|
||||
parameterType="org.alfresco.module.org_alfresco_module_rm.query.ChildrenWithPropertyValuesQueryParams"
|
||||
resultType="java.lang.Long">
|
||||
<!-- Get distinct property values of children for a given property qname -->
|
||||
<select id="select_GetPropertyValuesOfChildren"
|
||||
parameterType="org.alfresco.module.org_alfresco_module_rm.query.PropertyValuesOfChildrenQueryParams"
|
||||
resultType="java.lang.String">
|
||||
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
|
||||
<foreach item="item" index="index" collection="propertyValues" open="(" separator="," close=")">
|
||||
'${item}'
|
||||
</foreach>
|
||||
assoc.parent_node_id = #{parentId} and
|
||||
childProp.qname_id = #{propertyQnameId}
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
@@ -26,19 +26,16 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.query;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Select parameter for <b>select_CountChildrenWithPropertyValues</b>.
|
||||
* Select parameter for <b>select_GetPropertyValuesOfChildren</b>.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
@@ -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<Long, NodeRef> 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<String> childrenPropertyValues = template.selectList(GET_CHILDREN_PROPERTY_VALUES, queryParams);
|
||||
|
||||
//check if any propertyValues is in the childrenPropertyValues
|
||||
return !Collections.disjoint(propertyValues, childrenPropertyValues);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user