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:
Rodica Sutu
2018-01-24 15:22:10 +02:00
parent 4d1c8624cf
commit cbeebaedc0
3 changed files with 24 additions and 36 deletions

View File

@@ -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;
}
}

View File

@@ -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);
}
}