Search in sources :

Example 46 with ClobType

use of org.teiid.core.types.ClobType in project teiid by teiid.

the class TestGeometry method testAsFromEwkb.

@Test
public void testAsFromEwkb() throws Exception {
    Expression ex = TestFunctionResolving.getExpression("st_asewkt(st_geomfromewkb(st_asewkb(ST_GeomFromEwkt('SrID=4326;POINT(0 0)'))))");
    assertEquals("SRID=4326;POINT (0 0)", ClobType.getString((ClobType) Evaluator.evaluate(ex)));
}
Also used : ClobType(org.teiid.core.types.ClobType) Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 47 with ClobType

use of org.teiid.core.types.ClobType in project teiid by teiid.

the class TestGeometry method testSimplifyPreserveTopology.

@Test
public void testSimplifyPreserveTopology() throws Exception {
    Expression ex = TestFunctionResolving.getExpression("ST_AsText(ST_SimplifyPreserveTopology(ST_GeomFromText('POLYGON((6 3,1 -2,-4 3,1 8,6 3))'),5))");
    assertEquals("POLYGON ((6 3, 1 -2, -4 3, 1 8, 6 3))", ClobType.getString((ClobType) Evaluator.evaluate(ex)));
}
Also used : ClobType(org.teiid.core.types.ClobType) Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 48 with ClobType

use of org.teiid.core.types.ClobType in project teiid by teiid.

the class TestGeometry method testGmlParseSrid.

@Test
public void testGmlParseSrid() throws Exception {
    String gml = "<gml:Polygon srsName=\"SDO:8307\" xmlns:gml=\"http://www.opengis.net/gml\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates decimal=\".\" cs=\",\" ts=\" \">5,1 8,1 8,6 5,7 5,1 </gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>";
    GeometryType gt = GeometryUtils.geometryFromGml(new ClobType(ClobImpl.createClob(gml.toCharArray())), null);
    assertEquals(8307, gt.getSrid());
    // oracle will leave of the int with unknown
    gml = "<gml:Polygon srsName=\"SDO:\" xmlns:gml=\"http://www.opengis.net/gml\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates decimal=\".\" cs=\",\" ts=\" \">5,1 8,1 8,6 5,7 5,1 </gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>";
    gt = GeometryUtils.geometryFromGml(new ClobType(ClobImpl.createClob(gml.toCharArray())), null);
    assertEquals(GeometryType.UNKNOWN_SRID, gt.getSrid());
}
Also used : ClobType(org.teiid.core.types.ClobType) GeometryType(org.teiid.core.types.GeometryType) Test(org.junit.Test)

Example 49 with ClobType

use of org.teiid.core.types.ClobType in project teiid by teiid.

the class TestJDBCSocketTransport method testGeometryStreaming.

@Test
public void testGeometryStreaming() throws Exception {
    StringBuilder geomString = new StringBuilder();
    for (int i = 0; i < 600; i++) {
        geomString.append("100 100,");
    }
    geomString.append("100 100");
    final GeometryType geo = GeometryUtils.geometryFromClob(new ClobType(new ClobImpl("POLYGON ((" + geomString + "))")));
    long length = geo.length();
    PreparedStatement s = conn.prepareStatement("select st_geomfrombinary(?)");
    s.setBlob(1, new BlobImpl(new InputStreamFactory() {

        @Override
        public InputStream getInputStream() throws IOException {
            try {
                return geo.getBinaryStream();
            } catch (SQLException e) {
                throw new IOException(e);
            }
        }
    }));
    ResultSet rs = s.executeQuery();
    rs.next();
    Blob b = rs.getBlob(1);
    assertEquals(length, b.length());
    b.getBytes(1, (int) b.length());
    toggleInline(false);
    rs = s.executeQuery();
    rs.next();
    b = rs.getBlob(1);
    assertEquals(length, b.length());
    b.getBytes(1, (int) b.length());
}
Also used : Blob(java.sql.Blob) TeiidSQLException(org.teiid.jdbc.TeiidSQLException) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) IOException(java.io.IOException) InputStreamFactory(org.teiid.core.types.InputStreamFactory) ClobType(org.teiid.core.types.ClobType) GeometryType(org.teiid.core.types.GeometryType) ResultSet(java.sql.ResultSet) ClobImpl(org.teiid.core.types.ClobImpl) BlobImpl(org.teiid.core.types.BlobImpl) Test(org.junit.Test)

Aggregations

ClobType (org.teiid.core.types.ClobType)49 Test (org.junit.Test)31 ClobImpl (org.teiid.core.types.ClobImpl)20 Expression (org.teiid.query.sql.symbol.Expression)16 SQLException (java.sql.SQLException)8 InputStreamFactory (org.teiid.core.types.InputStreamFactory)8 IOException (java.io.IOException)7 BlobType (org.teiid.core.types.BlobType)6 Reader (java.io.Reader)4 Blob (java.sql.Blob)4 ArrayList (java.util.ArrayList)4 SerialBlob (javax.sql.rowset.serial.SerialBlob)4 SerialClob (javax.sql.rowset.serial.SerialClob)4 BlobImpl (org.teiid.core.types.BlobImpl)4 XMLType (org.teiid.core.types.XMLType)4 FunctionExecutionException (org.teiid.api.exception.query.FunctionExecutionException)3 TeiidProcessingException (org.teiid.core.TeiidProcessingException)3 BlobInputStreamFactory (org.teiid.core.types.InputStreamFactory.BlobInputStreamFactory)3 SQLXMLImpl (org.teiid.core.types.SQLXMLImpl)3 ReaderInputStream (org.teiid.core.util.ReaderInputStream)3