Search in sources :

Example 1 with SectionLinkDetail

use of org.mifos.platform.questionnaire.service.SectionLinkDetail in project head by mifos.

the class QuestionGroupController method setSectionLinkDetail.

public SectionLinkDetail setSectionLinkDetail(QuestionGroupForm questionGroupForm, String sourceQuestionId, String affectedSectionName, String value, String additionalValue, String linkType, String linkTypeDisplay) {
    SectionLinkDetail sectionLinkDetail = new SectionLinkDetail();
    SectionQuestionDetail sourceQuestion = findQuestionDetailById(questionGroupForm.getQuestionGroupDetail(), sourceQuestionId);
    sectionLinkDetail.setSourceQuestion(sourceQuestion);
    SectionDetail affectedSection = findSectionDetailByName(questionGroupForm.getQuestionGroupDetail(), affectedSectionName);
    sectionLinkDetail.setAffectedSection(affectedSection);
    sectionLinkDetail.setValue(value);
    sectionLinkDetail.setLinkType(Integer.valueOf(linkType));
    sectionLinkDetail.setLinkTypeDisplay(linkTypeDisplay);
    sectionLinkDetail.setState(false);
    if (additionalValue != null)
        sectionLinkDetail.setAdditionalValue(additionalValue);
    return sectionLinkDetail;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) SectionLinkDetail(org.mifos.platform.questionnaire.service.SectionLinkDetail) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail)

Example 2 with SectionLinkDetail

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

use of org.mifos.platform.questionnaire.service.SectionLinkDetail in project head by mifos.

the class QuestionnaireServiceImpl method createSectionLinks.

public void createSectionLinks(List<SectionLinkDetail> sectionLinks) {
    for (SectionLinkDetail sectionLinkDetail : sectionLinks) {
        QuestionGroupLink questionGroupLink = questionnaireMapper.mapToQuestionGroupLink(null, sectionLinkDetail);
        questionGroupLinkDao.saveOrUpdate(questionGroupLink);
        SectionLink sectionLink = questionnaireMapper.mapToSectionLink(sectionLinkDetail, questionGroupLink);
        sectionLinkDao.saveOrUpdate(sectionLink);
    }
}
Also used : SectionLinkDetail(org.mifos.platform.questionnaire.service.SectionLinkDetail)

Example 4 with SectionLinkDetail

use of org.mifos.platform.questionnaire.service.SectionLinkDetail in project head by mifos.

the class QuestionGroupController method addLink.

public String addLink(QuestionGroupForm questionGroupForm, String sourceQuestionId, String linkType, String appliesTo, String affectedQuestionId, String affectedSectionName, String value, String additionalValue, Map<String, String> linkTypes, RequestContext requestContext) {
    String result = "success";
    if (!questionGroupLinkHasErrors(questionGroupForm, requestContext, sourceQuestionId, linkType, appliesTo, affectedQuestionId, affectedSectionName, value, additionalValue)) {
        if (appliesTo.equals("question")) {
            QuestionLinkDetail questionLink = setQuestionLinkDetail(questionGroupForm, sourceQuestionId, affectedQuestionId, value, additionalValue, linkType, linkTypes.get(linkType));
            questionGroupForm.getQuestionLinks().add(questionLink);
        } else {
            SectionLinkDetail sectionLink = setSectionLinkDetail(questionGroupForm, sourceQuestionId, affectedSectionName, value, additionalValue, linkType, linkTypes.get(linkType));
            questionGroupForm.getSectionLinks().add(sectionLink);
        }
    } else {
        result = "failure";
    }
    return result;
}
Also used : QuestionLinkDetail(org.mifos.platform.questionnaire.service.QuestionLinkDetail) SectionLinkDetail(org.mifos.platform.questionnaire.service.SectionLinkDetail)

Example 5 with SectionLinkDetail

use of org.mifos.platform.questionnaire.service.SectionLinkDetail in project head by mifos.

the class QuestionGroupController method setFilledSectionDetailForQuestionLinks.

public List<SectionLinkDetail> setFilledSectionDetailForQuestionLinks(List<SectionLinkDetail> sectionLinkDetails, QuestionGroupDetail questionGroupDetail) {
    for (SectionLinkDetail sectionLinkDetail : sectionLinkDetails) {
        sectionLinkDetail.setSourceQuestion(findQuestionDetailByNickname(questionGroupDetail, String.valueOf(sectionLinkDetail.getSourceQuestion().getQuestionDetail().getNickname())));
        sectionLinkDetail.setAffectedSection(findSectionDetailByName(questionGroupDetail, sectionLinkDetail.getAffectedSection().getName()));
    }
    return sectionLinkDetails;
}
Also used : SectionLinkDetail(org.mifos.platform.questionnaire.service.SectionLinkDetail)

Aggregations

SectionLinkDetail (org.mifos.platform.questionnaire.service.SectionLinkDetail)7 QuestionLinkDetail (org.mifos.platform.questionnaire.service.QuestionLinkDetail)3 ArrayList (java.util.ArrayList)2 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)2 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)2 SystemException (org.mifos.framework.exceptions.SystemException)1 SectionLink (org.mifos.platform.questionnaire.domain.SectionLink)1 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)1 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1