@Override public String getTable() { return location.toString(); }
@Override public String getTable() { return location.toString(); }
@Override public boolean accepts(TableLocation table, Map<ATTRIBUTES, String> tableProperties) { return table.toString().toLowerCase().contains(nameFilter.toLowerCase()); } }
@Override public boolean accepts(TableLocation table, Map<ATTRIBUTES, String> tableProperties) { return !table.toString().toLowerCase().contains(nameFilter.toLowerCase()); } }
/** * Add the geometry type constraint and the SRID */ private void setGeometryTypeConstraints() throws SQLException { if(isH2){ connection.createStatement().execute(String.format("ALTER TABLE %s ALTER COLUMN the_geom %s", tableLocation.toString(), firstGeometryType)); SFSUtilities.addTableSRIDConstraint(connection, tableLocation, parsedSRID); } else{ connection.createStatement().execute(String.format("ALTER TABLE %s ALTER COLUMN the_geom SET DATA TYPE geometry(%s,%d)", tableLocation.toString(), firstGeometryType, parsedSRID)); } } }
/** * @return Fence layer name with good capitalization */ private String getFenceLayerName(boolean isH2) { return TableLocation.parse(FENCE_LAYER_NAME, isH2).toString(isH2); }
@Override public void init(Connection conn, String schemaName, String triggerName, String tableName, boolean before, int type) throws SQLException { this.update = type == UPDATE; this.tableIdentifier = new TableLocation(schemaName, tableName).toString(true); if(!dataManager.hasTableEditListener(tableIdentifier)) { try(Statement st = conn.createStatement()) { st.execute("DROP TRIGGER IF EXISTS "+triggerName); } throw new SQLException("This trigger does not exists"); } }
@Override public boolean hasTableEditListener(String tableIdentifier) { TableLocation table = TableLocation.parse(tableIdentifier, isH2); if("PUBLIC".equals(table.getSchema()) && !tableEditionListener.containsKey(table.toString(true))) { // Maybe schema is not given in listener table identifier table = new TableLocation("","",table.getTable()); } String parsedTable = table.toString(isH2); return tableEditionListener.containsKey(parsedTable); }
public Layer(String name, URI dataURI,DataManager dataManager) { super(name); this.dataURI = dataURI; this.dataManager = dataManager; if(JDBC_REFERENCE_SCHEME.equalsIgnoreCase(dataURI.getScheme())) { try { Map<String,String> query = URIUtility.getQueryKeyValuePairs(URI.create(dataURI.getSchemeSpecificPart())); tableReference = new TableLocation(query.get("catalog"),query.get("schema"),query.get("table")).toString(); } catch (UnsupportedEncodingException ex) { LOGGER.trace(ex.getLocalizedMessage(), ex); } } }
@Override public boolean hasTableEditListener(String tableIdentifier) { TableLocation table = TableLocation.parse(tableIdentifier, isH2); if("PUBLIC".equals(table.getSchema()) && !tableEditionListener.containsKey(table.toString(true))) { // Maybe schema is not given in listener table identifier table = new TableLocation("","",table.getTable()); } String parsedTable = table.toString(isH2); return tableEditionListener.containsKey(parsedTable); }
@Override public void init(Connection conn, String schemaName, String triggerName, String tableName, boolean before, int type) throws SQLException { this.update = type == UPDATE; this.tableIdentifier = new TableLocation(schemaName, tableName).toString(true); if(!dataManager.hasTableEditListener(tableIdentifier)) { try(Statement st = conn.createStatement()) { st.execute("DROP TRIGGER IF EXISTS "+triggerName); } throw new SQLException("This trigger does not exists"); } else { // Fetch primary key column pkColumn = JDBCUtilities.getIntegerPrimaryKey(conn, tableIdentifier); } }
/** * Explode Geometry Collection into multiple geometries * @param connection * @param tableName the name of the input table * @param fieldName the name of geometry field. If null the first geometry column is used. * @return * @throws java.sql.SQLException */ public static ResultSet explode(Connection connection, String tableName, String fieldName) throws SQLException { ExplodeResultSet rowSource = new ExplodeResultSet(connection, TableLocation.parse(tableName, JDBCUtilities.isH2DataBase(connection.getMetaData())).toString(),fieldName); return rowSource.getResultSet(); }
/** * Explode Geometry Collection into multiple geometries * @param connection * @param tableName the name of the input table * @param fieldName the name of geometry field. If null the first geometry column is used. * @return * @throws java.sql.SQLException */ public static ResultSet explode(Connection connection, String tableName, String fieldName) throws SQLException { ExplodeResultSet rowSource = new ExplodeResultSet(connection, TableLocation.parse(tableName, JDBCUtilities.isH2DataBase(connection.getMetaData())).toString(),fieldName); return rowSource.getResultSet(); }
/** * Explode Geometry Collection into multiple geometries * @param connection * @param tableName the name of the input table * @param fieldName the name of geometry field. If null the first geometry column is used. * @return * @throws java.sql.SQLException */ public static ResultSet explode(Connection connection, String tableName, String fieldName) throws SQLException { ExplodeResultSet rowSource = new ExplodeResultSet(connection, TableLocation.parse(tableName, JDBCUtilities.isH2DataBase(connection.getMetaData())).toString(),fieldName); return rowSource.getResultSet(); }
/** * Return the table identifier in the best fit depending on database type * * @param requestedTable Catalog and schema used * @param tableName Table without quotes * @param isH2 True if H2, false if PostGRES * @return Find table identifier */ private static String caseIdentifier(TableLocation requestedTable, String tableName, boolean isH2) { return new TableLocation(requestedTable.getCatalog(), requestedTable.getSchema(), TableLocation.parse(tableName, isH2).getTable()).toString(); }
/** * Return the table identifier in the best fit depending on database type * * @param requestedTable Catalog and schema used * @param tableName Table without quotes * @param isH2 True if H2, false if PostGRES * @return Find table identifier */ private static String caseIdentifier(TableLocation requestedTable, String tableName, boolean isH2) { return new TableLocation(requestedTable.getCatalog(), requestedTable.getSchema(), TableLocation.parse(tableName, isH2).getTable()).toString(); }
@Override public void insertRow() throws SQLException { if(insertRow == null) { throw new SQLException(I18N.tr("RowSet not moved to insert row")); } insertRow.redo(false); cachedRowCount++; manager.fireTableEditHappened(new TableEditEvent(location.toString(isH2), insertRow, TableModelEvent.ALL_COLUMNS, insertRow.getPrimaryKey(), insertRow.getPrimaryKey(), TableModelEvent.INSERT)); moveToInsertRow(); }
/** * Return the table identifier in the best fit depending on database type * * @param requestedTable Catalog and schema used * @param tableName Table without quotes * @param isH2 True if H2, false if PostGRES * @return Find table identifier */ public static String caseIdentifier(TableLocation requestedTable, String tableName, boolean isH2) { return new TableLocation(requestedTable.getCatalog(), requestedTable.getSchema(), TableLocation.parse(tableName, isH2).getTable()).toString(); } }
/** * Return the table identifier in the best fit depending on database type * * @param requestedTable Catalog and schema used * @param tableName Table without quotes * @param isH2 True if H2, false if PostGRES * * @return Find table identifier */ public static String caseIdentifier(TableLocation requestedTable, String tableName, boolean isH2) { return new TableLocation(requestedTable.getCatalog(), requestedTable.getSchema(), TableLocation.parse(tableName, isH2).getTable()).toString(); } }
@Override public void deleteRow() throws SQLException { checkCurrentRow(); TableUndoableDelete deleteEvt = new TableUndoableDelete(manager, location, pk_name, isH2); for(int idColumn = 0; idColumn < currentRow.row.length; idColumn++) { deleteEvt.setValue(getColumnLabel(idColumn + 1), currentRow.row[idColumn]); } deleteEvt.redo(false); cachedRowCount--; refreshRow(); manager.fireTableEditHappened(new TableEditEvent(location.toString(isH2), deleteEvt, TableModelEvent .ALL_COLUMNS, deleteEvt.getPrimaryKey(), deleteEvt.getPrimaryKey(), TableModelEvent.DELETE)); }