Package edu.uga.galileo.voci.db

Examples of edu.uga.galileo.voci.db.QueryParser


    sql.append(contentTypeString);
    sql.append(' ');
    sql.append("where metadata_id=? ");
    sql.append("and value=? ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(metadataId);
    qp.addPreparedStmtElementDefinition(metadataValue);

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      try {
        if (qp.getResultCount()>0) {
          return qp.getResult(Integer.class, "elementId");
        }
      } catch (DataTypeMismatchException e) {
        Logger.error("Data type mismatch (code problem).", e);
      }
    } catch (SQLException e1) {
View Full Code Here


    sql.append("and content_type=? ");
    sql.append("and community_id is null ");
    sql.append("and active=true ");
    sql.append("order by display_order asc ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(projectId);
    qp.addPreparedStmtElementDefinition(contentType);

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      return createObjectsFromQueryParser(MetadataElement.class, qp);
    } catch (SQLException e) {
View Full Code Here

    sql.append("select * ");
    sql.append("from metadata_registry ");
    sql.append("where metadata_id=? ");
    sql.append("and active=true ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(id);

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() > 0) {
        return createObjectFromQueryParser(MetadataElement.class, qp);
      } else {
        throw new NoSuchMetadataException(
            "The requested community pID (" + id
                + ") doesn't exist.");
View Full Code Here

    sql.append("index_multiplier, is_required, content_type, ");
    sql
        .append("display_order, is_key_field, is_unique, visible_in_face) values ");
    sql.append("(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(id);
    qp.addPreparedStmtElementDefinition(elem.getProjectId());
    qp.addPreparedStmtElementDefinition(QueryParserElement.INT, elem
        .getCommunityId() == -1 ? null : elem.getCommunityId());
    qp.addPreparedStmtElementDefinition(elem.getElement());
    qp.addPreparedStmtElementDefinition(elem.getQualifier());
    qp.addPreparedStmtElementDefinition(elem.getDisplayName());
    qp.addPreparedStmtElementDefinition(elem.getDescription());
    qp.addPreparedStmtElementDefinition(elem.isDublinCore());
    qp.addPreparedStmtElementDefinition(elem.isRepeatable());
    qp.addPreparedStmtElementDefinition(elem.getValidateRegex());
    qp.addPreparedStmtElementDefinition(elem.getFieldType());
    qp.addPreparedStmtElementDefinition(elem.getIndexMultiplier());
    qp.addPreparedStmtElementDefinition(elem.isRequired());
    qp.addPreparedStmtElementDefinition(elem.getContentType());
    qp.addPreparedStmtElementDefinition(getNextDisplayOrderId(elem
        .getProjectId(), elem.getContentType()));
    qp.addPreparedStmtElementDefinition(elem.isKeyField());
    qp.addPreparedStmtElementDefinition(elem.isUnique());
    qp.addPreparedStmtElementDefinition(elem.isVisibleInFace());

    try {
      Configuration.getConnectionPool().executeInsertOrUpdate(qp);
    } catch (SQLException e) {
      Logger.error("Metadata record couldn't be added", e);
View Full Code Here

    sql.append("repeatable=?, validate_regex=?, field_type=?, ");
    sql.append("index_multiplier=?, is_required=?, content_type=?, ");
    sql.append("visible_in_face=?, include_in_blurb=? ");
    sql.append("where metadata_id=? ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(elem.getElement());
    qp.addPreparedStmtElementDefinition(elem.getQualifier());
    qp.addPreparedStmtElementDefinition(elem.getDisplayName());
    qp.addPreparedStmtElementDefinition(elem.getDescription());
    qp.addPreparedStmtElementDefinition(elem.isDublinCore());
    qp.addPreparedStmtElementDefinition(elem.isUnique());
    qp.addPreparedStmtElementDefinition(elem.isRepeatable());
    qp.addPreparedStmtElementDefinition(elem.getValidateRegex());
    qp.addPreparedStmtElementDefinition(elem.getFieldType());
    qp.addPreparedStmtElementDefinition(elem.getIndexMultiplier());
    qp.addPreparedStmtElementDefinition(elem.isRequired());
    qp.addPreparedStmtElementDefinition(elem.getContentType());
    qp.addPreparedStmtElementDefinition(elem.isVisibleInFace());
    qp.addPreparedStmtElementDefinition(elem.isIncludeInBlurb());
    qp.addPreparedStmtElementDefinition(elem.getMetadataId());

    try {
      Configuration.getConnectionPool().executeInsertOrUpdate(qp);
    } catch (SQLException e) {
      Logger.error("Metadata record couldn't be updated", e);
View Full Code Here

      // first disable the element...
      StringBuffer sql = new StringBuffer();
      sql.append("delete from metadata_registry ");
      sql.append("where metadata_id=? ");

      QueryParser qp = new QueryParser(sql.toString());
      if (connection != null) {
        qp.setConnection(connection);
      }
      qp.addPreparedStmtElementDefinition(meta.getMetadataId());

      try {
        Configuration.getConnectionPool().executeInsertOrUpdate(qp);
      } catch (SQLException e) {
        Logger.error("Metadata record couldn't be disabled", e);
        throw new NoSuchMetadataException(
            "SQLException prevented metadata record disabled: "
                + e.getMessage());
      }

      // ...then renumber the display order of subsequent elements
      sql = new StringBuffer();
      sql.append("update metadata_registry ");
      sql.append("set display_order=display_order-1 ");
      sql.append("where project_id=? ");
      sql.append("and content_type=? ");
      sql.append("and display_order>? ");

      qp.clearForNewSQL();
      qp.setSql(sql.toString());
      qp.addPreparedStmtElementDefinition(meta.getProjectId());
      qp.addPreparedStmtElementDefinition(meta.getContentType());
      qp.addPreparedStmtElementDefinition(currentDisplayOrder);

      Configuration.getConnectionPool().executeInsertOrUpdate(qp);
    } catch (SQLException e) {
      Logger.error("Metadata record couldn't be disabled", e);
      throw new NoSuchMetadataException(
View Full Code Here

      sql.append("set display_order=? ");
      sql.append("where project_id=? ");
      sql.append("and content_type=? ");
      sql.append("and display_order=? ");

      QueryParser qp = new QueryParser(sql.toString());
      if (connection != null) {
        qp.setConnection(connection);
      }
      qp.addPreparedStmtElementDefinition(currentDisplayOrder);
      qp.addPreparedStmtElementDefinition(meta.getProjectId());
      qp.addPreparedStmtElementDefinition(meta.getContentType());
      qp.addPreparedStmtElementDefinition(moveTo);

      Configuration.getConnectionPool().executeInsertOrUpdate(qp);

      sql = new StringBuffer();
      sql.append("update metadata_registry ");
      sql.append("set display_order=? ");
      sql.append("where metadata_id=? ");

      qp.clearForNewSQL();
      qp.setSql(sql.toString());
      qp.addPreparedStmtElementDefinition(moveTo);
      qp.addPreparedStmtElementDefinition(meta.getMetadataId());

      Configuration.getConnectionPool().executeInsertOrUpdate(qp);
    } catch (SQLException e) {
      throw new NoSuchMetadataException(
          "SQLException prevented getting current display order for "
View Full Code Here

   */
  private int getNextMetadataId() throws NoSuchMetadataException {
    StringBuffer sql = new StringBuffer();
    sql.append("select nextval('metadata_id_seq') as nextVal ");

    QueryParser qp = new QueryParser(sql.toString());

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      return qp.getResult(Integer.class, "nextVal");
    } catch (SQLException e) {
      Logger.error(
          "Metadata ID couldn't be retrieved b/c of SQLException", e);
      throw new NoSuchMetadataException(
          "Couldn't get a metadata ID from the metadata_id_seq b/c of a SQLException: "
View Full Code Here

    sql.append("select max(display_order)+1 as displayOrder ");
    sql.append("from metadata_registry ");
    sql.append("where project_id=? ");
    sql.append("and content_type=? ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(projectId);
    qp.addPreparedStmtElementDefinition(contentType);

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      if (qp.getResultCount() == 0) {
        return 0;
      }

      return qp.getResult(Integer.class, "displayOrder");
    } catch (SQLException e) {
      Logger.error("Display order couldn't be retrieved b/c of "
          + "SQLException ... returning 1000.", e);
    } catch (DataTypeMismatchException e) {
      Logger.error("Display order couldn't be retrieved ... "
View Full Code Here

    StringBuffer sql = new StringBuffer();
    sql.append("select display_order ");
    sql.append("from metadata_registry ");
    sql.append("where metadata_id=? ");

    QueryParser qp = new QueryParser(sql.toString());
    qp.addPreparedStmtElementDefinition(metadataId);

    try {
      Configuration.getConnectionPool().executeQuery(qp);
      return qp.getResult(Integer.class, "display_order");
    } catch (DataTypeMismatchException e) {
      Logger
          .error(
              "Your code's requesting a bad data type for display_order.",
              e);
View Full Code Here

TOP

Related Classes of edu.uga.galileo.voci.db.QueryParser

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.