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