예제 #1
0
  @Override
  public String createSequence(
      String connectionToken,
      int schema,
      String sequenceName,
      boolean temporary,
      int increment,
      int minValue,
      int maxValue,
      int start,
      int cache,
      boolean cycle)
      throws DatabaseConnectionException, PostgreSQLException {

    ConnectionManager connMgr = new ConnectionManager();
    HttpServletRequest request = this.getThreadLocalRequest();

    String clientIP = ConnectionInfo.remoteAddr(request);
    String userAgent = request.getHeader("User-Agent");

    Sequences sequences =
        new Sequences(connMgr.getConnection(connectionToken, clientIP, userAgent));

    try {
      return sequences.create(
          schema, sequenceName, temporary, increment, minValue, maxValue, start, cache, cycle);
    } catch (SQLException e) {
      throw new PostgreSQLException(e.getMessage());
    }
  }
예제 #2
0
  @Override
  public String dropItem(String connectionToken, int item, ITEM_TYPE type, boolean cascade)
      throws IllegalArgumentException, DatabaseConnectionException, PostgreSQLException {
    ConnectionManager connMgr = new ConnectionManager();
    HttpServletRequest request = this.getThreadLocalRequest();

    String clientIP = ConnectionInfo.remoteAddr(request);
    String userAgent = request.getHeader("User-Agent");

    try {
      switch (type) {
        case FOREIGN_TABLE:
          ForeignTables fTables =
              new ForeignTables(connMgr.getConnection(connectionToken, clientIP, userAgent));
          return fTables.drop(item, cascade);
        case TABLE:
          Tables tables = new Tables(connMgr.getConnection(connectionToken, clientIP, userAgent));
          return tables.drop(item, cascade);
        case VIEW:
        case MATERIALIZED_VIEW:
          boolean isMaterialized = false;

          if (type == ITEM_TYPE.MATERIALIZED_VIEW) isMaterialized = true;

          Views views = new Views(connMgr.getConnection(connectionToken, clientIP, userAgent));
          return views.dropView(item, cascade, isMaterialized);
        case FUNCTION:
          Functions functions =
              new Functions(connMgr.getConnection(connectionToken, clientIP, userAgent));
          return functions.dropFunction(item, cascade);
        case SEQUENCE:
          Sequences sequences =
              new Sequences(connMgr.getConnection(connectionToken, clientIP, userAgent));
          return sequences.drop(item, cascade);
        case TYPE:
          Types types = new Types(connMgr.getConnection(connectionToken, clientIP, userAgent));
          return types.dropType(item, cascade);
        default:
          return "";
      }
    } catch (SQLException e) {
      throw new PostgreSQLException(e.getMessage());
    }
  }
예제 #3
0
  @Override
  public String getList(String connectionToken, int schema, ITEM_TYPE type)
      throws IllegalArgumentException, DatabaseConnectionException {

    ConnectionManager connMgr = new ConnectionManager();
    HttpServletRequest request = this.getThreadLocalRequest();

    String clientIP = ConnectionInfo.remoteAddr(request);
    String userAgent = request.getHeader("User-Agent");

    switch (type) {
      case TABLE:
        Tables tables = new Tables(connMgr.getConnection(connectionToken, clientIP, userAgent));
        return tables.getList(schema);
      case MATERIALIZED_VIEW:
      case VIEW:
        Views views = new Views(connMgr.getConnection(connectionToken, clientIP, userAgent));
        return views.getList(schema);
      case FOREIGN_TABLE:
        ForeignTables fTables =
            new ForeignTables(connMgr.getConnection(connectionToken, clientIP, userAgent));
        return fTables.getList(schema);
      case FUNCTION:
        Functions funcs =
            new Functions(connMgr.getConnection(connectionToken, clientIP, userAgent));
        return funcs.getList(schema);
      case SEQUENCE:
        Sequences seqs = new Sequences(connMgr.getConnection(connectionToken, clientIP, userAgent));
        return seqs.getList(schema);
      case TYPE:
        Types types = new Types(connMgr.getConnection(connectionToken, clientIP, userAgent));
        return types.getList(schema);
      default:
        return "";
    }
  }