/** * 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; }
@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; }
/** * 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); }
@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)); }
state.setFeatureType(incoming);
public void setFlattenSchema(boolean schemaFlattening) { getEntry().getState(getTransaction()).setFeatureType(null); this.flattenSchema = schemaFlattening; }
/** * 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; }
dataStore.getEntry(featureSource.getName()).getState(transaction).setFeatureType(simpleFeatureType); try { featureStore.addFeatures(collection);
/** * 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); }