Package org.geotools.data

Examples of org.geotools.data.Transaction


  }

  @Override
  protected void doCommit(DefaultTransactionStatus status) {
    GeoToolsTransactionObject txObject = (GeoToolsTransactionObject) status.getTransaction();
    Transaction tx = txObject.getTransactionHolder().getTransaction();
    try {
      tx.commit();
    } catch (IOException e) {
         log.warn(e.getMessage(), e);
    }
  }
View Full Code Here


  }

  @Override
  protected void doRollback(DefaultTransactionStatus status) {
    GeoToolsTransactionObject txObject = (GeoToolsTransactionObject) status.getTransaction();
    Transaction tx = txObject.getTransactionHolder().getTransaction();
    try {
      tx.rollback();
    } catch (IOException e) {
      log.warn(e.getMessage(), e);
    }
  }
View Full Code Here

              }
            }
            else
              throw new Exception("Unknown export type.");

            Transaction transaction = new DefaultTransaction("create");

            String typeName = dataStore.getTypeNames()[0];
            SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);

            if (featureSource instanceof SimpleFeatureStore)
            {
                SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;

                featureStore.setTransaction(transaction);
              
                featureStore.addFeatures(collection);
                transaction.commit();

                transaction.close();
            }
            else
            {
              throw new Exception(typeName + " does not support read/write access");
            }
View Full Code Here

            ProjectPlugin.log(message, illegalStateException);
            throw illegalStateException;
        }
        // grab the current map transaction
        EditManager editManager = (EditManager) layer.getMap().getEditManager();
        Transaction transaction = editManager.getTransaction();
       
        if (wrapped.getTransaction() == Transaction.AUTO_COMMIT) {
            // change over from autocommit to transactional
            wrapped.setTransaction(transaction);
        }
View Full Code Here

     * A: (Jody) They can use the id; and grab the actual IResource from
     * the catalog; and get there own that way.
     */
    public void startTransaction() {
        if (wrapped.getTransaction() == Transaction.AUTO_COMMIT) {
            Transaction transaction = ((EditManager) layer.getMap().getEditManager())
                    .getTransaction();
            wrapped.setTransaction(transaction);
        }
    }
View Full Code Here

            ProjectPlugin.log(message, illegalStateException);
            throw illegalStateException;
        }
        // grab the current map transaction
        EditManager editManager = (EditManager) layer.getMap().getEditManager();
        Transaction transaction = editManager.getTransaction();
       
        if (wrapped.getTransaction() == Transaction.AUTO_COMMIT) {
            // change over from autocommit to transactional
            wrapped.setTransaction(transaction);
        }
View Full Code Here

     * A: (Jody) They can use the id; and grab the actual IResource from
     * the catalog; and get there own that way.
     */
    public void startTransaction() {
        if (wrapped.getTransaction() == Transaction.AUTO_COMMIT) {
            Transaction transaction = ((EditManager) layer.getMap().getEditManager())
                    .getTransaction();
            wrapped.setTransaction(transaction);
        }
    }
View Full Code Here

    public void writeToShapefile( ShapefileDataStore dataStore, FeatureCollection<SimpleFeatureType, SimpleFeature> collection )
            throws IOException {
        String featureName = dataStore.getTypeNames()[0];
        FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = dataStore.getFeatureSource(featureName);

        Transaction transaction = new DefaultTransaction("create");
        try {
            FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
            featureStore.setTransaction(transaction);
            featureStore.addFeatures(collection);
            transaction.commit();
        } catch (Exception eek) {
            transaction.rollback();
            throw new IOException("The transaction could now be finished, an error orrcurred", eek);
        } finally {
            transaction.close();
        }
    }
View Full Code Here

     */
    @Test
    public void testGetGeoResourcesInterceptors() throws IOException {
        NullProgressMonitor nullProgressMonitor = new NullProgressMonitor();
        FeatureStore<SimpleFeatureType, SimpleFeature> resource = layer.getResource(FeatureStore.class, nullProgressMonitor);
        Transaction transaction = resource.getTransaction();
        assertNotNull(transaction);
        assertTrue(transaction==Transaction.AUTO_COMMIT);
        assertSame(transaction, resource.getTransaction());
        assertSame(resource, layer.getResource(FeatureStore.class, nullProgressMonitor));
        assertSame(resource, layer.getResource(FeatureSource.class, nullProgressMonitor));
View Full Code Here

    public void testLockUnlockFilter() throws Exception {
        FeatureLocking<SimpleFeatureType, SimpleFeature> fl;
        fl = (FeatureLocking<SimpleFeatureType, SimpleFeature>) 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);

        FeatureLocking<SimpleFeatureType, SimpleFeature> fl2;
        fl2 = (FeatureLocking<SimpleFeatureType, SimpleFeature>) rts.getFeatureSource(RENAMED);
View Full Code Here

TOP

Related Classes of org.geotools.data.Transaction

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.