@Override public String createFunction( String connectionToken, int schema, String functionName, String returns, String language, ArrayList<String> paramList, String definition) throws DatabaseConnectionException, PostgreSQLException { ConnectionManager connMgr = new ConnectionManager(); HttpServletRequest request = this.getThreadLocalRequest(); String clientIP = ConnectionInfo.remoteAddr(request); String userAgent = request.getHeader("User-Agent"); Functions funcs; funcs = new Functions(connMgr.getConnection(connectionToken, clientIP, userAgent)); try { return funcs.create(schema, functionName, returns, language, paramList, definition); } catch (SQLException e) { throw new PostgreSQLException(e.getMessage()); } }
@Override public String getTriggerFunctionList(String connectionToken, int schema) throws IllegalArgumentException, DatabaseConnectionException { ConnectionManager connMgr = new ConnectionManager(); HttpServletRequest request = this.getThreadLocalRequest(); String clientIP = ConnectionInfo.remoteAddr(request); String userAgent = request.getHeader("User-Agent"); Functions funcs; funcs = new Functions(connMgr.getConnection(connectionToken, clientIP, userAgent)); String funcList = funcs.getTriggerFunctionList(schema); return funcList; }
@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()); } }
@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 ""; } }