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();
}
use of uk.ac.ebi.spot.goci.model.Housekeeping in project goci by EBISPOT.
the class PrintController method getStudyInfoToPrint.
protected ArrayList<Object> getStudyInfoToPrint(Study studyToPrint) {
// Get relevant study details
Long studyId = studyToPrint.getId();
// Get association information
Collection<SnpAssociationTableView> snpAssociationTableViews = studyPrintService.generatePrintView(studyId);
// Get housekeeping and ancestry information
Housekeeping housekeeping = studyToPrint.getHousekeeping();
Collection<StudyNote> studyNotes = studyToPrint.getNotes();
String initialSampleDescription = studyToPrint.getInitialSampleSize();
String replicateSampleDescription = studyToPrint.getReplicateSampleSize();
// Creating a Hashtable
ArrayList<Object> infoToPrint = new ArrayList<Object>();
infoToPrint.add(studyToPrint);
infoToPrint.add(housekeeping);
infoToPrint.add(initialSampleDescription);
infoToPrint.add(replicateSampleDescription);
infoToPrint.add(ancestryRepository.findByStudyIdAndType(studyId, "initial"));
infoToPrint.add(ancestryRepository.findByStudyIdAndType(studyId, "replication"));
infoToPrint.add(snpAssociationTableViews);
infoToPrint.add(studyNotes);
return infoToPrint;
}
use of uk.ac.ebi.spot.goci.model.Housekeeping in project goci by EBISPOT.
the class StudyOperationServiceTest method testUnpublishStudy.
@Test
public void testUnpublishStudy() {
// Create clones of our study/housekeeping before the method runs
Housekeeping housekeepingBeforeUnpublish = new HousekeepingBuilder().setId(799L).setCurationStatus(AWAITING_CURATION).setCurator(UNASSIGNED).build();
Study beforeUnPublish = new StudyBuilder().setId(802L).setHousekeeping(housekeepingBeforeUnpublish).build();
// Stubbing
when(studyRepository.findOne(STU1.getId())).thenReturn(STU1);
when(housekeepingRepository.findOne(STU1.getHousekeeping().getId())).thenReturn(STU1.getHousekeeping());
when(curationStatusRepository.findByStatus("Unpublished from catalog")).thenReturn(UNPUBLISH);
when(eventTypeService.determineEventTypeFromStatus(UNPUBLISH)).thenReturn("STUDY_STATUS_CHANGE_UNPUBLISHED_FROM_CATALOG");
studyOperationsService.unpublishStudy(STU1.getId(), Matchers.any(UnpublishReason.class), SECURE_USER);
verify(studyRepository, times(1)).findOne(STU1.getId());
verify(housekeepingRepository, times(1)).findOne(STU1.getHousekeeping().getId());
verify(curationStatusRepository, times(1)).findByStatus("Unpublished from catalog");
verify(eventTypeService, times(1)).determineEventTypeFromStatus(STU1.getHousekeeping().getCurationStatus());
verify(trackingOperationService, times(1)).update(STU1, SECURE_USER, "STUDY_STATUS_CHANGE_UNPUBLISHED_FROM_CATALOG");
verify(studyRepository, times(1)).save(STU1);
verifyZeroInteractions(mailService);
verifyZeroInteractions(publishStudyCheckService);
verifyZeroInteractions(associationRepository);
// Check housekeeping was saved
assertThat(STU1).isEqualToIgnoringGivenFields(beforeUnPublish, "housekeeping");
assertThat(STU1.getHousekeeping()).isEqualToIgnoringGivenFields(housekeepingBeforeUnpublish, "catalogUnpublishDate", "lastUpdateDate", "curationStatus");
assertThat(STU1.getHousekeeping().getCurationStatus()).extracting("status").contains("Unpublished from catalog");
assertThat(STU1.getHousekeeping().getCatalogUnpublishDate()).isToday();
}
use of uk.ac.ebi.spot.goci.model.Housekeeping in project goci by EBISPOT.
the class StudyUpdateService method updateStudy.
/**
* Update a study entry in the database
*
* @param existingStudyId ID of study being edited
* @param study Study to update
* @param user User performing request
*/
public void updateStudy(Long existingStudyId, Study study, SecureUser user) {
// Use id in URL to get study and then its associated housekeeping
Study existingStudy = studyRepository.findOne(existingStudyId);
Housekeeping existingHousekeeping = existingStudy.getHousekeeping();
// Check changes and record update details
String updateDescription = generateUpdateDescription(existingStudy, study);
// Set the housekeeping of the study returned to one already linked to it in database
// Need to do this as we don't return housekeeping in form
study.setHousekeeping(existingHousekeeping);
trackingOperationService.update(study, user, "STUDY_UPDATE", updateDescription);
studyRepository.save(study);
getLog().info("Study ".concat(String.valueOf(study.getId())).concat(" updated"));
}
use of uk.ac.ebi.spot.goci.model.Housekeeping 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;
}
Aggregations