use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.
the class StudyPrintService method generatePrintView.
public Collection<SnpAssociationTableView> generatePrintView(Long studyId) {
// Get relevant study details
Study studyToView = studyRepository.findOne(studyId);
// Association information
Collection<Association> associations = new ArrayList<>();
associations.addAll(associationRepository.findByStudyId(studyId));
// For our associations create a table view object and return
Collection<SnpAssociationTableView> snpAssociationTableViews = new ArrayList<SnpAssociationTableView>();
for (Association association : associations) {
SnpAssociationTableView snpAssociationTableView = snpAssociationTableViewService.createSnpAssociationTableView(association);
snpAssociationTableViews.add(snpAssociationTableView);
}
return snpAssociationTableViews;
}
use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.
the class StudySampleDescriptionService method addStudyInitialReplcationSampleDescription.
public void addStudyInitialReplcationSampleDescription(Long studyId, InitialSampleDescription initialSampleDescription, ReplicationSampleDescription replicationSampleDescription, SecureUser user) {
// Find existing study to add details to
Study study = studyRepository.findOne(studyId);
// Check changes and record update details
String updateDescription = generateUpdateDescription(initialSampleDescription.getInitialSampleDescription(), replicationSampleDescription.getReplicationSampleDescription(), study);
// Set our descriptions which are attributes of the study
study.setInitialSampleSize(initialSampleDescription.getInitialSampleDescription());
study.setReplicateSampleSize(replicationSampleDescription.getReplicationSampleDescription());
// Save study
trackingOperationService.update(study, user, "STUDY_SAMPLE_DESCRIPTION_UPDATE", updateDescription);
studyRepository.save(study);
}
use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.
the class StudyUpdateService method generateUpdateDescription.
/**
* Generate a description of update made
*
* @param existingStudy Study based on whats stored in database
* @param study Updated study
*/
private String generateUpdateDescription(Study existingStudy, Study study) {
String updateDescription = null;
List<String> updateDetails = new ArrayList<>();
// Check disease trait for changes
String existingDiseaseTraitName = null;
if (existingStudy.getDiseaseTrait() != null && existingStudy.getDiseaseTrait().getTrait() != null) {
existingDiseaseTraitName = existingStudy.getDiseaseTrait().getTrait();
}
String updatedDiseaseTraitName = null;
if (study.getDiseaseTrait() != null && study.getDiseaseTrait().getTrait() != null) {
updatedDiseaseTraitName = study.getDiseaseTrait().getTrait();
}
String diseaseTraitUpdateDescription = checkForDiseaseTraitUpdate(existingDiseaseTraitName, updatedDiseaseTraitName);
if (diseaseTraitUpdateDescription != null) {
updateDetails.add(diseaseTraitUpdateDescription);
}
// Check EFO trait for changes
List<String> existingStudyEfoTraits = new ArrayList<>();
List<String> updatedStudyEfoTraits = new ArrayList<>();
existingStudyEfoTraits = existingStudy.getEfoTraits().stream().filter(efoTrait -> efoTrait.getTrait() != null).filter(efoTrait -> !efoTrait.getTrait().isEmpty()).map(efoTrait -> efoTrait.getTrait()).collect(Collectors.toList());
if (study.getEfoTraits() != null) {
updatedStudyEfoTraits = study.getEfoTraits().stream().filter(efoTrait -> !efoTrait.getTrait().isEmpty()).map(efoTrait -> efoTrait.getTrait()).collect(Collectors.toList());
}
String efoTraitUpdateDescription = checkForEfoTraitUpdate(existingStudyEfoTraits, updatedStudyEfoTraits);
if (efoTraitUpdateDescription != null) {
updateDetails.add(efoTraitUpdateDescription);
}
StringJoiner updateDetailsJoiner = new StringJoiner(", ");
if (!updateDetails.isEmpty()) {
updateDetails.forEach(s -> updateDetailsJoiner.add(s));
updateDescription = updateDetailsJoiner.toString();
}
return updateDescription;
}
use of uk.ac.ebi.spot.goci.model.Study in project goci by EBISPOT.
the class StudyAssociationBatchDeletionEventService method createBatchUploadEvent.
/**
* Upload a file to the study specific dir
*
* @param studyId Study to assign event to
* @param associationCount Number of associations deleted
* @param user User that triggered event
*/
public void createBatchUploadEvent(Long studyId, Integer associationCount, SecureUser user) {
Study study = studyRepository.findOne(studyId);
String description = associationCount.toString().concat(" associations deleted");
createEvent(study, user, description);
}
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