Ejemplo n.º 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();
  }
Ejemplo n.º 2
0
  /**
   * This method implements a procedure from morphing the object into an web page FORM
   * representation. What I meant to say is that I can say about an object for example: < INPUT
   * type='hidden" name="searchCriteria" value="natrix"> < INPUT type='hidden" name="oper"
   * value="1"> < INPUT type='hidden" name="searchType" value="1">.
   *
   * @return Web page FORM representation of the object.
   */
  public String toFORMParam() {
    StringBuffer res = new StringBuffer();

    if (null != searchType) {
      res.append(Utilities.writeFormParameter("searchType", searchType.toString()));
    }
    if (null != searchString) {
      res.append(Utilities.writeFormParameter("searchString", searchString));
    }
    if (null != relationOp) {
      res.append(Utilities.writeFormParameter("relationOp", relationOp.toString()));
    }
    if (null != searchStringMin) {
      res.append(Utilities.writeFormParameter("searchStringMin", searchStringMin));
    }
    if (null != searchStringMax) {
      res.append(Utilities.writeFormParameter("searchStringMax", searchStringMax));
    }
    if (null != country) {
      res.append(Utilities.writeFormParameter("country", country));
    }
    if (null != yearMin) {
      res.append(Utilities.writeFormParameter("yearMin", yearMin));
    }
    if (null != yearMax) {
      res.append(Utilities.writeFormParameter("yearMax", yearMax));
    }
    // Search in results
    if (null != criteriaSearch) {
      res.append(Utilities.writeFormParameter("criteriaSearch", criteriaSearch));
    }
    if (null != criteriaType) {
      res.append(Utilities.writeFormParameter("criteriaType", criteriaType.toString()));
    }
    if (null != oper) {
      res.append(Utilities.writeFormParameter("oper", oper.toString()));
    }
    return res.toString();
  }
Ejemplo n.º 3
0
  /**
   * Transform this object into an SQL representation.
   *
   * @return SQL string representing this object.
   */
  public String toSQL() {
    StringBuffer sql = new StringBuffer();

    // System.out.println("searchString = " + searchString);
    if (((null != searchString) || (null != searchStringMin && null != searchStringMax))
        && null != relationOp) {
      sql.append("(");
      if (0 == SEARCH_AREA.compareTo(searchType)) {
        sql.append(
            Utilities.prepareSQLOperator(
                "A.AREA", searchString, searchStringMin, searchStringMax, relationOp));
      }
      if (0 == SEARCH_LENGTH.compareTo(searchType)) {
        sql.append(
            Utilities.prepareSQLOperator(
                "A.LENGTH", searchString, searchStringMin, searchStringMax, relationOp));
      }
      sql.append(")");
      if (null != country) {
        // AND C.AREA_NAME_EN='FRANCE'
        sql.append(" AND (C.AREA_NAME_EN='" + country + "')");
      }
      if (null != yearMin) {
        sql.append(" AND (LENGTH(DESIGNATION_DATE) > 0) ");
        sql.append(
            " AND (CAST(CONCAT(IF(A.source_db='BIOGENETIC',left(designation_date,4),''), "
                + "IF(A.source_db='CDDA_INTERNATIONAL',right(designation_date,4),''), "
                + "IF(A.source_db='CDDA_NATIONAL',right(designation_date,4),''), "
                + "IF(A.source_db='EMERALD',right(designation_date,4),''), "
                + "IF(A.source_db='DIPLOMA',right(designation_date,4),''), "
                + "IF(A.source_db='NATURA2000',right(designation_date,4),''), "
                + "IF(A.source_db='CORINE',right(designation_date,4),''), "
                + "IF(A.source_db='NATURENET',right(designation_date,4),'')) AS SIGNED) >= "
                + yearMin
                + ") "
                + " AND A.DESIGNATION_DATE IS NOT NULL"
                + " AND A.DESIGNATION_DATE <> ''");
      }
      if (null != yearMax) {
        sql.append(" AND (LENGTH(DESIGNATION_DATE) > 0) ");
        sql.append(
            " AND (CAST(CONCAT(IF(A.source_db='BIOGENETIC',left(designation_date,4),''), "
                + "IF(A.source_db='CDDA_INTERNATIONAL',right(designation_date,4),''), "
                + "IF(A.source_db='CDDA_NATIONAL',right(designation_date,4),''), "
                + "IF(A.source_db='EMERALD',right(designation_date,4),''), "
                + "IF(A.source_db='DIPLOMA',right(designation_date,4),''), "
                + "IF(A.source_db='NATURA2000',right(designation_date,4),''), "
                + "IF(A.source_db='CORINE',right(designation_date,4),''), "
                + "IF(A.source_db='NATURENET',right(designation_date,4),'')) AS SIGNED) <= "
                + yearMax
                + ") "
                + " AND A.DESIGNATION_DATE IS NOT NULL"
                + " AND A.DESIGNATION_DATE <> ''");
      }
    }
    // Search in results
    if (null != criteriaSearch && null != criteriaType && null != oper) {
      if (0 == criteriaType.compareTo(CRITERIA_SOURCE_DB)) {
        sql.append(
            Utilities.prepareSQLOperator(
                (String) sqlMappings.get(criteriaType),
                SitesSearchUtility.translateSourceDBInvert(criteriaSearch),
                oper));
      } else {
        sql.append(
            Utilities.prepareSQLOperator(
                (String) sqlMappings.get(criteriaType), criteriaSearch, oper));
      }
    }
    return sql.toString();
  }
Ejemplo n.º 4
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 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();
  }
Ejemplo n.º 5
0
  /**
   * This method implements a procedure from morphing the object into an web page FORM
   * representation. What I meant to say is that I can say about an object for example: < INPUT
   * type='hidden" name="searchCriteria" value="natrix"> < INPUT type='hidden" name="oper"
   * value="1"> < INPUT type='hidden" name="searchType" value="1">.
   *
   * @return Web page FORM representation of the object.
   */
  public String toFORMParam() {
    StringBuffer form = new StringBuffer();

    if (null != author) {
      form.append(Utilities.writeFormParameter("author", author));
    }
    if (null != relationOpAuthor) {
      form.append(Utilities.writeFormParameter("relationOpAuthor", relationOpAuthor.toString()));
    }
    if (null != date) {
      form.append(Utilities.writeFormParameter("date", date));
    }
    if (null != date1) {
      form.append(Utilities.writeFormParameter("date1", date1));
    }
    if (null != relationOpDate) {
      form.append(Utilities.writeFormParameter("relationOpDate", relationOpDate.toString()));
    }
    if (null != title) {
      form.append(Utilities.writeFormParameter("title", title));
    }
    if (null != relationOpTitle) {
      form.append(Utilities.writeFormParameter("relationOpTitle", relationOpTitle.toString()));
    }
    if (null != editor) {
      form.append(Utilities.writeFormParameter("editor", editor));
    }
    if (null != relationOpEditor) {
      form.append(Utilities.writeFormParameter("relationOpEditor", relationOpEditor.toString()));
    }
    if (null != publisher) {
      form.append(Utilities.writeFormParameter("publisher", publisher));
    }
    if (null != relationOpPublisher) {
      form.append(
          Utilities.writeFormParameter("relationOpPublisher", relationOpPublisher.toString()));
    }

    // Search in results
    if (null != criteriaSearch) {
      form.append(Utilities.writeFormParameter("criteriaSearch", criteriaSearch));
    }
    if (null != criteriaType) {
      form.append(Utilities.writeFormParameter("criteriaType", criteriaType.toString()));
    }
    if (null != oper) {
      form.append(Utilities.writeFormParameter("oper", oper.toString()));
    }
    return form.toString();
  }
Ejemplo n.º 6
0
  /**
   * Transform this object into an SQL representation.
   *
   * @return SQL string representing this object.
   */
  public String toSQL() {
    StringBuffer sql = new StringBuffer();

    if (part.equalsIgnoreCase("ReferencesPart")) {
      // 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.prepareSQLOperator("A.SOURCE", 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");
        }

        if (relationOpDate.compareTo(Utilities.OPERATOR_BETWEEN) == 0) {
          if (date == null || (date != null && date.equalsIgnoreCase(""))) {
            sql.append(" A.CREATED <=" + date1 + " ");
          }
          if (date1 == null || (date1 != null && date1.equalsIgnoreCase(""))) {
            sql.append(" A.CREATED >=" + date + " ");
          }
          if (date != null
              && date1 != null
              && !date.equalsIgnoreCase("")
              && !date1.equalsIgnoreCase("")) {
            sql.append(" A.CREATED >=" + date + " AND A.CREATED<=" + date1 + " ");
          }
        } else {
          sql.append(Utilities.prepareSQLOperator("A.CREATED", date, relationOpDate));
        }
      }

      if (null != title && null != relationOpTitle) {
        if (!title.equalsIgnoreCase("")) {
          if (put_and.contains("true")) {
            sql.append(" AND ");
          } else {
            put_and.addElement("true");
          }
          sql.append(Utilities.prepareSQLOperator("A.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.prepareSQLOperator("A.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.prepareSQLOperator("A.PUBLISHER", publisher, relationOpPublisher));
        }
      }

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