Search in sources :

Example 41 with Study

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

the class StudyNoteController method addNoteToTable.

@RequestMapping(value = "/studies/{studyId}/notes", method = RequestMethod.POST, params = { "addNote" })
public String addNoteToTable(Model model, @PathVariable Long studyId, HttpServletRequest request) {
    //get the study
    Study study = studyRepository.findOne(studyId);
    model.addAttribute("study", study);
    if (study.getHousekeeping().getIsPublished()) {
        return "redirect:/studies/" + studyId + "/notes";
    }
    //the newly added note can only be assigned one of the availlable subject, not including system note subjects.
    Collection<NoteSubject> noteSubjects = noteSubjectService.findNonSystemNoteSubject();
    model.addAttribute("availableNoteSubject", noteSubjects);
    // an form object mapped from the studyNote object, it contains a list of notes
    MultiStudyNoteForm msnf = studyNoteOperationsService.generateMultiStudyNoteForm(study.getNotes(), study);
    SecureUser user = currentUserDetailsService.getUserFromRequest(request);
    //create a default study note with default setting
    StudyNote emptyNote = studyNoteOperationsService.createGeneralNote(study, user);
    StudyNoteForm emptyNoteForm = studyNoteOperationsService.convertToStudyNoteForm(emptyNote);
    //attach the empty form
    msnf.getNomalNoteForms().add(emptyNoteForm);
    //Index of value to add
    final Integer rowId = msnf.getNomalNoteForms().size() - 1;
    //enable the edit for the new note and disable all edit for other notes
    msnf.startEdit(rowId);
    //reload system notes because they are not part of the input
    msnf.setSystemNoteForms(studyNoteOperationsService.generateSystemNoteForms(study.getNotes()));
    model.addAttribute("multiStudyNoteForm", msnf);
    return "study_notes";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) StudyNoteForm(uk.ac.ebi.spot.goci.curation.model.StudyNoteForm) MultiStudyNoteForm(uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm) NoteSubject(uk.ac.ebi.spot.goci.model.NoteSubject) MultiStudyNoteForm(uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 42 with Study

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

the class StudyNoteController method removeNote.

@RequestMapping(value = "/studies/{studyId}/notes", method = RequestMethod.POST, params = { "removeNote" })
public String removeNote(@ModelAttribute("multiStudyNoteForm") MultiStudyNoteForm multiStudyNoteForm, BindingResult bindingResult, Model model, @PathVariable Long studyId, HttpServletRequest req) {
    //Index of value to remove
    final Integer rowId = Integer.valueOf(req.getParameter("removeNote"));
    //get the study
    Study study = studyRepository.findOne(studyId);
    model.addAttribute("study", study);
    StudyNoteForm snf = multiStudyNoteForm.getNomalNoteForms().get(rowId.intValue());
    StudyNote noteToRemove = studyNoteOperationsService.convertToStudyNote(snf, study);
    //if not removing empty row
    if (noteToRemove.getId() != null) {
        ErrorNotification notification = studyOperationsService.deleteStudyNote(study, noteToRemove);
        if (notification.hasErrors()) {
            //we want to display the error to the user simply on top of the form
            getLog().warn("Request: " + req.getRequestURL() + " raised an error." + notification.errorMessage());
            model.addAttribute("errors", "Delete FAIL! " + notification.errorMessage());
            Collection<NoteSubject> noteSubjects = noteSubjectService.findNonSystemNoteSubject();
            model.addAttribute("availableNoteSubject", noteSubjects);
            model.addAttribute("multiStudyNoteForm", multiStudyNoteForm);
            return "study_notes";
        } else {
            return "redirect:/studies/" + studyId + "/notes";
        }
    }
    return "redirect:/studies/" + studyId + "/notes";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) StudyNoteForm(uk.ac.ebi.spot.goci.curation.model.StudyNoteForm) MultiStudyNoteForm(uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm) NoteSubject(uk.ac.ebi.spot.goci.model.NoteSubject) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote) ErrorNotification(uk.ac.ebi.spot.goci.curation.model.errors.ErrorNotification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 43 with Study

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

the class WeeklyProgressReportService method calculateProgressiveQueues2.

public ArrayList<Integer[]> calculateProgressiveQueues2() {
    ArrayList<Object[]> progressionQueues = weeklyTrackingService.getMinYearWeek();
    BigDecimal yearBigDecimal = (BigDecimal) progressionQueues.get(0)[0];
    int year = yearBigDecimal.intValue();
    BigDecimal weekBigDecimal = (BigDecimal) progressionQueues.get(0)[1];
    int week = weekBigDecimal.intValue();
    ArrayList<Integer[]> progressiveQueues = new ArrayList<Integer[]>();
    Calendar calendar = new GregorianCalendar();
    calendar.add(Calendar.DATE, 1);
    Integer maxYear = calendar.get(Calendar.YEAR);
    Integer maxWeek = calendar.get(Calendar.WEEK_OF_YEAR);
    Set<Long> queueLevel1 = new HashSet<Long>();
    Set<Long> queueLevel2 = new HashSet<Long>();
    Set<Long> queueLevel3 = new HashSet<Long>();
    List<WeeklyTracking> weeklyTrackingList = weeklyTrackingService.findAll();
    while (!((year == maxYear) && (week == maxWeek))) {
        //HashSet<Long>  queueLevel1_week = weeklyTrackingService.findStudyByStatusAndYearAndWeek("In level 1 queue", year,week);
        Integer weekQuery = new Integer(week);
        Integer yearQuery = new Integer(year);
        Set<Long> queueLevel1_week = weeklyTrackingList.stream().filter(weeklyTracking -> weeklyTracking.getWeek().equals(weekQuery)).filter(weeklyTracking -> weeklyTracking.getYear().equals(yearQuery)).filter(weeklyTracking -> weeklyTracking.getStatus().equals("In level 1 queue")).map(WeeklyTracking::getStudyId).collect(Collectors.toSet());
        Set<Long> queueLevel2_week = weeklyTrackingList.stream().filter(weeklyTracking -> weeklyTracking.getWeek().equals(weekQuery)).filter(weeklyTracking -> weeklyTracking.getYear().equals(yearQuery)).filter(weeklyTracking -> weeklyTracking.getStatus().equals("In level 2 queue")).map(WeeklyTracking::getStudyId).collect(Collectors.toSet());
        Set<Long> queueLevel3_week = weeklyTrackingList.stream().filter(weeklyTracking -> weeklyTracking.getWeek().equals(weekQuery)).filter(weeklyTracking -> weeklyTracking.getYear().equals(yearQuery)).filter(weeklyTracking -> weeklyTracking.getStatus().equals("In level 3 queue")).map(WeeklyTracking::getStudyId).collect(Collectors.toSet());
        Set<Long> queuePublication_week = weeklyTrackingList.stream().filter(weeklyTracking -> weeklyTracking.getWeek().equals(weekQuery)).filter(weeklyTracking -> weeklyTracking.getYear().equals(yearQuery)).filter(weeklyTracking -> weeklyTracking.getStatus().equals("Publication Study")).map(WeeklyTracking::getStudyId).collect(Collectors.toSet());
        queueLevel1.removeAll(queueLevel2_week);
        queueLevel1.removeAll(queueLevel3_week);
        queueLevel1.removeAll(queuePublication_week);
        queueLevel1.addAll(queueLevel1_week);
        queueLevel2.removeAll(queueLevel3_week);
        queueLevel2.removeAll(queuePublication_week);
        queueLevel2.addAll(queueLevel2_week);
        queueLevel3.removeAll(queuePublication_week);
        queueLevel3.addAll(queueLevel3_week);
        Integer[] row = { year, week, queueLevel1.size(), queueLevel2.size(), queueLevel3.size(), queuePublication_week.size() };
        progressiveQueues.add(row);
        // to change
        if (week == 52) {
            week = 1;
            year = year + 1;
        } else {
            week = week + 1;
        }
    }
    return progressiveQueues;
}
Also used : BigDecimal(java.math.BigDecimal) java.util(java.util) WeeklyTrackingService(uk.ac.ebi.spot.goci.service.WeeklyTrackingService) Service(org.springframework.stereotype.Service) DefaultGroovyMethods.collect(org.codehaus.groovy.runtime.DefaultGroovyMethods.collect) Autowired(org.springframework.beans.factory.annotation.Autowired) Study(uk.ac.ebi.spot.goci.model.Study) WeeklyTracking(uk.ac.ebi.spot.goci.model.WeeklyTracking) Lazy(org.springframework.context.annotation.Lazy) Collectors(java.util.stream.Collectors) SQLDateUtilityService(uk.ac.ebi.spot.goci.service.SQLDateUtilityService) BigDecimal(java.math.BigDecimal) WeeklyTracking(uk.ac.ebi.spot.goci.model.WeeklyTracking)

Example 44 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)

Aggregations

Study (uk.ac.ebi.spot.goci.model.Study)44 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 ArrayList (java.util.ArrayList)7 Association (uk.ac.ebi.spot.goci.model.Association)7 Housekeeping (uk.ac.ebi.spot.goci.model.Housekeeping)6 MultiStudyNoteForm (uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm)5 Date (java.util.Date)4 Test (org.junit.Test)4 Ancestry (uk.ac.ebi.spot.goci.model.Ancestry)4 NoteSubject (uk.ac.ebi.spot.goci.model.NoteSubject)4 SecureUser (uk.ac.ebi.spot.goci.model.SecureUser)4 SingleNucleotidePolymorphism (uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism)4 ParseException (java.text.ParseException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Service (org.springframework.stereotype.Service)3 StudyNoteForm (uk.ac.ebi.spot.goci.curation.model.StudyNoteForm)3 RiskAllele (uk.ac.ebi.spot.goci.model.RiskAllele)3 StudyNote (uk.ac.ebi.spot.goci.model.StudyNote)3 IOException (java.io.IOException)2