@Test public void testMergeCases() throws Exception { assertNotNull(mergeCaseService); CaseFile sourceCaseFile = new CaseFile(); CaseFile targetCaseFile = new CaseFile(); fillSourceDammyData(sourceCaseFile); fillTargetDammyData(targetCaseFile); EasyMock.expect(saveCaseService.saveCase(sourceCaseFile, auth, ipAddress)).andReturn(sourceCaseFile); EasyMock.expect(saveCaseService.saveCase(targetCaseFile, auth, ipAddress)).andReturn(targetCaseFile); EasyMock.expect(acmParticipantService.saveParticipant("ann-acm", "assignee", 2l, "CASE_FILE")).andReturn(new AcmParticipant()); Capture<AcmFolder> folderCapture = new Capture<>(); EasyMock.expect(caseFileDao.find(sourceId)).andReturn(sourceCaseFile); EasyMock.expect(caseFileDao.find(targetId)).andReturn(targetCaseFile); EasyMock.expect(acmFolderService.moveRootFolder(EasyMock.anyObject(AcmFolder.class), EasyMock.anyObject(AcmFolder.class))) .andReturn(null); AcmFolder someFolder = new AcmFolder(); EasyMock.expect(acmFolderService.addNewFolder(1l, String.format("%s(%s)", "Source", "55435345435_2133"))).andReturn(someFolder); EasyMock.expect(ecmFileDao.changeContainer(EasyMock.anyObject(AcmContainer.class), EasyMock.anyObject(AcmContainer.class), EasyMock.anyObject(List.class))).andReturn(1); AcmCmisObjectList cmisObjlectList = new AcmCmisObjectList(); EasyMock.expect(ecmFileService.listFolderContents(EasyMock.anyObject(Authentication.class), EasyMock.anyObject(AcmContainer.class), EasyMock.eq(null), EasyMock.eq("name"), EasyMock.eq("ASC"), EasyMock.eq(0), EasyMock.eq(10000))).andReturn(cmisObjlectList); replayAll(); MergeCaseOptions mergeCaseOptions = new MergeCaseOptions(); mergeCaseOptions.setSourceCaseFileId(sourceId); mergeCaseOptions.setTargetCaseFileId(targetId); mergeCaseService.mergeCases(auth, ipAddress, mergeCaseOptions); }
@Override @Transactional public CaseFile mergeCases(Authentication auth, String ipAddress, MergeCaseOptions mergeCaseOptions) throws PipelineProcessException, MergeCaseFilesException, AcmUserActionFailedException, AcmCreateObjectFailedException, AcmAccessControlException { CaseFile source = caseFileDao.find(mergeCaseOptions.getSourceCaseFileId()); if (source == null) throw new AcmCaseFileNotFound("Source Case File with id = " + mergeCaseOptions.getSourceCaseFileId() + " not found"); if (hasBeenMerged(source)) throw new MergeCaseFilesException("Source is already merged"); CaseFile target = caseFileDao.find(mergeCaseOptions.getTargetCaseFileId()); if (target == null) throw new AcmCaseFileNotFound("Target Case File with id = " + mergeCaseOptions.getTargetCaseFileId() + " not found"); log.info("Going to merge {} into {}", source.getCaseNumber(), target.getCaseNumber()); mergeFoldersAndDocuments(source, target); ObjectAssociation childObjectSource = new ObjectAssociation(); childObjectSource.setAssociationType("REFERENCE"); childObjectSource.setCategory("MERGED_TO"); childObjectSource.setTargetId(target.getId()); childObjectSource.setTargetType(target.getObjectType()); childObjectSource.setTargetTitle(target.getTitle()); childObjectSource.setTargetName(target.getCaseNumber()); source.addChildObject(childObjectSource); ObjectAssociation childObjectTarget = new ObjectAssociation(); childObjectTarget.setAssociationType("REFERENCE"); childObjectTarget.setCategory("MERGED_FROM"); childObjectTarget.setTargetId(source.getId()); childObjectTarget.setTargetType(source.getObjectType()); childObjectTarget.setTargetTitle(source.getTitle()); childObjectTarget.setTargetName(source.getCaseNumber()); target.addChildObject(childObjectTarget); source.setStatus("CLOSED"); handleParticipants(auth, target); saveCaseService.saveCase(source, auth, ipAddress); target = saveCaseService.saveCase(target, auth, ipAddress); return target; }
MergeCaseServiceImpl implements MergeCaseService { @Override @Transactional public CaseFile mergeCases(Authentication auth, String ipAddress, MergeCaseOptions mergeCaseOptions) throws PipelineProcessException, MergeCaseFilesException, AcmUserActionFailedException, AcmCreateObjectFailedException, AcmAccessControlException { CaseFile source = caseFileDao.find(mergeCaseOptions.getSourceCaseFileId()); if (source == null) throw new AcmCaseFileNotFound("Source Case File with id = " + mergeCaseOptions.getSourceCaseFileId() + " not found"); if (hasBeenMerged(source)) throw new MergeCaseFilesException("Source is already merged"); CaseFile target = caseFileDao.find(mergeCaseOptions.getTargetCaseFileId()); if (target == null) throw new AcmCaseFileNotFound("Target Case File with id = " + mergeCaseOptions.getTargetCaseFileId() + " not found"); log.info("Going to merge {} into {}", source.getCaseNumber(), target.getCaseNumber()); mergeFoldersAndDocuments(source, target); ObjectAssociation childObjectSource = new ObjectAssociation(); childObjectSource.setAssociationType("REFERENCE"); childObjectSource.setCategory("MERGED_TO"); childObjectSource.setTargetId(target.getId()); childObjectSource.setTargetType(target.getObjectType()); childObjectSource.setTargetTitle(target.getTitle()); childObjectSource.setTargetName(target.getCaseNumber()); source.addChildObject(childObjectSource); ObjectAssociation childObjectTarget = new ObjectAssociation(); childObjectTarget.setAssociationType("REFERENCE"); childObjectTarget.setCategory("MERGED_FROM"); childObjectTarget.setTargetId(source.getId()); childObjectTarget.setTargetType(source.getObjectType()); childObjectTarget.setTargetTitle(source.getTitle()); childObjectTarget.setTargetName(source.getCaseNumber()); target.addChildObject(childObjectTarget); source.setStatus("CLOSED"); handleParticipants(auth, target); saveCaseService.saveCase(source, auth, ipAddress); target = saveCaseService.saveCase(target, auth, ipAddress); return target; } }
MergeCaseServiceImpl implements MergeCaseService { @Override @Transactional public CaseFile mergeCases(Authentication auth, String ipAddress, MergeCaseOptions mergeCaseOptions) throws PipelineProcessException, MergeCaseFilesException, AcmUserActionFailedException, AcmCreateObjectFailedException, AcmAccessControlException { CaseFile source = caseFileDao.find(mergeCaseOptions.getSourceCaseFileId()); if (source == null) throw new AcmCaseFileNotFound("Source Case File with id = " + mergeCaseOptions.getSourceCaseFileId() + " not found"); if (hasBeenMerged(source)) throw new MergeCaseFilesException("Source is already merged"); CaseFile target = caseFileDao.find(mergeCaseOptions.getTargetCaseFileId()); if (target == null) throw new AcmCaseFileNotFound("Target Case File with id = " + mergeCaseOptions.getTargetCaseFileId() + " not found"); log.info("Going to merge {} into {}", source.getCaseNumber(), target.getCaseNumber()); mergeFoldersAndDocuments(source, target); ObjectAssociation childObjectSource = new ObjectAssociation(); childObjectSource.setAssociationType("REFERENCE"); childObjectSource.setCategory("MERGED_TO"); childObjectSource.setTargetId(target.getId()); childObjectSource.setTargetType(target.getObjectType()); childObjectSource.setTargetTitle(target.getTitle()); childObjectSource.setTargetName(target.getCaseNumber()); source.addChildObject(childObjectSource); ObjectAssociation childObjectTarget = new ObjectAssociation(); childObjectTarget.setAssociationType("REFERENCE"); childObjectTarget.setCategory("MERGED_FROM"); childObjectTarget.setTargetId(source.getId()); childObjectTarget.setTargetType(source.getObjectType()); childObjectTarget.setTargetTitle(source.getTitle()); childObjectTarget.setTargetName(source.getCaseNumber()); target.addChildObject(childObjectTarget); source.setStatus("CLOSED"); handleParticipants(auth, target); saveCaseService.saveCase(source, auth, ipAddress); target = saveCaseService.saveCase(target, auth, ipAddress); return target; }  }
MergeCaseServiceImpl implements MergeCaseService { @Override @Transactional public CaseFile mergeCases(Authentication auth, String ipAddress, MergeCaseOptions mergeCaseOptions) throws PipelineProcessException, MergeCaseFilesException, AcmUserActionFailedException, AcmCreateObjectFailedException, AcmAccessControlException { CaseFile source = caseFileDao.find(mergeCaseOptions.getSourceCaseFileId()); if (source == null) throw new AcmCaseFileNotFound("Source Case File with id = " + mergeCaseOptions.getSourceCaseFileId() + " not found"); if (hasBeenMerged(source)) throw new MergeCaseFilesException("Source is already merged"); CaseFile target = caseFileDao.find(mergeCaseOptions.getTargetCaseFileId()); if (target == null) throw new AcmCaseFileNotFound("Target Case File with id = " + mergeCaseOptions.getTargetCaseFileId() + " not found"); log.info("Going to merge {} into {}", source.getCaseNumber(), target.getCaseNumber()); mergeFoldersAndDocuments(source, target); ObjectAssociation childObjectSource = new ObjectAssociation(); childObjectSource.setAssociationType("REFERENCE"); childObjectSource.setCategory("MERGED_TO"); childObjectSource.setTargetId(target.getId()); childObjectSource.setTargetType(target.getObjectType()); childObjectSource.setTargetTitle(target.getTitle()); childObjectSource.setTargetName(target.getCaseNumber()); source.addChildObject(childObjectSource); ObjectAssociation childObjectTarget = new ObjectAssociation(); childObjectTarget.setAssociationType("REFERENCE"); childObjectTarget.setCategory("MERGED_FROM"); childObjectTarget.setTargetId(source.getId()); childObjectTarget.setTargetType(source.getObjectType()); childObjectTarget.setTargetTitle(source.getTitle()); childObjectTarget.setTargetName(source.getCaseNumber()); target.addChildObject(childObjectTarget); source.setStatus("CLOSED"); handleParticipants(auth, target); saveCaseService.saveCase(source, auth, ipAddress); target = saveCaseService.saveCase(target, auth, ipAddress); return target; }  @Override @Transactional CaseFile mergeCases(Authentication auth, String ipAddress, MergeCaseOptions mergeCaseOptions); void setSaveCaseService(SaveCaseService saveCaseService); void setCaseFileDao(CaseFileDao caseFileDao); void setAcmFolderService(AcmFolderService acmFolderService); void setEcmFileDao(EcmFileDao ecmFileDao); void setAcmParticipantService(AcmParticipantService acmParticipantService); void setExcludeDocumentTypes(String excludeDocumentTypes); AcmParticipantDao getAcmParticipantDao(); void setAcmParticipantDao(AcmParticipantDao acmParticipantDao); }
MergeCaseServiceImpl implements MergeCaseService { @Override @Transactional public CaseFile mergeCases(Authentication auth, String ipAddress, MergeCaseOptions mergeCaseOptions) throws PipelineProcessException, MergeCaseFilesException, AcmUserActionFailedException, AcmCreateObjectFailedException, AcmAccessControlException { CaseFile source = caseFileDao.find(mergeCaseOptions.getSourceCaseFileId()); if (source == null) throw new AcmCaseFileNotFound("Source Case File with id = " + mergeCaseOptions.getSourceCaseFileId() + " not found"); if (hasBeenMerged(source)) throw new MergeCaseFilesException("Source is already merged"); CaseFile target = caseFileDao.find(mergeCaseOptions.getTargetCaseFileId()); if (target == null) throw new AcmCaseFileNotFound("Target Case File with id = " + mergeCaseOptions.getTargetCaseFileId() + " not found"); log.info("Going to merge {} into {}", source.getCaseNumber(), target.getCaseNumber()); mergeFoldersAndDocuments(source, target); ObjectAssociation childObjectSource = new ObjectAssociation(); childObjectSource.setAssociationType("REFERENCE"); childObjectSource.setCategory("MERGED_TO"); childObjectSource.setTargetId(target.getId()); childObjectSource.setTargetType(target.getObjectType()); childObjectSource.setTargetTitle(target.getTitle()); childObjectSource.setTargetName(target.getCaseNumber()); source.addChildObject(childObjectSource); ObjectAssociation childObjectTarget = new ObjectAssociation(); childObjectTarget.setAssociationType("REFERENCE"); childObjectTarget.setCategory("MERGED_FROM"); childObjectTarget.setTargetId(source.getId()); childObjectTarget.setTargetType(source.getObjectType()); childObjectTarget.setTargetTitle(source.getTitle()); childObjectTarget.setTargetName(source.getCaseNumber()); target.addChildObject(childObjectTarget); source.setStatus("CLOSED"); handleParticipants(auth, target); saveCaseService.saveCase(source, auth, ipAddress); target = saveCaseService.saveCase(target, auth, ipAddress); return target; }  @Override @Transactional CaseFile mergeCases(Authentication auth, String ipAddress, MergeCaseOptions mergeCaseOptions); void setSaveCaseService(SaveCaseService saveCaseService); void setCaseFileDao(CaseFileDao caseFileDao); void setAcmFolderService(AcmFolderService acmFolderService); void setEcmFileDao(EcmFileDao ecmFileDao); void setAcmParticipantService(AcmParticipantService acmParticipantService); void setExcludeDocumentTypes(String excludeDocumentTypes); AcmParticipantDao getAcmParticipantDao(); void setAcmParticipantDao(AcmParticipantDao acmParticipantDao);  }