@Override public long getNumberOfDocuments(final long processInstanceId) throws DocumentException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final DocumentService documentService = tenantAccessor.getDocumentService(); try { return documentService.getNumberOfDocumentsOfProcessInstance(processInstanceId); } catch (final SBonitaReadException e) { throw new DocumentException(e); } }
@Override public long getNumberOfDocuments(final long processInstanceId) throws DocumentException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final DocumentService documentService = tenantAccessor.getDocumentService(); try { return documentService.getNumberOfDocumentsOfProcessInstance(processInstanceId); } catch (final SBonitaReadException e) { throw new DocumentException(e); } }
@Override public List<Document> getLastVersionOfDocuments(final long processInstanceId, final int pageIndex, final int numberPerPage, final DocumentCriterion pagingCriterion) throws DocumentException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final DocumentService documentService = tenantAccessor.getDocumentService(); final OrderAndField orderAndField = OrderAndFields.getOrderAndFieldForDocument(pagingCriterion); try { final List<SMappedDocument> mappedDocuments = documentService.getDocumentsOfProcessInstance(processInstanceId, pageIndex, numberPerPage, orderAndField.getField(), orderAndField.getOrder()); if (mappedDocuments != null && !mappedDocuments.isEmpty()) { final List<Document> result = new ArrayList<Document>(mappedDocuments.size()); for (final SMappedDocument mappedDocument : mappedDocuments) { result.add(ModelConvertor.toDocument(mappedDocument, documentService)); } return result; } return Collections.emptyList(); } catch (final SBonitaReadException e) { throw new DocumentException(e); } }
@Override public List<Document> getLastVersionOfDocuments(final long processInstanceId, final int pageIndex, final int numberPerPage, final DocumentCriterion pagingCriterion) throws DocumentException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final DocumentService documentService = tenantAccessor.getDocumentService(); final OrderAndField orderAndField = OrderAndFields.getOrderAndFieldForDocument(pagingCriterion); try { final List<SMappedDocument> mappedDocuments = documentService.getDocumentsOfProcessInstance(processInstanceId, pageIndex, numberPerPage, orderAndField.getField(), orderAndField.getOrder()); if (mappedDocuments != null && !mappedDocuments.isEmpty()) { final List<Document> result = new ArrayList<Document>(mappedDocuments.size()); for (final SMappedDocument mappedDocument : mappedDocuments) { result.add(ModelConvertor.toDocument(mappedDocument, documentService)); } return result; } return Collections.emptyList(); } catch (final SBonitaReadException e) { throw new DocumentException(e); } }
@Override public void deleteContentOfArchivedDocument(final long archivedDocumentId) throws DocumentException, DocumentNotFoundException { final TenantServiceAccessor tenantAccessor = APIUtils.getTenantAccessor(); final DocumentService documentService = tenantAccessor.getDocumentService(); try { documentService.deleteContentOfArchivedDocument(archivedDocumentId); } catch (final SObjectNotFoundException e) { throw new DocumentNotFoundException("The document with id " + archivedDocumentId + " could not be found", e); } catch (final SBonitaException e) { throw new DocumentException("Unable to delete content of all version of the document " + archivedDocumentId, e); } }
@Override public void deleteContentOfArchivedDocument(final long archivedDocumentId) throws DocumentException, DocumentNotFoundException { final TenantServiceAccessor tenantAccessor = APIUtils.getTenantAccessor(); final DocumentService documentService = tenantAccessor.getDocumentService(); try { documentService.deleteContentOfArchivedDocument(archivedDocumentId); } catch (final SObjectNotFoundException e) { throw new DocumentNotFoundException("The document with id " + archivedDocumentId + " could not be found", e); } catch (final SBonitaException e) { throw new DocumentException("Unable to delete content of all version of the document " + archivedDocumentId, e); } }
@Override public void setDocumentList(final long processInstanceId, final String name, final List<DocumentValue> documentsValues) throws DocumentException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final DocumentHelper documentHelper = new DocumentHelper(tenantAccessor.getDocumentService(), tenantAccessor.getProcessDefinitionService(), tenantAccessor.getProcessInstanceService()); try { documentHelper.setDocumentList(documentsValues, name, processInstanceId, getUserId()); } catch (final SBonitaException e) { throw new DocumentException("Unable to set the list " + name + " on process instance " + processInstanceId, e); } }
@Override public void setDocumentList(final long processInstanceId, final String name, final List<DocumentValue> documentsValues) throws DocumentException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final DocumentHelper documentHelper = new DocumentHelper(tenantAccessor.getDocumentService(), tenantAccessor.getProcessDefinitionService(), tenantAccessor.getProcessInstanceService()); try { documentHelper.setDocumentList(documentsValues, name, processInstanceId, getUserId()); } catch (final SBonitaException e) { throw new DocumentException("Unable to set the list " + name + " on process instance " + processInstanceId, e); } }