/** * Check if two table identifier are equals * @param tableIdentifier First table identifier * @param otherTableIdentifier Second table identifier * @return True if there are equal. */ public static boolean isTableIdentifierEquals(String tableIdentifier, String otherTableIdentifier) { TableLocation tableLocation = TableLocation.parse(tableIdentifier); TableLocation tableLocation1 = TableLocation.parse(otherTableIdentifier); return (tableLocation.getSchema().isEmpty() && tableLocation1.getSchema().equalsIgnoreCase("public") || tableLocation1.getSchema().isEmpty() && tableLocation.getSchema().equalsIgnoreCase("public") || tableLocation1.getSchema().equals(tableLocation.getSchema())) && tableLocation.getTable().equals(tableLocation1.getTable()); }
@Override public boolean accepts(TableLocation table, Map<ATTRIBUTES, String> tableProperties) { return SYSTEM_SCHEMA.contains(table.getSchema().toLowerCase()) || SYSTEM_TABLES.contains(table.getTable().toLowerCase()); } }
public AskValidValue(DataSource ds,String tableReference, String fieldName) throws SQLException { super("Field '" + fieldName + "'", null, null); try(Connection connection = ds.getConnection()) { DatabaseMetaData meta = connection.getMetaData(); TableLocation location = TableLocation.parse(tableReference); try(ResultSet rs = meta.getColumns(location.getCatalog(), location.getSchema(), location.getTable(), fieldName)) { if(rs.next()) { this.fieldType = rs.getInt("DATA_TYPE"); } } } }
public AskValidValue(DataSource ds,String tableReference, String fieldName) throws SQLException { super("Field '" + fieldName + "'", null, null); try(Connection connection = ds.getConnection()) { DatabaseMetaData meta = connection.getMetaData(); TableLocation location = TableLocation.parse(tableReference); try(ResultSet rs = meta.getColumns(location.getCatalog(), location.getSchema(), location.getTable(), fieldName)) { if(rs.next()) { this.fieldType = rs.getInt("DATA_TYPE"); } } } }
@Override public boolean isTableExists(String tableName) throws SQLException { TableLocation tableLocation = TableLocation.parse(tableName); try (Connection connection = dataSource.getConnection(); ResultSet rs = connection.getMetaData().getTables(tableLocation.getCatalog(), tableLocation.getSchema(), tableLocation.getTable(), null)) { return rs.next(); } }
@Override public boolean isTableExists(String tableName) throws SQLException { TableLocation tableLocation = TableLocation.parse(tableName); try (Connection connection = dataSource.getConnection(); ResultSet rs = connection.getMetaData().getTables(tableLocation.getCatalog(), tableLocation.getSchema(), tableLocation.getTable(), null)) { return rs.next(); } }
@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 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); }
/** * Suffix a TableLocation * * @param inputTable Input table * @param suffix Suffix * * @return suffixed TableLocation */ public static TableLocation suffixTableLocation(TableLocation inputTable, String suffix) { return new TableLocation(inputTable.getCatalog(), inputTable.getSchema(), inputTable.getTable() + suffix); }
/** * Find geometry fields name of a table. * @param connection Active connection * @param location Table location * @return A list of Geometry fields name * @throws SQLException */ public static List<String> getGeometryFields(Connection connection,TableLocation location) throws SQLException { return getGeometryFields(connection, location.getCatalog(), location.getSchema(), location.getTable()); }
private static String getH2TriggerName(String table) { TableLocation tableIdentifier = TableLocation.parse(table, true); return new TableLocation(tableIdentifier.getCatalog(), tableIdentifier.getSchema(), "DM_"+tableIdentifier.getTable()).toString(true); } @Override
/** * Find geometry fields name of a table. * @param connection Active connection * @param location Table location * @return A list of Geometry fields name * @throws SQLException */ public static List<String> getGeometryFields(Connection connection,TableLocation location) throws SQLException { return getGeometryFields(connection, location.getCatalog(), location.getSchema(), location.getTable()); }
private static String getH2TriggerName(String table) { TableLocation tableIdentifier = TableLocation.parse(table, true); return new TableLocation(tableIdentifier.getCatalog(), tableIdentifier.getSchema(), "DM_"+tableIdentifier.getTable()).toString(true); } @Override
/** * Suffix a TableLocation * * @param inputTable Input table * @param suffix Suffix * @return suffixed TableLocation */ public static TableLocation suffixTableLocation(TableLocation inputTable, String suffix) { return new TableLocation(inputTable.getCatalog(), inputTable.getSchema(), inputTable.getTable() + suffix); }
/** * Suffix a TableLocation * * @param inputTable Input table * @param suffix Suffix * @return suffixed TableLocation */ public static TableLocation suffixTableLocation(TableLocation inputTable, String suffix) { return new TableLocation(inputTable.getCatalog(), inputTable.getSchema(), inputTable.getTable() + suffix); } }
@Override public String findUniqueTableName(String originalTableName) throws SQLException { TableLocation tableLocation = TableLocation.parse(originalTableName); String tableName = originalTableName; int offset = 0; while(isTableExists(tableName)) { tableName = new TableLocation(tableLocation.getCatalog(), tableLocation.getSchema(), tableLocation.getTable() + "_" + ++offset).toString(); } return tableName; }
private ResultSet getFunctionData(DatabaseMetaData metaData) throws SQLException { TableLocation functionLocation = TableLocation.parse(functionName); return metaData.getProcedureColumns( functionLocation.getCatalog(null), functionLocation.getSchema(null), functionLocation.getTable(), null); }
/** * 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(); }
/** * 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(); } }