@Override public void dispose() { super.dispose(); if (shpFiles != null) { shpFiles.dispose(); shpFiles = null; } }
private void flushState(ContentDataStore contentDataStore, String nativeName) throws IOException { ContentFeatureSource featureSource; featureSource = contentDataStore.getFeatureSource(nativeName); featureSource.getState().flush(); }
/** * Returns a feature writer for the specified type name and transaction. * * <p>This method is convenience for <code>getFeatureWriter(typeName,Filter.INCLUDE,tx)</code>. */ public final FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter( String typeName, Transaction tx) throws IOException { return getFeatureWriter(typeName, Filter.INCLUDE, tx); }
/** * Returns the feature source matching the specified name and explicitly specifies a * transaction. * * <p>Subclasses should not implement this method. However overriding in order to perform a type * narrowing to a subclasses of {@link ContentFeatureSource} is acceptable. * * @see DataStore#getFeatureSource(String) */ public ContentFeatureSource getFeatureSource(Name typeName, Transaction tx) throws IOException { ContentEntry entry = ensureEntry(typeName); ContentFeatureSource featureSource = createFeatureSource(entry); featureSource.setTransaction(tx); // if ( tx != Transaction.AUTO_COMMIT ) { // //setup the transaction state // synchronized (tx) { // if ( tx.getState( typeName ) == null ) { // tx.putState( typeName, createTransactionState(featureSource) ); // } // } // } return featureSource; }
/** * Returns the feature source matching the specified name and explicitly * specifies a transaction. * <p> * Subclasses should not implement this method. However overriding in order * to perform a type narrowing to a subclasses of {@link ContentFeatureSource} * is acceptable. * </p> * * @see DataStore#getFeatureSource(String) */ public ContentFeatureSource getFeatureSource(String typeName, Transaction tx) throws IOException { return getFeatureSource( name(typeName), tx ); }
/** * Delegates to {@link #getSchema(String)} with {@code name.getLocalPart()} * * @since 2.5 * @see DataAccess#getSchema(Name) */ public SimpleFeatureType getSchema(Name name) throws IOException { return getSchema(name.getLocalPart()); }
/** * Creates the entry. * * @param dataStore The DataStore of the entry. * @param typeName The name of the entry. */ public ContentEntry(ContentDataStore dataStore, Name typeName) { this.typeName = typeName; this.dataStore = dataStore; this.state = new ConcurrentHashMap<Transaction, ContentState>(); // create a state for the auto commit transaction ContentState autoState = dataStore.createContentState(this); autoState.setTransaction(Transaction.AUTO_COMMIT); this.state.put(Transaction.AUTO_COMMIT, autoState); }
/** * Returns a feature writer for the specified query and transaction. * * <p>This method is not intended to be overridden and is marked final. This implementation * delegates to {@link FeatureCollection} and wraps an iterator in a {@link FeatureWriter}. */ public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter( String typeName, Filter filter, Transaction tx) throws IOException { ContentFeatureStore featureStore = ensureFeatureStore(typeName, tx); return featureStore.getWriter(filter, WRITER_UPDATE | WRITER_ADD); }
/** * Returns the names of all entries or types provided by the datastore. * * <p>This method is marked final and delegates to {@link #createTypeNames()}, which subclasses * are intended to implement. * * @see DataStore#getTypeNames() */ public final String[] getTypeNames() throws IOException { List<Name> typeNames = createTypeNames(); String[] names = new String[typeNames.size()]; for (int i = 0; i < typeNames.size(); i++) { Name typeName = typeNames.get(i); names[i] = typeName.getLocalPart(); } return names; }
tb.userData( ContentDataStore.JOINED_FEATURE_TYPE, featureSource.getDataStore().getSchema(typeName)); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to retrieve the joined feature type");
throws IOException { ContentEntry entry = ensureEntry(typeName); ContentFeatureSource featureSource = createFeatureSource(entry); featureSource.setTransaction(tx);
@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; }
/** * Returns an appending feature writer for the specified type name and transaction. * * <p>This method is not intended to be overridden and is marked final. This implementation * delegates to {@link FeatureCollection} and wraps an iterator in a {@link FeatureWriter}. */ public final FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend( String typeName, Transaction tx) throws IOException { ContentFeatureStore featureStore = ensureFeatureStore(typeName, tx); FeatureWriter<SimpleFeatureType, SimpleFeature> writer = featureStore.getWriter(Filter.INCLUDE, WRITER_ADD); // ensure we are at the "end" as we are being asked to return this in "append" mode while (writer.hasNext()) { writer.next(); } return writer; }
List<Name> typeNames = createTypeNames();
/** * Delegates to {@link #getFeatureSource(Name, Transaction)} * * @since 2.5 * @see DataAccess#getFeatureSource(Name) */ public SimpleFeatureSource getFeatureSource(Name typeName) throws IOException { return getFeatureSource(typeName, Transaction.AUTO_COMMIT); }
public void dispose() { super.dispose(); if (dataSource != null && dataSource instanceof ManageableDataSource) { try { ManageableDataSource mds = (ManageableDataSource) dataSource; mds.close(); } catch (SQLException e) { // it's ok, we did our best.. LOGGER.log(Level.FINE, "Could not close dataSource", e); } } // Store the exception for logging later if the object is used after disposal if (TRACE_ENABLED) { disposedBy = new RuntimeException( "DataSource disposed by thread " + Thread.currentThread().getName()); } dataSource = null; } /**
@Override public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter( String typeName, Filter filter, Transaction tx) throws IOException { if (tx != Transaction.AUTO_COMMIT) { throw new IllegalArgumentException("Transactions not currently supported"); } return super.getFeatureWriter(typeName, filter, tx); }
/** * Delegates to {@link #getSchema(String)} with {@code name.getLocalPart()} * * @since 2.5 * @see DataAccess#getSchema(Name) */ public SimpleFeatureType getSchema(Name name) throws IOException { return getSchema(name.getLocalPart()); }
/** * Creates the entry. * * @param dataStore The datastore of the entry. * @param typeName The name of the entry. */ public ContentEntry(ContentDataStore dataStore, Name typeName) { this.typeName = typeName; this.dataStore = dataStore; this.state = new ConcurrentHashMap<Transaction, ContentState>(); //create a state for the auto commit transaction ContentState autoState = dataStore.createContentState(this); autoState.setTransaction(Transaction.AUTO_COMMIT); this.state.put(Transaction.AUTO_COMMIT, autoState); }
/** * Returns a feature writer for the specified query and transaction. * <p> * This method is not intended to be overridden and is marked final. This * implementation delegates to {@link FeatureCollection} and wraps an iterator * in a {@link FeatureWriter}. * </p> */ public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(String typeName, Filter filter, Transaction tx) throws IOException { ContentFeatureStore featureStore = ensureFeatureStore(typeName,tx); return featureStore.getWriter( filter , WRITER_UPDATE | WRITER_ADD ); }