use of teammates.storage.entity.Instructor in project teammates by TEAMMATES.
the class InstructorsDb method deleteInstructor.
/**
* Deletes the instructor specified by courseId and email.
*/
public void deleteInstructor(String courseId, String email) {
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, email);
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, courseId);
Instructor instructorToDelete = getInstructorEntityForEmail(courseId, email);
if (instructorToDelete == null) {
return;
}
InstructorAttributes instructorToDeleteAttributes = makeAttributes(instructorToDelete);
deleteDocument(instructorToDeleteAttributes);
deleteEntityDirect(instructorToDelete, instructorToDeleteAttributes);
Instructor instructorCheck = getInstructorEntityForEmail(courseId, email);
if (instructorCheck != null) {
putDocument(makeAttributes(instructorCheck));
}
// TODO: reuse the method in the parent class instead
}
use of teammates.storage.entity.Instructor in project teammates by TEAMMATES.
the class InstructorsDb method updateInstructorByGoogleId.
/**
* Updates the instructor. Cannot modify Course ID or google id.
*/
public void updateInstructorByGoogleId(InstructorAttributes instructorAttributesToUpdate) throws InvalidParametersException, EntityDoesNotExistException {
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, instructorAttributesToUpdate);
if (!instructorAttributesToUpdate.isValid()) {
throw new InvalidParametersException(instructorAttributesToUpdate.getInvalidityInfo());
}
instructorAttributesToUpdate.sanitizeForSaving();
Instructor instructorToUpdate = getInstructorEntityForGoogleId(instructorAttributesToUpdate.courseId, instructorAttributesToUpdate.googleId);
if (instructorToUpdate == null) {
throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT_ACCOUNT + instructorAttributesToUpdate.googleId + ThreadHelper.getCurrentThreadStack());
}
instructorToUpdate.setName(instructorAttributesToUpdate.name);
instructorToUpdate.setEmail(instructorAttributesToUpdate.email);
instructorToUpdate.setIsArchived(instructorAttributesToUpdate.isArchived);
instructorToUpdate.setRole(instructorAttributesToUpdate.role);
instructorToUpdate.setIsDisplayedToStudents(instructorAttributesToUpdate.isDisplayedToStudents);
instructorToUpdate.setDisplayedName(instructorAttributesToUpdate.displayedName);
instructorToUpdate.setInstructorPrivilegeAsText(instructorAttributesToUpdate.getTextFromInstructorPrivileges());
// TODO: make courseId+email the non-modifiable values
putDocument(makeAttributes(instructorToUpdate));
saveEntity(instructorToUpdate, instructorAttributesToUpdate);
}
Aggregations