Search in sources :

Example 6 with QuestionLinkDetail

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

the class QuestionGroupController method defineQuestionGroup.

@SuppressWarnings({ "ThrowableInstanceNeverThrown" })
public String defineQuestionGroup(QuestionGroupForm questionGroupForm, RequestContext requestContext, boolean createMode) {
    String result = "success";
    if (!questionGroupHasErrors(questionGroupForm, requestContext)) {
        QuestionGroupDetail questionGroupDetail = null;
        try {
            if (createMode) {
                questionGroupForm.setActive(true);
            }
            if (questionGroupForm.isActive()) {
                questionGroupDetail = questionnaireServiceFacade.createActiveQuestionGroup(questionGroupForm.getQuestionGroupDetail());
            } else {
                questionGroupDetail = questionnaireServiceFacade.createQuestionGroup(questionGroupForm.getQuestionGroupDetail());
            }
            if (containsCreateLoanEventSource(questionGroupForm.getEventSources()) && questionGroupForm.getApplyToAllLoanProducts()) {
                questionnaireServiceFacade.applyToAllLoanProducts(questionGroupDetail.getId());
            }
            List<QuestionLinkDetail> questionLinkDetails = setFilledQuestionDetailForQuestionLinks(questionGroupForm.getQuestionLinks(), questionGroupDetail);
            List<SectionLinkDetail> sectionLinkDetails = setFilledSectionDetailForQuestionLinks(questionGroupForm.getSectionLinks(), questionGroupDetail);
            questionnaireServiceFacade.createQuestionLinks(questionLinkDetails);
            questionnaireServiceFacade.createSectionLinks(sectionLinkDetails);
        } catch (AccessDeniedException e) {
            constructAndLogSystemError(requestContext.getMessageContext(), new SystemException(QuestionnaireConstants.MISSING_PERMISSION_TO_ACTIVATE_QG, e));
            result = "failure";
        } catch (SystemException e) {
            constructAndLogSystemError(requestContext.getMessageContext(), e);
            result = "failure";
        }
    } else {
        result = "failure";
    }
    return result;
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) SystemException(org.mifos.framework.exceptions.SystemException) QuestionLinkDetail(org.mifos.platform.questionnaire.service.QuestionLinkDetail) SectionLinkDetail(org.mifos.platform.questionnaire.service.SectionLinkDetail)

Example 7 with QuestionLinkDetail

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

the class QuestionGroupController method setQuestionLinkDetail.

public QuestionLinkDetail setQuestionLinkDetail(QuestionGroupForm questionGroupForm, String sourceQuestionId, String affectedQuestionId, String value, String additionalValue, String linkType, String linkTypeDisplay) {
    QuestionLinkDetail questionLinkDetail = new QuestionLinkDetail();
    SectionQuestionDetail sourceQuestion = findQuestionDetailById(questionGroupForm.getQuestionGroupDetail(), sourceQuestionId);
    questionLinkDetail.setSourceQuestion(sourceQuestion);
    SectionQuestionDetail affectedQuestion = findQuestionDetailById(questionGroupForm.getQuestionGroupDetail(), affectedQuestionId);
    questionLinkDetail.setAffectedQuestion(affectedQuestion);
    questionLinkDetail.setValue(value);
    questionLinkDetail.setLinkType(Integer.valueOf(linkType));
    questionLinkDetail.setLinkTypeDisplay(linkTypeDisplay);
    questionLinkDetail.setState(false);
    if (additionalValue != null)
        questionLinkDetail.setAdditionalValue(additionalValue);
    return questionLinkDetail;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionLinkDetail(org.mifos.platform.questionnaire.service.QuestionLinkDetail)

Aggregations

QuestionLinkDetail (org.mifos.platform.questionnaire.service.QuestionLinkDetail)7 SectionLinkDetail (org.mifos.platform.questionnaire.service.SectionLinkDetail)3 ArrayList (java.util.ArrayList)2 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)2 SystemException (org.mifos.framework.exceptions.SystemException)1 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 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1