Search in sources :

Example 1 with SectionLink

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

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

the class QuestionnaireMapperImpl method mapToSectionLink.

public SectionLink mapToSectionLink(SectionLinkDetail sectionLinkDetail, QuestionGroupLink questionGroupLink) {
    SectionLink sectionLink = new SectionLink();
    sectionLink.setAffectedSection(getSectionById(sectionLinkDetail.getAffectedSection().getId()));
    sectionLink.setQuestionGroupLink(questionGroupLink);
    sectionLink.setId(sectionLinkDetail.getLinkId());
    return sectionLink;
}
Also used : SectionLink(org.mifos.platform.questionnaire.domain.SectionLink)

Example 3 with SectionLink

use of org.mifos.platform.questionnaire.domain.SectionLink 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)

Aggregations

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