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