Search in sources :

Example 1 with Curator

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

the class HousekeepingOperationsService method createHousekeeping.

/**
     * Create study housekeeping
     */
public Housekeeping createHousekeeping() {
    // Create housekeeping object and create the study added date
    Housekeeping housekeeping = new Housekeeping();
    java.util.Date studyAddedDate = new java.util.Date();
    housekeeping.setStudyAddedDate(studyAddedDate);
    // Set status
    CurationStatus status = curationStatusRepository.findByStatus("Awaiting Curation");
    housekeeping.setCurationStatus(status);
    // Set curator
    Curator curator = curatorRepository.findByLastName("Level 1 Curator");
    housekeeping.setCurator(curator);
    // Save housekeeping
    housekeepingRepository.save(housekeeping);
    // Save housekeeping
    return housekeeping;
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) Date(java.util.Date) Curator(uk.ac.ebi.spot.goci.model.Curator) CurationStatus(uk.ac.ebi.spot.goci.model.CurationStatus) Date(java.util.Date)

Example 2 with Curator

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

the class StudyNoteOperationsService method createEmptyStudyNote.

public StudyNote createEmptyStudyNote(Study study, SecureUser user) {
    StudyNote note = new StudyNote();
    note.setStudy(study);
    //defult curator will be the one who is currently adding the note
    //#xintodo this needs to be change when a forgin key is added the curator table from the user table
    Curator curator = curatorService.getCuratorIdByEmail(user.getEmail());
    note.setCurator(curator);
    note.setStatus(false);
    note.setGenericId(study.getId());
    return note;
}
Also used : Curator(uk.ac.ebi.spot.goci.model.Curator) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote)

Example 3 with Curator

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

the class StudyOperationsService method updateHousekeeping.

/**
     * Update housekeeping
     */
public String updateHousekeeping(Housekeeping housekeeping, Study study, SecureUser user) {
    CurationStatus newStatus = housekeeping.getCurationStatus();
    CurationStatus currentStudyStatus = study.getHousekeeping().getCurationStatus();
    Curator newCurator = housekeeping.getCurator();
    Curator currentCurator = study.getHousekeeping().getCurator();
    // If curator has changed, record the curator change event
    if (newCurator != null && newCurator != currentCurator) {
        recordStudyCuratorChange(study, user, newCurator);
    }
    // If the current and new status are different
    String message = null;
    if (newStatus != null && newStatus != currentStudyStatus) {
        if (newStatus.getStatus().equals("Publish study")) {
            // Run pre-publish checks first
            Collection<Association> associations = associationRepository.findByStudyId(study.getId());
            message = publishStudyCheckService.runChecks(study, associations);
            // if checks pass then update the status
            if (message == null) {
                updateStatus(study, housekeeping, user);
            } else // restore old status
            {
                housekeeping.setCurationStatus(currentStudyStatus);
                housekeepingOperationsService.saveHousekeeping(study, housekeeping);
            }
        } else {
            updateStatus(study, housekeeping, user);
        }
    } else {
        // Save housekeeping returned from form
        housekeepingOperationsService.saveHousekeeping(study, housekeeping);
    }
    return message;
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) Curator(uk.ac.ebi.spot.goci.model.Curator) CurationStatus(uk.ac.ebi.spot.goci.model.CurationStatus)

Example 4 with Curator

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

the class HousekeepingOperationsServiceTest method createHousekeeping.

@Test
public void createHousekeeping() throws Exception {
    // Stubbing
    when(curationStatusRepository.findByStatus("Awaiting Curation")).thenReturn(AWAITING_CURATION);
    when(curatorRepository.findByLastName("Level 1 Curator")).thenReturn(LEVEL_1_CURATOR);
    Housekeeping housekeeping = housekeepingOperationsService.createHousekeeping();
    verify(curationStatusRepository, times(1)).findByStatus("Awaiting Curation");
    verify(curatorRepository, times(1)).findByLastName("Level 1 Curator");
    verify(housekeepingRepository, times(1)).save(Matchers.any(Housekeeping.class));
    verifyZeroInteractions(studyRepository);
    // Assertions
    assertThat(housekeeping).extracting(curator -> curator.getCurator().getLastName()).contains("Level 1 Curator");
    assertThat(housekeeping).extracting(curationStatus -> curationStatus.getCurationStatus().getStatus()).contains("Awaiting Curation");
    assertThat(housekeeping.getStudyAddedDate()).isToday();
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) CurationStatusRepository(uk.ac.ebi.spot.goci.repository.CurationStatusRepository) CuratorBuilder(uk.ac.ebi.spot.goci.builder.CuratorBuilder) Matchers(org.mockito.Matchers) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) CuratorRepository(uk.ac.ebi.spot.goci.repository.CuratorRepository) Mockito.verify(org.mockito.Mockito.verify) Mockito.verifyZeroInteractions(org.mockito.Mockito.verifyZeroInteractions) HousekeepingRepository(uk.ac.ebi.spot.goci.repository.HousekeepingRepository) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) CurationStatusBuilder(uk.ac.ebi.spot.goci.builder.CurationStatusBuilder) CurationStatus(uk.ac.ebi.spot.goci.model.CurationStatus) Study(uk.ac.ebi.spot.goci.model.Study) StudyRepository(uk.ac.ebi.spot.goci.repository.StudyRepository) StudyBuilder(uk.ac.ebi.spot.goci.builder.StudyBuilder) HousekeepingBuilder(uk.ac.ebi.spot.goci.builder.HousekeepingBuilder) Curator(uk.ac.ebi.spot.goci.model.Curator) Before(org.junit.Before) Test(org.junit.Test)

Example 5 with Curator

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

the class StudyOperationsService method assignStudyCurator.

/**
     * Assign curator to a study
     */
public void assignStudyCurator(Study study, Assignee assignee, SecureUser user) {
    Long curatorId = assignee.getCuratorId();
    Curator curator = curatorRepository.findOne(curatorId);
    // Set new curator on the study housekeeping
    Housekeeping housekeeping = study.getHousekeeping();
    housekeeping.setCurator(curator);
    housekeepingOperationsService.saveHousekeeping(study, housekeeping);
    // Add event
    recordStudyCuratorChange(study, user, curator);
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) Curator(uk.ac.ebi.spot.goci.model.Curator)

Aggregations

Curator (uk.ac.ebi.spot.goci.model.Curator)6 CurationStatus (uk.ac.ebi.spot.goci.model.CurationStatus)3 Housekeeping (uk.ac.ebi.spot.goci.model.Housekeeping)3 Date (java.util.Date)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Before (org.junit.Before)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 Matchers (org.mockito.Matchers)1 Mock (org.mockito.Mock)1 Mockito.times (org.mockito.Mockito.times)1 Mockito.verify (org.mockito.Mockito.verify)1 Mockito.verifyZeroInteractions (org.mockito.Mockito.verifyZeroInteractions)1 Mockito.when (org.mockito.Mockito.when)1 MockitoJUnitRunner (org.mockito.runners.MockitoJUnitRunner)1 CurationStatusBuilder (uk.ac.ebi.spot.goci.builder.CurationStatusBuilder)1 CuratorBuilder (uk.ac.ebi.spot.goci.builder.CuratorBuilder)1 HousekeepingBuilder (uk.ac.ebi.spot.goci.builder.HousekeepingBuilder)1 StudyBuilder (uk.ac.ebi.spot.goci.builder.StudyBuilder)1 ErrorNotification (uk.ac.ebi.spot.goci.curation.model.errors.ErrorNotification)1