Package de.forsthaus.backend.util

Examples of de.forsthaus.backend.util.HibernateSearchObject


   * 4. Call the ServiceDAO method with searchObject as parameter. <br>
   */
  @SuppressWarnings("unchecked")
  public void doSearch() {

    HibernateSearchObject<Customer> so = new HibernateSearchObject(Customer.class);

    if (StringUtils.isNotEmpty(kunNr.getValue())) {

      // get the search operator
      Listitem item = this.sortOperator_kunNr.getSelectedItem();

      if (item != null) {
        int searchOpId = ((SearchOperators) item.getAttribute("data")).getSearchOperatorId();

        if (searchOpId == Filter.OP_ILIKE) {
          so.addFilter(new Filter("kunNr", "%" + kunNr.getValue().toUpperCase() + "%", searchOpId));
        } else if (searchOpId == -1) {
          // do nothing
        } else {
          so.addFilter(new Filter("kunNr", kunNr.getValue(), searchOpId));
        }
      }
    }

    if (StringUtils.isNotEmpty(kunMatchcode.getValue())) {

      // get the search operator
      Listitem item = sortOperator_kunMatchcode.getSelectedItem();

      if (item != null) {
        int searchOpId = ((SearchOperators) item.getAttribute("data")).getSearchOperatorId();

        if (searchOpId == Filter.OP_ILIKE) {
          so.addFilter(new Filter("kunMatchcode", "%" + kunMatchcode.getValue().toUpperCase() + "%", searchOpId));
        } else if (searchOpId == -1) {
          // do nothing
        } else {
          so.addFilter(new Filter("kunMatchcode", kunMatchcode.getValue(), searchOpId));
        }
      }
    }

    if (StringUtils.isNotEmpty(kunName1.getValue())) {

      // get the search operator
      Listitem item = sortOperator_kunName1.getSelectedItem();

      if (item != null) {
        int searchOpId = ((SearchOperators) item.getAttribute("data")).getSearchOperatorId();

        if (searchOpId == Filter.OP_ILIKE) {
          so.addFilter(new Filter("kunName1", "%" + kunName1.getValue().toUpperCase() + "%", searchOpId));
        } else if (searchOpId == -1) {
          // do nothing
        } else {
          so.addFilter(new Filter("kunName1", kunName1.getValue(), searchOpId));
        }
      }
    }

    if (StringUtils.isNotEmpty(this.kunName2.getValue())) {

      // get the search operator
      Listitem item = sortOperator_kunName2.getSelectedItem();

      if (item != null) {
        int searchOpId = ((SearchOperators) item.getAttribute("data")).getSearchOperatorId();

        if (searchOpId == Filter.OP_ILIKE) {
          so.addFilter(new Filter("kunName2", "%" + kunName2.getValue().toUpperCase() + "%", searchOpId));
        } else if (searchOpId == -1) {
          // do nothing
        } else {
          so.addFilter(new Filter("kunName2", kunName2.getValue(), searchOpId));
        }
      }
    }

    if (StringUtils.isNotEmpty(this.kunOrt.getValue())) {

      // get the search operator
      Listitem item = sortOperator_kunOrt.getSelectedItem();

      if (item != null) {
        int searchOpId = ((SearchOperators) item.getAttribute("data")).getSearchOperatorId();

        if (searchOpId == Filter.OP_ILIKE) {
          so.addFilter(new Filter("kunOrt", "%" + kunOrt.getValue().toUpperCase() + "%", searchOpId));
        } else if (searchOpId == -1) {
          // do nothing
        } else {
          so.addFilter(new Filter("kunOrt", kunOrt.getValue(), searchOpId));
        }
      }
    }

    if (this.kunBranche.getSelectedCount() > 0) {

      // check if it the default empty item
      Listitem itemB = kunBranche.getSelectedItem();
      Branche branche = (Branche) itemB.getAttribute("data");

      if (!StringUtils.isEmpty(branche.getBraBezeichnung())) {

        // get the search operator
        Listitem item = this.sortOperator_kunBranch.getSelectedItem();

        if (item != null) {
          int searchOpId = ((SearchOperators) item.getAttribute("data")).getSearchOperatorId();

          if (searchOpId == Filter.OP_ILIKE) {
            so.addFilter(new Filter("branche", branche, searchOpId));
          } else if (searchOpId == -1) {
            // do nothing
          } else {
            so.addFilter(new Filter("branche", branche, searchOpId));
          }
        }
      }
    }

    if (logger.isDebugEnabled()) {
      List<Filter> lf = so.getFilters();
      for (Filter filter : lf) {
        logger.debug(filter.getProperty().toString() + " / " + filter.getValue().toString());

        if (Filter.OP_ILIKE == filter.getOperator()) {
          logger.debug(filter.getOperator());
View Full Code Here

TOP

Related Classes of de.forsthaus.backend.util.HibernateSearchObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.