use of org.teiid.metadata.KeyRecord in project teiid by teiid.
the class ODataSchemaBuilder method addTableAnnotations.
private static void addTableAnnotations(Table table, CsdlEntityType entityType, CsdlSchema csdlSchema) {
if (table.getAnnotation() != null) {
addStringAnnotation(entityType, "core.Description", table.getAnnotation());
}
if (table.getCardinality() != -1) {
addIntAnnotation(entityType, "teiid.CARDINALITY", table.getCardinality());
}
if (table.isMaterialized()) {
if (table.getMaterializedTable() != null) {
addStringAnnotation(entityType, "teiid.MATERIALIZED_TABLE", table.getMaterializedTable().getFullName());
}
if (table.getMaterializedStageTable() != null) {
addStringAnnotation(entityType, "teiid.MATERIALIZED_STAGE_TABLE", table.getMaterializedStageTable().getFullName());
}
}
if (table.getNameInSource() != null) {
addStringAnnotation(entityType, "teiid.NAMEINSOURCE", table.getNameInSource());
}
if (table.getAccessPatterns() != null && !table.getAccessPatterns().isEmpty()) {
ArrayList<String> values = new ArrayList<String>();
for (KeyRecord record : table.getAccessPatterns()) {
StringBuilder sb = new StringBuilder();
for (Column c : record.getColumns()) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(c.getName());
}
values.add(sb.toString());
}
addStringCollectionAnnotation(entityType, "teiid.ACCESS_PATTERNS", values);
}
if (table.supportsUpdate()) {
addBooleanAnnotation(entityType, "teiid.UPDATABLE", table.supportsUpdate());
}
// add all custom properties
for (String property : table.getProperties().keySet()) {
addTerm(normalizeTermName(property), new String[] { "EntityType" }, csdlSchema);
addStringAnnotation(entityType, csdlSchema.getAlias() + "." + normalizeTermName(property), table.getProperties().get(property));
}
}
use of org.teiid.metadata.KeyRecord in project teiid by teiid.
the class DocumentNode method addDefaultOrderBy.
OrderBy addDefaultOrderBy() {
if (this.table == null) {
return null;
}
OrderBy orderBy = new OrderBy();
// provide implicit ordering for cursor logic
KeyRecord record = this.table.getPrimaryKey();
if (record == null) {
// if PK is not available there MUST at least one unique key
record = this.table.getUniqueKeys().get(0);
}
// provide implicit ordering for cursor logic
for (Column column : record.getColumns()) {
ElementSymbol expr = new ElementSymbol(column.getName(), this.groupSymbol);
orderBy.addVariable(expr);
addProjectedColumn(column.getName(), expr);
}
return orderBy;
}
Aggregations