Search in sources :

Example 51 with Study

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);
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) Curator(uk.ac.ebi.spot.goci.model.Curator)

Example 52 with Study

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());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Study(uk.ac.ebi.spot.goci.model.Study) SnpAssociationStandardMultiForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm) LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) Association(uk.ac.ebi.spot.goci.model.Association) AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser) Test(org.junit.Test)

Example 53 with Study

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());
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) SnpAssociationStandardMultiForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm) LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) Association(uk.ac.ebi.spot.goci.model.Association) AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser) Test(org.junit.Test)

Example 54 with Study

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());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Study(uk.ac.ebi.spot.goci.model.Study) LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) Association(uk.ac.ebi.spot.goci.model.Association) AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) SnpAssociationInteractionForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationInteractionForm) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser) Test(org.junit.Test)

Example 55 with Study

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";
}
Also used : InitialSampleDescription(uk.ac.ebi.spot.goci.curation.model.InitialSampleDescription) Study(uk.ac.ebi.spot.goci.model.Study) Ancestry(uk.ac.ebi.spot.goci.model.Ancestry) ReplicationSampleDescription(uk.ac.ebi.spot.goci.curation.model.ReplicationSampleDescription) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Study (uk.ac.ebi.spot.goci.model.Study)65 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)23 Association (uk.ac.ebi.spot.goci.model.Association)14 SecureUser (uk.ac.ebi.spot.goci.model.SecureUser)14 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)8 AssociationValidationView (uk.ac.ebi.spot.goci.curation.model.AssociationValidationView)7 LastViewedAssociation (uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation)7 MultiStudyNoteForm (uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm)7 Housekeeping (uk.ac.ebi.spot.goci.model.Housekeeping)7 SnpAssociationStandardMultiForm (uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 NoteSubject (uk.ac.ebi.spot.goci.model.NoteSubject)4 SingleNucleotidePolymorphism (uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism)4 Autowired (org.springframework.beans.factory.annotation.Autowired)3 PageRequest (org.springframework.data.domain.PageRequest)3 Pageable (org.springframework.data.domain.Pageable)3 Service (org.springframework.stereotype.Service)3 StudyNoteForm (uk.ac.ebi.spot.goci.curation.model.StudyNoteForm)3 ErrorNotification (uk.ac.ebi.spot.goci.curation.model.errors.ErrorNotification)3