1) Added missing strings for italic, underline and strike through.
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.sql / src / net / sourceforge / phpdt / sql / adapters / GenericAdapter.java
index 9791480..653645a 100644 (file)
@@ -1,10 +1,18 @@
 package net.sourceforge.phpdt.sql.adapters;
 
-public class GenericAdapter extends DatabaseAdapter {
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
 
-       public DatabaseAdapter getInstance() {
-               return new GenericAdapter();
-       }
+import net.sourceforge.phpdt.sql.bookmarks.Bookmark;
+import net.sourceforge.phpdt.sql.model.Entity;
+import net.sourceforge.phpdt.sql.model.EntityFactory;
+
+
+public class GenericAdapter extends DatabaseAdapter {
 
        public String getShowTableQuery(DatabaseInfo info) {
                return null;
@@ -12,4 +20,42 @@ public class GenericAdapter extends DatabaseAdapter {
     public String getShowViewQuery(DatabaseInfo info) {
                return null;
     }
+    
+    public String getShowSequenceQuery(DatabaseInfo info) {
+        return null;
+    }
+
+    /**
+     * @param connection -
+     *      a database 
+     * @param schema - 
+     *      a schema name to filter on, or null to return all entities from all filters
+     * @param type - 
+     *      the type of entities (TABLES, VIEWS, etc.) to get
+     * @return
+     */
+    protected List getEntitiesList(Bookmark bookmark, Connection connection, String type) 
+        throws SQLException {
+        
+        List list = new ArrayList();
+        DatabaseMetaData metaData = connection.getMetaData();
+        ResultSet set = metaData.getTables(
+            null, bookmark.getSchema(), "%", new String[] { type }); 
+        while (set.next()) {
+            String schema = set.getString("TABLE_SCHEM");  
+            schema = (schema == null) ? "" : schema.trim();
+            String tableName = set.getString("TABLE_NAME").trim();
+            
+            if (tableName.length() > 0) {
+                Entity entity = EntityFactory.getInstance().create(
+                        bookmark, schema, tableName, type);
+                if (entity != null) {
+                    list.add(entity);
+                }
+            }
+        }
+        set.close();
+        return list;
+    }
+    
 }