Ejemplo n.º 1
0
  public QueryResult search(String queryString, Short officeId) throws PersistenceException {

    AccountBO accountBO = findBySystemId(queryString);

    if (accountBO == null) {
      return null;
    }
    if (accountBO.getType() == AccountTypes.CUSTOMER_ACCOUNT
        || accountBO.getType() == AccountTypes.INDIVIDUAL_LOAN_ACCOUNT) {
      return null;
    }
    QueryResult queryResult =
        QueryFactory.getQueryResult(CustomerSearchConstants.LOANACCOUNTIDSEARCH);
    ((QueryResultAccountIdSearch) queryResult).setSearchString(queryString);
    String[] namedQuery = new String[2];
    List<Param> paramList = new ArrayList<Param>();
    QueryInputs queryInputs = new QueryInputs();
    String[] aliasNames = {
      "customerId",
      "centerName",
      "centerGlobalCustNum",
      "customerType",
      "branchGlobalNum",
      "branchName",
      "loanOfficerName",
      "loanOffcerGlobalNum",
      "customerStatus",
      "groupName",
      "groupGlobalCustNum",
      "clientName",
      "clientGlobalCustNum",
      "loanGlobalAccountNumber"
    };
    queryInputs.setPath("org.mifos.customers.business.CustomerSearchDto");
    queryInputs.setAliasNames(aliasNames);
    if (officeId != null) {
      if (officeId.shortValue() == 0) {
        namedQuery[0] = NamedQueryConstants.ACCOUNT_ID_SEARCH_NOOFFICEID_COUNT;
        namedQuery[1] = NamedQueryConstants.ACCOUNT_ID_SEARCH_NOOFFICEID;
      } else {
        namedQuery[0] = NamedQueryConstants.ACCOUNT_ID_SEARCH_COUNT;
        namedQuery[1] = NamedQueryConstants.ACCOUNT_ID_SEARCH;
        paramList.add(typeNameValue("Short", "OFFICEID", officeId));
      }
      paramList.add(typeNameValue("String", "SEARCH_STRING", queryString));
    }
    queryInputs.setQueryStrings(namedQuery);
    queryInputs.setParamList(paramList);
    try {
      queryResult.setQueryInputs(queryInputs);
    } catch (HibernateSearchException e) {
      throw new PersistenceException(e);
    }
    return queryResult;
  }
Ejemplo n.º 2
0
 public QueryResult getAllAccountNotes(Integer accountId) throws PersistenceException {
   QueryResult notesResult = null;
   try {
     Session session = null;
     notesResult = QueryFactory.getQueryResult("NotesSearch");
     session = StaticHibernateUtil.getSessionTL();
     Query query = session.getNamedQuery(NamedQueryConstants.GETALLACCOUNTNOTES);
     query.setInteger("accountId", accountId);
     notesResult.executeQuery(query);
   } catch (Exception e) {
     throw new PersistenceException(e);
   }
   return notesResult;
 }