Search in sources :

Example 1 with InformationOrder

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);
}
Also used : InformationOrder(org.mifos.platform.questionnaire.service.InformationOrder) ArrayList(java.util.ArrayList) EntityMaster(org.mifos.framework.business.EntityMaster)

Example 2 with InformationOrder

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);
}
Also used : InformationOrder(org.mifos.platform.questionnaire.service.InformationOrder) ArrayList(java.util.ArrayList) Map(java.util.Map) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ArrayList (java.util.ArrayList)2 InformationOrder (org.mifos.platform.questionnaire.service.InformationOrder)2 Map (java.util.Map)1 EntityMaster (org.mifos.framework.business.EntityMaster)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1