/** * Used by the system table logic * @return */ public Clob getSpatialRefSys() { return new ClobImpl(new InputStreamFactory() { @Override public InputStream getInputStream() throws IOException { return getClass().getClassLoader().getResourceAsStream("org/teiid/metadata/spatial_ref_sys.csv"); //$NON-NLS-1$ } }, -1); }
/** * Used by the system table logic * @return */ public Clob getSpatialRefSys() { return new ClobImpl(new InputStreamFactory() { @Override public InputStream getInputStream() throws IOException { return getClass().getClassLoader().getResourceAsStream("org/teiid/metadata/spatial_ref_sys.csv"); //$NON-NLS-1$ } }, -1); }
/** * Used by the system table logic * @return */ public Clob getSpatialRefSys() { return new ClobImpl(new InputStreamFactory() { @Override public InputStream getInputStream() throws IOException { return getClass().getClassLoader().getResourceAsStream("org/teiid/metadata/spatial_ref_sys.csv"); //$NON-NLS-1$ } }, -1); }
@Override public Object retrieveValue(CallableStatement results, int parameterIndex, Class<?> expectedType) throws SQLException { if (expectedType == TypeFacility.RUNTIME_TYPES.JSON) { return new JsonType(new ClobImpl(results.getString(parameterIndex))); } return super.retrieveValue(results, parameterIndex, expectedType); }
@Override public Object retrieveValue(ResultSet results, int columnIndex, Class<?> expectedType) throws SQLException { if (expectedType == TypeFacility.RUNTIME_TYPES.JSON) { return new JsonType(new ClobImpl(results.getString(columnIndex))); } return super.retrieveValue(results, columnIndex, expectedType); }
public static ClobType geometryToClob(AbstractGeospatialType geometry, boolean withSrid) throws FunctionExecutionException { Geometry jtsGeometry = getGeometry(geometry); int srid = jtsGeometry.getSRID(); StringBuilder geomText = new StringBuilder(); if (withSrid && srid != GeometryType.UNKNOWN_SRID) { geomText.append("SRID=").append(jtsGeometry.getSRID()).append(";"); //$NON-NLS-1$ //$NON-NLS-2$ } geomText.append(jtsGeometry.toText()); return new ClobType(new ClobImpl(geomText.toString())); }
public static ClobType geometryToClob(GeometryType geometry, boolean withSrid) throws FunctionExecutionException { Geometry jtsGeometry = getGeometry(geometry); int srid = jtsGeometry.getSRID(); StringBuilder geomText = new StringBuilder(); if (withSrid && srid != GeometryType.UNKNOWN_SRID) { geomText.append("SRID=").append(jtsGeometry.getSRID()).append(";"); //$NON-NLS-1$ //$NON-NLS-2$ } geomText.append(jtsGeometry.toText()); return new ClobType(new ClobImpl(geomText.toString())); }
private static Object asLob(InputStreamFactory value, Class<?> desiredType) { if (desiredType == DataTypeManager.DefaultDataClasses.CLOB) { //assumes UTF-8 return new ClobType(new ClobImpl(value, -1)); } return new BlobType(new BlobImpl(value)); }
private static Object asLob(InputStreamFactory value, Class<?> desiredType) { if (desiredType == DataTypeManager.DefaultDataClasses.CLOB) { //assumes UTF-8 return new ClobType(new ClobImpl(value, -1)); } return new BlobType(new BlobImpl(value)); }
public static ClobType lowerCase(ClobType str) { return new ClobType(new ClobImpl(new ClobInputStreamFactory(str) { @Override public Reader getReader(Reader reader) { return new UpperLowerReader(reader, false); } }, str.getLength())); }
public static ClobType upperCase(ClobType str) { return new ClobType(new ClobImpl(new ClobInputStreamFactory(str) { @Override public Reader getReader(Reader reader) { return new UpperLowerReader(reader, true); } }, str.getLength())); }
public static ClobType lowerCase(ClobType str) { return new ClobType(new ClobImpl(new ClobInputStreamFactory(str) { @Override public Reader getReader(Reader reader) { return new UpperLowerReader(reader, false); } }, str.getLength())); }
public static ClobType upperCase(ClobType str) { return new ClobType(new ClobImpl(new ClobInputStreamFactory(str) { @Override public Reader getReader(Reader reader) { return new UpperLowerReader(reader, true); } }, str.getLength())); }
public static ClobType upperCase(ClobType str) { return new ClobType(new ClobImpl(new ClobInputStreamFactory(str) { @Override public Reader getReader(Reader reader) { return new UpperLowerReader(reader, true); } }, str.getLength())); }
public static ClobType lowerCase(ClobType str) { return new ClobType(new ClobImpl(new ClobInputStreamFactory(str) { @Override public Reader getReader(Reader reader) { return new UpperLowerReader(reader, false); } }, str.getLength())); }
public ClobImpl getVDBResourceAsClob(String resourcePath) { final VDBResources.Resource f = getFile(resourcePath); if (f == null) { return null; } return new ClobImpl(new VirtualFileInputStreamFactory(f), -1); }
public ClobImpl getVDBResourceAsClob(String resourcePath) { final VDBResources.Resource f = getFile(resourcePath); if (f == null) { return null; } return new ClobImpl(new VirtualFileInputStreamFactory(f), -1); }
@Test() public void testStringAggOrdering() throws Exception { String sql = "select string_agg(col1, ',' ORDER BY col1 DESC) as orderByDesc," + " string_agg(col1, ',' ORDER BY col1 ASC) as orderByAsc, " + " string_agg(DISTINCT col1, ',' ORDER BY col1 DESC) as distinctOrderByDesc, " + " string_agg(DISTINCT col1, ',' ORDER BY col1 ASC) as distinctOrderByAsc from (select 'a' as col1 union all select 'b' union all select 'b' union all select 'c') as x"; TransformationMetadata metadata = RealMetadataFactory.example1Cached(); HardcodedDataManager hdm = new HardcodedDataManager(); ProcessorPlan plan = TestProcessor.helpGetPlan(sql, metadata); TestProcessor.helpProcess(plan, TestProcessor.createCommandContext(), hdm, new List<?>[] { Arrays.asList(new ClobType(new ClobImpl("c,b,b,a")), new ClobType(new ClobImpl("a,b,b,c")), new ClobType(new ClobImpl("c,b,a")), new ClobType(new ClobImpl("a,b,c")))}); }
public static ClobType geometryToGeoJson(GeometryType geometry) throws FunctionExecutionException { Geometry jtsGeometry = getGeometry(geometry); GeoJSONWriter writer = new GeoJSONWriter(); try { GeoJSON geoJson = writer.write(jtsGeometry); ClobType result = new ClobType(new ClobImpl(geoJson.toString())); result.setType(Type.JSON); return result; } catch (Exception e) { throw new FunctionExecutionException(e); } }
@Test public void testJson() throws IOException, ClassNotFoundException { JsonType json = new JsonType(new ClobImpl("5")); json.setReferenceStreamId(null); Object val = helpTestSerialization(new String[] {DataTypeManager.DefaultDataTypes.JSON}, new List[] {Arrays.asList(json)}, BatchSerializer.VERSION_GEOGRAPHY).get(0).get(0); assertTrue(val instanceof JsonType); helpTestSerialization(new String[] {DataTypeManager.DefaultDataTypes.JSON}, new List[] {Arrays.asList(json)}, (byte)0); //object serialization - should fail on the client side val = helpTestSerialization(new String[] {DataTypeManager.DefaultDataTypes.JSON}, new List[] {Arrays.asList(json)}, (byte)1).get(0).get(0); //clob serialization assertTrue(val instanceof ClobType); val = helpTestSerialization(new String[] {DataTypeManager.DefaultDataTypes.OBJECT}, new List[] {Arrays.asList(json)}, (byte)1).get(0).get(0); //clob serialization assertTrue(val instanceof ClobType); }