Пример #1
0
  /**
   * This method supplies a human readable string representation of this object. for example
   * "Country is Romania"... so an representation of this object could be displayed on the page.
   *
   * @return A human readable representation of an object.
   */
  public String toHumanString() {
    StringBuffer ret = new StringBuffer();

    if (((null != searchString) || (null != searchStringMin && null != searchStringMax))
        && null != relationOp) {
      if (0 == SEARCH_AREA.compareTo(searchType)) {
        ret.append(
            Utilities.prepareHumanString(
                    "size <strong>"
                        + (relationOp.intValue() == Utilities.OPERATOR_IS.intValue() ? "" : "is"),
                    searchString,
                    searchStringMin,
                    searchStringMax,
                    relationOp)
                + "</strong> ha");
      }

      if (0 == SEARCH_LENGTH.compareTo(searchType)) {
        ret.append(
            Utilities.prepareHumanString(
                    "length <strong>"
                        + (relationOp.intValue() == Utilities.OPERATOR_IS.intValue() ? "" : "is"),
                    searchString,
                    searchStringMin,
                    searchStringMax,
                    relationOp)
                + "</strong> m");
      }
    }
    if (null != country) {
      // AND C.AREA_NAME_EN='FRANCE'
      ret.append(", in country <strong>" + country + "</strong>");
    }
    if (yearMin != null && yearMax != null) {
      ret.append(
          ", and year between: <strong>"
              + yearMin
              + "</strong> and <strong>"
              + yearMax
              + "</strong>");
    } else {
      if (null != yearMin) {
        ret.append(", and year greater than <strong>" + yearMin + "</strong>");
      }
      if (null != yearMax) {
        ret.append(", and year smaller that <strong>" + yearMax + "</strong>");
      }
    }
    // Search in results
    if (null != criteriaSearch && null != criteriaType && null != oper) {
      ret.append(
          Utilities.prepareHumanString(
              (String) humanMappings.get(criteriaType), criteriaSearch, oper));
    }
    return ret.toString();
  }
  /**
   * This method supplies a human readable string representation of this object. for example
   * "Country is Romania"... so an representation of this object could be displayed on the page.
   *
   * @return A human readable representation of an object.
   */
  public String toHumanString() {
    StringBuffer sql = new StringBuffer();
    // if sql where condition contains another conditions, will be put 'and' before the new
    // condition witch will be
    // attached to the sql where condition
    Vector put_and = new Vector();

    // Main search criteria
    if (null != author && null != relationOpAuthor) {
      if (!author.equalsIgnoreCase("")) {
        if (put_and.contains("true")) {
          sql.append(" AND ");
        } else {
          put_and.addElement("true");
        }
        sql.append(Utilities.prepareHumanString("Author", author, relationOpAuthor));
      }
    }

    if (((null != date && !date.equalsIgnoreCase("") && !date.equalsIgnoreCase("null"))
            || (null != date1 && !date1.equalsIgnoreCase("") && !date1.equalsIgnoreCase("null")))
        && null != relationOpDate) {
      if (put_and.contains("true")) {
        sql.append(" AND ");
      } else {
        put_and.addElement("true");
      }

      Integer relationOpForDate = relationOpDate;

      if (relationOpDate.compareTo(Utilities.OPERATOR_BETWEEN) == 0) {
        if (date == null || (date != null && date.equalsIgnoreCase(""))) {
          relationOpForDate = Utilities.OPERATOR_SMALLER_OR_EQUAL;
        }
        if (date1 == null || (date1 != null && date1.equalsIgnoreCase(""))) {
          relationOpForDate = Utilities.OPERATOR_GREATER_OR_EQUAL;
        }
        if (date != null
            && date1 != null
            && !date.equalsIgnoreCase("")
            && !date1.equalsIgnoreCase("")) {
          relationOpForDate = Utilities.OPERATOR_BETWEEN;
        }
      }

      sql.append(
          Utilities.prepareHumanString(
              "Year",
              (date == null || date.equalsIgnoreCase("") ? date1 : date),
              date,
              date1,
              relationOpForDate));
    }

    if (null != title && null != relationOpTitle) {
      if (!title.equalsIgnoreCase("")) {
        if (put_and.contains("true")) {
          sql.append(" AND ");
        } else {
          put_and.addElement("true");
        }
        sql.append(Utilities.prepareHumanString("Title", title, relationOpTitle));
      }
    }

    if (null != editor && null != relationOpEditor) {
      if (!editor.equalsIgnoreCase("")) {
        if (put_and.contains("true")) {
          sql.append(" AND ");
        } else {
          put_and.addElement("true");
        }
        sql.append(Utilities.prepareHumanString("Editor", editor, relationOpEditor));
      }
    }

    if (null != publisher && null != relationOpPublisher) {
      if (!publisher.equalsIgnoreCase("")) {
        if (put_and.contains("true")) {
          sql.append(" AND ");
        } else {
          put_and.addElement("true");
        }
        sql.append(Utilities.prepareHumanString("Publisher", publisher, relationOpPublisher));
      }
    }

    // Search in results
    if (null != criteriaSearch && null != criteriaType && null != oper) {
      sql.append(
          Utilities.prepareHumanString(
              (String) humanMappings.get(criteriaType), criteriaSearch, oper));
    }
    return sql.toString();
  }