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.Index;
10 import com.quantum.model.Schema;
15 public class EntitySubset implements Entity {
18 private String schema;
19 private String bookmarkName;
21 public EntitySubset(String name, String schema, String bookmarkName) {
24 this.bookmarkName = bookmarkName;
27 public String getName() {
31 public String getSchema() {
35 public String getType() {
39 public Column[] getColumns() {
40 // TODO: limit the columns
41 Entity relatedEntity = getEntityFromBookmark();
42 if (relatedEntity != null) {
43 Column[] columns = relatedEntity.getColumns();
50 public Index[] getIndexes() {
54 public Column getColumn(String columnName) {
55 Entity relatedEntity = getEntityFromBookmark();
56 return relatedEntity == null
57 ? null : relatedEntity.getColumn(columnName);
60 public String getCondQualifiedName() {
61 return this.schema + "." + this.name;
64 public Boolean exists() {
68 public Bookmark getBookmark() {
69 return BookmarkCollection.getInstance().find(this.bookmarkName);
72 private Entity getEntityFromBookmark() {
74 return getBookmark().getEntity(
75 new Schema(schema), name);
76 } catch (SQLException e) {
81 * @see com.quantum.model.Entity#getQuotedTableName()
83 public String getQuotedTableName() {
84 return getBookmark().getAdapter().filterTableName(getCondQualifiedName());