1 package com.quantum.view.subset;
3 import java.sql.SQLException;
5 import com.quantum.model.Bookmark;
6 import com.quantum.model.BookmarkCollection;
7 import com.quantum.model.Column;
8 import com.quantum.model.Entity;
9 import com.quantum.model.ForeignKey;
10 import com.quantum.model.Index;
11 import com.quantum.model.NotConnectedException;
12 import com.quantum.model.Schema;
17 public class EntitySubset implements Entity {
20 private String schema;
21 private String bookmarkName;
23 public EntitySubset(String name, String schema, String bookmarkName) {
26 this.bookmarkName = bookmarkName;
29 public String getName() {
33 public String getSchema() {
37 public String getType() {
41 public Column[] getColumns() {
42 // TODO: limit the columns
43 Entity relatedEntity = getEntityFromBookmark();
44 if (relatedEntity != null) {
46 Column[] columns = relatedEntity.getColumns();
48 } catch (NotConnectedException e) {
50 } catch (SQLException e) {
58 public Index[] getIndexes() {
62 public Column getColumn(String columnName) throws NotConnectedException, SQLException {
63 Entity relatedEntity = getEntityFromBookmark();
64 return relatedEntity == null
65 ? null : relatedEntity.getColumn(columnName);
68 public String getQualifiedName() {
69 return this.schema + "." + this.name;
72 public Boolean exists() {
76 public Bookmark getBookmark() {
77 return BookmarkCollection.getInstance().find(this.bookmarkName);
80 private Entity getEntityFromBookmark() {
82 return getBookmark().getEntity(
83 new Schema(schema), name);
84 } catch (SQLException e) {
89 * @see com.quantum.model.Entity#getQuotedTableName()
91 public String getQuotedTableName() {
92 return getBookmark().getAdapter().filterTableName(getQualifiedName());
96 * @see java.lang.Comparable#compareTo(java.lang.Object)
98 public int compareTo(Object arg0) {
99 // TODO Auto-generated method stub
104 * @see com.quantum.model.Entity#getExportedKeys()
106 public ForeignKey[] getExportedKeys() throws NotConnectedException, SQLException {
107 // TODO Auto-generated method stub
112 * @see com.quantum.model.Entity#getImportedKeys()
114 public ForeignKey[] getImportedKeys() throws NotConnectedException, SQLException {
115 // TODO Auto-generated method stub
120 * @see com.quantum.model.Entity#getReferences()
122 public ForeignKey[] getReferences() throws NotConnectedException, SQLException {
123 // TODO Auto-generated method stub