use of org.mifos.platform.questionnaire.service.SectionDetail 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.service.SectionDetail in project head by mifos.
the class GroupCustActionTest method getSectionDetail.
private SectionDetail getSectionDetail(String name, String title, List<String> answerChoices) {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName(name);
QuestionDetail questionDetail = new QuestionDetail(111, title, QuestionType.SINGLE_SELECT, true, true);
List<ChoiceDto> choiceDtos = new ArrayList<ChoiceDto>();
for (String answerChoice : answerChoices) {
choiceDtos.add(new ChoiceDto(answerChoice));
}
questionDetail.setAnswerChoices(choiceDtos);
sectionDetail.setQuestionDetails(asList(new SectionQuestionDetail(questionDetail, true)));
return sectionDetail;
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionnaireMapperTest method getSectionDetailWithQuestions.
private SectionDetail getSectionDetailWithQuestions(int id, String name, List<QuestionDetail> questionDetails, String answer, List<String> answers) {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName(name);
List<SectionQuestionDetail> sectionQuestionDetails = new ArrayList<SectionQuestionDetail>();
for (QuestionDetail questionDetail : questionDetails) {
SectionQuestionDetail sectionQuestionDetail = new SectionQuestionDetail(id, questionDetail, false, answer, getSelections(answers));
sectionQuestionDetails.add(sectionQuestionDetail);
}
sectionDetail.setQuestionDetails(sectionQuestionDetails);
return sectionDetail;
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionnaireMapperIntegrationTest method testMapEventSource.
private void testMapEventSource(String event, String source, String description) {
EventSourceDto eventSourceDto = new EventSourceDto(event, source, description);
List<SectionDetail> sectionDetails = getSectionDefinitions();
QuestionGroup questionGroup = questionnaireMapper.mapToQuestionGroup(new QuestionGroupDetail(0, "Title", Arrays.asList(eventSourceDto), sectionDetails, false));
Set<EventSourceEntity> eventSources = questionGroup.getEventSources();
assertThat(eventSources, is(not(nullValue())));
assertThat(eventSources.size(), is(1));
EventSourceEntity eventSourceEntity = eventSources.toArray(new EventSourceEntity[eventSources.size()])[0];
assertThat(eventSourceEntity.getEvent().getName(), is(event));
assertThat(eventSourceEntity.getSource().getEntityType(), is(source));
assertThat(eventSourceEntity.getDescription(), is(description));
assertThat(eventSourceEntity.getEvent().getName(), is(event));
assertThat(eventSourceEntity.getSource().getEntityType(), is(source));
assertThat(eventSourceEntity.getDescription(), is(description));
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionnaireMapperTest method getSectionDetailWithQuestions.
private SectionDetail getSectionDetailWithQuestions(int id, String name, List<QuestionDetail> questionDetails, List<SelectionDetail> answers) {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName(name);
List<SectionQuestionDetail> sectionQuestionDetails = new ArrayList<SectionQuestionDetail>();
for (QuestionDetail questionDetail : questionDetails) {
SectionQuestionDetail sectionQuestionDetail = new SectionQuestionDetail(id, questionDetail, false, null, answers);
sectionQuestionDetails.add(sectionQuestionDetail);
}
sectionDetail.setQuestionDetails(sectionQuestionDetails);
return sectionDetail;
}
Aggregations