public TableDesc(String schemaName, String tableName) { TapSchema.assertNotNull(TableDesc.class, "schemaName", schemaName); TapSchema.assertNotNull(TableDesc.class, "tableName", tableName); this.schemaName = schemaName; this.tableName = tableName; }
public TableDesc findTable(String tableName) { for (SchemaDesc sd : schemaDescs) { TableDesc td = sd.getTable(tableName); if (td != null) return td; } return null; }
/** * Get the complete TapSchema. * * @return complete TapSchema */ public TapSchema get() { // depth MIN = schemas and tables // depth MAX = columns + keys + functions return get(MAX_DEPTH); }
/** * Create a VOTableField from a ColumnDesc. * * @param column * @return The associated VOTableField */ public static VOTableField convert(ColumnDesc column) { VOTableField vtf = new VOTableField( column.getColumnName(), column.getDatatype().getDatatype(), column.getDatatype().arraysize); vtf.xtype = column.getDatatype().xtype; return vtf; }
private String generateInsertSQL(TableDesc td) { StringBuilder sb = new StringBuilder("insert into "); sb.append(td.getTableName()); sb.append(" ("); for (ColumnDesc cd : td.getColumnDescs()) { sb.append(cd.getColumnName()); sb.append(", "); } sb.setLength(sb.length() - 2); sb.append(") values ("); for (ColumnDesc cd : td.getColumnDescs()) { sb.append("?, "); } sb.setLength(sb.length() - 2); sb.append(")"); return sb.toString(); }
SchemaDesc getSchema(String schemaName) { // List of TAP_SCHEMA.schemas GetSchemasStatement gss = new GetSchemasStatement(schemasTableName); if (ordered) gss.setOrderBy(orderSchemaClause); JdbcTemplate jdbc = new JdbcTemplate(dataSource); List<SchemaDesc> schemaDescs = jdbc.query(gss, new SchemaMapper()); for (SchemaDesc sd : schemaDescs) { if (sd.getSchemaName().equals(schemaName)) { return sd; } } return null; }
/** * * @param columnDesc * @return data type code for use in PreparedStatement set methods */ @Override public Integer getType(ColumnDesc columnDesc) { TapDataType tt = columnDesc.getDatatype(); TypePair dbt = findTypePair(tt); return dbt.num; }
private TapDataType getDatatypeFromExpression(Expression expression) { // TODO: could check constant types instead iof lazy string return new TapDataType("char", "*", null); }
public static void checkValidTableName(String identifier) throws ADQLIdentifierException { String[] parts = identifier.split("[.]"); String schemaName = null; String tableName = identifier; if (parts.length == 2) { schemaName = parts[0]; tableName = parts[1]; } else if (parts.length > 2) { throw new ADQLIdentifierException("invalid table name: " + identifier + " (too many parts)"); } if (schemaName != null) { checkValidIdentifier(schemaName); } checkValidIdentifier(tableName); }
public Object mapRow(ResultSet rs, int rowNum) throws SQLException { String sn = rs.getString("schema_name"); String tn = rs.getString("table_name"); TableDesc tableDesc = new TableDesc(sn, tn); tableDesc.tableType = TableDesc.TableType.toValue(rs.getString("table_type")); tableDesc.description = rs.getString("description"); tableDesc.utype = rs.getString("utype"); return tableDesc; } }
public Object mapRow(ResultSet rs, int rowNum) throws SQLException { String sn = rs.getString("schema_name"); SchemaDesc schemaDesc = new SchemaDesc(sn); schemaDesc.description = rs.getString("description"); schemaDesc.utype = rs.getString("utype"); return schemaDesc; } }
protected TapSchemaDAO getTapSchemaDAO() { return new TapSchemaDAO(); }
@Override public int hashCode() { return toString().hashCode(); }
public Object mapRow(ResultSet rs, int rowNum) throws SQLException { String kid = rs.getString("key_id"); String fc = rs.getString("from_column"); String tc = rs.getString("target_column"); KeyColumnDesc keyColumnDesc = new KeyColumnDesc(kid, fc, tc); return keyColumnDesc; } }
public Object mapRow(ResultSet rs, int rowNum) throws SQLException { String kid = rs.getString("key_id"); String ft = rs.getString("from_table"); String tt = rs.getString("target_table"); KeyDesc keyDesc = new KeyDesc(kid, ft, tt); keyDesc.description = rs.getString("description"); keyDesc.utype = rs.getString("utype"); return keyDesc; } }
public TapDataType(String datatype) { TapSchema.assertNotNull(TapDataType.class, "datatype", datatype); this.datatype = datatype; }
public FunctionDesc(String name, TapDataType datatype) { TapSchema.assertNotNull(FunctionDesc.class, "name", name); TapSchema.assertNotNull(FunctionDesc.class, "datatype", datatype); this.name = name; this.datatype = datatype; }
public ColumnDesc(String tableName, String columnName, TapDataType datatype) { TapSchema.assertNotNull(TableDesc.class, "tableName", tableName); TapSchema.assertNotNull(TableDesc.class, "columnName", columnName); TapSchema.assertNotNull(TableDesc.class, "datatype", datatype); this.tableName = tableName; this.columnName = columnName; this.datatype = datatype; }
public SchemaDesc(String schemaName) { TapSchema.assertNotNull(SchemaDesc.class, "schemaName", schemaName); this.schemaName = schemaName; }
/** * A new column created by some sort of expression. This could be a function call, algebraic * expression, case statement, etc. The calling code must set any additional column * metadata. * * @param name * @param datatype */ public TapSelectItem(String name, TapDataType datatype) { TapSchema.assertNotNull(TapSelectItem.class, "name", name); TapSchema.assertNotNull(TapSelectItem.class, "datatype", datatype); this.name = name; this.datatype = datatype; }