Package org.geotools.data

Examples of org.geotools.data.DefaultTransaction


     
      String[] ps = new String []{"polyidl","polyidr","tlid"};
      Query q = new DefaultQuery("polychainlink",cf,ps);        
      
        
      FeatureReader fr = ds.getFeatureReader(q, new DefaultTransaction() );
  
        while (fr.hasNext())
        {
          Feature f= fr.next();
          f.getFeatureType();
View Full Code Here


     
      String[] ps = new String []{"wkb_geometry","polyid"};
      Query q = new DefaultQuery("pip",cf,ps);        
      
        
      FeatureReader fr = ds.getFeatureReader(q, new DefaultTransaction() );
  
        while (fr.hasNext())
        {
          Feature f= fr.next();
         
View Full Code Here

*/
public abstract class JDBCTransactionTest extends JDBCTestSupport {
    public void testCommit() throws IOException {
        //JDBCFeatureStore fs = (JDBCFeatureStore) dataStore.getFeatureSource(tname("ft1"));

        Transaction tx = new DefaultTransaction();

        //tx.putState( fs, new JDBCTransactionState( fs ) );
        FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriterAppend(tname("ft1"), tx);
        SimpleFeature feature = writer.next();
        feature.setAttribute(aname("intProperty"), new Integer(100));
        writer.write();
        writer.close();
        tx.commit();
        tx.close();

        SimpleFeatureCollection fc = dataStore.getFeatureSource(tname("ft1")).getFeatures();
        assertEquals(4, fc.size());
    }
View Full Code Here

    }

    public void testNoCommit() throws IOException {
        //JDBCFeatureStore fs = (JDBCFeatureStore) dataStore.getFeatureSource(tname("ft1"));

        Transaction tx = new DefaultTransaction();

        //tx.putState( fs, new JDBCTransactionState( fs ) );
        FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriterAppend(tname("ft1"), tx);
        SimpleFeature feature = writer.next();
        feature.setAttribute(aname("intProperty"), new Integer(100));
        writer.write();
        writer.close();
        tx.rollback();
        tx.close();

        SimpleFeatureCollection fc = dataStore.getFeatureSource(tname("ft1")).getFeatures();
        assertEquals(3, fc.size());
    }
View Full Code Here

    }

    public void testConcurrentTransactions() throws IOException {
        //JDBCFeatureStore fs = (JDBCFeatureStore) dataStore.getFeatureSource(tname("ft1"));

        Transaction tx1 = new DefaultTransaction();

        //tx1.putState( fs, new JDBCTransactionState( fs ) );
        Transaction tx2 = new DefaultTransaction();

        //tx2.putState( fs, new JDBCTransactionState( fs ) );
        FeatureWriter<SimpleFeatureType, SimpleFeature> w1 = dataStore.getFeatureWriterAppend(tname("ft1"), tx1);
        FeatureWriter<SimpleFeatureType, SimpleFeature> w2 = dataStore.getFeatureWriterAppend(tname("ft1"), tx2);

        SimpleFeature f1 = w1.next();
        SimpleFeature f2 = w2.next();

        f1.setAttribute(aname("intProperty"), new Integer(100));
        f2.setAttribute(aname("intProperty"), new Integer(101));

        w1.write();
        w2.write();

        w1.close();
        w2.close();

        tx1.commit();
        tx2.commit();
        tx1.close();
        tx2.close();

        SimpleFeatureCollection fc = dataStore.getFeatureSource(tname("ft1")).getFeatures();
        assertEquals(5, fc.size());
    }
View Full Code Here

        b.set(aname("intProperty"), new Integer(100));
        SimpleFeature f1 = b.buildFeature(null);
        DefaultFeatureCollection features = new DefaultFeatureCollection(null,null);
        features.add( f1 );

        Transaction tx1 = new DefaultTransaction();
        st.setTransaction(tx1);
        st.addFeatures( features );
        tx1.commit();
        tx1.close();
        assertEquals(4, dataStore.getFeatureSource(tname("ft1")).getCount(Query.ALL));
       
        Transaction tx2 = new DefaultTransaction();
        st.setTransaction(tx2);
        st.addFeatures( features );
        tx2.commit();
        tx2.close();
        assertEquals(5, dataStore.getFeatureSource(tname("ft1")).getCount(Query.ALL));
    }
View Full Code Here

        dataStore.setDataSource(dataSource);
       
        featureType = Mockito.mock(SimpleFeatureType.class);
        Mockito.when(featureType.getTypeName()).thenReturn(SAMPLE_FEATURE_NAME);
        Mockito.when(featureType.getName()).thenReturn(new NameImpl(SAMPLE_FEATURE_NAME));
        tx = new DefaultTransaction();
       
    }
View Full Code Here

                    throws IOException {
                return null;
            }
        };
   
        Transaction transaction = new DefaultTransaction();
   
        ContentEntry entry = new ContentEntry(dataStore, new NameImpl("test"));
        ContentState state = entry.getState(transaction);
        new DiffTransactionState(state);
   
        // state is extracted from state cache
        assertSame(state, entry.getState(transaction));
        // and contains our transaction
        assertSame(state.getTransaction(), transaction);
   
        try {
            transaction.close();
           
            // after transaction closing, the old state has been cleared, so
            // a new one is built and returned
            ContentState stateForClosedTransaction = entry.getState(transaction);
            assertNotSame(stateForClosedTransaction, state);
View Full Code Here

        r.close();
    }

    public void testInsertFeatures() throws Exception {
        Transaction transaction = new DefaultTransaction();
        SimpleFeatureStore featureStore = (SimpleFeatureStore) dataStore.getFeatureSource(tname("guid"));
        featureStore.setTransaction(transaction);
        assertEquals(featureStore.getCount(Query.ALL),2);

        SimpleFeatureType type = dataStore.getSchema(tname("guid"));
        SimpleFeature feature = SimpleFeatureBuilder.build(type, new Object[] { uuid3 }, "guid.3");

        SimpleFeatureCollection collection = DataUtilities.collection(feature);
        featureStore.addFeatures(collection);
        transaction.commit();
        assertEquals(featureStore.getCount(Query.ALL),3);
        transaction.close();
    }
View Full Code Here

        assertEquals(1, featureStore.getCount(Query.ALL));
    }

    public void testUUIDAsPrimaryKey() throws Exception {
        Transaction transaction = new DefaultTransaction();
        SimpleFeatureStore featureStore = (SimpleFeatureStore) dataStore.getFeatureSource(tname("uuidt"));
        featureStore.setTransaction(transaction);

        featureStore.addFeatures(createFeatureCollection());

        transaction.commit();
        assertEquals(3, featureStore.getCount(Query.ALL));
        transaction.close();
    }
View Full Code Here

TOP

Related Classes of org.geotools.data.DefaultTransaction

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.