use of org.mifos.platform.questionnaire.service.InformationOrder in project head by mifos.
the class QuestionnaireServiceImpl method defineQuestionGroup.
@Override
public QuestionGroupDetail defineQuestionGroup(QuestionGroupDetail questionGroupDetail) throws SystemException {
questionnaireValidator.validateForDefineQuestionGroup(questionGroupDetail);
generateNicknamesForQuestions(questionGroupDetail);
QuestionGroup questionGroup = questionnaireMapper.mapToQuestionGroup(questionGroupDetail);
questionGroupDao.create(questionGroup);
List<EntityMaster> usedSources = new ArrayList<EntityMaster>();
for (Section section : questionGroup.getSections()) {
for (SectionQuestion sectionQuestion : section.getQuestions()) {
usedSources.clear();
for (EventSourceEntity eventSourceEntity : questionGroup.getEventSources()) {
if (!(eventSourceEntity.getSource().getEntityType().equals("Client") || eventSourceEntity.getSource().getEntityType().equals("Loan"))) {
continue;
}
InformationOrder informationOrder = new InformationOrder(null, "additional", sectionQuestion.getId(), eventSourceEntity.getSource().getEntityType(), 999);
if (!sectionQuestion.isShowOnPage()) {
informationOrderService.removeAdditionalQuestionIfExists(informationOrder);
}
if (usedSources.contains(eventSourceEntity.getSource())) {
continue;
}
if (sectionQuestion.isShowOnPage()) {
informationOrderService.addAdditionalQuestionIfNotExists(informationOrder);
}
usedSources.add(eventSourceEntity.getSource());
}
}
}
return questionnaireMapper.mapToQuestionGroupDetail(questionGroup);
}
use of org.mifos.platform.questionnaire.service.InformationOrder in project head by mifos.
the class InformationOrderController method saveInformationOrder.
@RequestMapping(value = "/saveInformationOrder", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void saveInformationOrder(@RequestBody Map<String, Integer> order, HttpServletRequest request, HttpServletResponse response) {
List<InformationOrder> informationOrderList = new ArrayList<InformationOrder>();
InformationOrder informationOrder;
for (Map.Entry<String, Integer> entry : order.entrySet()) {
informationOrder = new InformationOrder(Integer.valueOf(entry.getKey()), null, null, null, entry.getValue());
informationOrderList.add(informationOrder);
}
informationOrderServiceFacade.updateInformationOrder(informationOrderList);
}
Aggregations