Search in sources :

Example 1 with SectionQuestionLink

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

the class QuestionnaireMapperImpl method mapToQuestionLinkDetails.

public List<QuestionLinkDetail> mapToQuestionLinkDetails(List<SectionQuestionLink> sectionQuestionLinks) {
    List<QuestionLinkDetail> questionLinkDetails = new ArrayList<QuestionLinkDetail>();
    for (SectionQuestionLink sectionQuestionLink : sectionQuestionLinks) {
        QuestionLinkDetail questionLinkDetail = new QuestionLinkDetail();
        questionLinkDetail.setValue(sectionQuestionLink.getQuestionGroupLink().getValue());
        questionLinkDetail.setAdditionalValue(sectionQuestionLink.getQuestionGroupLink().getAdditionalValue());
        questionLinkDetail.setLinkType(sectionQuestionLink.getQuestionGroupLink().getConditionTypeId());
        questionLinkDetail.setProperLinkTypeDisplay(sectionQuestionLink.getQuestionGroupLink().getConditionType());
        questionLinkDetail.setLinkId(sectionQuestionLink.getId());
        questionLinkDetail.setQuestionGroupLinkId(sectionQuestionLink.getQuestionGroupLink().getId());
        questionLinkDetail.setState(true);
        SectionQuestion sectionQuestion = sectionQuestionLink.getQuestionGroupLink().getSourceSectionQuestion();
        questionLinkDetail.setSourceQuestion(mapToSectionQuestionDetail(sectionQuestion, sectionQuestion.isRequired(), sectionQuestion.isShowOnPage(), (mapToQuestionDetail(sectionQuestion.getQuestion(), mapToQuestionType(sectionQuestion.getQuestion().getAnswerTypeAsEnum())))));
        sectionQuestion = sectionQuestionLink.getAffectedSectionQuestion();
        questionLinkDetail.setAffectedQuestion(mapToSectionQuestionDetail(sectionQuestion, sectionQuestion.isRequired(), sectionQuestion.isShowOnPage(), (mapToQuestionDetail(sectionQuestion.getQuestion(), mapToQuestionType(sectionQuestion.getQuestion().getAnswerTypeAsEnum())))));
        questionLinkDetails.add(questionLinkDetail);
    }
    return questionLinkDetails;
}
Also used : SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) SectionQuestionLink(org.mifos.platform.questionnaire.domain.SectionQuestionLink) ArrayList(java.util.ArrayList) QuestionLinkDetail(org.mifos.platform.questionnaire.service.QuestionLinkDetail)

Example 2 with SectionQuestionLink

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

the class QuestionnaireMapperImpl method mapToQuestionGroupDetail.

@Override
public QuestionGroupDetail mapToQuestionGroupDetail(QuestionGroup questionGroup) {
    List<SectionDetail> sectionDetails = mapToSectionDetails(questionGroup.getSections());
    List<SectionLink> sectionLinks = new ArrayList<SectionLink>();
    List<SectionQuestionLink> sectionQuestionLinks = new ArrayList<SectionQuestionLink>();
    for (SectionDetail sectionDetail : sectionDetails) {
        for (SectionQuestionDetail sectionQuestionDetail : sectionDetail.getQuestionDetails()) {
            if (!sectionLinkDao.retrieveDependentSectionLinksFromQuestion(sectionQuestionDetail.getId()).isEmpty())
                sectionLinks.addAll(sectionLinkDao.retrieveDependentSectionLinksFromQuestion(sectionQuestionDetail.getId()));
            if (!sectionQuestionLinkDao.retrieveDependentSectionQuestionLinksFromQuestion(sectionQuestionDetail.getId()).isEmpty())
                sectionQuestionLinks.addAll(sectionQuestionLinkDao.retrieveDependentSectionQuestionLinksFromQuestion(sectionQuestionDetail.getId()));
        }
    }
    List<EventSourceDto> eventSourceDtos = mapToEventSource(questionGroup.getEventSources());
    return new QuestionGroupDetail(questionGroup.getId(), questionGroup.getTitle(), eventSourceDtos, sectionDetails, questionGroup.isEditable(), QuestionGroupState.ACTIVE.equals(questionGroup.getState()), questionGroup.isPpi(), mapToQuestionLinkDetails(sectionQuestionLinks), mapToSectionLinkDetails(sectionLinks));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) SectionQuestionLink(org.mifos.platform.questionnaire.domain.SectionQuestionLink) SectionLink(org.mifos.platform.questionnaire.domain.SectionLink) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto)

Example 3 with SectionQuestionLink

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

the class QuestionnaireMapperImpl method mapToQuestionLink.

public SectionQuestionLink mapToQuestionLink(QuestionLinkDetail questionLinkDetail, QuestionGroupLink questionGroupLink) {
    SectionQuestionLink sectionQuestionLink = new SectionQuestionLink();
    sectionQuestionLink.setQuestionGroupLink(questionGroupLink);
    sectionQuestionLink.setAffectedSectionQuestion(getSectionQuestionById(questionLinkDetail.getAffectedQuestion().getId()));
    sectionQuestionLink.setId(questionLinkDetail.getLinkId());
    return sectionQuestionLink;
}
Also used : SectionQuestionLink(org.mifos.platform.questionnaire.domain.SectionQuestionLink)

Aggregations

SectionQuestionLink (org.mifos.platform.questionnaire.domain.SectionQuestionLink)3 ArrayList (java.util.ArrayList)2 SectionLink (org.mifos.platform.questionnaire.domain.SectionLink)1 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)1 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)1 QuestionLinkDetail (org.mifos.platform.questionnaire.service.QuestionLinkDetail)1 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)1 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)1 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)1