Search in sources :

Example 1 with SimpleSpatial

use of org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial in project eclipselink by eclipse-ee4j.

the class SampleGeometries method simplePopulation.

/**
 * @return population objects for database initialization
 */
public List<SimpleSpatial> simplePopulation() throws Exception {
    List<SimpleSpatial> population = new ArrayList<SimpleSpatial>();
    population.add(new SimpleSpatial(1000, pointCluster1()));
    population.add(new SimpleSpatial(1001, pointCluster2()));
    population.add(new SimpleSpatial(1002, simplyPolygon()));
    population.add(new SimpleSpatial(1003, polygonOfCircularArcs()));
    population.add(new SimpleSpatial(1004, circle()));
    population.add(new SimpleSpatial(1005, rectangle()));
    population.add(new SimpleSpatial(1006, compoundLineAndRectangle()));
    population.add(new SimpleSpatial(1007, compoundPolygonWithRectangularHole()));
    population.add(new SimpleSpatial(1008, geometry1008()));
    population.add(new SimpleSpatial(1009, geometryWithNulls()));
    population.add(new SimpleSpatial(1010, null));
    population.add(new SimpleSpatial(1011, polygon1011()));
    population.add(new SimpleSpatial(1012, polygon1012()));
    population.add(new SimpleSpatial(1013, point()));
    return population;
}
Also used : SimpleSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial) ArrayList(java.util.ArrayList)

Example 2 with SimpleSpatial

use of org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial in project eclipselink by eclipse-ee4j.

the class Query_Basic_Tests method testReadNotNullGeometry.

/**
 * Comparisons to geometry != NULL always fail.
 */
public void testReadNotNullGeometry() throws Exception {
    ReadAllQuery roq = new ReadAllQuery(SimpleSpatial.class);
    ExpressionBuilder eb = roq.getExpressionBuilder();
    roq.setSelectionCriteria(eb.get("geometry").notNull());
    List<SimpleSpatial> results = (List<SimpleSpatial>) session.executeQuery(roq);
    assertNotNull(results);
    int countAll = DeleteTests.countSimpleSpatial(session);
    assertEquals("More then one found", countAll - 1, results.size());
}
Also used : SimpleSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) List(java.util.List) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 3 with SimpleSpatial

use of org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial in project eclipselink by eclipse-ee4j.

the class UpdateTests method testUpdateSingleToNull.

public void testUpdateSingleToNull() throws Exception {
    UnitOfWork uow = session.acquireUnitOfWork();
    SimpleSpatial ss = (SimpleSpatial) uow.readObject(SimpleSpatial.class, new ExpressionBuilder().get("geometry").notNull());
    assertNotNull("No SimpleSpatial instances found", ss);
    ss.setJGeometry(null);
    uow.writeChanges();
    uow.release();
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) SimpleSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 4 with SimpleSpatial

use of org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial in project eclipselink by eclipse-ee4j.

the class Query_SpatialOp_ExpReport_Tests method populateTestGeometry.

private void populateTestGeometry(JGeometry g) {
    UnitOfWork uow = session.acquireUnitOfWork();
    uow.registerNewObject(new SimpleSpatial(6666, g));
    uow.commit();
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) SimpleSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial)

Example 5 with SimpleSpatial

use of org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial in project eclipselink by eclipse-ee4j.

the class Query_Basic_Tests method testSDORelateRectangle.

/**
 * SDO_RELATE using a dynamic rectangular window with lower left
 * and upper right coordinates of {(1,1), (20,20)}
 */
public void testSDORelateRectangle() throws Exception {
    double[] points = new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 };
    JGeometry rectangle = JGeometry.createLinearPolygon(points, 2, 0);
    ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
    ExpressionBuilder eb = raq.getExpressionBuilder();
    SpatialParameters parameters = new SpatialParameters();
    parameters.setQueryType(SpatialParameters.QueryType.WINDOW).setMask(Mask.ANYINTERACT);
    Expression selectionCriteria = SpatialExpressionFactory.relate(eb.get("geometry").getField("geom"), rectangle, parameters);
    raq.setSelectionCriteria(selectionCriteria);
    raq.addAscendingOrdering("id");
    List<SimpleSpatial> results = (List<SimpleSpatial>) session.executeQuery(raq);
    assertNotNull(results);
}
Also used : SimpleSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial) Expression(org.eclipse.persistence.expressions.Expression) 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

SimpleSpatial (org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial)13 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)8 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)7 List (java.util.List)4 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)4 JGeometry (oracle.spatial.geometry.JGeometry)2 Expression (org.eclipse.persistence.expressions.Expression)2 SpatialParameters (org.eclipse.persistence.expressions.spatial.SpatialParameters)2 ArrayList (java.util.ArrayList)1