Examples of FeatureLock


Examples of org.geotools.data.FeatureLock

    }

    private void createLock() throws IOException {
        dataStore.getLockingManager().lockFeatureID(SAMPLE_FEATURE_NAME,
                SAMPLE_FEATURE_ID, tx,
                new FeatureLock(SAMPLE_FEATURE_ID, 10000000L));
    }
View Full Code Here

Examples of org.geotools.data.FeatureLock

        store.setFeatureLock(FeatureLock.TRANSACTION);
    }
   
    public void testLockFeatures() throws Exception {
       
        FeatureLock lock =
            FeatureLockFactory.generate(tname("ft1"), 60 * 60 * 1000);
       
        Transaction tx = new DefaultTransaction();
        store.setTransaction( tx );
        store.setFeatureLock(lock);
       
        //lock features
        int locked = store.lockFeatures();
        assertTrue( locked > 0 );
       
        //grabbing a reader should be no problem
        DefaultQuery query = new DefaultQuery( tname("ft1") );
        FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query,tx);
       
        int count = 0;
        while( reader.hasNext() ) {
            count++;
            reader.next();
        }
        assertTrue( count > 0 );
        reader.close();
       
        //grab a writer
        FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(tname("ft1"), tx );
        assertTrue( writer.hasNext() );
        SimpleFeature feature = writer.next();
       
        feature.setAttribute(aname("intProperty"), new Integer(100) );
        try {
            writer.write()
            fail( "should have thrown feature lock exception" );
        }
        catch( FeatureLockException e ) {
            //good
        }
        finally {
            writer.close();
        }
       
        tx.addAuthorization(lock.getAuthorization());
        writer = dataStore.getFeatureWriter(tname("ft1"), tx);
        assertTrue( writer.hasNext() );
        feature = writer.next();
        feature.setAttribute(aname("intProperty"), new Integer(100) );
        writer.write();
View Full Code Here

Examples of org.geotools.data.FeatureLock

        tx.close();
    }
   
    public void testLockFeaturesWithFilter() throws Exception {
       
        FeatureLock lock =
            FeatureLockFactory.generate(tname("ft1"), 60 * 60 * 1000);
       
        Transaction tx = new DefaultTransaction();
        store.setTransaction( tx );
        store.setFeatureLock(lock);
View Full Code Here

Examples of org.geotools.data.FeatureLock

        tx.close();
    }
   
    public void testLockFeaturesWithInvalidFilter() throws Exception {
       
        FeatureLock lock = FeatureLockFactory.generate(tname("ft1"), 60 * 60 * 1000);
       
        Transaction tx = new DefaultTransaction();
        store.setTransaction( tx );
        store.setFeatureLock(lock);
       
View Full Code Here

Examples of org.geotools.data.FeatureLock

       
        tx.close();
    }
   
    public void testLockFeaturesWithInvalidQuery() throws Exception {
        FeatureLock lock = FeatureLockFactory.generate(tname("ft1"), 60 * 60 * 1000);
       
        Transaction tx = new DefaultTransaction();
        store.setTransaction( tx );
        store.setFeatureLock(lock);
       
View Full Code Here

Examples of org.geotools.data.FeatureLock

       
        tx.close();
    }
   
    public void testUnlockFeatures() throws Exception {
        FeatureLock lock =
            FeatureLockFactory.generate(tname("ft1"), 60 * 60 * 1000);
       
        Transaction tx = new DefaultTransaction();
        store.setTransaction( tx );
        store.setFeatureLock(lock);
       
        store.lockFeatures();
       
        FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(tname("ft1"), tx );
        assertTrue( writer.hasNext() );
        SimpleFeature feature = writer.next();
        feature.setAttribute( aname("intProperty"), new Integer(100) );
        try {
            writer.write();
            fail( "write should have thrown exception");
        }
        catch( FeatureLockException e) {
           
        }
        finally {
            writer.close();
        }
       
        try {
            store.unLockFeatures();   
            fail( "unlock should have thrown an exception");
        }
        catch( FeatureLockException e ) {}
       
        tx.addAuthorization(lock.getAuthorization());
        store.unLockFeatures();
       
        writer = dataStore.getFeatureWriter(tname("ft1"), tx );
        assertTrue( writer.hasNext() );
       
View Full Code Here

Examples of org.geotools.data.FeatureLock

        writer.close();
        tx.close();
    }
   
    public void testUnlockFeaturesInvalidFilter() throws Exception {
        FeatureLock lock =
            FeatureLockFactory.generate(tname("ft1"), 60 * 60 * 1000);
       
        Transaction tx = new DefaultTransaction();
        store.setTransaction( tx );
        store.setFeatureLock(lock);
        tx.addAuthorization(lock.getAuthorization());
       
        store.lockFeatures();
       
        // uhnlock features
        FilterFactory ff = dataStore.getFilterFactory();
View Full Code Here

Examples of org.geotools.data.FeatureLock

        store.unLockFeatures();
        tx.close();
    }
   
    public void testDeleteLockedFeatures() throws Exception {
        FeatureLock lock =
            FeatureLockFactory.generate(tname("ft1"), 60 * 60 * 1000);
       
        Transaction tx = new DefaultTransaction();
        store.setTransaction( tx );
        store.setFeatureLock(lock);
        tx.addAuthorization(lock.getAuthorization());
       
        FilterFactory ff = dataStore.getFilterFactory();
        Filter f1 = ff.id( Collections.singleton( ff.featureId( tname("ft1")+".1")));
       
        assertEquals( 1, store.lockFeatures(f1) );
View Full Code Here

Examples of org.geotools.data.FeatureLock

        FilterFactory ff = dataStore.getFilterFactory();
       
        Filter f0 = ff.equal( ff.property( aname("intProperty" ) ), ff.literal(1000), true);
        assertEquals( 0 , store.getCount( new DefaultQuery( tname("ft1"), f0 ) ));
       
        FeatureLock lock =
            FeatureLockFactory.generate(tname("ft1"), 60 * 60 * 1000);
       
        Transaction tx = new DefaultTransaction();
        store.setTransaction( tx );
        store.setFeatureLock(lock);
        tx.addAuthorization(lock.getAuthorization());
       
        Filter f1 = ff.id( Collections.singleton( ff.featureId( tname("ft1")+".1")));
        store.lockFeatures(f1);
       
        Transaction tx1 = new DefaultTransaction();
View Full Code Here

Examples of org.geotools.data.FeatureLock

    //
    /*
     * 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();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.