Search in sources :

Example 1 with RecordCategory

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);
}
Also used : AbstractList(java.util.AbstractList) FilterProp(org.alfresco.repo.node.getchildren.FilterProp) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) RecordCategoryChild(org.alfresco.rm.rest.api.model.RecordCategoryChild) UserInfo(org.alfresco.rest.api.model.UserInfo) RecordCategory(org.alfresco.rm.rest.api.model.RecordCategory) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 2 with RecordCategory

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;
}
Also used : DispositionSchedule(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) RecordCategory(org.alfresco.rm.rest.api.model.RecordCategory)

Example 3 with 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;
}
Also used : HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) RecordCategory(org.alfresco.rm.rest.api.model.RecordCategory) UserInfo(org.alfresco.rest.api.model.UserInfo) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) 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) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 4 with RecordCategory

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);
}
Also used : AbstractList(java.util.AbstractList) FilePlan(org.alfresco.rm.rest.api.model.FilePlan) FilterProp(org.alfresco.repo.node.getchildren.FilterProp) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) UserInfo(org.alfresco.rest.api.model.UserInfo) RecordCategory(org.alfresco.rm.rest.api.model.RecordCategory) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Aggregations

RecordCategory (org.alfresco.rm.rest.api.model.RecordCategory)4 AbstractList (java.util.AbstractList)3 HashMap (java.util.HashMap)3 UserInfo (org.alfresco.rest.api.model.UserInfo)3 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)3 FileInfo (org.alfresco.service.cmr.model.FileInfo)3 NodeRef (org.alfresco.service.cmr.repository.NodeRef)3 QName (org.alfresco.service.namespace.QName)3 FilterProp (org.alfresco.repo.node.getchildren.FilterProp)2 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 DispositionSchedule (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule)1 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)1 FilePlan (org.alfresco.rm.rest.api.model.FilePlan)1 RecordCategoryChild (org.alfresco.rm.rest.api.model.RecordCategoryChild)1