Search in sources :

Example 1 with SampleMultiLineString

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

the class JtsGeometryMappingTest method testMultiLineStringMapping.

public void testMultiLineStringMapping() throws SQLException, ParseException {
    if (!runTestsForDatastore()) {
        return;
    }
    MultiLineString multiLineString = (MultiLineString) wktReader.read("MULTILINESTRING((0 50,100 50),(50 0,50 100),(100 25,120 25,110 10,110 45))");
    SampleMultiLineString sampleMultiLineString;
    SampleMultiLineString sampleMultiLineString_read;
    PersistenceManager pm = pmf.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    Object id = null;
    try {
        tx.begin();
        sampleMultiLineString = new SampleMultiLineString(5001, "MultiLineString", multiLineString);
        pm.makePersistent(sampleMultiLineString);
        id = JDOHelper.getObjectId(sampleMultiLineString);
        sampleMultiLineString = (SampleMultiLineString) pm.detachCopy(sampleMultiLineString);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
    pm = pmf.getPersistenceManager();
    tx = pm.currentTransaction();
    try {
        tx.begin();
        sampleMultiLineString_read = (SampleMultiLineString) pm.getObjectById(id, true);
        assertEquals(sampleMultiLineString, sampleMultiLineString_read);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
}
Also used : SampleMultiLineString(org.datanucleus.samples.jtsgeometry.SampleMultiLineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) Transaction(javax.jdo.Transaction) PersistenceManager(javax.jdo.PersistenceManager) SampleMultiLineString(org.datanucleus.samples.jtsgeometry.SampleMultiLineString)

Aggregations

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