use of org.mifos.framework.exceptions.HibernateSearchException in project head by mifos.
the class LoanAccountServiceFacadeWebTier method retrievePossibleGuarantors.
public List<CustomerSearchResultDto> retrievePossibleGuarantors(CustomerSearchDto customerSearchDto, boolean isNewGLIMCreation, Integer clientId, Integer loanId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
List<CustomerSearchResultDto> pagedDetails = new ArrayList<CustomerSearchResultDto>();
QueryResult customerForSavings = customerPersistence.searchGroupClient(customerSearchDto.getSearchTerm(), userContext.getId(), isNewGLIMCreation);
int position = (customerSearchDto.getPage() - 1) * customerSearchDto.getPageSize();
List<AccountSearchResultsDto> pagedResults = customerForSavings.get(position, customerSearchDto.getPageSize());
int i = 1;
for (AccountSearchResultsDto customerBO : pagedResults) {
if (CustomerLevel.getLevel(customerBO.getLevelId()) == CustomerLevel.CLIENT && customerBO.getClientId() != clientId && isApplicableForGuaranty(customerBO, loanId)) {
CustomerSearchResultDto customer = new CustomerSearchResultDto();
customer.setCustomerId(customerBO.getClientId());
customer.setBranchName(customerBO.getOfficeName());
customer.setGlobalId(customerBO.getGlobelNo());
customer.setSearchIndex(i);
customer.setCenterName(StringUtils.defaultIfEmpty(customerBO.getCenterName(), "--"));
customer.setGroupName(StringUtils.defaultIfEmpty(customerBO.getGroupName(), "--"));
customer.setClientName(customerBO.getClientName());
pagedDetails.add(customer);
}
i++;
}
return pagedDetails;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
} catch (HibernateSearchException e) {
throw new MifosRuntimeException(e);
} catch (ConfigurationException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.framework.exceptions.HibernateSearchException in project head by mifos.
the class CustomerPersistence method searchCustForSavings.
public QueryResult searchCustForSavings(final String searchString, final Short userId) throws PersistenceException {
String[] namedQuery = new String[2];
List<Param> paramList = new ArrayList<Param>();
QueryInputs queryInputs = new QueryInputs();
QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.CUSTOMERSFORSAVINGSACCOUNT);
PersonnelBO personnel = getLegacyPersonnelDao().getPersonnel(userId);
if (personnel.getLevelEnum() == PersonnelLevel.LOAN_OFFICER) {
namedQuery[0] = NamedQueryConstants.SEARCH_CUSTOMER_FOR_SAVINGS_COUNT;
namedQuery[1] = NamedQueryConstants.SEARCH_CUSTOMER_FOR_SAVINGS;
paramList.add(typeNameValue("Short", "PERSONNEL_ID", userId));
} else {
namedQuery[0] = NamedQueryConstants.SEARCH_CUSTOMER_FOR_SAVINGS_COUNT_NOLO;
namedQuery[1] = NamedQueryConstants.SEARCH_CUSTOMER_FOR_SAVINGS_NOLO;
}
paramList.add(typeNameValue("String", "SEARCH_ID", personnel.getOffice().getSearchId() + "%"));
paramList.add(typeNameValue("String", "SEARCH_STRING", "%" + searchString + "%"));
String[] aliasNames = { "clientName", "clientId", "groupName", "centerName", "officeName", "globelNo" };
queryInputs.setQueryStrings(namedQuery);
queryInputs.setPath("org.mifos.accounts.util.helpers.AccountSearchResultsDto");
queryInputs.setAliasNames(aliasNames);
queryInputs.setParamList(paramList);
try {
queryResult.setQueryInputs(queryInputs);
} catch (HibernateSearchException e) {
throw new PersistenceException(e);
}
return queryResult;
}
use of org.mifos.framework.exceptions.HibernateSearchException in project head by mifos.
the class GroupPersistence method searchForAddingClientToGroup.
public QueryResult searchForAddingClientToGroup(String searchString, Short userId) throws PersistenceException {
String[] namedQuery = new String[2];
List<Param> paramList = new ArrayList<Param>();
QueryInputs queryInputs = new QueryInputs();
QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.GROUPLIST);
PersonnelBO personnel = legacyPersonnelDao.getPersonnel(userId);
String officeSearchId = personnel.getOffice().getSearchId();
if (ClientRules.getCenterHierarchyExists()) {
namedQuery[0] = NamedQueryConstants.GROUP_SEARCH_COUNT_WITH_CENTER_FOR_ADDING_GROUPMEMBER;
namedQuery[1] = NamedQueryConstants.GROUP_SEARCHWITH_CENTER_FOR_ADDING_GROUPMEMBER;
String[] aliasNames = { "officeName", "groupName", "centerName", "groupId" };
queryInputs.setAliasNames(aliasNames);
} else {
namedQuery[0] = NamedQueryConstants.GROUP_SEARCH_COUNT_WITHOUT_CENTER_FOR_ADDING_GROUPMEMBER;
namedQuery[1] = NamedQueryConstants.GROUP_SEARCH_WITHOUT_CENTER_FOR_ADDING_GROUPMEMBER;
String[] aliasNames = { "officeName", "groupName", "groupId" };
queryInputs.setAliasNames(aliasNames);
}
paramList.add(typeNameValue("String", "SEARCH_ID", officeSearchId + "%"));
paramList.add(typeNameValue("String", "SEARCH_STRING", searchString + "%"));
paramList.add(typeNameValue("Short", "LEVEL_ID", CustomerLevel.GROUP.getValue()));
paramList.add(typeNameValue("Short", "USER_ID", userId));
paramList.add(typeNameValue("Short", "USER_LEVEL_ID", personnel.getLevelEnum().getValue()));
paramList.add(typeNameValue("Short", "LO_LEVEL_ID", PersonnelLevel.LOAN_OFFICER.getValue()));
queryInputs.setQueryStrings(namedQuery);
queryInputs.setPath("org.mifos.customers.group.util.helpers.GroupSearchResults");
queryInputs.setParamList(paramList);
try {
queryResult.setQueryInputs(queryInputs);
} catch (HibernateSearchException e) {
throw new PersistenceException(e);
}
return queryResult;
}
use of org.mifos.framework.exceptions.HibernateSearchException in project head by mifos.
the class GroupPersistence method search.
public QueryResult search(String searchString, Short userId) throws PersistenceException {
String[] namedQuery = new String[2];
List<Param> paramList = new ArrayList<Param>();
QueryInputs queryInputs = new QueryInputs();
QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.GROUPLIST);
PersonnelBO personnel = legacyPersonnelDao.getPersonnel(userId);
String officeSearchId = personnel.getOffice().getSearchId();
if (ClientRules.getCenterHierarchyExists()) {
namedQuery[0] = NamedQueryConstants.GROUP_SEARCH_COUNT_WITH_CENTER;
namedQuery[1] = NamedQueryConstants.GROUP_SEARCHWITH_CENTER;
String[] aliasNames = { "officeName", "groupName", "centerName", "groupId" };
queryInputs.setAliasNames(aliasNames);
} else {
namedQuery[0] = NamedQueryConstants.GROUP_SEARCH_COUNT_WITHOUT_CENTER;
namedQuery[1] = NamedQueryConstants.GROUP_SEARCH_WITHOUT_CENTER;
String[] aliasNames = { "officeName", "groupName", "groupId" };
queryInputs.setAliasNames(aliasNames);
}
paramList.add(typeNameValue("String", "SEARCH_ID", officeSearchId + "%"));
paramList.add(typeNameValue("String", "SEARCH_STRING", "%" + searchString + "%"));
paramList.add(typeNameValue("Short", "LEVEL_ID", CustomerLevel.GROUP.getValue()));
paramList.add(typeNameValue("Short", "USER_ID", userId));
paramList.add(typeNameValue("Short", "USER_LEVEL_ID", personnel.getLevelEnum().getValue()));
paramList.add(typeNameValue("Short", "LO_LEVEL_ID", PersonnelLevel.LOAN_OFFICER.getValue()));
queryInputs.setQueryStrings(namedQuery);
queryInputs.setPath("org.mifos.customers.group.util.helpers.GroupSearchResults");
queryInputs.setParamList(paramList);
try {
queryResult.setQueryInputs(queryInputs);
} catch (HibernateSearchException e) {
throw new PersistenceException(e);
}
return queryResult;
}
use of org.mifos.framework.exceptions.HibernateSearchException in project head by mifos.
the class CenterPersistence method search.
/**
* @deprecated - use {@link CustomerDao#search(String, PersonnelBO)}.
*/
@Deprecated
public QueryResult search(String searchString, Short userId) throws PersistenceException {
String[] namedQuery = new String[2];
List<Param> paramList = new ArrayList<Param>();
QueryInputs queryInputs = new QueryInputs();
QueryResult queryResult = QueryFactory.getQueryResult(PersonnelConstants.USER_LIST);
PersonnelBO user = legacyPersonnelDao.getPersonnel(userId);
String officeSearchId = user.getOffice().getSearchId();
namedQuery[0] = NamedQueryConstants.CENTER_SEARCH_COUNT;
namedQuery[1] = NamedQueryConstants.CENTER_SEARCH;
paramList.add(typeNameValue("String", "SEARCH_ID", officeSearchId + "%"));
paramList.add(typeNameValue("String", "CENTER_NAME", searchString + "%"));
paramList.add(typeNameValue("Short", "LEVEL_ID", CustomerLevel.CENTER.getValue()));
paramList.add(typeNameValue("Short", "STATUS_ID", CustomerStatus.CENTER_ACTIVE.getValue()));
paramList.add(typeNameValue("Short", "USER_ID", userId));
paramList.add(typeNameValue("Short", "USER_LEVEL_ID", user.getLevelEnum().getValue()));
paramList.add(typeNameValue("Short", "LO_LEVEL_ID", PersonnelConstants.LOAN_OFFICER));
String[] aliasNames = { "parentOfficeId", "parentOfficeName", "centerSystemId", "centerName" };
queryInputs.setQueryStrings(namedQuery);
queryInputs.setPath("org.mifos.customers.center.util.helpers.CenterSearchResultsDto");
queryInputs.setAliasNames(aliasNames);
queryInputs.setParamList(paramList);
try {
queryResult.setQueryInputs(queryInputs);
} catch (HibernateSearchException e) {
throw new PersistenceException(e);
}
return queryResult;
}
Aggregations