Search in sources :

Example 1 with SectionDetail

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

the class SavingsAccountActionTest method getSectionDetail.

private SectionDetail getSectionDetail(String name, String title, List<String> answerChoices) {
    SectionDetail sectionDetail = new SectionDetail();
    sectionDetail.setName(name);
    QuestionDetail questionDetail = new QuestionDetail(111, title, QuestionType.SINGLE_SELECT, true, true);
    List<ChoiceDto> choiceDtos = new ArrayList<ChoiceDto>();
    for (String answerChoice : answerChoices) {
        choiceDtos.add(new ChoiceDto(answerChoice));
    }
    questionDetail.setAnswerChoices(choiceDtos);
    sectionDetail.setQuestionDetails(asList(new SectionQuestionDetail(questionDetail, true)));
    return sectionDetail;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 2 with SectionDetail

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

the class QuestionnaireFlowAdapterTest method getSectionDetailWithQuestions.

private SectionDetail getSectionDetailWithQuestions(String sectionName, List<QuestionDetail> questionDetails, String value, boolean mandatory) {
    SectionDetail section = new SectionDetail();
    section.setName(sectionName);
    List<SectionQuestionDetail> sectionQuestions = new ArrayList<SectionQuestionDetail>();
    for (QuestionDetail questionDetail : questionDetails) {
        SectionQuestionDetail sectionQuestion = new SectionQuestionDetail(questionDetail, mandatory);
        sectionQuestion.setValue(value);
        sectionQuestions.add(sectionQuestion);
    }
    section.setQuestionDetails(sectionQuestions);
    return section;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 3 with SectionDetail

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

the class QuestionnaireServiceTest method getSectionDefinition.

private SectionDetail getSectionDefinition(String name) {
    SectionDetail section = new SectionDetail();
    section.setName(name);
    section.addQuestion(new SectionQuestionDetail(new QuestionDetail(11, null, QuestionType.INVALID, true, true), true));
    section.addQuestion(new SectionQuestionDetail(new QuestionDetail(12, null, QuestionType.INVALID, true, true), false));
    return section;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 4 with SectionDetail

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

the class QuestionnaireServiceTest method shouldSaveResponses.

@Test
public void shouldSaveResponses() {
    List<QuestionDetail> questionDetails = asList(new QuestionDetail(12, "Question 1", QuestionType.FREETEXT, true, true));
    List<SectionDetail> sectionDetails = asList(getSectionDetailWithQuestions("Sec1", questionDetails, "value", false));
    QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(1, "QG1", Arrays.asList(new EventSourceDto("Create", "Client", null)), sectionDetails, true);
    QuestionGroupInstance questionGroupInstance = new QuestionGroupInstance();
    questionGroupInstance.setVersionNum(0);
    when(questionGroupInstanceDao.retrieveLatestQuestionGroupInstanceByQuestionGroupAndEntity(1, 1)).thenReturn(asList(questionGroupInstance));
    questionnaireService.saveResponses(new QuestionGroupDetails(1, 1, 1, asList(questionGroupDetail)));
    verify(questionGroupInstanceDao).retrieveLatestQuestionGroupInstanceByQuestionGroupAndEntity(1, 1);
    verify(questionnaireValidator, times(1)).validateForQuestionGroupResponses(asList(questionGroupDetail));
    // TODO: Verify the contents using a custom matcher
    verify(questionGroupInstanceDao, times(1)).saveOrUpdateAll(Matchers.<List<QuestionGroupInstance>>any());
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) QuestionGroupDetails(org.mifos.platform.questionnaire.service.QuestionGroupDetails) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto) Test(org.junit.Test)

Example 5 with SectionDetail

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

Aggregations

SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)56 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)34 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)25 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)24 Test (org.junit.Test)21 ArrayList (java.util.ArrayList)20 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)13 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)12 Transactional (org.springframework.transaction.annotation.Transactional)7 QuestionGroupInstance (org.mifos.platform.questionnaire.domain.QuestionGroupInstance)5 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)5 ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)5 ValidationException (org.mifos.platform.validations.ValidationException)5 EventSourceEntity (org.mifos.platform.questionnaire.domain.EventSourceEntity)4 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)3 Section (org.mifos.platform.questionnaire.domain.Section)3 BadNumericResponseException (org.mifos.platform.questionnaire.exceptions.BadNumericResponseException)3 QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)3 QuestionGroupResponse (org.mifos.platform.questionnaire.domain.QuestionGroupResponse)2 QuestionGroupDetails (org.mifos.platform.questionnaire.service.QuestionGroupDetails)2