use of teammates.storage.entity.FeedbackQuestion in project teammates by TEAMMATES.
the class FeedbackQuestionsDb method updateFeedbackQuestion.
/**
* Updates the feedback question identified by `{@code newAttributes.getId()}
* For the remaining parameters, the existing value is preserved
* if the parameter is null (due to 'keep existing' policy).<br>
* The timestamp for {@code updatedAt} is independent of the {@code newAttributes}
* and depends on the value of {@code keepUpdateTimestamp}
* Preconditions: <br>
* * {@code newAttributes.getId()} is non-null and
* correspond to an existing feedback question. <br>
*/
public void updateFeedbackQuestion(FeedbackQuestionAttributes newAttributes, boolean keepUpdateTimestamp) throws InvalidParametersException, EntityDoesNotExistException {
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, newAttributes);
if (!newAttributes.isValid()) {
throw new InvalidParametersException(newAttributes.getInvalidityInfo());
}
FeedbackQuestion fq = getEntity(newAttributes);
if (fq == null) {
throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT + newAttributes.toString());
}
fq.setQuestionNumber(newAttributes.questionNumber);
fq.setQuestionText(newAttributes.questionMetaData);
fq.setQuestionDescription(newAttributes.questionDescription);
fq.setQuestionType(newAttributes.questionType);
fq.setGiverType(newAttributes.giverType);
fq.setRecipientType(newAttributes.recipientType);
fq.setShowResponsesTo(newAttributes.showResponsesTo);
fq.setShowGiverNameTo(newAttributes.showGiverNameTo);
fq.setShowRecipientNameTo(newAttributes.showRecipientNameTo);
fq.setNumberOfEntitiesToGiveFeedbackTo(newAttributes.numberOfEntitiesToGiveFeedbackTo);
// set true to prevent changes to last update timestamp
fq.keepUpdateTimestamp = keepUpdateTimestamp;
saveEntity(fq, newAttributes);
}
Aggregations