use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.
the class StudyNoteController method viewStudyNotes.
@RequestMapping(value = "/studies/{studyId}/notes", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudyNotes(Model model, @PathVariable Long studyId) {
//get the study
Study study = studyRepository.findOne(studyId);
model.addAttribute("study", study);
// an form object mapped from the studyNote object, it contains a list of notes
MultiStudyNoteForm msnf = studyNoteOperationsService.generateMultiStudyNoteForm(study.getNotes(), study);
model.addAttribute("multiStudyNoteForm", msnf);
return "study_notes";
}
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"));
}
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));
}
use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.
the class StudySampleDescriptionsDownloadService method generateStudySampleDescriptions.
public Collection<StudySampleDescription> generateStudySampleDescriptions() {
// Get all ancestries, this will also find all studies with ancestry information
Collection<Ancestry> ancestries = ancestryRepository.findAll(sortByPublicationDateDesc());
Collection<StudySampleDescription> studySampleDescriptions = new ArrayList<>();
for (Ancestry ancestry : ancestries) {
// Make sure ancestry has an attached study
if (ancestry.getStudy() != null) {
Study study = ancestry.getStudy();
// Study attributes
Long studyId = study.getId();
String author = study.getAuthor();
Date publicationDate = study.getPublicationDate();
String pubmedId = study.getPubmedId();
String initialSampleSize = study.getInitialSampleSize();
String replicateSampleSize = study.getReplicateSampleSize();
// Housekeeping attributes
Boolean ancestryCheckedLevelOne = false;
Boolean ancestryCheckedLevelTwo = false;
if (study.getHousekeeping() != null) {
ancestryCheckedLevelOne = study.getHousekeeping().getAncestryCheckedLevelOne();
ancestryCheckedLevelTwo = study.getHousekeeping().getAncestryCheckedLevelTwo();
}
// Ancestry attributes
String type = ancestry.getType();
Integer numberOfIndividuals = ancestry.getNumberOfIndividuals();
Collection<AncestralGroup> ancestralGroup = ancestry.getAncestralGroups();
Collection<Country> countryOfOrigin = ancestry.getCountryOfOrigin();
Collection<Country> countryOfRecruitment = ancestry.getCountryOfRecruitment();
String sampleSizesMatch = ancestry.getSampleSizesMatch();
String description = ancestry.getDescription();
String notes = ancestry.getNotes();
StudySampleDescription studySampleDescription = new StudySampleDescription(studyId, author, publicationDate, pubmedId, initialSampleSize, replicateSampleSize, ancestryCheckedLevelOne, ancestryCheckedLevelTwo, type, numberOfIndividuals, ancestralGroup, countryOfOrigin, countryOfRecruitment, description, sampleSizesMatch, notes);
studySampleDescriptions.add(studySampleDescription);
}
}
return studySampleDescriptions;
}
use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.
the class StudyUpdateService method updateStudy.
/**
* Update a study entry in the database
*
* @param existingStudyId ID of study being edited
* @param study Study to update
* @param user User performing request
*/
public void updateStudy(Long existingStudyId, Study study, SecureUser user) {
// Use id in URL to get study and then its associated housekeeping
Study existingStudy = studyRepository.findOne(existingStudyId);
Housekeeping existingHousekeeping = existingStudy.getHousekeeping();
// Check changes and record update details
String updateDescription = generateUpdateDescription(existingStudy, study);
// Set the housekeeping of the study returned to one already linked to it in database
// Need to do this as we don't return housekeeping in form
study.setHousekeeping(existingHousekeeping);
trackingOperationService.update(study, user, "STUDY_UPDATE", updateDescription);
studyRepository.save(study);
getLog().info("Study ".concat(String.valueOf(study.getId())).concat(" updated"));
}
Aggregations