@Test public void startReviewDocumentsWorkflow() throws Exception { String businessProcessName = "acmDocumentWorkflow"; String attachedToObjectType = "COMPLAINT"; String attachedToObjectName = "20140827_202"; Long attachedToObjectId = 500l; ArrayList<EcmFile> documentsToReview = new ArrayList<>(); EcmFile documentToReview = new EcmFile(); documentToReview.setFileId(500l); documentToReview.setFileName("Test File"); documentsToReview.add(documentToReview); AcmTask reviewTask = new AcmTask(); reviewTask.setAssignee("assignee"); reviewTask.setAttachedToObjectType(attachedToObjectType); reviewTask.setTaskStartDate(new Date()); reviewTask.setTitle("title"); reviewTask.setAttachedToObjectName(attachedToObjectName); reviewTask.setAttachedToObjectId(attachedToObjectId); reviewTask.setDocumentsToReview(documentsToReview); reviewTask.setDueDate(new Date()); reviewTask.setPercentComplete(0); List<String> candidateGroup = new ArrayList<>(); candidateGroup.add("Test Group"); reviewTask.setCandidateGroups(candidateGroup); Map<String, Object> pVars = new HashMap<>(); List<String> reviewers = new ArrayList<>(); reviewers.add(reviewTask.getAssignee()); pVars.put("reviewers", reviewers); pVars.put("assignee", reviewTask.getAssignee()); pVars.put("taskName", "title"); pVars.put("documentAuthor", "assignee"); pVars.put("pdfRenditionId", 500l); pVars.put("formXmlId", null); pVars.put("dueDate", reviewTask.getDueDate()); pVars.put("candidateGroups", "Test Group"); pVars.put("OBJECT_TYPE", "FILE"); pVars.put("OBJECT_ID", 500l); pVars.put("OBJECT_NAME", "Test File"); pVars.put("PARENT_OBJECT_TYPE", "COMPLAINT"); pVars.put("PARENT_OBJECT_ID", 500l); pVars.put("REQUEST_TYPE", "DOCUMENT_REVIEW"); expect(mockAuthentication.getName()).andReturn("assignee").atLeastOnce(); expect(mockTaskDao.startBusinessProcess(pVars, businessProcessName)).andReturn(reviewTask); replayAll(); List<AcmTask> createdAcmTasks = acmTaskService.startReviewDocumentsWorkflow(reviewTask, businessProcessName, mockAuthentication); verifyAll(); assertNotNull(createdAcmTasks); assertEquals(createdAcmTasks.get(0).getDocumentsToReview().get(0).getFileId(), documentToReview.getFileId()); }
@Override public List<AcmTask> startReviewDocumentsWorkflow(AcmTask task, String businessProcessName, Authentication authentication) throws AcmTaskException { List<String> reviewers = new ArrayList<>(); reviewers.add(task.getAssignee()); List<AcmTask> createdAcmTasks = new ArrayList<>(); Long parentObjectId = task.getAttachedToObjectId(); String parentObjectType = (StringUtils.isNotBlank(task.getAttachedToObjectType())) ? task.getAttachedToObjectType() : null; if (task.getDocumentsToReview() == null || task.getDocumentsToReview().isEmpty()) { throw new AcmTaskException("You must select at least one document to be reviewed."); } else { for (EcmFile documentToReview : task.getDocumentsToReview()) { Map<String, Object> pVars = new HashMap<>(); pVars.put("reviewers", reviewers); pVars.put("assignee", task.getAssignee()); pVars.put("taskName", task.getTitle()); pVars.put("dueDate", task.getDueDate()); pVars.put("documentAuthor", authentication.getName()); pVars.put("pdfRenditionId", documentToReview.getFileId()); pVars.put("formXmlId", null); pVars.put("candidateGroups", String.join(",", task.getCandidateGroups())); pVars.put("OBJECT_TYPE", "FILE"); pVars.put("OBJECT_ID", documentToReview.getFileId()); pVars.put("OBJECT_NAME", documentToReview.getFileName()); if(documentToReview.getContainer() != null) { pVars.put("PARENT_OBJECT_TYPE", documentToReview.getContainer().getContainerObjectType()); pVars.put("PARENT_OBJECT_ID", documentToReview.getContainer().getContainerObjectId()); } else { pVars.put("PARENT_OBJECT_TYPE", parentObjectType); pVars.put("PARENT_OBJECT_ID", parentObjectId); } pVars.put("REQUEST_TYPE", "DOCUMENT_REVIEW"); AcmTask createdAcmTask = taskDao.startBusinessProcess(pVars, businessProcessName); createdAcmTasks.add(createdAcmTask); } return createdAcmTasks; } }
AcmTaskServiceImpl implements AcmTaskService { @Override public List<AcmTask> startReviewDocumentsWorkflow(AcmTask task, String businessProcessName, Authentication authentication) throws AcmTaskException { List<String> reviewers = new ArrayList<>(); reviewers.add(task.getAssignee()); List<AcmTask> createdAcmTasks = new ArrayList<>(); Long parentObjectId = task.getAttachedToObjectId(); String parentObjectType = (StringUtils.isNotBlank(task.getAttachedToObjectType())) ? task.getAttachedToObjectType() : null; if (task.getDocumentsToReview() == null || task.getDocumentsToReview().isEmpty()) { throw new AcmTaskException("You must select at least one document to be reviewed."); } else { for (EcmFile documentToReview : task.getDocumentsToReview()) { Map<String, Object> pVars = new HashMap<>(); pVars.put("reviewers", reviewers); pVars.put("assignee", task.getAssignee()); pVars.put("taskName", task.getTitle()); pVars.put("dueDate", task.getDueDate()); pVars.put("documentAuthor", authentication.getName()); pVars.put("pdfRenditionId", documentToReview.getFileId()); pVars.put("formXmlId", null); pVars.put("candidateGroups", String.join(",", task.getCandidateGroups())); pVars.put("OBJECT_TYPE", "FILE"); pVars.put("OBJECT_ID", documentToReview.getFileId()); pVars.put("OBJECT_NAME", documentToReview.getFileName()); if(documentToReview.getContainer() != null) { pVars.put("PARENT_OBJECT_TYPE", documentToReview.getContainer().getContainerObjectType()); pVars.put("PARENT_OBJECT_ID", documentToReview.getContainer().getContainerObjectId()); } else { pVars.put("PARENT_OBJECT_TYPE", parentObjectType); pVars.put("PARENT_OBJECT_ID", parentObjectId); } pVars.put("REQUEST_TYPE", "DOCUMENT_REVIEW"); AcmTask createdAcmTask = taskDao.startBusinessProcess(pVars, businessProcessName); createdAcmTasks.add(createdAcmTask); } return createdAcmTasks; } } }
AcmTaskServiceImpl implements AcmTaskService { @Override public List<AcmTask> startReviewDocumentsWorkflow(AcmTask task, String businessProcessName, Authentication authentication) throws AcmTaskException { List<String> reviewers = new ArrayList<>(); reviewers.add(task.getAssignee()); List<AcmTask> createdAcmTasks = new ArrayList<>(); Long parentObjectId = task.getAttachedToObjectId(); String parentObjectType = (StringUtils.isNotBlank(task.getAttachedToObjectType())) ? task.getAttachedToObjectType() : null; if (task.getDocumentsToReview() == null || task.getDocumentsToReview().isEmpty()) { throw new AcmTaskException("You must select at least one document to be reviewed."); } else { for (EcmFile documentToReview : task.getDocumentsToReview()) { Map<String, Object> pVars = new HashMap<>(); pVars.put("reviewers", reviewers); pVars.put("assignee", task.getAssignee()); pVars.put("taskName", task.getTitle()); pVars.put("dueDate", task.getDueDate()); pVars.put("documentAuthor", authentication.getName()); pVars.put("pdfRenditionId", documentToReview.getFileId()); pVars.put("formXmlId", null); pVars.put("candidateGroups", String.join(",", task.getCandidateGroups())); pVars.put("OBJECT_TYPE", "FILE"); pVars.put("OBJECT_ID", documentToReview.getFileId()); pVars.put("OBJECT_NAME", documentToReview.getFileName()); if(documentToReview.getContainer() != null) { pVars.put("PARENT_OBJECT_TYPE", documentToReview.getContainer().getContainerObjectType()); pVars.put("PARENT_OBJECT_ID", documentToReview.getContainer().getContainerObjectId()); } else { pVars.put("PARENT_OBJECT_TYPE", parentObjectType); pVars.put("PARENT_OBJECT_ID", parentObjectId); } pVars.put("REQUEST_TYPE", "DOCUMENT_REVIEW"); AcmTask createdAcmTask = taskDao.startBusinessProcess(pVars, businessProcessName); createdAcmTasks.add(createdAcmTask); } return createdAcmTasks; } }  }
AcmTaskServiceImpl implements AcmTaskService { @Override public List<AcmTask> startReviewDocumentsWorkflow(AcmTask task, String businessProcessName, Authentication authentication) throws AcmTaskException { List<String> reviewers = new ArrayList<>(); reviewers.add(task.getAssignee()); List<AcmTask> createdAcmTasks = new ArrayList<>(); Long parentObjectId = task.getAttachedToObjectId(); String parentObjectType = (StringUtils.isNotBlank(task.getAttachedToObjectType())) ? task.getAttachedToObjectType() : null; if (task.getDocumentsToReview() == null || task.getDocumentsToReview().isEmpty()) { throw new AcmTaskException("You must select at least one document to be reviewed."); } else { for (EcmFile documentToReview : task.getDocumentsToReview()) { Map<String, Object> pVars = new HashMap<>(); pVars.put("reviewers", reviewers); pVars.put("assignee", task.getAssignee()); pVars.put("taskName", task.getTitle()); pVars.put("dueDate", task.getDueDate()); pVars.put("documentAuthor", authentication.getName()); pVars.put("pdfRenditionId", documentToReview.getFileId()); pVars.put("formXmlId", null); pVars.put("candidateGroups", String.join(",", task.getCandidateGroups())); pVars.put("OBJECT_TYPE", "FILE"); pVars.put("OBJECT_ID", documentToReview.getFileId()); pVars.put("OBJECT_NAME", documentToReview.getFileName()); if(documentToReview.getContainer() != null) { pVars.put("PARENT_OBJECT_TYPE", documentToReview.getContainer().getContainerObjectType()); pVars.put("PARENT_OBJECT_ID", documentToReview.getContainer().getContainerObjectId()); } else { pVars.put("PARENT_OBJECT_TYPE", parentObjectType); pVars.put("PARENT_OBJECT_ID", parentObjectId); } pVars.put("REQUEST_TYPE", "DOCUMENT_REVIEW"); AcmTask createdAcmTask = taskDao.startBusinessProcess(pVars, businessProcessName); createdAcmTasks.add(createdAcmTask); } return createdAcmTasks; } }  @Override List<BuckslipProcess> getBuckslipProcessesForObject(String objectType, Long objectId); @Override List<BuckslipProcess> getBuckslipProcessesForChildren(String parentObjectType, Long parentObjectId); @Override Long getCompletedBuckslipProcessIdForObjectFromSolr(String objectType, Long objectId, Authentication authentication); @Override String getBusinessProcessVariable(String businessProcessId, String processVariableKey, boolean readFromHistory); @Override String getBusinessProcessVariableByObjectType(String objectType, Long objectId, String processVariableKey,
            boolean readFromHistory, Authentication authentication); @Override BuckslipProcess updateBuckslipProcess(BuckslipProcess in); @Override boolean isInitiatable(String businessProcessId); @Override boolean isWithdrawable(String businessProcessId); @Override List<BuckslipFutureTask> getBuckslipFutureTasks(String businessProcessId); @Override void setBuckslipFutureTasks(String businessProcessId, List<BuckslipFutureTask> buckslipFutureTasks); @Override String getBuckslipPastTasks(String businessProcessId, boolean readFromHistory); @Override void signalTask(String businessProcessId, String receiveTaskId); @Override void messageTask(Long taskId, String messageName); @Override void createTasks(String taskAssignees, String taskName, String owningGroup, String parentType,
            Long parentId); @Override byte[] getDiagram(Long id); @Override byte[] getDiagram(String processId); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void copyTasks(Long fromObjectId, String fromObjectType, Long toObjectId, String toObjectType, String toObjectName,
            Authentication auth, String ipAddress); @Override void copyTaskFilesAndFoldersToParent(AcmTask task); @Override List<ObjectAssociation> findChildObjects(Long taskId); @Override AcmTask retrieveTask(Long id); @Override List<AcmTask> startReviewDocumentsWorkflow(AcmTask task, String businessProcessName, Authentication authentication); @Override @Transactional List<AcmTask> startReviewDocumentsWorkflow(AcmTask task, String businessProcessName, Authentication authentication, List<MultipartFile> filesToUpload); void setTaskEventPublisher(TaskEventPublisher taskEventPublisher); void setExecuteSolrQuery(ExecuteSolrQuery executeSolrQuery); void setTaskDao(TaskDao taskDao); AcmContainerDao getAcmContainerDao(); void setAcmContainerDao(AcmContainerDao acmContainerDao); AcmFolderService getAcmFolderService(); void setAcmFolderService(AcmFolderService acmFolderService); void setNoteDao(NoteDao noteDao); EcmFileService getEcmFileService(); void setEcmFileService(EcmFileService ecmFileService); void setObjectAssociationService(ObjectAssociationService objectAssociationService); void setFileDao(EcmFileDao fileDao); AcmParticipantDao getAcmParticipantDao(); void setAcmParticipantDao(AcmParticipantDao acmParticipantDao); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter objectConverter); AcmAuthenticationManager getAuthenticationManager(); void setAuthenticationManager(AcmAuthenticationManager authenticationManager); void setSaveBusinessProcess(SaveBusinessProcess saveBusinessProcess); }
AcmTaskServiceImpl implements AcmTaskService { @Override public List<AcmTask> startReviewDocumentsWorkflow(AcmTask task, String businessProcessName, Authentication authentication) throws AcmTaskException { List<String> reviewers = new ArrayList<>(); reviewers.add(task.getAssignee()); List<AcmTask> createdAcmTasks = new ArrayList<>(); Long parentObjectId = task.getAttachedToObjectId(); String parentObjectType = (StringUtils.isNotBlank(task.getAttachedToObjectType())) ? task.getAttachedToObjectType() : null; if (task.getDocumentsToReview() == null || task.getDocumentsToReview().isEmpty()) { throw new AcmTaskException("You must select at least one document to be reviewed."); } else { for (EcmFile documentToReview : task.getDocumentsToReview()) { Map<String, Object> pVars = new HashMap<>(); pVars.put("reviewers", reviewers); pVars.put("assignee", task.getAssignee()); pVars.put("taskName", task.getTitle()); pVars.put("dueDate", task.getDueDate()); pVars.put("documentAuthor", authentication.getName()); pVars.put("pdfRenditionId", documentToReview.getFileId()); pVars.put("formXmlId", null); pVars.put("candidateGroups", String.join(",", task.getCandidateGroups())); pVars.put("OBJECT_TYPE", "FILE"); pVars.put("OBJECT_ID", documentToReview.getFileId()); pVars.put("OBJECT_NAME", documentToReview.getFileName()); if(documentToReview.getContainer() != null) { pVars.put("PARENT_OBJECT_TYPE", documentToReview.getContainer().getContainerObjectType()); pVars.put("PARENT_OBJECT_ID", documentToReview.getContainer().getContainerObjectId()); } else { pVars.put("PARENT_OBJECT_TYPE", parentObjectType); pVars.put("PARENT_OBJECT_ID", parentObjectId); } pVars.put("REQUEST_TYPE", "DOCUMENT_REVIEW"); AcmTask createdAcmTask = taskDao.startBusinessProcess(pVars, businessProcessName); createdAcmTasks.add(createdAcmTask); } return createdAcmTasks; } }  @Override List<BuckslipProcess> getBuckslipProcessesForObject(String objectType, Long objectId); @Override List<BuckslipProcess> getBuckslipProcessesForChildren(String parentObjectType, Long parentObjectId); @Override Long getCompletedBuckslipProcessIdForObjectFromSolr(String objectType, Long objectId, Authentication authentication); @Override String getBusinessProcessVariable(String businessProcessId, String processVariableKey, boolean readFromHistory); @Override String getBusinessProcessVariableByObjectType(String objectType, Long objectId, String processVariableKey,
            boolean readFromHistory, Authentication authentication); @Override BuckslipProcess updateBuckslipProcess(BuckslipProcess in); @Override boolean isInitiatable(String businessProcessId); @Override boolean isWithdrawable(String businessProcessId); @Override List<BuckslipFutureTask> getBuckslipFutureTasks(String businessProcessId); @Override void setBuckslipFutureTasks(String businessProcessId, List<BuckslipFutureTask> buckslipFutureTasks); @Override String getBuckslipPastTasks(String businessProcessId, boolean readFromHistory); @Override void signalTask(String businessProcessId, String receiveTaskId); @Override void messageTask(Long taskId, String messageName); @Override void createTasks(String taskAssignees, String taskName, String owningGroup, String parentType,
            Long parentId); @Override byte[] getDiagram(Long id); @Override byte[] getDiagram(String processId); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) void copyTasks(Long fromObjectId, String fromObjectType, Long toObjectId, String toObjectType, String toObjectName,
            Authentication auth, String ipAddress); @Override void copyTaskFilesAndFoldersToParent(AcmTask task); @Override List<ObjectAssociation> findChildObjects(Long taskId); @Override AcmTask retrieveTask(Long id); @Override List<AcmTask> startReviewDocumentsWorkflow(AcmTask task, String businessProcessName, Authentication authentication); @Override @Transactional List<AcmTask> startReviewDocumentsWorkflow(AcmTask task, String businessProcessName, Authentication authentication, List<MultipartFile> filesToUpload); void setTaskEventPublisher(TaskEventPublisher taskEventPublisher); void setExecuteSolrQuery(ExecuteSolrQuery executeSolrQuery); void setTaskDao(TaskDao taskDao); AcmContainerDao getAcmContainerDao(); void setAcmContainerDao(AcmContainerDao acmContainerDao); AcmFolderService getAcmFolderService(); void setAcmFolderService(AcmFolderService acmFolderService); void setNoteDao(NoteDao noteDao); EcmFileService getEcmFileService(); void setEcmFileService(EcmFileService ecmFileService); void setObjectAssociationService(ObjectAssociationService objectAssociationService); void setFileDao(EcmFileDao fileDao); AcmParticipantDao getAcmParticipantDao(); void setAcmParticipantDao(AcmParticipantDao acmParticipantDao); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter objectConverter); AcmAuthenticationManager getAuthenticationManager(); void setAuthenticationManager(AcmAuthenticationManager authenticationManager); void setSaveBusinessProcess(SaveBusinessProcess saveBusinessProcess);  }