use of uk.ac.ebi.spot.goci.curation.model.Assignee in project goci by EBISPOT.
the class StudyController method allStudiesPage.
/* All studies and various filtered lists */
@RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String allStudiesPage(Model model, @RequestParam(required = false) Integer page, @RequestParam(required = false) String pubmed, @RequestParam(required = false) String author, @RequestParam(value = "studytype", required = false) String studyType, @RequestParam(value = "efotraitid", required = false) Long efoTraitId, @RequestParam(value = "notesquery", required = false) String notesQuery, @RequestParam(required = false) Long status, @RequestParam(required = false) Long curator, @RequestParam(value = "sorttype", required = false) String sortType, @RequestParam(value = "diseasetraitid", required = false) Long diseaseTraitId, @RequestParam(required = false) Integer year, @RequestParam(required = false) Integer month) {
// This is passed back to model and determines if pagination is applied
Boolean pagination = true;
// Return all studies ordered by date if no page number given
if (page == null) {
// Find all studies ordered by study date and only display first page
return "redirect:/studies?page=1";
}
// This will be returned to view and store what curator has searched for
StudySearchFilter studySearchFilter = new StudySearchFilter();
// Store filters which will be need for pagination bar and to build URI passed back to view
String filters = "";
// Set sort object and sort string for URI
Sort sort = findSort(sortType);
String sortString = "";
if (sortType != null && !sortType.isEmpty()) {
sortString = "&sorttype=" + sortType;
}
// This is the default study page will all studies
Page<Study> studyPage = studyRepository.findAll(constructPageSpecification(page - 1, sort));
// For multi-snp and snp interaction studies pagination is not applied as the query leads to duplicates
List<Study> studies = null;
// Search by pubmed ID option available from landing page
if (pubmed != null && !pubmed.isEmpty()) {
studyPage = studyRepository.findByPubmedId(pubmed, constructPageSpecification(page - 1, sort));
filters = filters + "&pubmed=" + pubmed;
studySearchFilter.setPubmedId(pubmed);
}
// Search by author option available from landing page
if (author != null && !author.isEmpty()) {
studyPage = studyRepository.findByAuthorContainingIgnoreCase(author, constructPageSpecification(page - 1, sort));
filters = filters + "&author=" + author;
studySearchFilter.setAuthor(author);
}
// Search by study type
if (studyType != null && !studyType.isEmpty()) {
if (studyType.equals("GXE")) {
studyPage = studyRepository.findByGxe(true, constructPageSpecification(page - 1, sort));
}
if (studyType.equals("GXG")) {
studyPage = studyRepository.findByGxg(true, constructPageSpecification(page - 1, sort));
}
if (studyType.equals("CNV")) {
studyPage = studyRepository.findByCnv(true, constructPageSpecification(page - 1, sort));
}
if (studyType.equals("Genomewide array studies")) {
studyPage = studyRepository.findByGenomewideArray(true, constructPageSpecification(page - 1, sort));
}
if (studyType.equals("Targeted array studies")) {
studyPage = studyRepository.findByTargetedArray(true, constructPageSpecification(page - 1, sort));
}
if (studyType.equals("Studies in curation queue")) {
CurationStatus errorStatus = curationStatusRepository.findByStatus("Publish study");
Long errorStatusId = errorStatus.getId();
studyPage = studyRepository.findByHousekeepingCurationStatusIdNot(errorStatusId, constructPageSpecification(page - 1, sort));
}
if (studyType.equals("p-Value Set")) {
studyPage = studyRepository.findByFullPvalueSet(true, constructPageSpecification(page - 1, sort));
}
if (studyType.equals("Multi-SNP haplotype studies")) {
studies = studyRepository.findStudyDistinctByAssociationsMultiSnpHaplotypeTrue(sort);
pagination = false;
}
if (studyType.equals("SNP Interaction studies")) {
studies = studyRepository.findStudyDistinctByAssociationsSnpInteractionTrue(sort);
pagination = false;
}
studySearchFilter.setStudyType(studyType);
filters = filters + "&studytype=" + studyType;
}
// Search by efo trait id
if (efoTraitId != null) {
studyPage = studyRepository.findByEfoTraitsId(efoTraitId, constructPageSpecification(page - 1, sort));
studySearchFilter.setEfoTraitSearchFilterId(efoTraitId);
filters = filters + "&efotraitid=" + efoTraitId;
}
// Search by disease trait id
if (diseaseTraitId != null) {
studyPage = studyRepository.findByDiseaseTraitId(diseaseTraitId, constructPageSpecification(page - 1, sort));
studySearchFilter.setDiseaseTraitSearchFilterId(diseaseTraitId);
filters = filters + "&diseasetraitid=" + diseaseTraitId;
}
// Search by notes for entered string
if (notesQuery != null && !notesQuery.isEmpty()) {
studyPage = studyRepository.findDistinctByNotesTextNoteContainingIgnoreCase(notesQuery, constructPageSpecification(page - 1, sort));
studySearchFilter.setNotesQuery(notesQuery);
filters = filters + "¬esquery=" + notesQuery;
}
// If user entered a status
if (status != null) {
// If we have curator and status find by both
if (curator != null) {
// This is just used to link from reports tab
if (year != null && month != null) {
studyPage = studyRepository.findByPublicationDateAndCuratorAndStatus(curator, status, year, month, constructPageSpecification(page - 1, sort));
studySearchFilter.setMonthFilter(month);
studySearchFilter.setYearFilter(year);
filters = filters + "&status=" + status + "&curator=" + curator + "&year=" + year + "&month=" + month;
} else {
studyPage = studyRepository.findByHousekeepingCurationStatusIdAndHousekeepingCuratorId(status, curator, constructPageSpecification(page - 1, sort));
filters = filters + "&status=" + status + "&curator=" + curator;
}
// Return these values so they appear in filter results
studySearchFilter.setCuratorSearchFilterId(curator);
studySearchFilter.setStatusSearchFilterId(status);
} else {
studyPage = studyRepository.findByHousekeepingCurationStatusId(status, constructPageSpecification(page - 1, sort));
filters = filters + "&status=" + status;
// Return this value so it appears in filter result
studySearchFilter.setStatusSearchFilterId(status);
}
} else // If user entered curator
{
if (curator != null) {
studyPage = studyRepository.findByHousekeepingCuratorId(curator, constructPageSpecification(page - 1, sort));
filters = filters + "&curator=" + curator;
// Return this value so it appears in filter result
studySearchFilter.setCuratorSearchFilterId(curator);
}
}
// Return URI, this will build thymeleaf links using by sort buttons.
// At present, do not add the current sort to the URI,
// just maintain any filter values (pubmed id, author etc) used by curator
String uri = "/studies?page=1";
if (!filters.isEmpty()) {
uri = uri + filters;
}
model.addAttribute("uri", uri);
// filters will be used by pagination bar
if (!filters.isEmpty()) {
if (!sortString.isEmpty()) {
filters = filters + sortString;
}
} else // If user has just sorted without any filter we need
// to pass this back to pagination bar
{
if (!sortString.isEmpty()) {
filters = sortString;
}
}
model.addAttribute("filters", filters);
long totalStudies;
int current = 1;
// Construct table using pagination
if (studies == null) {
model.addAttribute("studies", studyPage);
//Pagination variables
totalStudies = studyPage.getTotalElements();
current = studyPage.getNumber() + 1;
// Returns the greater of two values
int begin = Math.max(1, current - 5);
int end = // how many pages to display in the pagination bar
Math.min(begin + 10, studyPage.getTotalPages());
model.addAttribute("beginIndex", begin);
model.addAttribute("endIndex", end);
model.addAttribute("currentIndex", current);
} else {
model.addAttribute("studies", studies);
totalStudies = studies.size();
}
model.addAttribute("totalStudies", totalStudies);
model.addAttribute("pagination", pagination);
// Add studySearchFilter to model so user can filter table
model.addAttribute("studySearchFilter", studySearchFilter);
// Add assignee and status assignment so user can assign
// study to curator or assign a status
// Also set uri so we can redirect to page user was on
Assignee assignee = new Assignee();
StatusAssignment statusAssignment = new StatusAssignment();
assignee.setUri("/studies?page=" + current + filters);
statusAssignment.setUri("/studies?page=" + current + filters);
model.addAttribute("assignee", assignee);
model.addAttribute("statusAssignment", statusAssignment);
return "studies";
}
Aggregations