mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
modify the hasChildrenWithPropertyValues to getChildrenPropertyValues in order to return the query result
update the implementation where the modified method is used update tests
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.query;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -53,13 +53,11 @@ public interface RecordsManagementQueryDAO
|
||||
int getCountRmaIdentifier(String identifierValue);
|
||||
|
||||
/**
|
||||
* Returns whether a given node contains children with one of the given values for the given property
|
||||
* Returns the property values from children for the given property
|
||||
*
|
||||
* @param parent the parent to evaluate
|
||||
* @param property the QName of the property to evaluate
|
||||
* @param propertyValues the list of values to look for
|
||||
* @return true if there is at least one child with one of the values from the list set on the given property
|
||||
* false otherwise
|
||||
* @return list of property values
|
||||
*/
|
||||
public boolean hasChildrenWithPropertyValues(NodeRef parent, QName property, Collection propertyValues);
|
||||
public List<String> getChildrenPropertyValues(NodeRef parent, QName property);
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@
|
||||
|
||||
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;
|
||||
@@ -118,13 +117,8 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO,
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChildrenWithPropertyValues(NodeRef parent, QName property, Collection propertyValues)
|
||||
public List<String> getChildrenPropertyValues(NodeRef parent, QName property)
|
||||
{
|
||||
if (propertyValues.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
PropertyValuesOfChildrenQueryParams queryParams = new PropertyValuesOfChildrenQueryParams();
|
||||
|
||||
// Set the parent node id
|
||||
@@ -140,15 +134,12 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO,
|
||||
Pair<Long, QName> pair = qnameDAO.getQName(property);
|
||||
if (pair == null)
|
||||
{
|
||||
return false;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
queryParams.setPropertyQnameId(pair.getFirst());
|
||||
|
||||
// Perform the query
|
||||
List<String> childrenPropertyValues = template.selectList(GET_CHILDREN_PROPERTY_VALUES, queryParams);
|
||||
|
||||
//check if any propertyValues is in the childrenPropertyValues
|
||||
return !Collections.disjoint(propertyValues, childrenPropertyValues);
|
||||
return template.selectList(GET_CHILDREN_PROPERTY_VALUES, queryParams);
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,8 @@ package org.alfresco.module.org_alfresco_module_rm.test.legacy.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
@@ -130,7 +132,8 @@ public class RecordsManagementQueryDAOImplTest extends BaseRMTestCase implements
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
result = queryDAO.hasChildrenWithPropertyValues(parentFolder, PROP_DESCRIPTION, Arrays.asList(propValue1, propValue2, propValue4));
|
||||
List<String> propertyValues = queryDAO.getChildrenPropertyValues(parentFolder, PROP_DESCRIPTION);
|
||||
result = !Collections.disjoint(Arrays.asList(propValue1, propValue2, propValue4),propertyValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,7 +182,8 @@ public class RecordsManagementQueryDAOImplTest extends BaseRMTestCase implements
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
result = queryDAO.hasChildrenWithPropertyValues(parentFolder, PROP_DESCRIPTION, Arrays.asList("descr1", "descr2", "descr3"));
|
||||
List<String> propertyValues = queryDAO.getChildrenPropertyValues(parentFolder, PROP_DESCRIPTION);
|
||||
result = !Collections.disjoint(Arrays.asList("descr1", "descr2", "descr3"), propertyValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -224,7 +228,8 @@ public class RecordsManagementQueryDAOImplTest extends BaseRMTestCase implements
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
result = queryDAO.hasChildrenWithPropertyValues(folder, PROP_DESCRIPTION, Arrays.asList("descr"));
|
||||
List<String> propertyValues = queryDAO.getChildrenPropertyValues(folder, PROP_DESCRIPTION);
|
||||
result = !Collections.disjoint(Arrays.asList("descr"), propertyValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -271,7 +276,8 @@ public class RecordsManagementQueryDAOImplTest extends BaseRMTestCase implements
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
result = queryDAO.hasChildrenWithPropertyValues(folder, property, Arrays.asList("descr"));
|
||||
List<String> propertyValues = queryDAO.getChildrenPropertyValues(folder, property);
|
||||
result = !Collections.disjoint(Arrays.asList("descr"), propertyValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -293,7 +299,7 @@ public class RecordsManagementQueryDAOImplTest extends BaseRMTestCase implements
|
||||
|
||||
/**
|
||||
* Given any folder and any property
|
||||
* When I pass an empty array to the hasChildrenWithPropertyValues method
|
||||
* When I pass an empty array to the getChildrenPropertyValues method
|
||||
* Then the answer is negative
|
||||
*/
|
||||
@org.junit.Test
|
||||
@@ -318,7 +324,8 @@ public class RecordsManagementQueryDAOImplTest extends BaseRMTestCase implements
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
result = queryDAO.hasChildrenWithPropertyValues(folder, PROP_DESCRIPTION, new ArrayList());
|
||||
List<String> propertyValues = queryDAO.getChildrenPropertyValues(folder, PROP_DESCRIPTION);
|
||||
result = !Collections.disjoint(new ArrayList(), propertyValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user