use of org.mifos.platform.questionnaire.domain.QuestionEntity in project head by mifos.
the class QuestionnaireMapperImpl method mapToQuestion.
@Override
public QuestionEntity mapToQuestion(QuestionDto questionDto) {
QuestionEntity questionEntity = new QuestionEntity();
questionEntity.setQuestionText(questionDto.getText());
questionEntity.setNickname(questionDto.getNickname());
questionEntity.setAnswerType(mapToAnswerType(questionDto.getType()));
questionEntity.setNumericMin(questionDto.getMinValue());
questionEntity.setNumericMax(questionDto.getMaxValue());
questionEntity.setQuestionState(questionDto.isActive() ? questionDto.isEditable() ? QuestionState.ACTIVE : QuestionState.ACTIVE_NOT_EDITABLE : questionDto.isEditable() ? QuestionState.INACTIVE : QuestionState.INACTIVE_NOT_EDITABLE);
questionEntity.setChoices(mapToChoices(questionDto.getChoices()));
return questionEntity;
}
use of org.mifos.platform.questionnaire.domain.QuestionEntity in project head by mifos.
the class QuestionnaireMapperImpl method mapToSectionDetail.
private SectionDetail mapToSectionDetail(Section section) {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setId(section.getId());
sectionDetail.setName(section.getName());
if (section.getSequenceNumber() != null) {
sectionDetail.setSequenceNumber(section.getSequenceNumber());
}
for (SectionQuestion sectionQuestion : section.getQuestions()) {
QuestionEntity question = sectionQuestion.getQuestion();
QuestionType type = mapToQuestionType(question.getAnswerTypeAsEnum());
boolean required = sectionQuestion.isRequired();
QuestionDetail questionDetail = mapToQuestionDetail(question, type);
sectionDetail.addQuestion(mapToSectionQuestionDetail(sectionQuestion, required, sectionQuestion.isShowOnPage(), questionDetail));
}
return sectionDetail;
}
use of org.mifos.platform.questionnaire.domain.QuestionEntity in project head by mifos.
the class QuestionnaireMapperTest method shouldMapQuestionDetailToQuestion.
@Test
public void shouldMapQuestionDetailToQuestion() {
QuestionDetail questionDefinition = new QuestionDetail(TITLE, QuestionType.FREETEXT);
questionDefinition.setActive(false);
QuestionEntity question = questionnaireMapper.mapToQuestion(questionDefinition);
assertThat(question.getAnswerTypeAsEnum(), CoreMatchers.is(AnswerType.FREETEXT));
assertThat(question.getQuestionText(), is(TITLE));
assertThat(question.getQuestionStateAsEnum(), is(QuestionState.INACTIVE));
}
use of org.mifos.platform.questionnaire.domain.QuestionEntity in project head by mifos.
the class QuestionnaireMapperTest method getQuestionEntity.
private QuestionEntity getQuestionEntity(int questionId, String questionText) {
QuestionEntity questionEntity = new QuestionEntity();
questionEntity.setQuestionId(questionId);
questionEntity.setQuestionText(questionText);
questionEntity.setAnswerType(AnswerType.FREETEXT);
questionEntity.setQuestionState(QuestionState.ACTIVE);
return questionEntity;
}
use of org.mifos.platform.questionnaire.domain.QuestionEntity in project head by mifos.
the class QuestionnaireMapperTest method getSection.
private Section getSection(String sectionName, int questionId) {
Section section = new Section(sectionName);
SectionQuestion sectionQuestion = new SectionQuestion();
QuestionEntity question = new QuestionEntity();
question.setQuestionId(questionId);
question.setQuestionText(sectionName);
question.setAnswerType(AnswerType.DATE);
question.setChoices(new LinkedList<QuestionChoiceEntity>());
sectionQuestion.setQuestion(question);
section.setQuestions(asList(sectionQuestion));
return section;
}
Aggregations