Search in sources :

Example 6 with SectionDetail

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;
}
Also used : SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) QuestionType(org.mifos.platform.questionnaire.service.QuestionType) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 7 with 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;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 8 with 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;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 9 with 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));
}
Also used : EventSourceEntity(org.mifos.platform.questionnaire.domain.EventSourceEntity) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) QuestionGroup(org.mifos.platform.questionnaire.domain.QuestionGroup) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto)

Example 10 with 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, 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;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Aggregations

SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)56 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)34 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)25 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)24 Test (org.junit.Test)21 ArrayList (java.util.ArrayList)20 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)13 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)12 Transactional (org.springframework.transaction.annotation.Transactional)7 QuestionGroupInstance (org.mifos.platform.questionnaire.domain.QuestionGroupInstance)5 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)5 ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)5 ValidationException (org.mifos.platform.validations.ValidationException)5 EventSourceEntity (org.mifos.platform.questionnaire.domain.EventSourceEntity)4 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)3 Section (org.mifos.platform.questionnaire.domain.Section)3 BadNumericResponseException (org.mifos.platform.questionnaire.exceptions.BadNumericResponseException)3 QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)3 QuestionGroupResponse (org.mifos.platform.questionnaire.domain.QuestionGroupResponse)2 QuestionGroupDetails (org.mifos.platform.questionnaire.service.QuestionGroupDetails)2