rs = ps.executeQuery(); if (rs.next()) { c.setProperty(MetadataFactory.SPATIAL_URI + "coord_dimension", rs.getString(1)); //$NON-NLS-1$ c.setProperty(MetadataFactory.SPATIAL_URI + "srid", rs.getString(2)); //$NON-NLS-1$
rs = ps.executeQuery(); if (rs.next()) { c.setProperty(MetadataFactory.SPATIAL_URI + "coord_dimension", rs.getString(1)); //$NON-NLS-1$ c.setProperty(MetadataFactory.SPATIAL_URI + "srid", rs.getString(2)); //$NON-NLS-1$ c.setProperty(MetadataFactory.SPATIAL_URI + "type", rs.getString(3)); //$NON-NLS-1$
private void addForeignKey(MetadataFactory mf, String name, List<String> columnNames, String referenceTable, Table table) throws TranslatorException { ForeignKey fk = mf.addForeignKey("FK_"+name, columnNames, referenceTable, table); for (String column:columnNames) { Column c = table.getColumnByName(column); c.setProperty(KEY_ASSOSIATED_WITH_FOREIGN_TABLE, mf.getName()+Tokens.DOT+referenceTable); } fk.setNameInSource(name); }
private Column addColumn(MetadataFactory mf, Table table, Column property, String newName) { Column c = mf.addColumn(newName, property.getRuntimeType(),table); c.setUpdatable(true); c.setNullType(property.getNullType()); c.setLength(property.getLength()); c.setPrecision(property.getPrecision()); c.setScale(property.getScale()); c.setDefaultValue(property.getDefaultValue()); c.setProperty("MIME-TYPE", c.getProperty("MIME-TYPE", false)); c.setProperty(BaseColumn.SPATIAL_SRID, property.getProperty(BaseColumn.SPATIAL_SRID, false)); c.setProperty("NATIVE_TYPE", property.getProperty("NATIVE_TYPE", false)); return c; }
private List<String> addLinkTableColumns(MetadataFactory mf, Table table, List<String> columnNames, Table linkTable) throws TranslatorException { if (columnNames != null) { for (String columnName:columnNames) { Column column = table.getColumnByName(columnName); if (column == null) { throw new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17003, columnName, table.getName())); } column = mf.addColumn(column.getName(), column.getRuntimeType(), linkTable); column.setProperty(JOIN_COLUMN, String.valueOf(true)); } } else { columnNames = new ArrayList<String>(); for (Column column :table.getPrimaryKey().getColumns()) { columnNames.add(column.getName()); if (linkTable.getColumnByName(column.getName()) == null) { column = mf.addColumn(column.getName(), column.getRuntimeType(), linkTable); } column.setProperty(JOIN_COLUMN, String.valueOf(true)); } } return columnNames; }
c.setProperty("pg_type:oid", String.valueOf(PG_TYPE_OIDVECTOR)); //$NON-NLS-1$ c.setProperty("pg_type:oid", String.valueOf(PG_TYPE_TEXTARRAY)); //$NON-NLS-1$ c.setProperty("pg_type:oid", String.valueOf(PG_TYPE_CHARARRAY)); //$NON-NLS-1$ c.setProperty("pg_type:oid", String.valueOf(PG_TYPE_OIDARRAY)); //$NON-NLS-1$
private Table addNavigationAsTable(MetadataFactory mf, XMLMetadata metadata, Table fromTable, CsdlNavigationProperty property) throws TranslatorException { String name = join(fromTable.getName(), NAME_SEPARATOR, property.getName()); Table toTable = addTable(mf, name, property.getType(), property.isCollection()?ODataType.NAVIGATION_COLLECTION:ODataType.NAVIGATION, metadata); toTable.setNameInSource(property.getName()); KeyRecord pk = fromTable.getPrimaryKey(); List<String> columnNames = new ArrayList<String>(); for (Column c : pk.getColumns()) { String columnName = join(fromTable.getName(), NAME_SEPARATOR, c.getName()); Column column = mf.addColumn(columnName, c.getRuntimeType(), toTable); column.setProperty(PSEUDO, String.valueOf(Boolean.TRUE)); columnNames.add(columnName); } mf.addForeignKey("FK0", columnNames, getColumnNames(pk.getColumns()), fromTable.getFullName(), toTable); return toTable; }
String fk = attr.getName() + "_" + column.getName(); Column c = addColumn(mf, fk, column.getDatatype().getRuntimeTypeName(), entityTable); c.setProperty(RELATION_PROPERTY, attr.getName()); c.setProperty(RELATION_KEY, column.getName()); c.setNameInSource(column.getNameInSource()); keys.add(fk);
@Test public void testGeometryTypes() { Column c = new Column(); c.setDatatype(SystemMetadata.getInstance().getRuntimeTypeMap().get(DefaultDataTypes.GEOMETRY)); c.setProperty(BaseColumn.SPATIAL_TYPE, "MULTIPOLYGON"); //$NON-NLS-1$ assertEquals("GeometryMultiPolygon", ODataTypeManager.odataType(c).name()); c.setProperty(BaseColumn.SPATIAL_TYPE, "LINESTRING"); //$NON-NLS-1$ assertEquals("GeometryLineString", ODataTypeManager.odataType(c).name()); assertEquals("geometry", ODataTypeManager.teiidType(EdmGeometryPoint.getInstance(), false)); }
@Test public void testGeographyTypes() { Column c = new Column(); c.setDatatype(SystemMetadata.getInstance().getRuntimeTypeMap().get(DefaultDataTypes.GEOGRAPHY)); c.setProperty(BaseColumn.SPATIAL_TYPE, "MULTILINESTRING"); //$NON-NLS-1$ assertEquals("GeographyMultiLineString", ODataTypeManager.odataType(c).name()); c.setProperty(BaseColumn.SPATIAL_TYPE, "POLYGON"); //$NON-NLS-1$ assertEquals("GeographyPolygon", ODataTypeManager.odataType(c).name()); assertEquals("geography", ODataTypeManager.teiidType(EdmGeographyPoint.getInstance(), false)); }
columnName.add(element); if (inferType) { column.setProperty(MetadataValidator.UNTYPED, "true");
columnName.add(element); if (inferType) { column.setProperty(MetadataValidator.UNTYPED, "true");
c.setProperty("pg_type:oid", String.valueOf(PG_TYPE_INT2VECTOR)); //$NON-NLS-1$
public void addOrSetOption(String recordName, Database.ResourceType type, String childName, Database.ResourceType childType, String key, String value, boolean reload) { if (!assertInEditMode(Mode.SCHEMA)) { return; } key = getCurrentDatabase().resolveNamespaceInPropertyKey(key); AbstractMetadataRecord record = getSchemaRecord(recordName, type); if (record instanceof Table) { Column c = ((Table)record).getColumnByName(childName); if (c == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31248, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31248, childName, recordName)); } c.setProperty(key, value); OptionsUtil.setOptions(c); } else if (record instanceof Procedure) { ProcedureParameter p = ((Procedure)record).getParameterByName(childName); if (p == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31249, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31249, childName, recordName)); } p.setProperty(key, value); OptionsUtil.setOptions(p); } else { //exception } }
public void addOrSetOption(String recordName, Database.ResourceType type, String childName, Database.ResourceType childType, String key, String value, boolean reload) { if (!assertInEditMode(Mode.SCHEMA)) { return; } key = getCurrentDatabase().resolveNamespaceInPropertyKey(key); AbstractMetadataRecord record = getSchemaRecord(recordName, type); if (record instanceof Table) { Column c = ((Table)record).getColumnByName(childName); if (c == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31248, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31248, childName, recordName)); } c.setProperty(key, value); OptionsUtil.setOptions(c); } else if (record instanceof Procedure) { ProcedureParameter p = ((Procedure)record).getParameterByName(childName); if (p == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31249, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31249, childName, recordName)); } p.setProperty(key, value); OptionsUtil.setOptions(p); } else { //exception } }
public void addOrSetOption(String recordName, Database.ResourceType type, String childName, Database.ResourceType childType, String key, String value, boolean reload) { if (!assertInEditMode(Mode.SCHEMA)) { return; } key = getCurrentDatabase().resolveNamespaceInPropertyKey(key); AbstractMetadataRecord record = getSchemaRecord(recordName, type); if (record instanceof Table) { Column c = ((Table)record).getColumnByName(childName); if (c == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31248, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31248, childName, recordName)); } c.setProperty(key, value); OptionsUtil.setOptions(c); } else if (record instanceof Procedure) { ProcedureParameter p = ((Procedure)record).getParameterByName(childName); if (p == null) { throw new org.teiid.metadata.MetadataException(QueryPlugin.Event.TEIID31249, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31249, childName, recordName)); } p.setProperty(key, value); OptionsUtil.setOptions(p); } else { //exception } }
col.setProperty(PSEUDO, String.valueOf(Boolean.TRUE));
c.setProperty("MIME-TYPE", property.getMimeType());
&& ((EdmCollectionType)property.getType()).getItemType().isSimple())) { Column column = addPropertyAsColumn(mf, table, property, entitySet, ep.getName()); column.setProperty(COMPLEX_TYPE, embedded.getFullyQualifiedTypeName()); // complex type column.setProperty(COLUMN_GROUP, ep.getName()); // name of parent column
new String[] { "a", "b", "c" }, //$NON-NLS-1$ //$NON-NLS-2$ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER }); cols.get(2).setProperty(MultiSourceMetadataWrapper.MULTISOURCE_PARTITIONED_PROPERTY, Boolean.TRUE.toString());