Search in sources :

Example 1 with UnfiledRecordFolderChild

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;
}
Also used : HashMap(java.util.HashMap) UserInfo(org.alfresco.rest.api.model.UserInfo) LinkedList(java.util.LinkedList) UnfiledRecordFolderChild(org.alfresco.rm.rest.api.model.UnfiledRecordFolderChild) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) AbstractList(java.util.AbstractList) LinkedList(java.util.LinkedList) List(java.util.List) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 2 with UnfiledRecordFolderChild

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;
}
Also used : UnfiledRecordFolderChild(org.alfresco.rm.rest.api.model.UnfiledRecordFolderChild)

Example 3 with 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);
}
Also used : AbstractList(java.util.AbstractList) UnfiledRecordFolder(org.alfresco.rm.rest.api.model.UnfiledRecordFolder) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) UserInfo(org.alfresco.rest.api.model.UserInfo) UnfiledRecordFolderChild(org.alfresco.rm.rest.api.model.UnfiledRecordFolderChild) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Aggregations

UnfiledRecordFolderChild (org.alfresco.rm.rest.api.model.UnfiledRecordFolderChild)3 AbstractList (java.util.AbstractList)2 HashMap (java.util.HashMap)2 UserInfo (org.alfresco.rest.api.model.UserInfo)2 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)2 FileInfo (org.alfresco.service.cmr.model.FileInfo)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 LinkedList (java.util.LinkedList)1 List (java.util.List)1 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)1 UnfiledRecordFolder (org.alfresco.rm.rest.api.model.UnfiledRecordFolder)1 QName (org.alfresco.service.namespace.QName)1