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>
|
</select>
|
||||||
|
|
||||||
<!-- Counts the children that have at least one of the provided property values for a given property qname -->
|
<!-- Get distinct property values of children for a given property qname -->
|
||||||
<select id="select_CountChildrenWithPropertyValues"
|
<select id="select_GetPropertyValuesOfChildren"
|
||||||
parameterType="org.alfresco.module.org_alfresco_module_rm.query.ChildrenWithPropertyValuesQueryParams"
|
parameterType="org.alfresco.module.org_alfresco_module_rm.query.PropertyValuesOfChildrenQueryParams"
|
||||||
resultType="java.lang.Long">
|
resultType="java.lang.String">
|
||||||
select
|
select
|
||||||
count( distinct assoc.child_node_id )
|
distinct childProp.string_value
|
||||||
from
|
from
|
||||||
alf_child_assoc assoc
|
alf_child_assoc assoc
|
||||||
left join alf_node_properties childProp on assoc.child_node_id = childProp.node_id
|
left join alf_node_properties childProp on assoc.child_node_id = childProp.node_id
|
||||||
where
|
where
|
||||||
assoc.parent_node_id = #{parentId}
|
assoc.parent_node_id = #{parentId} and
|
||||||
and childProp.qname_id = #{propertyQnameId}
|
childProp.qname_id = #{propertyQnameId}
|
||||||
and childProp.string_value in
|
|
||||||
<foreach item="item" index="index" collection="propertyValues" open="(" separator="," close=")">
|
|
||||||
'${item}'
|
|
||||||
</foreach>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@@ -26,19 +26,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.query;
|
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
|
* @author Ana Manolache
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
public class ChildrenWithPropertyValuesQueryParams
|
public class PropertyValuesOfChildrenQueryParams
|
||||||
{
|
{
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
private Long propertyQnameId;
|
private Long propertyQnameId;
|
||||||
private Collection propertyValues;
|
|
||||||
|
|
||||||
public Long getParentId()
|
public Long getParentId()
|
||||||
{
|
{
|
||||||
@@ -60,14 +57,5 @@ public class ChildrenWithPropertyValuesQueryParams
|
|||||||
this.propertyQnameId = propertyQnameId;
|
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;
|
package org.alfresco.module.org_alfresco_module_rm.query;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
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
|
public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, RecordsManagementModel
|
||||||
{
|
{
|
||||||
private static final String COUNT_IDENTIFIER = "alfresco.query.rm.select_CountRMIndentifier";
|
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 */
|
/** SQL session template */
|
||||||
protected SqlSessionTemplate template;
|
protected SqlSessionTemplate template;
|
||||||
@@ -118,12 +120,12 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO,
|
|||||||
@Override
|
@Override
|
||||||
public boolean hasChildrenWithPropertyValues(NodeRef parent, QName property, Collection propertyValues)
|
public boolean hasChildrenWithPropertyValues(NodeRef parent, QName property, Collection propertyValues)
|
||||||
{
|
{
|
||||||
if(propertyValues.isEmpty())
|
if (propertyValues.isEmpty())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChildrenWithPropertyValuesQueryParams queryParams = new ChildrenWithPropertyValuesQueryParams();
|
PropertyValuesOfChildrenQueryParams queryParams = new PropertyValuesOfChildrenQueryParams();
|
||||||
|
|
||||||
// Set the parent node id
|
// Set the parent node id
|
||||||
Pair<Long, NodeRef> nodePair = nodeDAO.getNodePair(tenantService.getName(parent));
|
Pair<Long, NodeRef> nodePair = nodeDAO.getNodePair(tenantService.getName(parent));
|
||||||
@@ -142,12 +144,11 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO,
|
|||||||
}
|
}
|
||||||
queryParams.setPropertyQnameId(pair.getFirst());
|
queryParams.setPropertyQnameId(pair.getFirst());
|
||||||
|
|
||||||
|
|
||||||
// Set the property values
|
|
||||||
queryParams.setPropertyValues(propertyValues);
|
|
||||||
|
|
||||||
// Perform the query
|
// Perform the query
|
||||||
Long count = template.selectOne(COUNT_CHILDREN_WITH_PROPERTY_VALUES, queryParams);
|
List<String> childrenPropertyValues = template.selectList(GET_CHILDREN_PROPERTY_VALUES, queryParams);
|
||||||
return count > 0;
|
|
||||||
|
//check if any propertyValues is in the childrenPropertyValues
|
||||||
|
return !Collections.disjoint(propertyValues, childrenPropertyValues);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user