Search in sources :

Example 6 with QuestionGroupInstanceDetail

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

the class QuestionnaireMapperImpl method mapToEmptyQuestionGroupInstanceDetail.

@Override
public QuestionGroupInstanceDetail mapToEmptyQuestionGroupInstanceDetail(QuestionGroup questionGroup) {
    QuestionGroupInstanceDetail questionGroupInstanceDetail = new QuestionGroupInstanceDetail();
    questionGroupInstanceDetail.setId(0);
    questionGroupInstanceDetail.setQuestionGroupDetail(mapToQuestionGroupDetail(questionGroup));
    return questionGroupInstanceDetail;
}
Also used : QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)

Example 7 with QuestionGroupInstanceDetail

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

the class GroupCustActionTest method getQuestionGroupInstanceDetail.

private QuestionGroupInstanceDetail getQuestionGroupInstanceDetail(String questionGroupTitle) {
    QuestionGroupInstanceDetail detail = new QuestionGroupInstanceDetail();
    detail.setDateCompleted(Calendar.getInstance().getTime());
    detail.setQuestionGroupDetail(getQuestionGroupDetail(questionGroupTitle, asList("red", "green", "blue")));
    return detail;
}
Also used : QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)

Example 8 with QuestionGroupInstanceDetail

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

the class QuestionnaireServiceTest method shouldGetQuestionGroupInstancesIncludingUnansweredQuestionGroups.

@Test
public void shouldGetQuestionGroupInstancesIncludingUnansweredQuestionGroups() {
    List<Section> sections = new ArrayList<Section>();
    List<QuestionGroup> questionGroups = asList(getQuestionGroup(4041, "QG1", sections), getQuestionGroup(4042, "QG2", sections), getQuestionGroup(4043, "QG3", sections), getQuestionGroup(4044, "QG4", sections));
    List<QuestionGroupInstance> questionGroupInstances = asList(getQuestionGroupInstance(3031, 2010, 7, 26, questionGroups.get(0)), getQuestionGroupInstance(3032, 2010, 7, 26, questionGroups.get(1)), getQuestionGroupInstance(3033, 2010, 7, 26, questionGroups.get(2)), getQuestionGroupInstance(3034, 2010, 7, 25, questionGroups.get(0)), getQuestionGroupInstance(3035, 2010, 7, 25, questionGroups.get(1)), getQuestionGroupInstance(3036, 2010, 7, 24, questionGroups.get(1)), getQuestionGroupInstance(3037, 2010, 7, 24, questionGroups.get(2)));
    when(questionGroupDao.retrieveQuestionGroupsByEventSource("View", "Client")).thenReturn(questionGroups);
    when(questionGroupInstanceDao.retrieveQuestionGroupInstancesByEntityIdAndEventSourceId(101, 202)).thenReturn(questionGroupInstances);
    when(eventSourceDao.retrieveByEventAndSource("View", "Client")).thenReturn(asList(getEventSourceEntity(202)));
    EventSourceDto eventSourceDto = new EventSourceDto("View", "Client", "View.Client");
    List<QuestionGroupInstanceDetail> instances = questionnaireService.getQuestionGroupInstances(101, eventSourceDto, true, false);
    assertThat(instances, is(notNullValue()));
    assertThat(instances.size(), is(8));
    assertQuestionGroupInstanceDetail(instances.get(0), "QG1", 2010, 7, 26, questionGroupInstances.get(0).getId());
    assertQuestionGroupInstanceDetail(instances.get(1), "QG2", 2010, 7, 26, questionGroupInstances.get(1).getId());
    assertQuestionGroupInstanceDetail(instances.get(2), "QG3", 2010, 7, 26, questionGroupInstances.get(2).getId());
    assertQuestionGroupInstanceDetail(instances.get(3), "QG1", 2010, 7, 25, questionGroupInstances.get(3).getId());
    assertQuestionGroupInstanceDetail(instances.get(4), "QG2", 2010, 7, 25, questionGroupInstances.get(4).getId());
    assertQuestionGroupInstanceDetail(instances.get(5), "QG2", 2010, 7, 24, questionGroupInstances.get(5).getId());
    assertQuestionGroupInstanceDetail(instances.get(6), "QG3", 2010, 7, 24, questionGroupInstances.get(6).getId());
    verify(questionGroupInstanceDao, times(1)).retrieveQuestionGroupInstancesByEntityIdAndEventSourceId(101, 202);
    verify(questionnaireValidator, times(1)).validateForEventSource(eventSourceDto);
    verify(eventSourceDao, times(1)).retrieveByEventAndSource("View", "Client");
}
Also used : ArrayList(java.util.ArrayList) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto) QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail) Test(org.junit.Test)

Example 9 with QuestionGroupInstanceDetail

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

the class QuestionnaireFlowAdapter method getQuestionGroupInstances.

public List<QuestionGroupInstanceDetail> getQuestionGroupInstances(HttpServletRequest request, Integer entityId) {
    QuestionnaireServiceFacade questionnaireServiceFacade = serviceLocator.getService(request);
    Criteria<QuestionGroupInstanceDetail> criteria = new Criteria<QuestionGroupInstanceDetail>() {

        @Override
        public QuestionGroupInstanceDetail filter(Integer questionGroupId, List<QuestionGroupInstanceDetail> questionGroupInstanceDetails) {
            QuestionGroupInstanceDetail result = null;
            for (QuestionGroupInstanceDetail questionGroupInstanceDetail : questionGroupInstanceDetails) {
                if (questionGroupId.equals(questionGroupInstanceDetail.getQuestionGroupDetail().getId())) {
                    result = questionGroupInstanceDetail;
                    break;
                }
            }
            return result;
        }
    };
    return questionnaireServiceFacade != null ? questionGroupFilter.doFilter(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(entityId, event, source), criteria) : new ArrayList<QuestionGroupInstanceDetail>();
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Criteria(org.mifos.accounts.loan.struts.action.Criteria) QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade) QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)

Example 10 with QuestionGroupInstanceDetail

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

the class LoanAccountAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    LoanAccountActionForm loanAccountActionForm = (LoanAccountActionForm) form;
    loanAccountActionForm.clearDetailsForLoan();
    String globalAccountNum = request.getParameter(GLOBAL_ACCOUNT_NUM);
    UserContext userContext = getUserContext(request);
    LoanInformationDto loanInformationDto;
    try {
        loanInformationDto = this.loanAccountServiceFacade.retrieveLoanInformation(globalAccountNum);
    } catch (MifosRuntimeException e) {
        if (e.getCause() instanceof ApplicationException) {
            throw (ApplicationException) e.getCause();
        }
        throw e;
    }
    request.getSession().setAttribute("guarantyInformation", loanAccountServiceFacade.handleGuaranties(loanInformationDto));
    final String accountStateNameLocalised = ApplicationContextProvider.getBean(MessageLookup.class).lookup(loanInformationDto.getAccountStateName());
    SessionUtils.removeThenSetAttribute("accountStateNameLocalised", accountStateNameLocalised, request);
    final String gracePeriodTypeNameLocalised = ApplicationContextProvider.getBean(MessageLookup.class).lookup(loanInformationDto.getGracePeriodTypeName());
    SessionUtils.removeThenSetAttribute("gracePeriodTypeNameLocalised", gracePeriodTypeNameLocalised, request);
    final String interestTypeNameLocalised = ApplicationContextProvider.getBean(MessageLookup.class).lookup(loanInformationDto.getInterestTypeName());
    SessionUtils.removeThenSetAttribute("interestTypeNameLocalised", interestTypeNameLocalised, request);
    final Set<String> accountFlagStateEntityNamesLocalised = new HashSet<String>();
    for (String name : loanInformationDto.getAccountFlagNames()) {
        accountFlagStateEntityNamesLocalised.add(ApplicationContextProvider.getBean(MessageLookup.class).lookup(name));
    }
    SessionUtils.setCollectionAttribute("accountFlagNamesLocalised", accountFlagStateEntityNamesLocalised, request);
    SessionUtils.removeAttribute(BUSINESS_KEY, request);
    Integer loanIndividualMonitoringIsEnabled = configurationPersistence.getConfigurationValueInteger(LOAN_INDIVIDUAL_MONITORING_IS_ENABLED);
    if (null != loanIndividualMonitoringIsEnabled && loanIndividualMonitoringIsEnabled.intValue() != 0) {
        SessionUtils.setAttribute(LOAN_INDIVIDUAL_MONITORING_IS_ENABLED, loanIndividualMonitoringIsEnabled.intValue(), request);
    }
    Boolean GroupLoanWithMembers = AccountingRules.isGroupLoanWithMembers();
    if (null != GroupLoanWithMembers && GroupLoanWithMembers != false) {
        SessionUtils.setAttribute("GroupLoanWithMembers", GroupLoanWithMembers.booleanValue(), request);
    }
    List<ValueListElement> allLoanPurposes = this.loanProductDao.findAllLoanPurposes();
    //        List<BusinessActivityEntity> loanPurposes = (List<BusinessActivityEntity>)masterDataService.retrieveMasterEntities(MasterConstants.LOAN_PURPOSES, getUserContext(request).getLocaleId());
    SessionUtils.setCollectionAttribute(MasterConstants.BUSINESS_ACTIVITIES, allLoanPurposes, request);
    if ((null != loanIndividualMonitoringIsEnabled && 0 != loanIndividualMonitoringIsEnabled.intValue() || (null != GroupLoanWithMembers && GroupLoanWithMembers != false)) && loanInformationDto.isGroup()) {
        List<LoanAccountDetailsDto> loanAccountDetails = this.loanAccountServiceFacade.retrieveLoanAccountDetails(loanInformationDto);
        addEmptyBuisnessActivities(loanAccountDetails);
        SessionUtils.setCollectionAttribute("loanAccountDetailsView", loanAccountDetails, request);
    }
    SessionUtils.setCollectionAttribute(CUSTOM_FIELDS, new ArrayList<CustomFieldDefinitionEntity>(), request);
    // Retrieve and set into the session all collateral types from the
    // lookup_value_locale table associated with the current user context
    // locale
    SessionUtils.setCollectionAttribute(MasterConstants.COLLATERAL_TYPES, legacyMasterDao.getLookUpEntity(MasterConstants.COLLATERAL_TYPES).getCustomValueListElements(), request);
    SessionUtils.setAttribute(AccountConstants.LAST_PAYMENT_ACTION, loanBusinessService.getLastPaymentAction(loanInformationDto.getAccountId()), request);
    SessionUtils.removeThenSetAttribute("loanInformationDto", loanInformationDto, request);
    // inject preferred date
    List<LoanActivityDto> activities = loanInformationDto.getRecentAccountActivity();
    for (LoanActivityDto activity : activities) {
        activity.setUserPrefferedDate(DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), activity.getActionDate().toString()));
    }
    SessionUtils.setCollectionAttribute(RECENTACCOUNTACTIVITIES, activities, request);
    request.setAttribute(CustomerConstants.SURVEY_KEY, loanInformationDto.getAccountSurveys());
    request.setAttribute(CustomerConstants.SURVEY_COUNT, loanInformationDto.getActiveSurveys());
    request.setAttribute(AccountConstants.SURVEY_KEY, loanInformationDto.getAccountSurveys());
    Integer administrativeDocumentsIsEnabled = configurationPersistence.getConfigurationValueInteger(ADMINISTRATIVE_DOCUMENT_IS_ENABLED);
    if (null != administrativeDocumentsIsEnabled && administrativeDocumentsIsEnabled.intValue() == 1) {
        SessionUtils.setCollectionAttribute(AdminDocumentsContants.ADMINISTRATIVEDOCUMENTSLIST, legacyAdminDocumentDao.getAllActiveAdminDocuments(), request);
        SessionUtils.setCollectionAttribute(AdminDocumentsContants.ADMINISTRATIVEDOCUMENTSACCSTATEMIXLIST, legacyAdminDocAccStateMixDao.getAllMixedAdminDocuments(), request);
    }
    List<QuestionGroupInstanceDetail> questions = new ArrayList<QuestionGroupInstanceDetail>();
    QuestionnaireServiceFacade questionnaireServiceFacade = ApplicationContextProvider.getBean(QuestionnaireServiceFacade.class);
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(loanInformationDto.getAccountId(), "Create", "Loan"));
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(loanInformationDto.getAccountId(), "Approve", "Loan"));
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(loanInformationDto.getAccountId(), "View", "Loan"));
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(loanInformationDto.getAccountId(), "Disburse", "Loan"));
    questions.addAll(questionnaireServiceFacade.getQuestionGroupInstancesWithUnansweredQuestionGroups(loanInformationDto.getAccountId(), "Close", "Loan"));
    SessionUtils.setCollectionAttribute("questionGroups", questions, request);
    SessionUtils.setCollectionAttribute("personalInformationOrder", informationOrderServiceFacade.getInformationOrder("Loan"), request);
    // John W - temporarily put back because needed in applychargeaction - update
    // keithW - and for recentAccountNotes
    LoanBO loan = getLoan(loanInformationDto.getAccountId());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
    LoanAccountAction.setSessionAtributeForGLIM(request, loan);
    setCurrentPageUrl(request, loan);
    setQuestionGroupInstances(request, loan);
    setOverpayments(request, loan);
    List<RepaymentScheduleInstallment> installments = loan.toRepaymentScheduleDto(userContext.getPreferredLocale());
    loanAccountActionForm.initializeInstallments(installments);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : ArrayList(java.util.ArrayList) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) LoanAccountActionForm(org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm) RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) MessageLookup(org.mifos.application.master.MessageLookup) HashSet(java.util.HashSet) QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail) LoanActivityDto(org.mifos.dto.domain.LoanActivityDto) UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) ApplicationException(org.mifos.framework.exceptions.ApplicationException) LoanInformationDto(org.mifos.dto.screen.LoanInformationDto) ValueListElement(org.mifos.dto.domain.ValueListElement) MifosRuntimeException(org.mifos.core.MifosRuntimeException) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

QuestionGroupInstanceDetail (org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)23 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4 Flow (org.mifos.framework.util.helpers.Flow)4 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)4 QuestionnaireServiceFacade (org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade)4 HashSet (java.util.HashSet)3 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 LoanAccountActionForm (org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm)3 RepaymentScheduleInstallment (org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment)3 MessageLookup (org.mifos.application.master.MessageLookup)3 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)3 LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)3 LoanActivityDto (org.mifos.dto.domain.LoanActivityDto)3 ValueListElement (org.mifos.dto.domain.ValueListElement)3 LoanInformationDto (org.mifos.dto.screen.LoanInformationDto)3 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)3 UserContext (org.mifos.security.util.UserContext)3