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));
}
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;
}
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);
}
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));
}
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;
}
Aggregations