use of org.alfresco.rm.rest.api.model.UnfiledRecordFolderChild in project records-management by Alfresco.
the class UnfiledRecordFolderChildrenRelation method create.
@Override
@WebApiDescription(title = "Create one (or more) nodes as children of a unfiled record folder identified by 'unfiledRecordFolderId'")
public List<UnfiledRecordFolderChild> create(String unfiledRecordFolderId, final List<UnfiledRecordFolderChild> nodeInfos, Parameters parameters) {
checkNotBlank("unfiledRecordFolderId", unfiledRecordFolderId);
mandatory("nodeInfos", nodeInfos);
mandatory("parameters", parameters);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER);
// Create the children
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>() {
public List<NodeRef> execute() {
List<NodeRef> createdNodes = new LinkedList<>();
for (UnfiledRecordFolderChild nodeInfo : nodeInfos) {
NodeRef nodeParent;
if (StringUtils.isNoneBlank(nodeInfo.getRelativePath())) {
nodeParent = apiUtils.lookupAndValidateRelativePath(parentNodeRef, nodeInfo.getRelativePath(), RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER);
} else {
nodeParent = parentNodeRef;
}
NodeRef newNodeRef = apiUtils.createRMNode(nodeParent, nodeInfo, parameters);
createdNodes.add(newNodeRef);
}
return createdNodes;
}
};
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
// Get the nodes info
List<UnfiledRecordFolderChild> result = new LinkedList<>();
Map<String, UserInfo> mapUserInfo = new HashMap<>();
for (NodeRef newNodeRef : createdNodes) {
FileInfo info = fileFolderService.getFileInfo(newNodeRef);
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
result.add(nodesModelFactory.createUnfiledRecordFolderChild(info, parameters, mapUserInfo, false));
}
return result;
}
use of org.alfresco.rm.rest.api.model.UnfiledRecordFolderChild in project records-management by Alfresco.
the class ApiNodesModelFactory method createUnfiledRecordFolderChild.
/**
* Creates an object of type UnfiledRecordFolderChild
*
* @param info
* @param parameters
* @param mapUserInfo
* @param isMinimalInfo
* @return UnfiledRecordFolderChild object
*/
public UnfiledRecordFolderChild createUnfiledRecordFolderChild(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo, boolean isMinimalInfo) {
UnfiledRecordFolderChild unfiledRecordFolderChild = new UnfiledRecordFolderChild();
mapBasicInfo(unfiledRecordFolderChild, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
mapOptionalInfo(unfiledRecordFolderChild, info, parameters.getInclude(), isMinimalInfo);
mapUnfiledChildInfo(unfiledRecordFolderChild, info, parameters.getFilter());
if (unfiledRecordFolderChild.getIsRecord()) {
mapAssociations(unfiledRecordFolderChild, info, parameters.getInclude());
}
return unfiledRecordFolderChild;
}
use of org.alfresco.rm.rest.api.model.UnfiledRecordFolderChild in project records-management by Alfresco.
the class UnfiledRecordFolderChildrenRelation method readAll.
@Override
@WebApiDescription(title = "Return a paged list of unfiled container children for the container identified by 'unfiledContainerId'")
public CollectionWithPagingInfo<UnfiledRecordFolderChild> readAll(String unfileRecordFolderId, Parameters parameters) {
checkNotBlank("unfileRecordFolderId", unfileRecordFolderId);
mandatory("parameters", parameters);
String relativePath = parameters.getParameter(Nodes.PARAM_RELATIVE_PATH);
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfileRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, relativePath, true);
// list unfiled record folders and records
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForUnfiledEndpoint(parameters, LIST_UNFILED_RECORD_FOLDER_CHILDREN_EQUALS_QUERY_PROPERTIES);
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef, null, searchTypeQNames, null, apiUtils.getSortProperties(parameters), null, Util.getPagingRequest(parameters.getPaging()));
final List<FileInfo> page = pagingResults.getPage();
Map<String, UserInfo> mapUserInfo = new HashMap<>();
List<UnfiledRecordFolderChild> nodes = new AbstractList<UnfiledRecordFolderChild>() {
@Override
public UnfiledRecordFolderChild get(int index) {
FileInfo info = page.get(index);
return nodesModelFactory.createUnfiledRecordFolderChild(info, parameters, mapUserInfo, true);
}
@Override
public int size() {
return page.size();
}
};
UnfiledRecordFolder sourceEntity = null;
if (parameters.includeSource()) {
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
sourceEntity = nodesModelFactory.createUnfiledRecordFolder(info, parameters, mapUserInfo, true);
}
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
}
Aggregations