package com.quantum.view.subset; import java.sql.SQLException; import com.quantum.model.Bookmark; import com.quantum.model.BookmarkCollection; import com.quantum.model.Column; import com.quantum.model.Entity; import com.quantum.model.Index; import com.quantum.model.Schema; /** * @author BC */ public class EntitySubset implements Entity { private String name; private String schema; private String bookmarkName; public EntitySubset(String name, String schema, String bookmarkName) { this.name = name; this.schema = schema; this.bookmarkName = bookmarkName; } public String getName() { return this.name; } public String getSchema() { return schema; } public String getType() { return null; } public Column[] getColumns() { // TODO: limit the columns Entity relatedEntity = getEntityFromBookmark(); if (relatedEntity != null) { Column[] columns = relatedEntity.getColumns(); return columns; } else { return null; } } public Index[] getIndexes() { return new Index[0]; } public Column getColumn(String columnName) { Entity relatedEntity = getEntityFromBookmark(); return relatedEntity == null ? null : relatedEntity.getColumn(columnName); } public String getCondQualifiedName() { return this.schema + "." + this.name; } public Boolean exists() { return null; } public Bookmark getBookmark() { return BookmarkCollection.getInstance().find(this.bookmarkName); } private Entity getEntityFromBookmark() { try { return getBookmark().getEntity( new Schema(schema), name); } catch (SQLException e) { return null; } } /** * @see com.quantum.model.Entity#getQuotedTableName() */ public String getQuotedTableName() { return getBookmark().getAdapter().filterTableName(getCondQualifiedName()); } }