Package org.geotools.data.simple

Examples of org.geotools.data.simple.SimpleFeatureLocking


    /*
     * Test for void lockFeatures()
     */
    public void testLockFeatures() throws IOException {
        FeatureLock lock = new FeatureLock("test", 3600);
        SimpleFeatureLocking road = (SimpleFeatureLocking) data.getFeatureSource("road");
        road.setFeatureLock(lock);

        assertFalse(isLocked("road", "road.rd1"));
        road.lockFeatures();
        assertTrue(isLocked("road", "road.rd1"));
    }
View Full Code Here


        updateMap(map, false);
        SimpleFeatureSource source = wrapped.getFeatureSource(map.getOriginalName());
        if (map.isUnchanged())
            return source;
        if (source instanceof FeatureLocking) {
            SimpleFeatureLocking locking = DataUtilities.simple((FeatureLocking) source);
            return new RetypingFeatureLocking(this, locking, map);
        } else if (source instanceof FeatureStore) {
            SimpleFeatureStore store = DataUtilities.simple((FeatureStore) source);
            return new RetypingFeatureStore(this, store, map);
        }
View Full Code Here

                damaged = store.getFeatures(filter).getBounds();
            }

            if ((request.getLockId() != null) && store instanceof FeatureLocking
                    && (request.getReleaseAction() == AllSomeType.SOME_LITERAL)) {
                SimpleFeatureLocking locking;
                locking = (SimpleFeatureLocking) store;

                // TODO: Revisit Lock/Delete interaction in gt2
                if (false) {
                    // REVISIT: This is bad - by releasing locks before
                    // we remove features we open ourselves up to the
                    // danger of someone else locking the features we
                    // are about to remove.
                    //
                    // We cannot do it the other way round, as the
                    // Features will not exist
                    //
                    // We cannot grab the fids offline using AUTO_COMMIT
                    // because we may have removed some of them earlier
                    // in the transaction
                    //
                    locking.unLockFeatures(filter);
                    store.removeFeatures(filter);
                } else {
                    // This a bit better and what should be done, we
                    // will need to rework the gt2 locking api to work
                    // with fids or something
                    //
                    // The only other thing that would work
                    // would be to specify that FeatureLocking is
                    // required to remove locks when removing Features.
                    //
                    // While that sounds like a good idea, it
                    // would be extra work when doing release mode ALL.
                    //
                    DataStore data = (DataStore) store.getDataStore();
                    FeatureWriter<SimpleFeatureType, SimpleFeature> writer;
                    writer = data.getFeatureWriter(typeName, filter, store.getTransaction());

                    try {
                        while (writer.hasNext()) {
                            String fid = writer.next().getID();
                            Set featureIds = new HashSet();
                            featureIds.add(factory.featureId(fid));
                            locking.unLockFeatures(factory.id(featureIds));
                            writer.remove();
                            deleted++;
                        }
                    } finally {
                        writer.close();
View Full Code Here

            }
            finally {
                // make sure we unlock
                if ((request.getLockId() != null) && store instanceof FeatureLocking
                        && (request.getReleaseAction() == AllSomeType.SOME_LITERAL)) {
                    SimpleFeatureLocking locking;
                    locking = (SimpleFeatureLocking) store;
                    locking.unLockFeatures(filter);
                }
            }

            // Post process - gather the same features after the update, and 
            if (!fids.isEmpty()) {
View Full Code Here

            }
            finally {
                // make sure we unlock
                if ((request.getLockId() != null) && store instanceof FeatureLocking
                        && (request.isReleaseActionSome())) {
                    SimpleFeatureLocking locking;
                    locking = (SimpleFeatureLocking) store;
                    locking.unLockFeatures(filter);
                }
            }

            // Post process - gather the same features after the update, and 
            if (!fids.isEmpty()) {
View Full Code Here

        updateMap(map, false);
        SimpleFeatureSource source = wrapped.getFeatureSource(map.getOriginalName());
        if (map.isUnchanged())
            return source;
        if (source instanceof FeatureLocking) {
            SimpleFeatureLocking locking = DataUtilities.simple((FeatureLocking) source);
            return new RetypingFeatureLocking(this, locking, map);
        } else if (source instanceof FeatureStore) {
            SimpleFeatureStore store = DataUtilities.simple((FeatureStore) source);
            return new RetypingFeatureStore(this, store, map);
        }
View Full Code Here

                damaged = store.getFeatures(filter).getBounds();
            }

            if ((request.getLockId() != null) && store instanceof FeatureLocking
                    && (request.isReleaseActionSome())) {
                SimpleFeatureLocking locking;
                locking = (SimpleFeatureLocking) store;

                // TODO: Revisit Lock/Delete interaction in gt2
                if (false) {
                    // REVISIT: This is bad - by releasing locks before
                    // we remove features we open ourselves up to the
                    // danger of someone else locking the features we
                    // are about to remove.
                    //
                    // We cannot do it the other way round, as the
                    // Features will not exist
                    //
                    // We cannot grab the fids offline using AUTO_COMMIT
                    // because we may have removed some of them earlier
                    // in the transaction
                    //
                    locking.unLockFeatures(filter);
                    store.removeFeatures(filter);
                } else {
                    // This a bit better and what should be done, we
                    // will need to rework the gt2 locking api to work
                    // with fids or something
                    //
                    // The only other thing that would work
                    // would be to specify that FeatureLocking is
                    // required to remove locks when removing Features.
                    //
                    // While that sounds like a good idea, it
                    // would be extra work when doing release mode ALL.
                    //
                    DataStore data = (DataStore) store.getDataStore();
                    FeatureWriter<SimpleFeatureType, SimpleFeature> writer;
                    writer = data.getFeatureWriter(typeName, filter, store.getTransaction());

                    try {
                        while (writer.hasNext()) {
                            String fid = writer.next().getID();
                            Set featureIds = new HashSet();
                            featureIds.add(factory.featureId(fid));
                            locking.unLockFeatures(factory.id(featureIds));
                            writer.remove();
                            deleted++;
                        }
                    } finally {
                        writer.close();
View Full Code Here

        assertTrue("Id does not start with " + "oaks" + " it's " + id, id.startsWith("oaks"));
    }

    @Test
    public void testLockUnlockFilter() throws Exception {
        SimpleFeatureLocking fl;
        fl = (SimpleFeatureLocking) rts.getFeatureSource(RENAMED);
        final FeatureLock lock = FeatureLockFactory.generate(10 * 60 * 1000);
        Transaction t = new DefaultTransaction();
        t.addAuthorization(lock.getAuthorization());
        fl.setTransaction(t);
        fl.setFeatureLock(lock);

        SimpleFeatureLocking fl2;
        fl2 = (SimpleFeatureLocking) rts.getFeatureSource(RENAMED);
        fl.setFeatureLock(lock);
        fl2.setTransaction(new DefaultTransaction());

        assertEquals(1, fl.lockFeatures(fidFilter));
        assertEquals(0, fl2.lockFeatures(fidFilter));

        fl.unLockFeatures(fidFilter);
        assertEquals(1, fl2.lockFeatures(fidFilter));
    }
View Full Code Here

        assertEquals(1, fl2.lockFeatures(fidFilter));
    }
   
    @Test
    public void testLockUnlockQuery() throws Exception {
        SimpleFeatureLocking fl;
        fl = (SimpleFeatureLocking) rts.getFeatureSource(RENAMED);
        final FeatureLock lock = FeatureLockFactory.generate(10 * 60 * 1000);
        Transaction t = new DefaultTransaction();
        t.addAuthorization(lock.getAuthorization());
        fl.setTransaction(t);
        fl.setFeatureLock(lock);

        SimpleFeatureLocking fl2;
        fl2 = (SimpleFeatureLocking) rts.getFeatureSource(RENAMED);
        fl.setFeatureLock(lock);
        fl2.setTransaction(new DefaultTransaction());

        Query q = new Query(RENAMED, fidFilter);
        assertEquals(1, fl.lockFeatures(q));
        assertEquals(0, fl2.lockFeatures(q));

        fl.unLockFeatures(q);
        assertEquals(1, fl2.lockFeatures(q));
    }
View Full Code Here

        assertTrue("Id does not start with " + "oaks" + " it's " + id, id.startsWith("oaks"));
    }

    @Test
    public void testLockUnlockFilter() throws Exception {
        SimpleFeatureLocking fl;
        fl = (SimpleFeatureLocking) rts.getFeatureSource(RENAMED);
        final FeatureLock lock = FeatureLockFactory.generate(10 * 60 * 1000);
        Transaction t = new DefaultTransaction();
        t.addAuthorization(lock.getAuthorization());
        fl.setTransaction(t);
        fl.setFeatureLock(lock);

        SimpleFeatureLocking fl2;
        fl2 = (SimpleFeatureLocking) rts.getFeatureSource(RENAMED);
        fl.setFeatureLock(lock);
        fl2.setTransaction(new DefaultTransaction());

        assertEquals(1, fl.lockFeatures(fidFilter));
        assertEquals(0, fl2.lockFeatures(fidFilter));

        fl.unLockFeatures(fidFilter);
        assertEquals(1, fl2.lockFeatures(fidFilter));
    }
View Full Code Here

TOP

Related Classes of org.geotools.data.simple.SimpleFeatureLocking

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.