Search in sources :

Example 1 with Housekeeping

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

the class StudyOperationServiceTest method setUpMock.

@Before
public void setUpMock() {
    studyOperationsService = new StudyOperationsService(associationRepository, mailService, housekeepingRepository, publishStudyCheckService, studyRepository, curatorRepository, curationStatusRepository, trackingOperationService, eventTypeService, housekeepingOperationsService, studyNoteService, studyNoteOperationsService, curatorService);
    // Create these objects before each test
    Housekeeping CURRENT_HOUSEKEEPING = new HousekeepingBuilder().setId(799L).setCurationStatus(AWAITING_CURATION).setCurator(UNASSIGNED).build();
    STU1 = new StudyBuilder().setId(802L).setHousekeeping(CURRENT_HOUSEKEEPING).build();
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) HousekeepingBuilder(uk.ac.ebi.spot.goci.builder.HousekeepingBuilder) StudyBuilder(uk.ac.ebi.spot.goci.builder.StudyBuilder) Before(org.junit.Before)

Example 2 with Housekeeping

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

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

the class StudyController method viewStudyToDelete.

// Delete an existing study
@RequestMapping(value = "/{studyId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudyToDelete(Model model, @PathVariable Long studyId) {
    Study studyToDelete = studyRepository.findOne(studyId);
    // Check if it has any associations
    Collection<Association> associations = associationRepository.findByStudyId(studyId);
    Long housekeepingId = studyToDelete.getHousekeeping().getId();
    Housekeeping housekeepingAttachedToStudy = housekeepingRepository.findOne(housekeepingId);
    model.addAttribute("studyToDelete", studyToDelete);
    if (housekeepingAttachedToStudy.getCatalogPublishDate() != null) {
        return "delete_published_study_warning";
    } else if (!associations.isEmpty()) {
        return "delete_study_with_associations_warning";
    } else {
        return "delete_study";
    }
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) Study(uk.ac.ebi.spot.goci.model.Study) Association(uk.ac.ebi.spot.goci.model.Association) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Housekeeping

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

the class StudyController method viewStudyHousekeeping.

/* Study housekeeping/curator information */
// Generate page with housekeeping/curator information linked to a study
@RequestMapping(value = "/{studyId}/housekeeping", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudyHousekeeping(Model model, @PathVariable Long studyId) {
    // Find study
    Study study = studyRepository.findOne(studyId);
    // If we don't have a housekeeping object create one, this should not occur though as they are created when study is created
    if (study.getHousekeeping() == null) {
        model.addAttribute("studyHousekeeping", new Housekeeping());
    } else {
        model.addAttribute("studyHousekeeping", study.getHousekeeping());
    }
    // Return the housekeeping object attached to study and return the study
    model.addAttribute("study", study);
    // Return a DTO that holds a summary of any automated mappings
    model.addAttribute("mappingDetails", mappingDetailsService.createMappingSummary(study));
    return "study_housekeeping";
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) Study(uk.ac.ebi.spot.goci.model.Study) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with Housekeeping

use of uk.ac.ebi.spot.goci.model.Housekeeping 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)

Aggregations

Housekeeping (uk.ac.ebi.spot.goci.model.Housekeeping)12 Study (uk.ac.ebi.spot.goci.model.Study)7 CurationStatus (uk.ac.ebi.spot.goci.model.CurationStatus)4 HousekeepingBuilder (uk.ac.ebi.spot.goci.builder.HousekeepingBuilder)3 StudyBuilder (uk.ac.ebi.spot.goci.builder.StudyBuilder)3 Curator (uk.ac.ebi.spot.goci.model.Curator)3 Date (java.util.Date)2 Before (org.junit.Before)2 Test (org.junit.Test)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Association (uk.ac.ebi.spot.goci.model.Association)2 ArrayList (java.util.ArrayList)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)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