use of uk.ac.ebi.spot.goci.model.Curator 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.Curator in project goci by EBISPOT.
the class StudyNoteOperationsService method createEmptyStudyNote.
public StudyNote createEmptyStudyNote(Study study, SecureUser user) {
StudyNote note = new StudyNote();
note.setStudy(study);
//defult curator will be the one who is currently adding the note
//#xintodo this needs to be change when a forgin key is added the curator table from the user table
Curator curator = curatorService.getCuratorIdByEmail(user.getEmail());
note.setCurator(curator);
note.setStatus(false);
note.setGenericId(study.getId());
return note;
}
use of uk.ac.ebi.spot.goci.model.Curator 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.Curator 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.Curator in project goci by EBISPOT.
the class StudyOperationsService method assignStudyCurator.
/**
* Assign curator to a study
*/
public void assignStudyCurator(Study study, Assignee assignee, SecureUser user) {
Long curatorId = assignee.getCuratorId();
Curator curator = curatorRepository.findOne(curatorId);
// Set new curator on the study housekeeping
Housekeeping housekeeping = study.getHousekeeping();
housekeeping.setCurator(curator);
housekeepingOperationsService.saveHousekeeping(study, housekeeping);
// Add event
recordStudyCuratorChange(study, user, curator);
}
Aggregations