Search in sources :

Example 16 with EventSourceDto

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

the class QuestionGroupFormTest method shouldSetEventSource.

@Test
public void shouldSetEventSource() {
    QuestionGroupForm questionGroupForm;
    questionGroupForm = new QuestionGroupForm();
    questionGroupForm.setEventSources(Arrays.asList(new EventSourceDto("Create", "Client", null)));
    assertThat(questionGroupForm.getEventSourceIds().get(0), is("Create.Client"));
    questionGroupForm = new QuestionGroupForm();
    questionGroupForm.setEventSources(null);
    assertThat(questionGroupForm.getEventSourceIds().size(), is(0));
    questionGroupForm = new QuestionGroupForm();
    questionGroupForm.setEventSources(Arrays.asList(new EventSourceDto("", null, null)));
    assertThat(questionGroupForm.getEventSourceIds().size(), is(0));
}
Also used : QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto) Test(org.junit.Test)

Example 17 with EventSourceDto

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

the class QuestionGroupControllerTest method getQuestionGroupDetail.

private QuestionGroupDetail getQuestionGroupDetail(String title, String event, String source, String... sectionNames) {
    QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail();
    questionGroupDetail.setTitle(title);
    questionGroupDetail.setEventSources(Arrays.asList(new EventSourceDto(event, source, null)));
    List<SectionDetail> sectionDetails = new ArrayList<SectionDetail>();
    for (String sectionName : sectionNames) {
        SectionDetail sectionDetail = new SectionDetail();
        sectionDetail.setName(sectionName);
        sectionDetails.add(sectionDetail);
    }
    questionGroupDetail.setSectionDetails(sectionDetails);
    return questionGroupDetail;
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ArrayList(java.util.ArrayList) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto)

Example 18 with EventSourceDto

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

the class QuestionGroupControllerTest method getQuestionGroupDetail.

private QuestionGroupDetail getQuestionGroupDetail(int questionGroupId, String title, String event, String source, boolean active, boolean editable, String... sectionNames) {
    List<SectionDetail> sectionDetails = new ArrayList<SectionDetail>();
    for (String sectionName : sectionNames) {
        SectionDetail sectionDetail = new SectionDetail();
        sectionDetail.setName(sectionName);
        sectionDetails.add(sectionDetail);
    }
    return new QuestionGroupDetail(questionGroupId, title, Arrays.asList(new EventSourceDto(event, source, null)), sectionDetails, editable, active);
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ArrayList(java.util.ArrayList) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto)

Example 19 with EventSourceDto

use of org.mifos.platform.questionnaire.service.dtos.EventSourceDto 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 20 with EventSourceDto

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

the class QuestionGroupController method getAllQgEventSources.

public Map<String, String> getAllQgEventSources() {
    List<EventSourceDto> eventSourceDtos = questionnaireServiceFacade.getAllEventSources();
    Map<String, String> evtSourcesMap = new LinkedHashMap<String, String>();
    for (EventSourceDto evtSrc : eventSourceDtos) {
        evtSourcesMap.put(getEventSourceId(evtSrc), evtSrc.getDescription());
    }
    return evtSourcesMap;
}
Also used : EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)39 Test (org.junit.Test)28 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)15 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)12 ArrayList (java.util.ArrayList)10 Transactional (org.springframework.transaction.annotation.Transactional)7 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)6 EventSourceEntity (org.mifos.platform.questionnaire.domain.EventSourceEntity)5 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)5 SystemException (org.mifos.framework.exceptions.SystemException)4 EventSourcesMatcher (org.mifos.platform.questionnaire.matchers.EventSourcesMatcher)3 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)3 QuestionGroupInstanceDetail (org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)3 ValidationException (org.mifos.platform.validations.ValidationException)3 LinkedHashMap (java.util.LinkedHashMap)2 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)2 Section (org.mifos.platform.questionnaire.domain.Section)2 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)2 MandatoryAnswerNotFoundException (org.mifos.platform.questionnaire.exceptions.MandatoryAnswerNotFoundException)2 QuestionGroupDetails (org.mifos.platform.questionnaire.service.QuestionGroupDetails)2