Search in sources :

Example 1 with CurationStatus

use of uk.ac.ebi.spot.goci.model.CurationStatus 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 2 with CurationStatus

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

the class StudyOperationsService method unpublishStudy.

/**
     * Unpublish a study entry in the database
     *
     * @param studyId         ID of study to unpublish
     * @param unpublishReason Reason the study is being unpublished
     * @param user            User performing request
     */
public void unpublishStudy(Long studyId, UnpublishReason unpublishReason, SecureUser user) {
    Study study = studyRepository.findOne(studyId);
    // Before we unpublish the study get its associated housekeeping
    Long housekeepingId = study.getHousekeeping().getId();
    Housekeeping housekeepingAttachedToStudy = housekeepingRepository.findOne(housekeepingId);
    //Set the unpublishDate and a new lastUpdateDate in houskeeping
    java.util.Date unpublishDate = new java.util.Date();
    housekeepingAttachedToStudy.setCatalogUnpublishDate(unpublishDate);
    housekeepingAttachedToStudy.setLastUpdateDate(unpublishDate);
    //Set the reason for unpublishing
    housekeepingAttachedToStudy.setUnpublishReason(unpublishReason);
    housekeepingAttachedToStudy.setIsPublished(false);
    //Set the unpublised status in housekeeping
    CurationStatus status = curationStatusRepository.findByStatus("Unpublished from catalog");
    housekeepingAttachedToStudy.setCurationStatus(status);
    updateStatus(study, housekeepingAttachedToStudy, user);
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) Study(uk.ac.ebi.spot.goci.model.Study) Date(java.util.Date) CurationStatus(uk.ac.ebi.spot.goci.model.CurationStatus) Date(java.util.Date)

Example 3 with CurationStatus

use of uk.ac.ebi.spot.goci.model.CurationStatus 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 4 with CurationStatus

use of uk.ac.ebi.spot.goci.model.CurationStatus 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 5 with CurationStatus

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

the class StudyOperationsService method assignStudyStatus.

/**
     * Assign status to a study
     */
public String assignStudyStatus(Study study, StatusAssignment statusAssignment, SecureUser userFromRequest) {
    CurationStatus newStatus = curationStatusRepository.findOne(statusAssignment.getStatusId());
    CurationStatus currentStudyStatus = study.getHousekeeping().getCurationStatus();
    String message = null;
    // If the current and new status are different
    if (newStatus != null && newStatus != currentStudyStatus) {
        // Get housekeeping object and assign new status
        Housekeeping housekeeping = study.getHousekeeping();
        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 and save objects
            if (message == null) {
                housekeeping.setCurationStatus(newStatus);
                updateStatus(study, housekeeping, userFromRequest);
            }
        } else {
            housekeeping.setCurationStatus(newStatus);
            updateStatus(study, housekeeping, userFromRequest);
        }
    } else {
        message = "Current status and new status are the same, no change required";
    }
    return message;
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) Association(uk.ac.ebi.spot.goci.model.Association) CurationStatus(uk.ac.ebi.spot.goci.model.CurationStatus)

Aggregations

CurationStatus (uk.ac.ebi.spot.goci.model.CurationStatus)5 Housekeeping (uk.ac.ebi.spot.goci.model.Housekeeping)4 Curator (uk.ac.ebi.spot.goci.model.Curator)3 Date (java.util.Date)2 Association (uk.ac.ebi.spot.goci.model.Association)2 Study (uk.ac.ebi.spot.goci.model.Study)2 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