use of org.eclipse.persistence.expressions.spatial.SpatialParameters in project eclipselink by eclipse-ee4j.
the class Query_SpatialOp_ExpReport_Tests method testSDOWithinDistanceRectangleUsingMaxResolution.
public void testSDOWithinDistanceRectangleUsingMaxResolution() throws Exception {
String sql = "select GID, GEOMETRY from SIMPLE_SPATIAL where mdsys.sdo_within_distance(" + "geometry, 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);
double[] points = new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 };
populateTestGeometry(JGeometry.createLinearPolygon(points, 2, 0));
ReadAllQuery raq = new ReadAllQuery(SimpleSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
Expression geom1 = eb.get("geometry");
ExpressionBuilder eb2 = new ExpressionBuilder();
ReportQuery rq = new ReportQuery(SimpleSpatial.class, eb2);
rq.addAttribute("geometry");
rq.setSelectionCriteria(eb2.get("id").equal(6666));
SpatialParameters parameters = new SpatialParameters();
parameters.setDistance(10d).setMaxResolution(5);
Expression selectionCriteria = SpatialExpressionFactory.withinDistance(geom1, rq, parameters);
selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666));
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
List<Spatial> results = (List) session.executeQuery(raq);
String compareResult = reader.compare(results);
assertNull(compareResult, compareResult);
}
use of org.eclipse.persistence.expressions.spatial.SpatialParameters in project eclipselink by eclipse-ee4j.
the class Query_SpatialOp_ExpReport_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 SIMPLE_SPATIAL where mdsys.sdo_filter(" + "geometry, 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);
double[] points = new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 };
populateTestGeometry(JGeometry.createLinearPolygon(points, 2, 0));
ReadAllQuery raq = new ReadAllQuery(SimpleSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
Expression geom1 = eb.get("geometry");
ExpressionBuilder eb2 = new ExpressionBuilder();
ReportQuery rq = new ReportQuery(SimpleSpatial.class, eb2);
rq.addAttribute("geometry");
rq.setSelectionCriteria(eb2.get("id").equal(6666));
SpatialParameters parameters = new SpatialParameters();
parameters.setQueryType(QueryType.WINDOW);
Expression selectionCriteria = SpatialExpressionFactory.filter(geom1, rq, parameters);
selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666));
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
List<Spatial> results = (List) session.executeQuery(raq);
String compareResult = reader.compare(results);
assertNull(compareResult, compareResult);
}
use of org.eclipse.persistence.expressions.spatial.SpatialParameters in project eclipselink by eclipse-ee4j.
the class Query_SpatialOp_ExpReport_Tests method testSDOWithinDistanceNullParamsNotMatching.
/**
* SDO_WITHIN_DISTANCE with NULL params not matching existing
*/
public void testSDOWithinDistanceNullParamsNotMatching() throws Exception {
String sql = "select GID, GEOMETRY from SIMPLE_SPATIAL where " + "mdsys.sdo_within_distance(geometry, mdsys.sdo_geometry(3, " + "NULL, null, mdsys.sdo_elem_info_array(1,3,4), " + "mdsys.sdo_ordinate_array(10, 0, 0, 10, 0, -10)), " + "NULL) = 'TRUE' ORDER BY GID";
SQLReader reader = new SQLReader(session, sql);
populateTestGeometry(JGeometry.createCircle(10, 0, 0, 10, 0, -10, 0));
ReadAllQuery raq = new ReadAllQuery(SimpleSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
Expression geom1 = eb.get("geometry");
ExpressionBuilder eb2 = new ExpressionBuilder();
ReportQuery rq = new ReportQuery(SimpleSpatial.class, eb2);
rq.addAttribute("geometry");
rq.setSelectionCriteria(eb2.get("id").equal(6666));
Expression selectionCriteria = SpatialExpressionFactory.withinDistance(geom1, rq, new SpatialParameters(""));
selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666));
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
List<Spatial> results = (List) session.executeQuery(raq);
String compareResult = reader.compare(results);
assertNull(compareResult, compareResult);
}
use of org.eclipse.persistence.expressions.spatial.SpatialParameters in project eclipselink by eclipse-ee4j.
the class NamedQueryTests method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.setName("NamedQueryTests");
suite.addTest(new NamedQueryTests("testNamedSessionQueryNoBinding"));
suite.addTest(new NamedQueryTests("testNamedSessionQueryBindAllParameters"));
suite.addTest(new NamedQueryTests("testNamedSessionQueryBindQueryParameters"));
suite.addTest(new NamedQueryTests("testDescriptorNamedQueryNoBinding"));
suite.addTest(new NamedQueryTests("testDescriptorNamedQueryBindAllParameter"));
suite.addTest(new NamedQueryTests("testDescriptorNamedQueryBindQueryParameter"));
return new TestSetup(suite) {
protected void setUp() {
try {
SimpleSpatialTestCase.repopulate(getSession(), true);
ReadAllQuery raq = new ReadAllQuery(SimpleSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
SpatialParameters parameters = new SpatialParameters();
parameters.setQueryType(SpatialParameters.QueryType.WINDOW).setMask(Mask.ANYINTERACT);
Expression selectionCriteria = SpatialExpressionFactory.relate(eb.get("geometry"), eb.getParameter("GEOMETRY"), parameters);
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
raq.addArgument("GEOMETRY", JGeometry.class);
getSession().addQuery(SESSION_QUERY_NAME, raq);
raq = new ReadAllQuery(SimpleSpatial.class);
eb = raq.getExpressionBuilder();
parameters = new SpatialParameters();
parameters.setDistance(10d);
selectionCriteria = SpatialExpressionFactory.withinDistance(eb.get("geometry"), eb.getParameter("GEOMETRY"), parameters);
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
raq.addArgument("GEOMETRY", JGeometry.class);
getSession().getClassDescriptor(SimpleSpatial.class).getDescriptorQueryManager().addQuery(DESCRIPTOR_QUERY_NAME, raq);
} catch (Exception e) {
throw new TestProblemException("Could not setup JGeometry test model", e);
}
}
protected void tearDown() {
try {
getSession().removeQuery(SESSION_QUERY_NAME);
getSession().getClassDescriptor(SimpleSpatial.class).getDescriptorQueryManager().removeQuery(DESCRIPTOR_QUERY_NAME);
} catch (Exception e) {
throw new TestProblemException("Could not tearDown NamedQueryTests for SimpleSpatialTestCase.", e);
}
}
};
}
use of org.eclipse.persistence.expressions.spatial.SpatialParameters in project eclipselink by eclipse-ee4j.
the class NamedQueryTests method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.setName("NamedQueryTests");
suite.addTest(new NamedQueryTests("testNamedSessionQueryNoBinding"));
suite.addTest(new NamedQueryTests("testNamedSessionQueryBindAllParameters"));
suite.addTest(new NamedQueryTests("testNamedSessionQueryBindQueryParameters"));
suite.addTest(new NamedQueryTests("testDescriptorNamedQueryNoBinding"));
suite.addTest(new NamedQueryTests("testDescriptorNamedQueryBindAllParameter"));
suite.addTest(new NamedQueryTests("testDescriptorNamedQueryBindQueryParameter"));
return new TestSetup(suite) {
protected void setUp() {
try {
WrappedSpatialTestCase.repopulate(getSession(), true);
ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
SpatialParameters parameters = new SpatialParameters();
parameters.setMask(Mask.ANYINTERACT).setQueryType(QueryType.WINDOW);
Expression selectionCriteria = SpatialExpressionFactory.relate(eb.get("geometry").getField("geom"), eb.getParameter("GEOMETRY"), parameters);
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
raq.addArgument("GEOMETRY", JGeometry.class);
getSession().addQuery(SESSION_QUERY_NAME, raq);
raq = new ReadAllQuery(WrappedSpatial.class);
eb = raq.getExpressionBuilder();
parameters = new SpatialParameters();
parameters.setDistance(10d);
selectionCriteria = SpatialExpressionFactory.withinDistance(eb.get("geometry").getField("geom"), eb.getParameter("GEOMETRY"), parameters);
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
raq.addArgument("GEOMETRY", MyGeometry.class);
getSession().getClassDescriptor(WrappedSpatial.class).getDescriptorQueryManager().addQuery(DESCRIPTOR_QUERY_NAME, raq);
} catch (Exception e) {
throw new TestProblemException("Could not setup JGeometry test model. Note: This model requires you to run the following CREATE OR REPLACE TYPE MY_GEOMETRY AS OBJECT (id NUMBER, geom MDSYS.SDO_GEOMETRY): ", e);
}
}
protected void tearDown() {
try {
getSession().removeQuery(SESSION_QUERY_NAME);
getSession().getClassDescriptor(WrappedSpatial.class).getDescriptorQueryManager().removeQuery(DESCRIPTOR_QUERY_NAME);
} catch (Exception e) {
throw new TestProblemException("Could not tearDown NamedQueryTests for SimpleSpatialTestCase.", e);
}
}
};
}
Aggregations