Search in sources :

Example 46 with Study

use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.

the class StudyAncestryService method addAncestry.

public void addAncestry(Long studyId, Ancestry ancestry, SecureUser user) {
    Study study = studyRepository.findOne(studyId);
    // Set the study for our ancestry and save
    ancestry.setStudy(study);
    trackingOperationService.create(ancestry, user);
    ancestryRepository.save(ancestry);
    getLog().info("Ancestry ".concat(ancestry.getId().toString()).concat(" created"));
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study)

Example 47 with Study

use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.

the class StudyAncestryService method deleteAll.

public void deleteAll(Long studyId, SecureUser user) {
    // Get all study ancestry's
    Study study = studyRepository.findOne(studyId);
    Collection<Ancestry> studyAncestry = ancestryRepository.findByStudyId(studyId);
    // Delete ancestry
    studyAncestry.forEach(ancestry -> deleteAncestry(ancestry, user));
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) DeletedAncestry(uk.ac.ebi.spot.goci.model.DeletedAncestry) Ancestry(uk.ac.ebi.spot.goci.model.Ancestry)

Example 48 with Study

use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.

the class StudyDataService method updateStudyDiseaseTraitByAccessionId.

public Study updateStudyDiseaseTraitByAccessionId(String trait, String accessionId) {
    Study study = this.getStudyByAccessionId(accessionId).orElseThrow(() -> new ResourceNotFoundException("Study", accessionId));
    DiseaseTrait diseaseTrait = Optional.ofNullable(diseaseTraitRepository.findByTraitIgnoreCase(trait)).orElseThrow(() -> new ResourceNotFoundException("Disease Trait", trait));
    study.setDiseaseTrait(diseaseTrait);
    studyRepository.save(study);
    log.info("Study with accession Id: {} found and updated", accessionId);
    return study;
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) DiseaseTrait(uk.ac.ebi.spot.goci.model.DiseaseTrait) ResourceNotFoundException(uk.ac.ebi.spot.goci.curation.exception.ResourceNotFoundException)

Example 49 with Study

use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.

the class StudyFileService method createFileUploadEvent.

/**
 * Record file upload event
 *
 * @param studyId Study ID which is used to find study specific dir
 * @param user    User carrying out request
 */
public void createFileUploadEvent(Long studyId, SecureUser user) {
    Study study = studyRepository.findOne(studyId);
    trackingOperationService.update(study, user, "STUDY_FILE_UPLOAD");
    studyRepository.save(study);
    getLog().info("Study ".concat(String.valueOf(study.getId())).concat(" updated"));
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study)

Example 50 with Study

use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.

the class BulkOperationsService method flipOpenTargets.

public void flipOpenTargets(Publication publication, SecureUser user) {
    Pair<Boolean, Boolean> existingStatus = getFlagStatus(publication);
    boolean existingOpenTargets = existingStatus.getLeft();
    boolean newOpenTargets = !existingOpenTargets;
    getLog().info("[{}] Changing 'Open Targets' flag for {} studies", publication.getPubmedId(), publication.getStudies().size());
    List<Long> ids = new ArrayList<>();
    for (Study study : publication.getStudies()) {
        ids.add(study.getId());
    }
    for (Long studyId : ids) {
        Study existingStudy = studyRepository.findOne(studyId);
        existingStudy.setOpenTargets(newOpenTargets);
        String updateDescription = "Changed 'Open Targets' flag to: " + Boolean.toString(newOpenTargets);
        trackingOperationService.update(existingStudy, user, "STUDY_UPDATE", updateDescription);
        studyRepository.save(existingStudy);
        getLog().info("Study ".concat(String.valueOf(studyId)).concat(" updated"));
    }
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) ArrayList(java.util.ArrayList)

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