RM-5115 Get category children REST API disposition schedule fix

This commit is contained in:
Sara Aspery
2017-05-09 14:34:08 +01:00
parent dd89f9864c
commit 9627b8ff70
3 changed files with 46 additions and 4 deletions

View File

@@ -52,6 +52,7 @@ import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail; import static org.testng.Assert.fail;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
@@ -66,7 +67,10 @@ import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder;
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI; import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
import org.alfresco.rest.v0.RecordCategoriesAPI;
import org.alfresco.rest.core.v0.BaseAPI.RETENTION_SCHEDULE;
import org.alfresco.utility.report.Bug; import org.alfresco.utility.report.Bug;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@@ -83,6 +87,9 @@ public class RecordCategoryTests extends BaseRMRestTest
private static final int NUMBER_OF_CHILDREN = 10; private static final int NUMBER_OF_CHILDREN = 10;
private static final int NUMBER_OF_FOLDERS = 5; private static final int NUMBER_OF_FOLDERS = 5;
@Autowired
private RecordCategoriesAPI recordCategoriesAPI;
/** /**
* Invalid containers that cannot be deleted with record category end-point * Invalid containers that cannot be deleted with record category end-point
*/ */
@@ -287,6 +294,7 @@ public class RecordCategoryTests extends BaseRMRestTest
assertEquals(folderProperties.getTitle(), TITLE_PREFIX + RECORD_FOLDER_NAME); assertEquals(folderProperties.getTitle(), TITLE_PREFIX + RECORD_FOLDER_NAME);
assertNotNull(folderProperties.getIdentifier()); assertNotNull(folderProperties.getIdentifier());
} }
/** /**
* <pre> * <pre>
* Given that a record category exists * Given that a record category exists
@@ -294,17 +302,37 @@ public class RecordCategoryTests extends BaseRMRestTest
* When I ask the API to get me the children of the record category * When I ask the API to get me the children of the record category
* Then I am returned the contained record categories and record folders and their details * Then I am returned the contained record categories and record folders and their details
* </pre> * </pre>
* <pre>
* Given that a record category with a disposition schedule exists
* And contains a number of record categories and record folders
* When I ask the API to get me the children of the record category
* Then I am returned the contained record categories and record folders but not the disposition schedule
* </pre>
*/ */
@Test @Test
( (
description = "Get children of a record category" description = "Get children of a record category excluding the disposition schedule"
) )
@Bug (id="RM-5115")
public void getRecordCategoryChildren() throws Exception public void getRecordCategoryChildren() throws Exception
{ {
// Create root level category // Create root level category
RecordCategory rootRecordCategory = createRootCategory(getRandomAlphanumeric()); RecordCategory rootRecordCategory = createRootCategory(getRandomAlphanumeric());
assertNotNull(rootRecordCategory.getId()); assertNotNull(rootRecordCategory.getId());
// Create disposition schedule
String userName = getAdminUser().getUsername();
String userPassword = getAdminUser().getPassword();
String categoryName = rootRecordCategory.getName();
recordCategoriesAPI.createRetentionSchedule(userName, userPassword, categoryName);
// Add disposition schedule cut off step
HashMap<RETENTION_SCHEDULE, String> cutOffStep = new HashMap<>();
cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff");
cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, "day|2");
cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off after 2 days");
recordCategoriesAPI.addDispositionScheduleSteps(userName, userPassword, categoryName, cutOffStep);
// Add record category children // Add record category children
List<RecordCategoryChild> children = new ArrayList<RecordCategoryChild>(); List<RecordCategoryChild> children = new ArrayList<RecordCategoryChild>();
for (int i=0; i < NUMBER_OF_CHILDREN; i++) for (int i=0; i < NUMBER_OF_CHILDREN; i++)

View File

@@ -29,6 +29,7 @@ package org.alfresco.rm.rest.api.impl;
import java.security.InvalidParameterException; import java.security.InvalidParameterException;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@@ -198,6 +199,7 @@ public class SearchTypesFactory
Boolean isRecordFolder = propertyWalker.getProperty(RecordCategoryChild.PARAM_IS_RECORD_FOLDER, Boolean isRecordFolder = propertyWalker.getProperty(RecordCategoryChild.PARAM_IS_RECORD_FOLDER,
WhereClauseParser.EQUALS, Boolean.class); WhereClauseParser.EQUALS, Boolean.class);
Boolean isRecordCategory = propertyWalker.getProperty(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY, WhereClauseParser.EQUALS, Boolean.class); Boolean isRecordCategory = propertyWalker.getProperty(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY, WhereClauseParser.EQUALS, Boolean.class);
if ((isRecordFolder != null && isRecordFolder.booleanValue()) || (isRecordCategory != null && !isRecordCategory.booleanValue())) if ((isRecordFolder != null && isRecordFolder.booleanValue()) || (isRecordCategory != null && !isRecordCategory.booleanValue()))
{ {
includeRecordFolders = true; includeRecordFolders = true;
@@ -221,6 +223,7 @@ public class SearchTypesFactory
if (nodeTypeQNameStr.equals(RecordsManagementModel.TYPE_RECORD_FOLDER)) if (nodeTypeQNameStr.equals(RecordsManagementModel.TYPE_RECORD_FOLDER))
{ {
includeRecordFolders = true; includeRecordFolders = true;
} }
else if (filterNodeTypeQName.equals(RecordsManagementModel.TYPE_RECORD_CATEGORY)) else if (filterNodeTypeQName.equals(RecordsManagementModel.TYPE_RECORD_CATEGORY))
{ {
@@ -249,6 +252,16 @@ public class SearchTypesFactory
return searchTypeQNames; return searchTypeQNames;
} }
/**
* Helper method to build association types for categories endpoint
* @return
*/
public Set<QName> buildAssocTypesCategoriesEndpoint()
{
Set<QName> assocTypeQNames = Collections.singleton(ContentModel.ASSOC_CONTAINS);
return assocTypeQNames;
}
/** /**
* Helper method to build search types for transfer containers endpoint * Helper method to build search types for transfer containers endpoint
* @return * @return

View File

@@ -114,10 +114,11 @@ public class RecordCategoryChildrenRelation implements RelationshipResourceActio
// list record categories and record folders // list record categories and record folders
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesCategoriesEndpoint(parameters, LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES); Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesCategoriesEndpoint(parameters, LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES);
Set<QName> assocTypeQNames = searchTypesFactory.buildAssocTypesCategoriesEndpoint();
List<FilterProp> filterProps = apiUtils.getListChildrenFilterProps(parameters, LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES); List<FilterProp> filterProps = apiUtils.getListChildrenFilterProps(parameters, LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES);
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef, final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef,
null, assocTypeQNames,
searchTypeQNames, searchTypeQNames,
null, null,
apiUtils.getSortProperties(parameters), apiUtils.getSortProperties(parameters),