Ejemplo n.º 1
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());
    }
  }
Ejemplo n.º 2
0
  @Override
  public String createType(
      String connectionToken,
      String schema,
      String typeName,
      TYPE_FORM form,
      String baseType,
      String definition,
      ArrayList<String> attributeList)
      throws DatabaseConnectionException {
    ConnectionManager connMgr = new ConnectionManager();
    HttpServletRequest request = this.getThreadLocalRequest();

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

    Types types;

    types = new Types(connMgr.getConnection(connectionToken, clientIP, userAgent));

    return types.createType(
        connectionToken, schema, typeName, form, baseType, definition, attributeList);
  }
Ejemplo n.º 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 "";
    }
  }