use of org.alfresco.rm.rest.api.model.RecordCategoryChild in project records-management by Alfresco.
the class RecordCategoryChildrenRelation method readAll.
@Override
@WebApiDescription(title = "Return a paged list of record category children for the container identified by 'recordCategoryId'")
public CollectionWithPagingInfo<RecordCategoryChild> readAll(String recordCategoryId, Parameters parameters) {
checkNotBlank("recordCategoryId", recordCategoryId);
mandatory("parameters", parameters);
String relativePath = parameters.getParameter(Nodes.PARAM_RELATIVE_PATH);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(recordCategoryId, RecordsManagementModel.TYPE_RECORD_CATEGORY, relativePath, true);
// list record categories and record folders
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesCategoriesEndpoint(parameters, LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES);
Set<QName> assocTypeQNames = Collections.singleton(ContentModel.ASSOC_CONTAINS);
List<FilterProp> filterProps = apiUtils.getListChildrenFilterProps(parameters, LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES);
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef, assocTypeQNames, searchTypeQNames, null, apiUtils.getSortProperties(parameters), filterProps, Util.getPagingRequest(parameters.getPaging()));
final List<FileInfo> page = pagingResults.getPage();
Map<String, UserInfo> mapUserInfo = new HashMap<>();
List<RecordCategoryChild> nodes = new AbstractList<RecordCategoryChild>() {
@Override
public RecordCategoryChild get(int index) {
FileInfo info = page.get(index);
return nodesModelFactory.createRecordCategoryChild(info, parameters, mapUserInfo, true);
}
@Override
public int size() {
return page.size();
}
};
RecordCategory sourceEntity = null;
if (parameters.includeSource()) {
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
sourceEntity = nodesModelFactory.createRecordCategory(info, parameters, mapUserInfo, true);
}
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
}
use of org.alfresco.rm.rest.api.model.RecordCategoryChild in project records-management by Alfresco.
the class RecordCategoryChildrenRelation method create.
@Override
@WebApiDescription(title = "Create one (or more) nodes as children of a record category identified by 'recordCategoryId'")
public List<RecordCategoryChild> create(String recordCategoryId, List<RecordCategoryChild> nodeInfos, Parameters parameters) {
checkNotBlank("recordCategoryId", recordCategoryId);
mandatory("nodeInfos", nodeInfos);
mandatory("parameters", parameters);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(recordCategoryId, RecordsManagementModel.TYPE_RECORD_CATEGORY);
List<RecordCategoryChild> result = new ArrayList<>(nodeInfos.size());
Map<String, UserInfo> mapUserInfo = new HashMap<>();
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>() {
public List<NodeRef> execute() {
List<NodeRef> createdNodes = new LinkedList<>();
for (RecordCategoryChild nodeInfo : nodeInfos) {
// Resolve the parent node
NodeRef nodeParent = parentNodeRef;
if (StringUtils.isNoneBlank(nodeInfo.getRelativePath())) {
nodeParent = apiUtils.lookupAndValidateRelativePath(parentNodeRef, nodeInfo.getRelativePath(), RecordsManagementModel.TYPE_RECORD_CATEGORY);
}
// Create the node
NodeRef newNode = apiUtils.createRMNode(nodeParent, nodeInfo, parameters);
createdNodes.add(newNode);
}
return createdNodes;
}
};
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
for (NodeRef nodeInfo : createdNodes) {
FileInfo info = fileFolderService.getFileInfo(nodeInfo);
result.add(nodesModelFactory.createRecordCategoryChild(info, parameters, mapUserInfo, false));
}
return result;
}
use of org.alfresco.rm.rest.api.model.RecordCategoryChild in project records-management by Alfresco.
the class ApiNodesModelFactory method createRecordCategoryChild.
/**
* Creates an object of type RecordCategoryChild
*
* @param info
* @param parameters
* @param mapUserInfo
* @param isMinimalInfo
* @return
*/
public RecordCategoryChild createRecordCategoryChild(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo, boolean isMinimalInfo) {
RecordCategoryChild recordCategoryChild = new RecordCategoryChild();
mapBasicInfo(recordCategoryChild, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
mapOptionalInfo(recordCategoryChild, info, parameters.getInclude(), isMinimalInfo);
mapRecordCategoryChildInfo(recordCategoryChild, info, parameters.getInclude(), parameters.getFilter(), isMinimalInfo);
return recordCategoryChild;
}
Aggregations