Search in sources :

Example 1 with QuestionGroupReference

use of org.mifos.accounts.productdefinition.business.QuestionGroupReference in project head by mifos.

the class LoanAccountServiceFacadeWebTier method retrieveApplicableQuestionGroups.

@Override
public List<QuestionGroupDetail> retrieveApplicableQuestionGroups(Integer productId) {
    List<QuestionGroupDetail> questionGroupDetails = new ArrayList<QuestionGroupDetail>();
    LoanOfferingBO loanProduct = this.loanProductDao.findById(productId);
    Set<QuestionGroupReference> questionGroupReferences = loanProduct.getQuestionGroups();
    if (!questionGroupReferences.isEmpty()) {
        List<QuestionGroupDetail> allQuestionGroupDetails = questionnaireServiceFacade.getQuestionGroups("Create", "Loan");
        for (QuestionGroupDetail questionGroupDetail : allQuestionGroupDetails) {
            for (QuestionGroupReference questionGroupReference : questionGroupReferences) {
                if (questionGroupDetail.isActive() && questionGroupReference.getQuestionGroupId().equals(questionGroupDetail.getId())) {
                    questionGroupDetails.add(questionGroupDetail);
                }
            }
        }
    }
    return questionGroupDetails;
}
Also used : QuestionGroupReference(org.mifos.accounts.productdefinition.business.QuestionGroupReference) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ArrayList(java.util.ArrayList) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO)

Example 2 with QuestionGroupReference

use of org.mifos.accounts.productdefinition.business.QuestionGroupReference in project head by mifos.

the class QuestionGroupFilterForLoanTest method shouldDoFilterForNoLoanOfferingQuestionGroups.

@Test
public void shouldDoFilterForNoLoanOfferingQuestionGroups() {
    QuestionGroupFilterForLoan questionGroupFilterForLoan = new QuestionGroupFilterForLoan();
    LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
    loanOfferingBO.setQuestionGroups(new HashSet<QuestionGroupReference>());
    questionGroupFilterForLoan.setLoanOfferingBO(loanOfferingBO);
    List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1"), getQuestionGroupDetail(2, "QG2"), getQuestionGroupDetail(3, "QG3"), getQuestionGroupDetail(4, "QG4"));
    List<QuestionGroupDetail> filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(questionGroupDetails, null);
    assertThat(filteredQuestionGroupDetails, is(notNullValue()));
    assertThat(filteredQuestionGroupDetails.size(), is(0));
    loanOfferingBO.setQuestionGroups(null);
    filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(questionGroupDetails, null);
    assertThat(filteredQuestionGroupDetails, is(notNullValue()));
    assertThat(filteredQuestionGroupDetails.size(), is(0));
}
Also used : QuestionGroupReference(org.mifos.accounts.productdefinition.business.QuestionGroupReference) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) Test(org.junit.Test)

Example 3 with QuestionGroupReference

use of org.mifos.accounts.productdefinition.business.QuestionGroupReference in project head by mifos.

the class LoanPrdAction method getQuestionGroups.

// Intentionally made public to aid testing !!!
@SuppressWarnings("unchecked")
public Set<QuestionGroupReference> getQuestionGroups(HttpServletRequest request) throws PageExpiredException {
    Set<QuestionGroupReference> questionGroupReferences = null;
    List<QuestionGroupDetail> questionGroups = (List<QuestionGroupDetail>) SessionUtils.getAttribute(ProductDefinitionConstants.SELECTEDQGLIST, request);
    if (CollectionUtils.isNotEmpty(questionGroups)) {
        questionGroupReferences = new LinkedHashSet<QuestionGroupReference>(questionGroups.size());
        for (QuestionGroupDetail questionGroupDetail : questionGroups) {
            QuestionGroupReference questionGroupReference = new QuestionGroupReference();
            questionGroupReference.setQuestionGroupId(questionGroupDetail.getId());
            questionGroupReferences.add(questionGroupReference);
        }
    }
    return questionGroupReferences;
}
Also used : QuestionGroupReference(org.mifos.accounts.productdefinition.business.QuestionGroupReference) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) List(java.util.List) ArrayList(java.util.ArrayList)

Example 4 with QuestionGroupReference

use of org.mifos.accounts.productdefinition.business.QuestionGroupReference in project head by mifos.

the class QuestionGroupFilterForLoan method doFilter.

@Override
public <T> List<T> doFilter(List<T> t, Criteria<T> criteria) {
    if (t == null || loanOfferingBO == null)
        return t;
    List<T> filteredResult = new ArrayList<T>();
    Set<QuestionGroupReference> questionGroupReferences = loanOfferingBO.getQuestionGroups();
    if (questionGroupReferences != null) {
        for (QuestionGroupReference questionGroupReference : questionGroupReferences) {
            T result = criteria.filter(questionGroupReference.getQuestionGroupId(), t);
            if (result != null)
                filteredResult.add(result);
        }
    }
    return filteredResult;
}
Also used : QuestionGroupReference(org.mifos.accounts.productdefinition.business.QuestionGroupReference) ArrayList(java.util.ArrayList)

Example 5 with QuestionGroupReference

use of org.mifos.accounts.productdefinition.business.QuestionGroupReference in project head by mifos.

the class LoanPrdActionTest method makeQuestionGroupRef.

private QuestionGroupReference makeQuestionGroupRef(int questionGroupId) {
    QuestionGroupReference questionGroupReference = new QuestionGroupReference();
    questionGroupReference.setQuestionGroupId(questionGroupId);
    return questionGroupReference;
}
Also used : QuestionGroupReference(org.mifos.accounts.productdefinition.business.QuestionGroupReference)

Aggregations

QuestionGroupReference (org.mifos.accounts.productdefinition.business.QuestionGroupReference)8 ArrayList (java.util.ArrayList)4 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)4 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)3 List (java.util.List)1 Test (org.junit.Test)1 LoanPrdBusinessService (org.mifos.accounts.productdefinition.business.service.LoanPrdBusinessService)1 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)1 LoanProductBuilder (org.mifos.domain.builders.LoanProductBuilder)1 ServiceException (org.mifos.framework.exceptions.ServiceException)1 SystemException (org.mifos.framework.exceptions.SystemException)1