Package org.geotools.data.store

Examples of org.geotools.data.store.ContentState


        }
    }

    @Override
    protected ContentState createContentState(ContentEntry entry) {
        return new ContentState(entry);
    }
View Full Code Here


                return;
            }
        }

        // Filter fully supported, lets batch modify
        final ContentState contentState = getState();

        ReferencedEnvelope affectedBounds = new ReferencedEnvelope(getInfo().getCRS());
        if (contentState.hasListener()) {
            // gather bounds before modification
            ReferencedEnvelope before = getBounds(new Query(getSchema().getTypeName(), filter));
            if (before != null && !before.isEmpty()) {
                affectedBounds = before;
            }
        }
        final Transaction transaction = getTransaction();

        FeatureReader<SimpleFeatureType, SimpleFeature> oldFeatures = getReader(filter);
        try {
            if (!oldFeatures.hasNext()) {
                // don't bother
                oldFeatures.close();
                return;
            }
        } catch (IOException e) {
            oldFeatures.close();
            throw e;
        } catch (RuntimeException e) {
            oldFeatures.close();
            throw e;
        }

        if (Transaction.AUTO_COMMIT.equals(transaction)) {
            // we're in auto commit. Do a batch update and commit right away
            WFSLocalTransactionState localState = getState().getLocalTransactionState();
            WFSRemoteTransactionState committingState = new WFSRemoteTransactionState(
                    getDataStore());
            committingState.watch(localState.getState());

            WFSDiff diff = localState.getDiff();

            ReferencedEnvelope bounds;
            bounds = diff.batchModify(properties, values, filter, oldFeatures, contentState);
            affectedBounds.expandToInclude(bounds);
            committingState.commit();

        } else {
            // we're in a transaction, record to local state and wait for commit to be called
            WFSLocalTransactionState localState;
            localState = (WFSLocalTransactionState) transaction.getState(getEntry());
            WFSDiff diff = localState.getDiff();

            ReferencedEnvelope bounds;
            bounds = diff.batchModify(properties, values, filter, oldFeatures, contentState);
            affectedBounds.expandToInclude(bounds);
        }

        if (contentState.hasListener()) {
            // issue notificaiton
            FeatureEvent event = new FeatureEvent(this, Type.CHANGED, affectedBounds, filter);
            contentState.fireFeatureEvent(event);
        }

    }
View Full Code Here

    @Override
    protected ContentState createContentState(ContentEntry entry) {
        //
        // Forward to default implementation
        //
        ContentState state = super.createContentState(entry);
        //
        // Get EFeature structure info
        //
        EFeatureInfo eStructure = ePackageInfo.eGetFeatureInfo(entry.getTypeName());
        //
        // Set SimpleFeature type definition
        //
        state.setFeatureType(eStructure.getFeatureType());       
        //
        // Finished
        //
        return state;
    }
View Full Code Here

        try {
            dataStore.delete(featureType, last.getID(), st.getConnection());
           
            // issue notification
            ContentEntry entry = featureSource.getEntry();
            ContentState state = entry.getState( this.tx );
            if( state.hasListener() ){
                state.fireFeatureRemoved( featureSource, last );
            }
        } catch (SQLException e) {
            throw (IOException) new IOException().initCause(e);
        }
    }
View Full Code Here

            // do the write
            dataStore.update(featureType, changed, values, filter, st.getConnection());
           
            // issue notification
            ContentEntry entry = featureSource.getEntry();
            ContentState state = entry.getState( this.tx );
            if( state.hasListener() ){
                state.fireFeatureUpdated( featureSource, last, lastBounds );
            }
        } catch (Exception e) {
            throw (IOException) new IOException().initCause(e);
        }
    }
View Full Code Here

                    getDataStore().ensureAuthorization(featureType, preFilter, getTransaction(), cx);
                }
                catch (SQLException e) {
                    throw (IOException) new IOException().initCause( e );
                }
                ContentState state = getEntry().getState(transaction);
                ReferencedEnvelope bounds = new ReferencedEnvelope( getSchema().getCoordinateReferenceSystem() );
                if( state.hasListener() ){
                    // gather bounds before modification
                    ReferencedEnvelope before = getBounds( new DefaultQuery( getSchema().getTypeName(), preFilter ) );               
                    if( before != null && !before.isEmpty() ){
                        bounds = before;
                    }
                }
                try {
                    getDataStore().update(getSchema(), innerTypes, values, preFilter, cx);
                } catch(SQLException e) {
                    throw (IOException) (new IOException(e.getMessage()).initCause(e));
                }
               
                if( state.hasListener() ){
                    // gather any updated bounds due to a geometry modification
                    for( Object value : values ){
                        if( value instanceof Geometry ){
                            Geometry geometry = (Geometry) value;
                            bounds.expandToInclude( geometry.getEnvelopeInternal() );
                        }
                    }
                    // issue notificaiton
                    FeatureEvent event = new FeatureEvent(this, Type.CHANGED, bounds, preFilter );
                    state.fireFeatureEvent( event );
                }
            } finally {
                if(tx == null || tx == Transaction.AUTO_COMMIT) {
                    getDataStore().closeSafe(cx);
                }
View Full Code Here

                    getDataStore().ensureAuthorization(featureType, preFilter, getTransaction(), cx);
                }
                catch (SQLException e) {
                    throw (IOException) new IOException().initCause( e );
                }
                ContentState state = getEntry().getState(transaction);
                ReferencedEnvelope bounds = new ReferencedEnvelope( getSchema().getCoordinateReferenceSystem() );
                if( state.hasListener() ){
                    // gather bounds before modification
                    ReferencedEnvelope before = getBounds( new DefaultQuery( getSchema().getTypeName(), preFilter ) );               
                    if( before != null && !before.isEmpty() ){
                        bounds = before;
                    }
                }           
                getDataStore().delete(featureType, preFilter, cx);
                if( state.hasListener() ){
                    // issue notification
                    FeatureEvent event = new FeatureEvent(this, Type.REMOVED, bounds, preFilter );
                    state.fireFeatureEvent( event );
                }
            } finally {
                if(tx == null || tx == Transaction.AUTO_COMMIT) {
                    getDataStore().closeSafe(cx);
                }
View Full Code Here

            //the datastore sets as userData, grab it and update the fid
            String fid = (String) last.getUserData().get( "fid" );
            last.setID( fid );
           
            ContentEntry entry = featureSource.getEntry();
            ContentState state = entry.getState( this.tx );           
            state.fireFeatureAdded( featureSource, last );
        } catch (SQLException e) {
            throw (IOException) new IOException().initCause(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.geotools.data.store.ContentState

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.