Search in sources :

Example 1 with SectionQuestion

use of org.mifos.platform.questionnaire.domain.SectionQuestion in project head by mifos.

the class QuestionnaireMapperImpl method mapToSectionLinkDetails.

public List<SectionLinkDetail> mapToSectionLinkDetails(List<SectionLink> sectionLinks) {
    List<SectionLinkDetail> sectionLinkDetails = new ArrayList<SectionLinkDetail>();
    for (SectionLink sectionLink : sectionLinks) {
        SectionLinkDetail sectionLinkDetail = new SectionLinkDetail();
        sectionLinkDetail.setValue(sectionLink.getQuestionGroupLink().getValue());
        sectionLinkDetail.setAdditionalValue(sectionLink.getQuestionGroupLink().getAdditionalValue());
        sectionLinkDetail.setLinkType(sectionLink.getQuestionGroupLink().getConditionTypeId());
        sectionLinkDetail.setProperLinkTypeDisplay(sectionLink.getQuestionGroupLink().getConditionType());
        sectionLinkDetail.setLinkId(sectionLink.getId());
        sectionLinkDetail.setQuestionGroupLinkId(sectionLink.getQuestionGroupLink().getId());
        sectionLinkDetail.setState(true);
        SectionQuestion sectionQuestion = sectionLink.getQuestionGroupLink().getSourceSectionQuestion();
        sectionLinkDetail.setSourceQuestion(mapToSectionQuestionDetail(sectionQuestion, sectionQuestion.isRequired(), sectionQuestion.isShowOnPage(), (mapToQuestionDetail(sectionQuestion.getQuestion(), mapToQuestionType(sectionQuestion.getQuestion().getAnswerTypeAsEnum())))));
        sectionLinkDetail.setAffectedSection(mapToSectionDetail(sectionLink.getAffectedSection()));
        sectionLinkDetails.add(sectionLinkDetail);
    }
    return sectionLinkDetails;
}
Also used : SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) SectionLink(org.mifos.platform.questionnaire.domain.SectionLink) ArrayList(java.util.ArrayList) SectionLinkDetail(org.mifos.platform.questionnaire.service.SectionLinkDetail)

Example 2 with SectionQuestion

use of org.mifos.platform.questionnaire.domain.SectionQuestion 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 3 with SectionQuestion

use of org.mifos.platform.questionnaire.domain.SectionQuestion in project head by mifos.

the class QuestionnaireMapperImpl method mapToQuestionGroupResponse.

private QuestionGroupResponse mapToQuestionGroupResponse(QuestionGroupInstance questionGroupInstance, QuestionGroupResponseDto questionGroupResponseDto) {
    QuestionGroupResponse questionGroupResponse = new QuestionGroupResponse();
    questionGroupResponse.setResponse(questionGroupResponseDto.getResponse());
    questionGroupResponse.setQuestionGroupInstance(questionGroupInstance);
    SectionQuestion sq;
    if (sectionQuestionMap.containsKey(questionGroupResponseDto.getSectionQuestionId())) {
        sq = sectionQuestionMap.get(questionGroupResponseDto.getSectionQuestionId());
    } else {
        sq = sectionQuestionDao.getDetails(questionGroupResponseDto.getSectionQuestionId());
        sectionQuestionMap.put(questionGroupResponseDto.getSectionQuestionId(), sq);
    }
    questionGroupResponse.setSectionQuestion(sq);
    return questionGroupResponse;
}
Also used : QuestionGroupResponse(org.mifos.platform.questionnaire.domain.QuestionGroupResponse) SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion)

Example 4 with SectionQuestion

use of org.mifos.platform.questionnaire.domain.SectionQuestion in project head by mifos.

the class QuestionnaireMapperImpl method mapToSectionQuestion.

private SectionQuestion mapToSectionQuestion(SectionQuestionDetail sectionQuestionDetail, int seqNum, Section section) {
    QuestionDetail questionDetail = sectionQuestionDetail.getQuestionDetail();
    SectionQuestion sectionQuestion = getSectionQuestion(questionDetail, section);
    sectionQuestion.setRequired(sectionQuestionDetail.isMandatory());
    sectionQuestion.setShowOnPage(sectionQuestionDetail.isShowOnPage());
    sectionQuestion.setSequenceNumber(sectionQuestionDetail.getSequenceNumber());
    if (sectionQuestion.isNewSectionQuestion()) {
        sectionQuestion.setQuestion(mapToQuestion(questionDetail));
        sectionQuestion.setSequenceNumber(seqNum);
        sectionQuestion.setSection(section);
    }
    return sectionQuestion;
}
Also used : SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 5 with SectionQuestion

use of org.mifos.platform.questionnaire.domain.SectionQuestion in project head by mifos.

the class QuestionnaireMapperImpl method mapToSectionQuestion.

private SectionQuestion mapToSectionQuestion(QuestionDto questionDto, Section section) {
    SectionQuestion sectionQuestion = new SectionQuestion();
    sectionQuestion.setSection(section);
    sectionQuestion.setSequenceNumber(questionDto.getOrder());
    sectionQuestion.setRequired(questionDto.isMandatory());
    sectionQuestion.setShowOnPage(questionDto.isShowOnPage());
    sectionQuestion.setQuestion(mapToQuestion(questionDto));
    return sectionQuestion;
}
Also used : SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion)

Aggregations

SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)20 Section (org.mifos.platform.questionnaire.domain.Section)7 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)5 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)5 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)4 QuestionGroupResponse (org.mifos.platform.questionnaire.domain.QuestionGroupResponse)4 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)4 EventSourceEntity (org.mifos.platform.questionnaire.domain.EventSourceEntity)3 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)3 QuestionGroupInstance (org.mifos.platform.questionnaire.domain.QuestionGroupInstance)3 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)3 QuestionChoiceEntity (org.mifos.platform.questionnaire.domain.QuestionChoiceEntity)2 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)2 Transactional (org.springframework.transaction.annotation.Transactional)2 LinkedList (java.util.LinkedList)1 SectionLink (org.mifos.platform.questionnaire.domain.SectionLink)1 SectionQuestionLink (org.mifos.platform.questionnaire.domain.SectionQuestionLink)1 QuestionGroupDetails (org.mifos.platform.questionnaire.service.QuestionGroupDetails)1