@Test public void updateStudyChangeDiseaseTraitAndEfoTrait() throws Exception { when(studyRepository.findOne(STU2.getId())).thenReturn(STU2); when(attributeUpdateService.compareAttribute("Disease Trait", "Acne", STU2_UPDATED.getDiseaseTrait().getTrait())).thenReturn( "Disease Trait updated from 'Acne' to 'Asthma'"); when(attributeUpdateService.compareAttribute("EFO Trait", null, "asthma")).thenReturn( "EFO Trait set to 'asthma'"); studyUpdateService.updateStudy(STU2.getId(), STU2_UPDATED, null, SECURE_USER); verify(trackingOperationService, times(1)).update(STU2_UPDATED, SECURE_USER, "STUDY_UPDATE", "Disease Trait updated from 'Acne' to 'Asthma', EFO Trait set to 'asthma'"); verify(studyRepository, times(1)).save(STU2_UPDATED); verify(extensionRepository, times(0)).save(any(StudyExtension.class)); verify(attributeUpdateService, times(2)).compareAttribute(Matchers.anyString(), Matchers.anyString(), Matchers.anyString()); }
public void updateStudy(Long existingStudyId, Study study, StudyExtension studyExtension, SecureUser user) { Study existingStudy = studyRepository.findOne(existingStudyId); Housekeeping existingHousekeeping = existingStudy.getHousekeeping(); String updateDescription = generateUpdateDescription(existingStudy, study); study.setHousekeeping(existingHousekeeping); trackingOperationService.update(study, user, "STUDY_UPDATE", updateDescription); if (studyExtension != null) { StudyExtension existing = studyExtensionRepository.getStudyExtensionId(study.getId()); if (existing != null) { existing.setStudyDescription(studyExtension.getStudyDescription()); existing.setCohort(studyExtension.getCohort()); existing.setCohortSpecificReference(studyExtension.getCohortSpecificReference()); existing.setStatisticalModel(studyExtension.getStatisticalModel()); existing.setSummaryStatisticsFile(studyExtension.getSummaryStatisticsFile()); existing.setSummaryStatisticsAssembly(studyExtension.getSummaryStatisticsAssembly()); studyExtensionRepository.save(existing); } else { studyExtensionRepository.save(studyExtension); } } studyRepository.save(study); getLog().info("Study ".concat(String.valueOf(study.getId())).concat(" updated")); }
StudyUpdateService { public void updateStudy(Long existingStudyId, Study study, StudyExtension studyExtension, SecureUser user) { Study existingStudy = studyRepository.findOne(existingStudyId); Housekeeping existingHousekeeping = existingStudy.getHousekeeping(); String updateDescription = generateUpdateDescription(existingStudy, study); study.setHousekeeping(existingHousekeeping); trackingOperationService.update(study, user, "STUDY_UPDATE", updateDescription); if (studyExtension != null) { StudyExtension existing = studyExtensionRepository.getStudyExtensionId(study.getId()); if (existing != null) { existing.setStudyDescription(studyExtension.getStudyDescription()); existing.setCohort(studyExtension.getCohort()); existing.setCohortSpecificReference(studyExtension.getCohortSpecificReference()); existing.setStatisticalModel(studyExtension.getStatisticalModel()); existing.setSummaryStatisticsFile(studyExtension.getSummaryStatisticsFile()); existing.setSummaryStatisticsAssembly(studyExtension.getSummaryStatisticsAssembly()); studyExtensionRepository.save(existing); } else { studyExtensionRepository.save(studyExtension); } } studyRepository.save(study); getLog().info("Study ".concat(String.valueOf(study.getId())).concat(" updated")); } }
StudyUpdateService { public void updateStudy(Long existingStudyId, Study study, StudyExtension studyExtension, SecureUser user) { Study existingStudy = studyRepository.findOne(existingStudyId); Housekeeping existingHousekeeping = existingStudy.getHousekeeping(); String updateDescription = generateUpdateDescription(existingStudy, study); study.setHousekeeping(existingHousekeeping); trackingOperationService.update(study, user, "STUDY_UPDATE", updateDescription); if (studyExtension != null) { StudyExtension existing = studyExtensionRepository.getStudyExtensionId(study.getId()); if (existing != null) { existing.setStudyDescription(studyExtension.getStudyDescription()); existing.setCohort(studyExtension.getCohort()); existing.setCohortSpecificReference(studyExtension.getCohortSpecificReference()); existing.setStatisticalModel(studyExtension.getStatisticalModel()); existing.setSummaryStatisticsFile(studyExtension.getSummaryStatisticsFile()); existing.setSummaryStatisticsAssembly(studyExtension.getSummaryStatisticsAssembly()); studyExtensionRepository.save(existing); } else { studyExtensionRepository.save(studyExtension); } } studyRepository.save(study); getLog().info("Study ".concat(String.valueOf(study.getId())).concat(" updated")); } @Autowired  StudyUpdateService(@Qualifier("studyTrackingOperationServiceImpl") TrackingOperationService trackingOperationService,
                              StudyRepository studyRepository,
                              AttributeUpdateService attributeUpdateService,
                              StudyExtensionRepository studyExtensionRepository); }
StudyUpdateService { public void updateStudy(Long existingStudyId, Study study, StudyExtension studyExtension, SecureUser user) { Study existingStudy = studyRepository.findOne(existingStudyId); Housekeeping existingHousekeeping = existingStudy.getHousekeeping(); String updateDescription = generateUpdateDescription(existingStudy, study); study.setHousekeeping(existingHousekeeping); trackingOperationService.update(study, user, "STUDY_UPDATE", updateDescription); if (studyExtension != null) { StudyExtension existing = studyExtensionRepository.getStudyExtensionId(study.getId()); if (existing != null) { existing.setStudyDescription(studyExtension.getStudyDescription()); existing.setCohort(studyExtension.getCohort()); existing.setCohortSpecificReference(studyExtension.getCohortSpecificReference()); existing.setStatisticalModel(studyExtension.getStatisticalModel()); existing.setSummaryStatisticsFile(studyExtension.getSummaryStatisticsFile()); existing.setSummaryStatisticsAssembly(studyExtension.getSummaryStatisticsAssembly()); studyExtensionRepository.save(existing); } else { studyExtensionRepository.save(studyExtension); } } studyRepository.save(study); getLog().info("Study ".concat(String.valueOf(study.getId())).concat(" updated")); } @Autowired  StudyUpdateService(@Qualifier("studyTrackingOperationServiceImpl") TrackingOperationService trackingOperationService,
                              StudyRepository studyRepository,
                              AttributeUpdateService attributeUpdateService,
                              StudyExtensionRepository studyExtensionRepository); void updateStudy(Long existingStudyId, Study study, StudyExtension studyExtension, SecureUser user); }
StudyUpdateService { public void updateStudy(Long existingStudyId, Study study, StudyExtension studyExtension, SecureUser user) { Study existingStudy = studyRepository.findOne(existingStudyId); Housekeeping existingHousekeeping = existingStudy.getHousekeeping(); String updateDescription = generateUpdateDescription(existingStudy, study); study.setHousekeeping(existingHousekeeping); trackingOperationService.update(study, user, "STUDY_UPDATE", updateDescription); if (studyExtension != null) { StudyExtension existing = studyExtensionRepository.getStudyExtensionId(study.getId()); if (existing != null) { existing.setStudyDescription(studyExtension.getStudyDescription()); existing.setCohort(studyExtension.getCohort()); existing.setCohortSpecificReference(studyExtension.getCohortSpecificReference()); existing.setStatisticalModel(studyExtension.getStatisticalModel()); existing.setSummaryStatisticsFile(studyExtension.getSummaryStatisticsFile()); existing.setSummaryStatisticsAssembly(studyExtension.getSummaryStatisticsAssembly()); studyExtensionRepository.save(existing); } else { studyExtensionRepository.save(studyExtension); } } studyRepository.save(study); getLog().info("Study ".concat(String.valueOf(study.getId())).concat(" updated")); } @Autowired  StudyUpdateService(@Qualifier("studyTrackingOperationServiceImpl") TrackingOperationService trackingOperationService,
                              StudyRepository studyRepository,
                              AttributeUpdateService attributeUpdateService,
                              StudyExtensionRepository studyExtensionRepository); void updateStudy(Long existingStudyId, Study study, StudyExtension studyExtension, SecureUser user);  }