public MemoryFeatureReader(ContentState state, Query query) throws IOException { featureType = state.getFeatureType(); MemoryEntry entry = (MemoryEntry) state.getEntry(); final List<SimpleFeature> internalCollection = new ArrayList<>(entry.getMemory().values()); iterator = internalCollection.iterator(); }
/** * Helper method for returning the underlying schema of the feature source. This is a non-view * this is the same as calling getSchema(), but in the view case the underlying "true" schema is * returned. */ protected final SimpleFeatureType getAbsoluteSchema() { // load the type from the state shared among feature sources ContentState state = entry.getState(transaction); SimpleFeatureType featureType = state.getFeatureType(); if (featureType == null) { // build and cache it synchronized (state) { if (featureType == null) { try { featureType = buildFeatureType(); } catch (IOException e) { throw new RuntimeException(e); } state.setFeatureType(featureType); } } } return featureType; }
/** * Writes out the current feature. * * @throws IOException * @see org.geotools.data.FeatureWriter#write() */ public void write() throws IOException { if (writer == null) { throw new IOException("FeatureWriter has been closed"); } writer.write(); if (feature == null) { throw new IOException("No feature available to write"); } if (writer.hasNext()) { // modify existing feature ReferencedEnvelope bounds = ReferencedEnvelope.reference(feature.getBounds()); state.fireFeatureUpdated(store, feature, bounds); feature = null; } else { // modify a new feature - ie we are adding something state.fireFeatureAdded(store, feature); } }
public void fireFeatureRemoved(FeatureSource<?, ?> source, Feature feature) { if (listeners.isEmpty() && tx != Transaction.AUTO_COMMIT) return; Filter filter = idFilter(feature); ReferencedEnvelope bounds = ReferencedEnvelope.reference(feature.getBounds()); FeatureEvent event = new FeatureEvent(source, Type.REMOVED, bounds, filter); fireFeatureEvent(event); }
public SimpleFeatureType getFeatureType() { return state.getFeatureType(); } // getFeatureType end
@Override public MemoryEntry getEntry() { return (MemoryEntry) super.getEntry(); }
ContentEntry entry = state.getEntry(); Name name = entry.getName(); ContentDataStore dataStore = entry.getDataStore(); state.fireFeatureRemoved(store, feature); } else { try { state.fireFeatureUpdated(store, update, bounds); } catch (IllegalAttributeException e) { throw new DataSourceException("Could update " + fid, e); state.fireFeatureAdded(store, nextFeature); } catch (IllegalAttributeException e) { throw new DataSourceException("Could update " + fid, e); try { writer.close(); state.fireBatchFeatureEvent(true); diff.clear(); } catch (IOException e) {
ReferencedEnvelope bounds = ReferencedEnvelope.create(getSchema().getCoordinateReferenceSystem()); if (state.hasListener()) { if (state.hasListener()) { state.fireFeatureEvent(event);
ContentEntry entry = state.getEntry(); Name name = entry.getName(); ContentDataStore dataStore = entry.getDataStore(); try { writer.close(); state.fireBatchFeatureEvent(true); diff.clear(); } catch (IOException e) {
@Override protected ContentState createContentState(ContentEntry entry) { ContentState state = super.createContentState(entry); try { SimpleFeatureType type = schemaStore.retrieveSchema(entry.getName()); if (type != null) { state.setFeatureType(type); } } catch (IOException e) { LOGGER.log( Level.WARNING, "Exception thrown while attempting to retrieve the schema for {0}: {1}", new Object[] {entry.getName(), e}); } return state; }
private void flushState(ContentDataStore contentDataStore, String nativeName) throws IOException { ContentFeatureSource featureSource; featureSource = contentDataStore.getFeatureSource(nativeName); featureSource.getState().flush(); }
public void remove() throws IOException { if (live == null) { throw new IOException("No current feature to remove"); } if (origional != null) { // String typeName = live.getFeatureType().getTypeName(); // Transaction autoCommit = Transaction.AUTO_COMMIT; state.fireFeatureRemoved(featureSource, origional); // store.listenerManager.fireFeaturesRemoved(typeName, // autoCommit,ReferencedEnvelope.reference(origional.getBounds()), false); } origional = null; live = null; // prevent live and remove from being written out } // remove end
public void remove() throws IOException { 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); } }
public void write() throws IOException { try { // figure out what the fid is PrimaryKey key = dataStore.getPrimaryKey(featureType); String fid = dataStore.encodeFID(key, rs); Id filter = dataStore .getFilterFactory() .id(Collections.singleton(dataStore.getFilterFactory().featureId(fid))); // figure out which attributes changed List<AttributeDescriptor> changed = new ArrayList<AttributeDescriptor>(); List<Object> values = new ArrayList<Object>(); for (AttributeDescriptor att : featureType.getAttributeDescriptors()) { if (last.isDirty(att.getLocalName())) { changed.add(att); values.add(last.getAttribute(att.getLocalName())); } } // 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); } }
state.fireFeatureAdded(featureSource, cur);
final void initMapper() { // use schema with mapping info if it exists SimpleFeatureType type = entry.getState(null).getFeatureType(); setMapper(type != null ? new MongoSchemaMapper(type) : new MongoInferredMapper()); }
@Override /** * We are already holding onto our transaction from ContentState; however this method does check * that the transaction is correct. */ public synchronized void setTransaction(Transaction transaction) { if (this.transaction != null && transaction == null) { // clear ContentEntry transaction to fix GEOT-3315 state.getEntry().clearTransaction(this.transaction); } this.transaction = transaction; }
/** * Used to issue a Type.ADDED FeatureEvent indicating a new feature being created * * @param source * @param feature */ public final void fireFeatureAdded(FeatureSource<?, ?> source, Feature feature) { if (listeners.isEmpty() && tx != Transaction.AUTO_COMMIT) return; Filter filter = idFilter(feature); ReferencedEnvelope bounds = ReferencedEnvelope.reference(feature.getBounds()); FeatureEvent event = new FeatureEvent(source, Type.ADDED, bounds, filter); fireFeatureEvent(event); }
ReferencedEnvelope bounds = ReferencedEnvelope.create(getSchema().getCoordinateReferenceSystem()); if (state.hasListener()) { if (state.hasListener()) { state.fireFeatureEvent(event);
state.setFeatureType(incoming);