Search in sources :

Example 1 with SampleLinearRing

use of org.datanucleus.samples.jtsgeometry.SampleLinearRing in project tests by datanucleus.

the class JtsGeometryMappingTest method testLinearRingMapping.

public void testLinearRingMapping() throws SQLException, ParseException {
    if (!runTestsForDatastore()) {
        return;
    }
    LinearRing linearRing = (LinearRing) wktReader.read("LINEARRING(0 0,10 0,10 10,0 10,0 0)");
    SampleLinearRing sampleLinearRing;
    SampleLinearRing sampleLinearRing_read;
    PersistenceManager pm = pmf.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    Object id = null;
    try {
        tx.begin();
        sampleLinearRing = new SampleLinearRing(2101, "LinearRing", linearRing);
        pm.makePersistent(sampleLinearRing);
        id = JDOHelper.getObjectId(sampleLinearRing);
        sampleLinearRing = (SampleLinearRing) pm.detachCopy(sampleLinearRing);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
    pm = pmf.getPersistenceManager();
    tx = pm.currentTransaction();
    try {
        tx.begin();
        sampleLinearRing_read = (SampleLinearRing) pm.getObjectById(id, true);
        assertEquals(sampleLinearRing, sampleLinearRing_read);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
}
Also used : Transaction(javax.jdo.Transaction) PersistenceManager(javax.jdo.PersistenceManager) SampleLinearRing(org.datanucleus.samples.jtsgeometry.SampleLinearRing) SampleLinearRing(org.datanucleus.samples.jtsgeometry.SampleLinearRing) LinearRing(com.vividsolutions.jts.geom.LinearRing)

Aggregations

LinearRing (com.vividsolutions.jts.geom.LinearRing)1 PersistenceManager (javax.jdo.PersistenceManager)1 Transaction (javax.jdo.Transaction)1 SampleLinearRing (org.datanucleus.samples.jtsgeometry.SampleLinearRing)1