Search in sources :

Example 1 with UnfiledContainerChild

use of org.alfresco.rm.rest.api.model.UnfiledContainerChild in project records-management by Alfresco.

the class ApiNodesModelFactory method createUnfiledContainerChild.

/**
 * Creates an object of type UnfiledContainerChild
 *
 * @param info
 * @param parameters
 * @param mapUserInfo
 * @param isMinimalInfo
 * @return UnfiledContainerChild object
 */
public UnfiledContainerChild createUnfiledContainerChild(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo, boolean isMinimalInfo) {
    UnfiledContainerChild unfiledContainerChild = new UnfiledContainerChild();
    mapBasicInfo(unfiledContainerChild, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
    mapOptionalInfo(unfiledContainerChild, info, parameters.getInclude(), isMinimalInfo);
    mapUnfiledChildInfo(unfiledContainerChild, info, parameters.getFilter());
    if (unfiledContainerChild.getIsRecord()) {
        mapAssociations(unfiledContainerChild, info, parameters.getInclude());
    }
    return unfiledContainerChild;
}
Also used : UnfiledContainerChild(org.alfresco.rm.rest.api.model.UnfiledContainerChild)

Example 2 with UnfiledContainerChild

use of org.alfresco.rm.rest.api.model.UnfiledContainerChild in project records-management by Alfresco.

the class UnfiledContainerChildrenRelation method readAll.

@Override
@WebApiDescription(title = "Return a paged list of unfiled container children for the container identified by 'unfiledContainerId'")
public CollectionWithPagingInfo<UnfiledContainerChild> readAll(String unfiledContainerId, Parameters parameters) {
    // validate parameters
    checkNotBlank("unfiledContainerId", unfiledContainerId);
    mandatory("parameters", parameters);
    NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledContainerId, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
    // list unfiled record folders and records
    Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForUnfiledEndpoint(parameters, LIST_UNFILED_CONTAINER_CHILDREN_EQUALS_QUERY_PROPERTIES);
    List<FilterProp> filterProps = apiUtils.getListChildrenFilterProps(parameters, LIST_UNFILED_CONTAINER_CHILDREN_EQUALS_QUERY_PROPERTIES);
    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<UnfiledContainerChild> nodes = new AbstractList<UnfiledContainerChild>() {

        @Override
        public UnfiledContainerChild get(int index) {
            FileInfo info = page.get(index);
            return nodesModelFactory.createUnfiledContainerChild(info, parameters, mapUserInfo, true);
        }

        @Override
        public int size() {
            return page.size();
        }
    };
    UnfiledContainer sourceEntity = null;
    if (parameters.includeSource()) {
        FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
        sourceEntity = nodesModelFactory.createUnfiledContainer(info, parameters, mapUserInfo, true);
    }
    return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
}
Also used : AbstractList(java.util.AbstractList) FilterProp(org.alfresco.repo.node.getchildren.FilterProp) HashMap(java.util.HashMap) UnfiledContainerChild(org.alfresco.rm.rest.api.model.UnfiledContainerChild) QName(org.alfresco.service.namespace.QName) UserInfo(org.alfresco.rest.api.model.UserInfo) UnfiledContainer(org.alfresco.rm.rest.api.model.UnfiledContainer) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 3 with UnfiledContainerChild

use of org.alfresco.rm.rest.api.model.UnfiledContainerChild in project records-management by Alfresco.

the class UnfiledContainerChildrenRelation method create.

@Override
@WebApiDescription(title = "Create one (or more) nodes as children of a unfiled container identified by 'unfiledContainerId'")
public List<UnfiledContainerChild> create(String unfiledContainerId, final List<UnfiledContainerChild> nodeInfos, Parameters parameters) {
    checkNotBlank("unfiledContainerId", unfiledContainerId);
    mandatory("nodeInfos", nodeInfos);
    mandatory("parameters", parameters);
    final NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledContainerId, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
    // Create the nodes
    RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>() {

        public List<NodeRef> execute() {
            List<NodeRef> createdNodes = new LinkedList<>();
            for (UnfiledContainerChild nodeInfo : nodeInfos) {
                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<UnfiledContainerChild> 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.createUnfiledContainerChild(info, parameters, mapUserInfo, false));
    }
    return result;
}
Also used : UnfiledContainerChild(org.alfresco.rm.rest.api.model.UnfiledContainerChild) HashMap(java.util.HashMap) UserInfo(org.alfresco.rest.api.model.UserInfo) LinkedList(java.util.LinkedList) 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)

Aggregations

UnfiledContainerChild (org.alfresco.rm.rest.api.model.UnfiledContainerChild)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 FilterProp (org.alfresco.repo.node.getchildren.FilterProp)1 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)1 UnfiledContainer (org.alfresco.rm.rest.api.model.UnfiledContainer)1 QName (org.alfresco.service.namespace.QName)1