use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.
the class StudyNoteOperationsService method updateDuplicatedNote.
public void updateDuplicatedNote(StudyNote copiedNote, SecureUser user) {
String body = copiedNote.getTextNote();
Curator curator = curatorService.getCuratorIdByEmail(user.getEmail());
Study sourceStudy = copiedNote.getStudy();
copiedNote.setTextNote(body.concat("\n").concat("Duplicated to other studies with Pubmed ID ").concat(sourceStudy.getPublicationId().getPubmedId()).concat(" by ").concat(curator.getLastName()));
studyNoteService.saveStudyNote(copiedNote);
}
use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.
the class AssociationControllerTest method addMultiSnpsWithNoErrors.
// @Test
// public void addMultiSnpsWithErrors() throws Exception {
// AssociationValidationView associationValidationView =
// new AssociationValidationView("OR", "Value is empty", false);
// List<AssociationValidationView> errors = Collections.singletonList(associationValidationView);
//
// // Stubbing
// when(studyRepository.findOne(Matchers.anyLong())).thenReturn(STUDY);
// when(currentUserDetailsService.getUserFromRequest(Matchers.any(HttpServletRequest.class))).thenReturn(
// SECURE_USER);
// when(associationOperationsService.checkSnpAssociationFormErrors(Matchers.any(SnpAssociationStandardMultiForm.class),
// Matchers.anyString()))
// .thenReturn(Collections.EMPTY_LIST);
// when(singleSnpMultiSnpAssociationService.createAssociation(Matchers.any(SnpAssociationStandardMultiForm.class)))
// .thenReturn(ASSOCIATION);
// when(associationOperationsService.saveAssociationCreatedFromForm(STUDY, ASSOCIATION, SECURE_USER, "")).thenReturn(
// errors);
//
// mockMvc.perform(post("/studies/1234/associations/add_multi").param("measurementType", "or"))
// .andExpect(status().isOk())
// .andExpect(model().attribute("form", instanceOf(SnpAssociationStandardMultiForm.class)))
// .andExpect(model().attribute("errors", instanceOf(List.class)))
// .andExpect(model().attribute("errors", hasSize(1)))
// .andExpect(model().attributeExists("study"))
// .andExpect(model().attributeExists("measurementType"))
// .andExpect(view().name("add_multi_snp_association"));
//
// //verify properties of bound object
// ArgumentCaptor<SnpAssociationStandardMultiForm> formArgumentCaptor =
// ArgumentCaptor.forClass(SnpAssociationStandardMultiForm.class);
// verify(associationOperationsService).checkSnpAssociationFormErrors(formArgumentCaptor.capture(),
// Matchers.anyString());
// verify(singleSnpMultiSnpAssociationService).createAssociation(formArgumentCaptor.capture());
// verify(studyRepository, times(1)).findOne(Matchers.anyLong());
// verify(currentUserDetailsService, times(1)).getUserFromRequest(Matchers.any(HttpServletRequest.class));
// verify(associationOperationsService, times(1)).saveAssociationCreatedFromForm(Matchers.any(Study.class),
// Matchers.any(Association.class),
// Matchers.any(SecureUser.class),
// Matchers.anyString());
// }
@Test
public void addMultiSnpsWithNoErrors() throws Exception {
AssociationValidationView associationValidationView = new AssociationValidationView("SNP", "SNP identifier rs34tt is not valid", true);
List<AssociationValidationView> errors = Collections.singletonList(associationValidationView);
// Stubbing
when(studyRepository.findOne(Matchers.anyLong())).thenReturn(STUDY);
when(currentUserDetailsService.getUserFromRequest(Matchers.any(HttpServletRequest.class))).thenReturn(SECURE_USER);
when(associationOperationsService.checkSnpAssociationFormErrors(Matchers.any(SnpAssociationStandardMultiForm.class), Matchers.anyString())).thenReturn(Collections.EMPTY_LIST);
when(singleSnpMultiSnpAssociationService.createAssociation(Matchers.any(SnpAssociationStandardMultiForm.class))).thenReturn(ASSOCIATION);
when(associationOperationsService.saveAssociationCreatedFromForm(STUDY, ASSOCIATION, SECURE_USER, "")).thenReturn(errors);
mockMvc.perform(post("/studies/1234/associations/add_multi").param("measurementType", "or")).andExpect(status().is3xxRedirection()).andExpect(model().attributeExists("study")).andExpect(model().attributeExists("measurementType")).andExpect(view().name("redirect:/associations/100"));
// verify properties of bound object
ArgumentCaptor<SnpAssociationStandardMultiForm> formArgumentCaptor = ArgumentCaptor.forClass(SnpAssociationStandardMultiForm.class);
verify(associationOperationsService).checkSnpAssociationFormErrors(formArgumentCaptor.capture(), Matchers.anyString());
verify(singleSnpMultiSnpAssociationService).createAssociation(formArgumentCaptor.capture());
verify(studyRepository, times(1)).findOne(Matchers.anyLong());
verify(currentUserDetailsService, times(1)).getUserFromRequest(Matchers.any(HttpServletRequest.class));
verify(associationOperationsService, times(1)).saveAssociationCreatedFromForm(Matchers.any(Study.class), Matchers.any(Association.class), Matchers.any(SecureUser.class), Matchers.anyString());
}
use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.
the class AssociationControllerTest method addMultiSnpsWithRowErrors.
@Test
public void addMultiSnpsWithRowErrors() throws Exception {
AssociationValidationView associationValidationView = new AssociationValidationView("SNP", "Value is empty", false);
List<AssociationValidationView> errors = Collections.singletonList(associationValidationView);
// Stubbing
when(studyRepository.findOne(Matchers.anyLong())).thenReturn(STUDY);
when(associationOperationsService.checkSnpAssociationFormErrors(Matchers.any(SnpAssociationStandardMultiForm.class), Matchers.anyString())).thenReturn(errors);
mockMvc.perform(post("/studies/1234/associations/add_multi").param("measurementType", "or")).andExpect(status().isOk()).andExpect(model().attribute("form", instanceOf(SnpAssociationStandardMultiForm.class))).andExpect(model().attribute("errors", instanceOf(List.class))).andExpect(model().attribute("errors", hasSize(1))).andExpect(model().attributeExists("study")).andExpect(model().attributeExists("measurementType")).andExpect(view().name("add_multi_snp_association"));
// verify properties of bound object
ArgumentCaptor<SnpAssociationStandardMultiForm> formArgumentCaptor = ArgumentCaptor.forClass(SnpAssociationStandardMultiForm.class);
verify(associationOperationsService).checkSnpAssociationFormErrors(formArgumentCaptor.capture(), Matchers.anyString());
verify(studyRepository, times(1)).findOne(Matchers.anyLong());
verifyZeroInteractions(singleSnpMultiSnpAssociationService);
verifyZeroInteractions(currentUserDetailsService);
verify(associationOperationsService, never()).saveAssociationCreatedFromForm(Matchers.any(Study.class), Matchers.any(Association.class), Matchers.any(SecureUser.class), Matchers.anyString());
}
use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.
the class AssociationControllerTest method addSnpInteractionsWithNoErrors.
// @Test
// public void addSnpInteractionWithErrors() throws Exception {
// AssociationValidationView associationValidationView =
// new AssociationValidationView("OR", "Value is empty", false);
// List<AssociationValidationView> errors = Collections.singletonList(associationValidationView);
//
// // Stubbing
// when(studyRepository.findOne(Matchers.anyLong())).thenReturn(STUDY);
// when(currentUserDetailsService.getUserFromRequest(Matchers.any(HttpServletRequest.class))).thenReturn(
// SECURE_USER);
// when(associationOperationsService.checkSnpAssociationInteractionFormErrors(Matchers.any(
// SnpAssociationInteractionForm.class), Matchers.anyString()))
// .thenReturn(Collections.EMPTY_LIST);
// when(snpInteractionAssociationService.createAssociation(Matchers.any(SnpAssociationInteractionForm.class)))
// .thenReturn(ASSOCIATION);
// when(associationOperationsService.saveAssociationCreatedFromForm(STUDY, ASSOCIATION, SECURE_USER,"")).thenReturn(
// errors);
//
// mockMvc.perform(post("/studies/1234/associations/add_interaction").param("measurementType", "or"))
// .andExpect(status().isOk())
// .andExpect(model().attribute("form", instanceOf(SnpAssociationInteractionForm.class)))
// .andExpect(model().attribute("errors", instanceOf(List.class)))
// .andExpect(model().attribute("errors", hasSize(1)))
// .andExpect(model().attributeExists("study"))
// .andExpect(model().attributeExists("measurementType"))
// .andExpect(view().name("add_snp_interaction_association"));
//
// //verify properties of bound object
// ArgumentCaptor<SnpAssociationInteractionForm> formArgumentCaptor =
// ArgumentCaptor.forClass(SnpAssociationInteractionForm.class);
// verify(associationOperationsService).checkSnpAssociationInteractionFormErrors(formArgumentCaptor.capture(),
// Matchers.anyString());
// verify(snpInteractionAssociationService).createAssociation(formArgumentCaptor.capture());
// verify(studyRepository, times(1)).findOne(Matchers.anyLong());
// verify(currentUserDetailsService, times(1)).getUserFromRequest(Matchers.any(HttpServletRequest.class));
// verify(associationOperationsService, times(1)).saveAssociationCreatedFromForm(Matchers.any(Study.class),
// Matchers.any(Association.class),
// Matchers.any(SecureUser.class),
// Matchers.anyString());
// }
@Test
public void addSnpInteractionsWithNoErrors() throws Exception {
AssociationValidationView associationValidationView = new AssociationValidationView("SNP", "SNP identifier rs34tt is not valid", true);
List<AssociationValidationView> errors = Collections.singletonList(associationValidationView);
// Stubbing
when(studyRepository.findOne(Matchers.anyLong())).thenReturn(STUDY);
when(currentUserDetailsService.getUserFromRequest(Matchers.any(HttpServletRequest.class))).thenReturn(SECURE_USER);
when(associationOperationsService.checkSnpAssociationInteractionFormErrors(Matchers.any(SnpAssociationInteractionForm.class), Matchers.anyString())).thenReturn(Collections.EMPTY_LIST);
when(snpInteractionAssociationService.createAssociation(Matchers.any(SnpAssociationInteractionForm.class))).thenReturn(ASSOCIATION);
when(associationOperationsService.saveAssociationCreatedFromForm(STUDY, ASSOCIATION, SECURE_USER, "")).thenReturn(errors);
mockMvc.perform(post("/studies/1234/associations/add_interaction").param("measurementType", "or")).andExpect(status().is3xxRedirection()).andExpect(model().attributeExists("study")).andExpect(model().attributeExists("measurementType")).andExpect(view().name("redirect:/associations/100"));
// verify properties of bound object
ArgumentCaptor<SnpAssociationInteractionForm> formArgumentCaptor = ArgumentCaptor.forClass(SnpAssociationInteractionForm.class);
verify(associationOperationsService).checkSnpAssociationInteractionFormErrorsForView(formArgumentCaptor.capture(), Matchers.anyString());
verify(snpInteractionAssociationService).createAssociation(formArgumentCaptor.capture());
verify(studyRepository, times(1)).findOne(Matchers.anyLong());
verify(currentUserDetailsService, times(1)).getUserFromRequest(Matchers.any(HttpServletRequest.class));
verify(associationOperationsService, times(1)).saveAssociationCreatedFromForm(Matchers.any(Study.class), Matchers.any(Association.class), Matchers.any(SecureUser.class), Matchers.anyString());
}
use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.
the class AncestryController method viewStudySampleDescription.
/* Ancestry/Sample information associated with a study */
// Generate view of ancestry/sample information linked to a study
@RequestMapping(value = "/studies/{studyId}/sampledescription", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudySampleDescription(Model model, @PathVariable Long studyId) {
// Two types of ancestry information which the view needs to form two different tables
Collection<Ancestry> initialStudyAncestryDescriptions = new ArrayList<>();
Collection<Ancestry> replicationStudyAncestryDescriptions = new ArrayList<>();
String initialType = "initial";
String replicationType = "replication";
initialStudyAncestryDescriptions.addAll(ancestryRepository.findByStudyIdAndType(studyId, initialType));
replicationStudyAncestryDescriptions.addAll(ancestryRepository.findByStudyIdAndType(studyId, replicationType));
Collection<Ancestry> allAncestry = new ArrayList<>();
allAncestry.addAll(initialStudyAncestryDescriptions);
allAncestry.addAll(replicationStudyAncestryDescriptions);
for (Ancestry ancestry : allAncestry) {
if (ancestry.getCountryOfRecruitment() == null || ancestry.getCountryOfRecruitment().isEmpty()) {
String message = "No country of recruitment recorded for at least one ancestry entry!";
model.addAttribute("noCountryRecruitment", message);
break;
}
}
// Add all ancestry/sample information for the study to our model
model.addAttribute("initialStudyAncestryDescriptions", initialStudyAncestryDescriptions);
model.addAttribute("replicationStudyAncestryDescriptions", replicationStudyAncestryDescriptions);
// Return an empty ancestry object so curators can add new ancestry/sample information to study
model.addAttribute("ancestry", new Ancestry());
// Return an SampleDescription object for each type
Study study = studyRepository.findOne(studyId);
if (study.getInitialSampleSize() != null && !study.getInitialSampleSize().isEmpty()) {
InitialSampleDescription initialSampleDescription = new InitialSampleDescription();
initialSampleDescription.setInitialSampleDescription(study.getInitialSampleSize());
model.addAttribute("initialSampleDescription", initialSampleDescription);
} else {
model.addAttribute("initialSampleDescription", new InitialSampleDescription());
}
if (study.getReplicateSampleSize() != null && !study.getReplicateSampleSize().isEmpty()) {
ReplicationSampleDescription replicationSampleDescription = new ReplicationSampleDescription();
replicationSampleDescription.setReplicationSampleDescription(study.getReplicateSampleSize());
model.addAttribute("replicationSampleDescription", replicationSampleDescription);
} else {
model.addAttribute("replicationSampleDescription", new ReplicationSampleDescription());
}
// Also passes back study object to view so we can create links back to main study page
model.addAttribute("study", study);
return "study_sample_description";
}
Aggregations