public void watch(WFSContentState localState) { Name typeName = localState.getEntry().getName(); localStates.put(typeName, localState); } }
/** * Access MemoryState for typeName. * * <p>Technically this is accessing the MemoryState for {@link Transaction#AUTO_COMMIT}, which * is the definitive storage for the feature content. * * @param typeName * @return MemoryState storing feature (by FeatureID) * @throws IOException If typeName cannot be found */ protected MemoryEntry entry(String typeName) throws IOException { synchronized (entries) { for (ContentEntry entry : this.entries.values()) { if (entry.getName().getLocalPart().equals(typeName)) { return (MemoryEntry) entry; } } } throw new IOException("Type name " + typeName + " not found"); }
@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; }
public QName getRemoteTypeName() throws IOException { Name localTypeName = getEntry().getName(); QName remoteTypeName = getDataStore().getRemoteTypeName(localTypeName); return remoteTypeName; }
/** * @see WFSFeatureSource * @see WFSFeatureStore * @see WFSClient#supportsTransaction(QName) * @see * org.geotools.data.store.ContentDataStore#createFeatureSource(org.geotools.data.store.ContentEntry) */ @Override protected ContentFeatureSource createFeatureSource(final ContentEntry entry) throws IOException { ContentFeatureSource source; if (!isStoredQuery(entry.getName())) { final QName remoteTypeName = getRemoteTypeName(entry.getName()); source = new WFSFeatureSource(entry, client); if (client.supportsTransaction(remoteTypeName)) { source = new WFSFeatureStore((WFSFeatureSource) source); } } else { String storedQueryId = configuredStoredQueries.get(entry.getName().getLocalPart()); StoredQueryDescriptionType desc = getStoredQueryDescriptionType(storedQueryId); source = new WFSStoredQueryFeatureSource(entry, client, desc); } return source; }
@Override public void removeSchema(Name typeName) throws IOException { // check file ContentEntry entry = ensureEntry(typeName); org.geotools.data.shapefile.files.FileWriter writer = new org.geotools.data.shapefile.files.FileWriter() { @Override public String id() { return "TheShapefileRemover"; } }; for (ShpFileType type : ShpFileType.values()) { File file = shpFiles.acquireWriteFile(type, writer); try { if (file.exists()) { if (!file.delete()) { throw new IOException("Failed to delete " + file.getAbsolutePath()); } } } finally { shpFiles.unlockWrite(file, writer); } } removeEntry(entry.getName()); } }
@Override protected SimpleFeatureType buildFeatureType() throws IOException { SimpleFeatureType type = mapper.buildFeatureType(entry.getName(), collection); getDataStore().getSchemaStore().storeSchema(type); return type; }
@Override protected SimpleFeatureType buildFeatureType() throws IOException { String typeName = getEntry().getTypeName(); String namespace = getEntry().getName().getNamespaceURI(); String typeSpec = property("_"); try { return DataUtilities.createType(namespace, typeName, typeSpec); } catch (SchemaException e) { java.util.logging.Logger.getGlobal().log(java.util.logging.Level.INFO, "", e); throw new DataSourceException(typeName + " schema not available", e); } }
String tableName = entry.getName().getLocalPart(); if (virtualTables.containsKey(tableName)) { VirtualTable vt = virtualTables.get(tableName);
@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)); }
@Override protected SimpleFeatureType buildFeatureType() throws IOException { final WFSDataStore dataStore = getDataStore(); final Name localTypeName = getEntry().getName(); final QName remoteTypeName = dataStore.getRemoteTypeName(localTypeName); final SimpleFeatureType remoteSimpleFeatureType; remoteSimpleFeatureType = dataStore.getRemoteSimpleFeatureType(remoteTypeName); // adapt the feature type name SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.init(remoteSimpleFeatureType); builder.setName(localTypeName); String namespaceOverride = entry.getName().getNamespaceURI(); if (namespaceOverride != null) { builder.setNamespaceURI(namespaceOverride); } GeometryDescriptor defaultGeometry = remoteSimpleFeatureType.getGeometryDescriptor(); if (defaultGeometry != null) { builder.setDefaultGeometry(defaultGeometry.getLocalName()); builder.setCRS(defaultGeometry.getCoordinateReferenceSystem()); } final SimpleFeatureType adaptedFeatureType = builder.buildFeatureType(); return adaptedFeatureType; }
@Override protected SimpleFeatureType buildFeatureType() throws IOException { List<AttributeDescriptor> types = readAttributes(); SimpleFeatureType parent = null; GeometryDescriptor geomDescriptor = (GeometryDescriptor) types.get(0); Class<?> geomBinding = geomDescriptor.getType().getBinding(); if ((geomBinding == Point.class) || (geomBinding == MultiPoint.class)) { parent = BasicFeatureTypes.POINT; } else if ((geomBinding == Polygon.class) || (geomBinding == MultiPolygon.class)) { parent = BasicFeatureTypes.POLYGON; } else if ((geomBinding == LineString.class) || (geomBinding == MultiLineString.class)) { parent = BasicFeatureTypes.LINE; } SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setDefaultGeometry(geomDescriptor.getLocalName()); builder.addAll(types); builder.setName(entry.getName()); builder.setAbstract(false); if (parent != null) { builder.setSuperType(parent); } return builder.buildFeatureType(); }
ContentFeatureStore store; ContentEntry entry = state.getEntry(); Name name = entry.getName(); ContentDataStore dataStore = entry.getDataStore(); ContentFeatureSource source = (ContentFeatureSource) dataStore.getFeatureSource(name);
/** * Overrides {@link ContentFeatureSource#getName()} to restore back the original meaning of * {@link FeatureSource#getName()} */ public @Override Name getName() { return getEntry().getName(); }
/** * Overrides {@link ContentFeatureSource#getName()} to restore back the original meaning of * {@link FeatureSource#getName()} */ @Override public Name getName() { return getEntry().getName(); }
public void watch(WFSContentState localState) { Name typeName = localState.getEntry().getName(); localStates.put(typeName, localState); } }
protected GetFeatureRequest createGetFeature(Query query, ResultType resultType) throws IOException { GetFeatureRequest request = client.createGetFeatureRequest(); final WFSDataStore dataStore = getDataStore(); final QName remoteTypeName = dataStore.getRemoteTypeName(getEntry().getName()); final SimpleFeatureType remoteSimpleFeatureType; remoteSimpleFeatureType = dataStore.getRemoteSimpleFeatureType(remoteTypeName); request.setTypeName(remoteTypeName); request.setFullType(remoteSimpleFeatureType); invertAxisInFilterIfNeeded(query, remoteSimpleFeatureType); request.setFilter(query.getFilter()); request.setResultType(resultType); request.setHints(query.getHints()); int maxFeatures = query.getMaxFeatures(); if (Integer.MAX_VALUE > maxFeatures) { request.setMaxFeatures(maxFeatures); } // let the request decide request.setOutputFormat(outputFormat); request.setPropertyNames(query.getPropertyNames()); request.setSortBy(query.getSortBy()); String srsName = getSupportedSrsName(request, query); request.setSrsName(srsName); return request; }
@Override protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException { ContentEntry type = ensureEntry(entry.getName()); return new SolrFeatureSource(type, defaultFeatureTypes); }
private void setSourceIncludes(final ElasticRequest searchRequest) throws IOException { final ElasticDataStore dataStore = getDataStore(); final List<ElasticAttribute> attributes = dataStore.getElasticAttributes(entry.getName()); for (final ElasticAttribute attribute : attributes) { if (attribute.isUse() && attribute.isStored()) { searchRequest.addField(attribute.getName()); } else if (attribute.isUse()) { searchRequest.addSourceInclude(attribute.getName()); } } }