Search in sources :

Example 21 with SQLReader

use of org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader in project eclipselink by eclipse-ee4j.

the class Query_SpatialExpOp_ExpGeom_Tests method testSDOFilterRectangleNullParams.

public void testSDOFilterRectangleNullParams() throws Exception {
    String sql = "select GID, GEOMETRY from WRAPPED_SPATIAL WS where mdsys.sdo_filter(" + "WS.geometry.geom, mdsys.sdo_geometry(3,null,null, " + "mdsys.sdo_elem_info_array(1,3,3), " + "mdsys.sdo_ordinate_array(1,1, 20, 20)), " + "NULL) = 'TRUE' ORDER BY GID";
    SQLReader reader = new SQLReader(session, sql);
    JGeometry rectangle = JGeometry.createLinearPolygon(new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 }, 2, 0);
    ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
    ExpressionBuilder eb = raq.getExpressionBuilder();
    Expression selectionCriteria = SpatialExpressionFactory.filter(eb.get("geometry").getField("geom"), rectangle, null);
    raq.setSelectionCriteria(selectionCriteria);
    raq.addAscendingOrdering("id");
    List<Spatial> results = (List<Spatial>) session.executeQuery(raq);
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : SQLReader(org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader) Expression(org.eclipse.persistence.expressions.Expression) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) WrappedSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial) JGeometry(oracle.spatial.geometry.JGeometry) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) List(java.util.List) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 22 with SQLReader

use of org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader in project eclipselink by eclipse-ee4j.

the class NamedQueryTests method executeNamedSessionQuery.

public void executeNamedSessionQuery() throws Exception {
    String sql = "select GID, GEOMETRY FROM WRAPPED_SPATIAL WS where mdsys.sdo_relate(ws.geometry.geom, " + "mdsys.sdo_geometry(3,null,null, mdsys.sdo_elem_info_array(1,3,3),  " + "mdsys.sdo_ordinate_array(1,1, 20, 20)), " + "'MASK=ANYINTERACT QUERYTYPE=WINDOW') = 'TRUE' ORDER BY GID";
    SQLReader reader = new SQLReader(session, sql);
    double[] points = new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 };
    JGeometry rectangle = JGeometry.createLinearPolygon(points, 2, 0);
    List<Spatial> results = (List) session.executeQuery(SESSION_QUERY_NAME, rectangle);
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : SQLReader(org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) WrappedSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial) JGeometry(oracle.spatial.geometry.JGeometry) List(java.util.List)

Example 23 with SQLReader

use of org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader in project eclipselink by eclipse-ee4j.

the class NamedQueryTests method executeDescriptorNamedQuery.

public void executeDescriptorNamedQuery() throws Exception {
    String sql = "select GID, GEOMETRY FROM WRAPPED_SPATIAL WS where " + "mdsys.sdo_within_distance(ws.geometry.geom, " + "mdsys.sdo_geometry(3,null,null, " + "mdsys.sdo_elem_info_array(1,3,4), " + "mdsys.sdo_ordinate_array(-10,0, 0, 10, 10, 0)), " + "'DISTANCE=10') = 'TRUE' ORDER BY GID";
    SQLReader reader = new SQLReader(session, sql);
    JGeometry circle = JGeometry.createCircle(-10, 0, 0, 10, 10, 0, 0);
    List<Spatial> results = (List) session.executeQuery(DESCRIPTOR_QUERY_NAME, WrappedSpatial.class, circle);
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : WrappedSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial) SQLReader(org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) WrappedSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial) JGeometry(oracle.spatial.geometry.JGeometry) List(java.util.List)

Example 24 with SQLReader

use of org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader in project eclipselink by eclipse-ee4j.

the class Query_SpatialExpOp_ExpGeom_Tests method testSDOFilterRectangle.

/**
 * SDO_Filter using a dynamic rectangular window with lower left
 * and upper right coordinates of {(1,1), (20,20)}
 */
public void testSDOFilterRectangle() throws Exception {
    String sql = "select GID, GEOMETRY from WRAPPED_SPATIAL WS where mdsys.sdo_filter(" + "WS.geometry.geom, mdsys.sdo_geometry(3,null,null, " + "mdsys.sdo_elem_info_array(1,3,3), " + "mdsys.sdo_ordinate_array(1,1, 20, 20)), " + "'QUERYTYPE=WINDOW') = 'TRUE' ORDER BY GID";
    SQLReader reader = new SQLReader(session, sql);
    JGeometry rectangle = JGeometry.createLinearPolygon(new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 }, 2, 0);
    ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
    ExpressionBuilder eb = raq.getExpressionBuilder();
    String params = "QUERYTYPE=WINDOW";
    Expression selectionCriteria = SpatialExpressionFactory.filter(eb.get("geometry").getField("geom"), rectangle, new SpatialParameters(params));
    raq.setSelectionCriteria(selectionCriteria);
    raq.addAscendingOrdering("id");
    List<Spatial> results = (List<Spatial>) session.executeQuery(raq);
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : SQLReader(org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader) Expression(org.eclipse.persistence.expressions.Expression) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) WrappedSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial) JGeometry(oracle.spatial.geometry.JGeometry) SpatialParameters(org.eclipse.persistence.expressions.spatial.SpatialParameters) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) List(java.util.List) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 25 with SQLReader

use of org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader in project eclipselink by eclipse-ee4j.

the class Query_SpatialExpOp_ExpGeom_Tests method testSDOWithinDistanceRectangleUsingMaxResolution.

public void testSDOWithinDistanceRectangleUsingMaxResolution() throws Exception {
    String sql = "select GID, GEOMETRY from WRAPPED_SPATIAL WS where mdsys.sdo_within_distance(" + "WS.geometry.geom, mdsys.sdo_geometry(3,null,null, mdsys.sdo_elem_info_array(1,3,3), " + "mdsys.sdo_ordinate_array(1,1, 20, 20)), " + "'DISTANCE=10 MAX_RESOLUTION=5') = 'TRUE' ORDER BY GID";
    SQLReader reader = new SQLReader(session, sql);
    JGeometry rectangle = JGeometry.createLinearPolygon(new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 }, 2, 0);
    ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
    ExpressionBuilder eb = raq.getExpressionBuilder();
    String params = "DISTANCE=10 MAX_RESOLUTION=5";
    Expression selectionCriteria = SpatialExpressionFactory.withinDistance(eb.get("geometry").getField("geom"), rectangle, new SpatialParameters(params));
    raq.setSelectionCriteria(selectionCriteria);
    raq.addAscendingOrdering("id");
    List<Spatial> results = (List<Spatial>) session.executeQuery(raq);
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : SQLReader(org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader) Expression(org.eclipse.persistence.expressions.Expression) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) WrappedSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial) JGeometry(oracle.spatial.geometry.JGeometry) SpatialParameters(org.eclipse.persistence.expressions.spatial.SpatialParameters) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) List(java.util.List) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Aggregations

List (java.util.List)43 Spatial (org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial)43 WrappedSpatial (org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial)43 SQLReader (org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader)43 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)41 Expression (org.eclipse.persistence.expressions.Expression)39 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)39 SpatialParameters (org.eclipse.persistence.expressions.spatial.SpatialParameters)38 JGeometry (oracle.spatial.geometry.JGeometry)15 ReportQuery (org.eclipse.persistence.queries.ReportQuery)13 SimpleSpatial (org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial)1