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();
}
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);
}
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";
}
}
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";
}
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();
}
Aggregations