@Test public void testDeleteStudy() throws Exception { when(studyRepository.findOne(UNPUBLISHED_STUDY.getId())).thenReturn(UNPUBLISHED_STUDY); when(currentUserDetailsService.getUserFromRequest(Matchers.any(HttpServletRequest.class))).thenReturn( SECURE_USER); mockMvc.perform(MockMvcRequestBuilders.post("/studies/1235/delete").accept(MediaType.TEXT_HTML_VALUE)) .andExpect(status().is3xxRedirection()); verify(studyRepository, times(1)).findOne(UNPUBLISHED_STUDY.getId()); verify(studyDeletionService, times(1)).deleteStudy(UNPUBLISHED_STUDY, SECURE_USER); }
@RequestMapping(value = "/{studyId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) public String deleteStudy(@PathVariable Long studyId, HttpServletRequest request) { Study studyToDelete = studyRepository.findOne(studyId); studyDeletionService.deleteStudy(studyToDelete, currentUserDetailsService.getUserFromRequest(request)); return "redirect:/studies"; }
StudyController { @RequestMapping(value = "/{studyId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) public String deleteStudy(@PathVariable Long studyId, HttpServletRequest request) { Study studyToDelete = studyRepository.findOne(studyId); studyDeletionService.deleteStudy(studyToDelete, currentUserDetailsService.getUserFromRequest(request)); return "redirect:/studies"; } }
StudyController { @RequestMapping(value = "/{studyId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) public String deleteStudy(@PathVariable Long studyId, HttpServletRequest request) { Study studyToDelete = studyRepository.findOne(studyId); studyDeletionService.deleteStudy(studyToDelete, currentUserDetailsService.getUserFromRequest(request)); return "redirect:/studies"; } @Autowired  StudyController(StudyRepository studyRepository,
                           HousekeepingRepository housekeepingRepository,
                           DiseaseTraitRepository diseaseTraitRepository,
                           EfoTraitRepository efoTraitRepository,
                           CuratorRepository curatorRepository,
                           CurationStatusRepository curationStatusRepository,
                           PlatformRepository platformRepository,
                           AssociationRepository associationRepository,
                           AncestryRepository ancestryRepository,
                           UnpublishReasonRepository unpublishReasonRepository,
                           GenotypingTechnologyRepository genotypingTechnologyRepository,
                           StudyOperationsService studyOperationsService,
                           MappingDetailsService mappingDetailsService,
                           CurrentUserDetailsService currentUserDetailsService,
                           StudyFileService studyFileService,
                           StudyDuplicationService studyDuplicationService,
                           StudyDeletionService studyDeletionService,
                           @Qualifier("studyEventsViewService") EventsViewService eventsViewService,
                           StudyUpdateService studyUpdateService,
                           PublicationOperationsService publicationOperationsService,
                           StudyExtensionRepository studyExtensionRepository,
                           DepositionSubmissionService submissionService); }
StudyController { @RequestMapping(value = "/{studyId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) public String deleteStudy(@PathVariable Long studyId, HttpServletRequest request) { Study studyToDelete = studyRepository.findOne(studyId); studyDeletionService.deleteStudy(studyToDelete, currentUserDetailsService.getUserFromRequest(request)); return "redirect:/studies"; } @Autowired  StudyController(StudyRepository studyRepository,
                           HousekeepingRepository housekeepingRepository,
                           DiseaseTraitRepository diseaseTraitRepository,
                           EfoTraitRepository efoTraitRepository,
                           CuratorRepository curatorRepository,
                           CurationStatusRepository curationStatusRepository,
                           PlatformRepository platformRepository,
                           AssociationRepository associationRepository,
                           AncestryRepository ancestryRepository,
                           UnpublishReasonRepository unpublishReasonRepository,
                           GenotypingTechnologyRepository genotypingTechnologyRepository,
                           StudyOperationsService studyOperationsService,
                           MappingDetailsService mappingDetailsService,
                           CurrentUserDetailsService currentUserDetailsService,
                           StudyFileService studyFileService,
                           StudyDuplicationService studyDuplicationService,
                           StudyDeletionService studyDeletionService,
                           @Qualifier("studyEventsViewService") EventsViewService eventsViewService,
                           StudyUpdateService studyUpdateService,
                           PublicationOperationsService publicationOperationsService,
                           StudyExtensionRepository studyExtensionRepository,
                           DepositionSubmissionService submissionService); @RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String allStudiesPage(Model model,
                                 @RequestParam(required = false) Integer page,
                                 @RequestParam(required = false) String pubmed,
                                 @RequestParam(required = false) String author,
                                 @RequestParam(value = "studytype", required = false) String studyType,
                                 @RequestParam(value = "efotraitid", required = false) Long efoTraitId,
                                 @RequestParam(value = "notesquery", required = false) String notesQuery,
                                 @RequestParam(required = false) String gcstId,
                                 @RequestParam(required = false) String studyId,
                                 @RequestParam(required = false) Long status,
                                 @RequestParam(required = false) Long curator,
                                 @RequestParam(value = "sorttype", required = false) String sortType,
                                 @RequestParam(value = "diseasetraitid", required = false) Long diseaseTraitId,
                                 @RequestParam(required = false) Integer year,
                                 @RequestParam(required = false) Integer month); @RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String searchForStudyByFilter(@ModelAttribute StudySearchFilter studySearchFilter); @RequestMapping(value = "/new", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String newStudyForm(Model model); @CrossOrigin @RequestMapping(value = "/new/import", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST) @ResponseBody ResponseEntity<ArrayList<HashMap<String,String>>> importStudy(@RequestBody String pubmedIdForImport,
                               HttpServletRequest request); @RequestMapping(value = "/new/migratePublications", produces = MediaType.TEXT_HTML_VALUE, method = {RequestMethod.GET,RequestMethod.POST}) synchronized String importAllStudy(@ModelAttribute PubmedIdForImport pubmedIdForImport,
                                           HttpServletRequest request,
                                           Model model); @RequestMapping(value = "/new", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) synchronized String addStudy(@Valid @ModelAttribute Study study,
                                        BindingResult bindingResult,
                                        Model model,
                                        HttpServletRequest request); @RequestMapping(value = "/{studyId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String viewStudy(Model model, @PathVariable Long studyId); @RequestMapping(value = "/{studyId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String updateStudy(@ModelAttribute Study study,
                              @ModelAttribute StudyExtension extension,
                              @PathVariable Long studyId,
                              RedirectAttributes redirectAttributes, HttpServletRequest request); @CrossOrigin @RequestMapping(value = "/{studyId}/changeFirstAuthor/{authorId}", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST) @ResponseBody ResponseEntity<HashMap<String,String>> changeFirstAuthor(@PathVariable(value="studyId") Long studyId,
                                                                                  @PathVariable(value="authorId") Long authorId); @RequestMapping(value = "/{studyId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String viewStudyToDelete(Model model, @PathVariable Long studyId); @RequestMapping(value = "/{studyId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String deleteStudy(@PathVariable Long studyId, HttpServletRequest request); @RequestMapping(value = "/{studyId}/duplicate", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String duplicateStudyGet(Model model, @PathVariable Long studyId,
                                 RedirectAttributes redirectAttributes,
                                 HttpServletRequest request); @RequestMapping(value = "/{studyId}/duplicate", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST) @ResponseBody ResponseEntity<String> duplicateStudyPost(@PathVariable Long studyId,
            @RequestBody String tagsNoteList, HttpServletRequest request); @RequestMapping(value = "/{studyId}/assign", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String assignStudyCurator(@PathVariable Long studyId,
                                     @ModelAttribute Assignee assignee,
                                     RedirectAttributes redirectAttributes, HttpServletRequest request); @RequestMapping(value = "/{studyId}/status_update", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String assignStudyStatus(@PathVariable Long studyId,
                                    @ModelAttribute StatusAssignment statusAssignment,
                                    RedirectAttributes redirectAttributes, HttpServletRequest request); @RequestMapping(value = "/{studyId}/housekeeping", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String viewStudyHousekeeping(Model model, @PathVariable Long studyId); @RequestMapping(value = "/{studyId}/housekeeping", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String updateStudyHousekeeping(@ModelAttribute Housekeeping housekeeping,
                                          @PathVariable Long studyId,
                                          RedirectAttributes redirectAttributes, HttpServletRequest request); @RequestMapping(value = "/{studyId}/unpublish", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String viewStudyToUnpublish(Model model, @PathVariable Long studyId); @RequestMapping(value = "/{studyId}/unpublish", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String unpublishStudy(@ModelAttribute Study studyToUnpublish, @PathVariable Long studyId,
                                 HttpServletRequest request); @RequestMapping(value = "/{studyId}/studyfiles", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String getStudyFiles(Model model, @PathVariable Long studyId); @RequestMapping(value = "/{studyId}/studyfiles/{fileName}", method = RequestMethod.GET) @ResponseBody FileSystemResource downloadStudyFile(@PathVariable Long studyId,
                                                HttpServletRequest request,
                                                HttpServletResponse response); @RequestMapping(value = "/{studyId}/studyfiles/{fileName}/delete", method = RequestMethod.GET) String deleteStudyFile(@PathVariable Long studyId,
                                  @PathVariable String fileName); @RequestMapping(value = "/{studyId}/studyfiles", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) Callable<String> uploadStudyFile(@RequestParam("file") MultipartFile file,
                                            @PathVariable Long studyId,
                                            Model model,
                                            HttpServletRequest request); @RequestMapping(value = "/{studyId}/tracking", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String getStudyEvents(Model model, @PathVariable Long studyId); @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(PubmedLookupException.class) String handlePubmedLookupException(PubmedLookupException pubmedLookupException); @ExceptionHandler(PubmedImportException.class) String handlePubmedImportException(PubmedImportException pubmedImportException); @ExceptionHandler({FileNotFoundException.class}) String handleFileNotFound(); @ModelAttribute("diseaseTraits") List<DiseaseTrait> populateDiseaseTraits(); @ModelAttribute("efoTraits") List<EfoTrait> populateEFOTraits(); @ModelAttribute("curators") List<Curator> populateCurators(); @ModelAttribute("platforms") List<Platform> populatePlatforms(); @ModelAttribute("genotypingTechnologies") List<GenotypingTechnology> populateGenotypingTechnologies(); @ModelAttribute("curationstatuses") List<CurationStatus> populateCurationStatuses(); @ModelAttribute("unpublishreasons") List<UnpublishReason> populateUnpublishReasons(); @ModelAttribute("studyTypes") List<String> populateStudyTypeOptions(); @ModelAttribute("qualifiers") List<String> populateQualifierOptions(); @ModelAttribute("authors") List<String> populateAuthors(); }
StudyController { @RequestMapping(value = "/{studyId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) public String deleteStudy(@PathVariable Long studyId, HttpServletRequest request) { Study studyToDelete = studyRepository.findOne(studyId); studyDeletionService.deleteStudy(studyToDelete, currentUserDetailsService.getUserFromRequest(request)); return "redirect:/studies"; } @Autowired  StudyController(StudyRepository studyRepository,
                           HousekeepingRepository housekeepingRepository,
                           DiseaseTraitRepository diseaseTraitRepository,
                           EfoTraitRepository efoTraitRepository,
                           CuratorRepository curatorRepository,
                           CurationStatusRepository curationStatusRepository,
                           PlatformRepository platformRepository,
                           AssociationRepository associationRepository,
                           AncestryRepository ancestryRepository,
                           UnpublishReasonRepository unpublishReasonRepository,
                           GenotypingTechnologyRepository genotypingTechnologyRepository,
                           StudyOperationsService studyOperationsService,
                           MappingDetailsService mappingDetailsService,
                           CurrentUserDetailsService currentUserDetailsService,
                           StudyFileService studyFileService,
                           StudyDuplicationService studyDuplicationService,
                           StudyDeletionService studyDeletionService,
                           @Qualifier("studyEventsViewService") EventsViewService eventsViewService,
                           StudyUpdateService studyUpdateService,
                           PublicationOperationsService publicationOperationsService,
                           StudyExtensionRepository studyExtensionRepository,
                           DepositionSubmissionService submissionService); @RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String allStudiesPage(Model model,
                                 @RequestParam(required = false) Integer page,
                                 @RequestParam(required = false) String pubmed,
                                 @RequestParam(required = false) String author,
                                 @RequestParam(value = "studytype", required = false) String studyType,
                                 @RequestParam(value = "efotraitid", required = false) Long efoTraitId,
                                 @RequestParam(value = "notesquery", required = false) String notesQuery,
                                 @RequestParam(required = false) String gcstId,
                                 @RequestParam(required = false) String studyId,
                                 @RequestParam(required = false) Long status,
                                 @RequestParam(required = false) Long curator,
                                 @RequestParam(value = "sorttype", required = false) String sortType,
                                 @RequestParam(value = "diseasetraitid", required = false) Long diseaseTraitId,
                                 @RequestParam(required = false) Integer year,
                                 @RequestParam(required = false) Integer month); @RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String searchForStudyByFilter(@ModelAttribute StudySearchFilter studySearchFilter); @RequestMapping(value = "/new", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String newStudyForm(Model model); @CrossOrigin @RequestMapping(value = "/new/import", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST) @ResponseBody ResponseEntity<ArrayList<HashMap<String,String>>> importStudy(@RequestBody String pubmedIdForImport,
                               HttpServletRequest request); @RequestMapping(value = "/new/migratePublications", produces = MediaType.TEXT_HTML_VALUE, method = {RequestMethod.GET,RequestMethod.POST}) synchronized String importAllStudy(@ModelAttribute PubmedIdForImport pubmedIdForImport,
                                           HttpServletRequest request,
                                           Model model); @RequestMapping(value = "/new", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) synchronized String addStudy(@Valid @ModelAttribute Study study,
                                        BindingResult bindingResult,
                                        Model model,
                                        HttpServletRequest request); @RequestMapping(value = "/{studyId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String viewStudy(Model model, @PathVariable Long studyId); @RequestMapping(value = "/{studyId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String updateStudy(@ModelAttribute Study study,
                              @ModelAttribute StudyExtension extension,
                              @PathVariable Long studyId,
                              RedirectAttributes redirectAttributes, HttpServletRequest request); @CrossOrigin @RequestMapping(value = "/{studyId}/changeFirstAuthor/{authorId}", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST) @ResponseBody ResponseEntity<HashMap<String,String>> changeFirstAuthor(@PathVariable(value="studyId") Long studyId,
                                                                                  @PathVariable(value="authorId") Long authorId); @RequestMapping(value = "/{studyId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String viewStudyToDelete(Model model, @PathVariable Long studyId); @RequestMapping(value = "/{studyId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String deleteStudy(@PathVariable Long studyId, HttpServletRequest request); @RequestMapping(value = "/{studyId}/duplicate", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String duplicateStudyGet(Model model, @PathVariable Long studyId,
                                 RedirectAttributes redirectAttributes,
                                 HttpServletRequest request); @RequestMapping(value = "/{studyId}/duplicate", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST) @ResponseBody ResponseEntity<String> duplicateStudyPost(@PathVariable Long studyId,
            @RequestBody String tagsNoteList, HttpServletRequest request); @RequestMapping(value = "/{studyId}/assign", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String assignStudyCurator(@PathVariable Long studyId,
                                     @ModelAttribute Assignee assignee,
                                     RedirectAttributes redirectAttributes, HttpServletRequest request); @RequestMapping(value = "/{studyId}/status_update", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String assignStudyStatus(@PathVariable Long studyId,
                                    @ModelAttribute StatusAssignment statusAssignment,
                                    RedirectAttributes redirectAttributes, HttpServletRequest request); @RequestMapping(value = "/{studyId}/housekeeping", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String viewStudyHousekeeping(Model model, @PathVariable Long studyId); @RequestMapping(value = "/{studyId}/housekeeping", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String updateStudyHousekeeping(@ModelAttribute Housekeeping housekeeping,
                                          @PathVariable Long studyId,
                                          RedirectAttributes redirectAttributes, HttpServletRequest request); @RequestMapping(value = "/{studyId}/unpublish", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String viewStudyToUnpublish(Model model, @PathVariable Long studyId); @RequestMapping(value = "/{studyId}/unpublish", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String unpublishStudy(@ModelAttribute Study studyToUnpublish, @PathVariable Long studyId,
                                 HttpServletRequest request); @RequestMapping(value = "/{studyId}/studyfiles", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String getStudyFiles(Model model, @PathVariable Long studyId); @RequestMapping(value = "/{studyId}/studyfiles/{fileName}", method = RequestMethod.GET) @ResponseBody FileSystemResource downloadStudyFile(@PathVariable Long studyId,
                                                HttpServletRequest request,
                                                HttpServletResponse response); @RequestMapping(value = "/{studyId}/studyfiles/{fileName}/delete", method = RequestMethod.GET) String deleteStudyFile(@PathVariable Long studyId,
                                  @PathVariable String fileName); @RequestMapping(value = "/{studyId}/studyfiles", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) Callable<String> uploadStudyFile(@RequestParam("file") MultipartFile file,
                                            @PathVariable Long studyId,
                                            Model model,
                                            HttpServletRequest request); @RequestMapping(value = "/{studyId}/tracking", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String getStudyEvents(Model model, @PathVariable Long studyId); @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(PubmedLookupException.class) String handlePubmedLookupException(PubmedLookupException pubmedLookupException); @ExceptionHandler(PubmedImportException.class) String handlePubmedImportException(PubmedImportException pubmedImportException); @ExceptionHandler({FileNotFoundException.class}) String handleFileNotFound(); @ModelAttribute("diseaseTraits") List<DiseaseTrait> populateDiseaseTraits(); @ModelAttribute("efoTraits") List<EfoTrait> populateEFOTraits(); @ModelAttribute("curators") List<Curator> populateCurators(); @ModelAttribute("platforms") List<Platform> populatePlatforms(); @ModelAttribute("genotypingTechnologies") List<GenotypingTechnology> populateGenotypingTechnologies(); @ModelAttribute("curationstatuses") List<CurationStatus> populateCurationStatuses(); @ModelAttribute("unpublishreasons") List<UnpublishReason> populateUnpublishReasons(); @ModelAttribute("studyTypes") List<String> populateStudyTypeOptions(); @ModelAttribute("qualifiers") List<String> populateQualifierOptions(); @ModelAttribute("authors") List<String> populateAuthors();  }