for (int i = 0; i < types.length; i++) {
list.addAll(getEntitiesList(bookmark, connection, types[i], schema));
+ // TODO: This should be polished so that synonyms can be shown with different icons as regular Entities
+ list.addAll(getSynonymsList(bookmark, connection, types[i], schema));
}
return (Entity[]) list.toArray(new Entity[list.size()]);
tableName = (tableName == null) ? "" : tableName.trim();
if (tableName != null && tableName.length() > 0) {
- Entity entity = EntityFactory.getInstance().create(bookmark, tempSchema, tableName, type);
+ Entity entity = EntityFactory.getInstance().create(bookmark, tempSchema, tableName, type, false);
if (entity != null) {
list.add(entity);
}
: results.getElement(2, i).toString();
if (tableName != null && tableName.length() > 0) {
Entity entity = EntityFactory.getInstance().create(
- bookmark, schemaName, tableName, type);
+ bookmark, schemaName, tableName, type, false);
if (entity != null) {
list.add(entity);
}
}
return list;
}
+ /**
+ * Returns a list with the synonym objects of the given type, using a query
+ * @param bookmark
+ * @param connection
+ * @param type
+ * @param schema
+ * @return
+ * @throws SQLException
+ */
+ protected List getSynonymsList(Bookmark bookmark, Connection connection, String type, Schema schema)
+ throws SQLException {
+
+ List list = new ArrayList();
+ // We try first the JDBC driver
+ DatabaseMetaData metaData = connection.getMetaData();
+ SQLResultSetResults results = null;
+ // Get the proper sql query to the appropiate type of entity
+ String sql = this.databaseAdapter.getShowSynonymsQuery(schema.getName(), type);
+ // If nothing returned, too bad, it seems there is no sql query for that database and entity type
+ if (sql != null) {
+ results = (SQLResultSetResults) MultiSQLServer.getInstance().execute(
+ bookmark, connection, sql, Integer.MAX_VALUE);
+ for (int i = 1, size = (results == null) ? 0 : results.getRowCount(); i <= size; i++) {
+ String schemaName = results.getColumnCount() == 1
+ ? schema.getName() : results.getElement(1, i).toString();
+ if (schemaName != null) {
+ schemaName = schemaName.trim();
+ }
+ String tableName = results.getColumnCount() == 1
+ ? results.getElement(1, i).toString()
+ : results.getElement(2, i).toString();
+ if (tableName != null && tableName.length() > 0) {
+ Entity entity = EntityFactory.getInstance().create(
+ bookmark, schemaName, tableName, type, true);
+ if (entity != null) {
+ list.add(entity);
+ }
+ }
+ }
+ }
+ return list;
+}
public DataType[] getTypes() throws NotConnectedException, SQLException {
DatabaseMetaData metaData = getMetaData();
list.add(new DataType(
results.getInt(TYPE_INFO_METADATA_DATA_TYPE),
results.getString(TYPE_INFO_METADATA_TYPE_NAME),
- results.getInt(TYPE_INFO_METADATA_PRECISION),
+ results.getLong(TYPE_INFO_METADATA_PRECISION),
results.getString(TYPE_INFO_METADATA_LITERAL_PREFIX),
results.getString(TYPE_INFO_METADATA_LITERAL_SUFFIX),
results.getString(TYPE_INFO_METADATA_CREATE_PARMS)