use of org.alfresco.rm.rest.api.model.RecordCategory 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.RecordCategory in project records-management by Alfresco.
the class ApiNodesModelFactory method createRecordCategory.
/**
* Creates an object of type RecordCategory
*
* @param info info of the record category
* @param propertyFilter
* @param includeParam
* @param mapUserInfo
* @param isMinimalInfo
* @return RecordCategory object
*/
public RecordCategory createRecordCategory(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo, boolean isMinimalInfo) {
RecordCategory recordCategory = new RecordCategory();
mapBasicInfo(recordCategory, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
mapOptionalInfo(recordCategory, info, parameters.getInclude(), isMinimalInfo);
if (parameters.getInclude().contains(RMNode.PARAM_HAS_RETENTION_SCHEDULE)) {
DispositionSchedule ds = dispositionService.getDispositionSchedule(info.getNodeRef());
recordCategory.setHasRetentionSchedule(ds != null ? true : false);
}
return recordCategory;
}
use of org.alfresco.rm.rest.api.model.RecordCategory in project records-management by Alfresco.
the class FilePlanChildrenRelation method create.
@Override
@WebApiDescription(title = "Create one (or more) record categories as children of container identified by 'filePlanId'")
public List<RecordCategory> create(String filePlanId, List<RecordCategory> nodeInfos, Parameters parameters) {
checkNotBlank("filePlanId", filePlanId);
mandatory("nodeInfos", nodeInfos);
mandatory("parameters", parameters);
QName filePlanType = apiUtils.getFilePlanType();
if (// rm site not created
filePlanType == null) {
throw new EntityNotFoundException(filePlanId);
}
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>() {
public List<NodeRef> execute() {
List<NodeRef> createdNodes = new LinkedList<>();
for (RecordCategory nodeInfo : nodeInfos) {
// Create the node
nodeInfo.setNodeType(RECORD_CATEGORY_TYPE);
NodeRef newNodeRef = apiUtils.createRMNode(parentNodeRef, nodeInfo, parameters);
createdNodes.add(newNodeRef);
}
return createdNodes;
}
};
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
// Get the nodes info
List<RecordCategory> result = new ArrayList<>(nodeInfos.size());
Map<String, UserInfo> mapUserInfo = new HashMap<>();
for (NodeRef newNodeRef : createdNodes) {
FileInfo info = fileFolderService.getFileInfo(newNodeRef);
result.add(nodesModelFactory.createRecordCategory(info, parameters, mapUserInfo, false));
}
return result;
}
use of org.alfresco.rm.rest.api.model.RecordCategory in project records-management by Alfresco.
the class FilePlanChildrenRelation method readAll.
@Override
@WebApiDescription(title = "Return a paged list of file plan children (record categories) for the container identified by 'filePlanId'")
public CollectionWithPagingInfo<RecordCategory> readAll(String filePlanId, Parameters parameters) {
// validate parameters
checkNotBlank("filePlanId", filePlanId);
mandatory("parameters", parameters);
QName filePlanType = apiUtils.getFilePlanType();
if (// rm site not created
filePlanType == null) {
throw new EntityNotFoundException(filePlanId);
}
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
// list record categories
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForFilePlanEndpoint();
// FIXME this param null
List<FilterProp> filterProps = apiUtils.getListChildrenFilterProps(parameters, null);
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef, null, searchTypeQNames, null, apiUtils.getSortProperties(parameters), filterProps, Util.getPagingRequest(parameters.getPaging()));
final List<FileInfo> page = pagingResults.getPage();
Map<String, UserInfo> mapUserInfo = new HashMap<>();
List<RecordCategory> nodes = new AbstractList<RecordCategory>() {
@Override
public RecordCategory get(int index) {
FileInfo info = page.get(index);
return nodesModelFactory.createRecordCategory(info, parameters, mapUserInfo, true);
}
@Override
public int size() {
return page.size();
}
};
FilePlan sourceEntity = null;
if (parameters.includeSource()) {
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
sourceEntity = nodesModelFactory.createFilePlan(info, parameters, mapUserInfo, true);
}
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
}
Aggregations