/** * The current state for the feature source. * * <p>This value is derived from current transaction of the feature source. * * @see {@link #setTransaction(Transaction)}. */ public ContentState getState() { return entry.getState(transaction); }
/** * The flag which will expose columns which compose a tables identifying or primary key, through * feature type attributes. */ public boolean isExposePrimaryKeyColumns() { return ((JDBCState) entry.getState(transaction)).isExposePrimaryKeyColumns(); }
/** * Adds an listener or observer to the feature source. * * <p>Listeners are stored on a per-transaction basis. */ public final void addFeatureListener(FeatureListener listener) { entry.getState(transaction).addListener(listener); }
/** * Sets the flag which will expose columns which compose a tables identifying or primary key, * through feature type attributes. * * <p>Note: setting this flag which affect all feature sources created from or working against * the current transaction. */ public void setExposePrimaryKeyColumns(boolean exposePrimaryKeyColumns) { ((JDBCState) entry.getState(transaction)) .setExposePrimaryKeyColumns(exposePrimaryKeyColumns); }
/** Removes a listener from the feature source. */ public final void removeFeatureListener(FeatureListener listener) { entry.getState(transaction).removeListener(listener); }
/** * Returns the expose primary key columns flag for the specified feature type * * @param featureType * @return * @throws IOException */ protected boolean isExposePrimaryKeyColumns(SimpleFeatureType featureType) throws IOException { ContentEntry entry = ensureEntry(featureType.getName()); JDBCState state = (JDBCState) entry.getState(Transaction.AUTO_COMMIT); return state.isExposePrimaryKeyColumns(); }
/** * 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; }
/** * Creates a new instance of {@link JDBCFeatureStore}. * * @see ContentDataStore#createFeatureSource(ContentEntry) */ protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException { // grab the schema, it carries a flag telling us if the feature type is read only SimpleFeatureType schema = entry.getState(Transaction.AUTO_COMMIT).getFeatureType(); if (schema == null) { // if the schema still haven't been computed, force its computation so // that we can decide if the feature type is read only schema = new JDBCFeatureSource(entry, null).buildFeatureType(); entry.getState(Transaction.AUTO_COMMIT).setFeatureType(schema); } Object readOnlyMarker = schema.getUserData().get(JDBC_READ_ONLY); if (Boolean.TRUE.equals(readOnlyMarker)) { return new JDBCFeatureSource(entry, null); } return new JDBCFeatureStore(entry, null); }
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); } }
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()); }
public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { ensureNext(); try { last.init(); } catch (Exception e) { java.util.logging.Logger.getGlobal().log(java.util.logging.Level.INFO, "", e); } // reset next flag setNext(null); if (this.featureSource.getEntry().getState(tx).hasListener()) { // record bounds as we have a listener who will be interested this.lastBounds = new ReferencedEnvelope(last.getBounds()); } return last; }
final ContentState state = entry.getState(this.tx); state.fireFeatureAdded(featureSource, cur);
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); } }
JDBCState state = (JDBCState) entry.getState(Transaction.AUTO_COMMIT);
@Override protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException { ContentState state = entry.getState(null); SimpleFeatureType type = state.getFeatureType(); if (type == null) { type = schemaStore.retrieveSchema(entry.getName()); if (type != null) { state.setFeatureType(type); } } String collectionName = type != null ? collectionNameFromType(type) : entry.getTypeName(); return new MongoFeatureStore(entry, null, dataStoreDB.getCollection(collectionName)); }
ContentState state = entry.getState(null); state.setFeatureType(incoming);
throw (IOException) new IOException().initCause(e); ContentState state = getEntry().getState(transaction); ReferencedEnvelope bounds = ReferencedEnvelope.create(getSchema().getCoordinateReferenceSystem());
throw (IOException) new IOException().initCause(e); ContentState state = getEntry().getState(transaction); ReferencedEnvelope bounds = ReferencedEnvelope.create(getSchema().getCoordinateReferenceSystem());
/** * Adds an listener or observer to the feature source. * <p> * Listeners are stored on a per-transaction basis. * </p> */ public final void addFeatureListener(FeatureListener listener) { entry.getState(transaction).addListener(listener); }