String[] queriedAtts = query.getPropertyNames(); int queriedAttCount = queriedAtts.length; List allowedAtts = new LinkedList();
((SimpleFeatureStore) storeDelegate).modifyFeatures(names, values, filter); } else if (writeQuery.getFilter() == Filter.EXCLUDE || writeQuery.getPropertyNames() == Query.NO_NAMES) { throw unsupportedOperation(); Query mixed = mixQueries(local, writeQuery); if (writeQuery.getPropertyNames() == Query.ALL_NAMES) { new HashSet<String>(Arrays.asList(writeQuery.getPropertyNames()));
return; } else if (writeQuery.getFilter() == Filter.EXCLUDE || writeQuery.getPropertyNames() == Query.NO_NAMES) { throw unsupportedOperation(); Query mixed = mixQueries(local, writeQuery); if (writeQuery.getPropertyNames() == Query.ALL_NAMES) { new HashSet<String>(Arrays.asList(writeQuery.getPropertyNames()));
/** * * Takes into account eventual joins * * @param query * @return */ public SimpleFeatureType getFeatureType(Query query) { SimpleFeatureType result; if (query.getPropertyNames() != Query.ALL_NAMES) { result = SimpleFeatureTypeBuilder.retype(featureType, query.getPropertyNames()); } else { result = featureType; } // add back the joined features in case of join if (!query.getJoins().isEmpty()) { SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.init(result); for (Join join : query.getJoins()) { String joinedFeatureAttribute = join.getAlias(); if (joinedFeatureAttribute == null) { joinedFeatureAttribute = join.getTypeName(); } tb.add(joinedFeatureAttribute, SimpleFeature.class); } result = tb.buildFeatureType(); } return result; }
return; } else if (writeQuery.getFilter() == Filter.EXCLUDE || writeQuery.getPropertyNames() == Query.NO_NAMES) { throw unsupportedOperation(); Query mixed = mixQueries(local, writeQuery); if (writeQuery.getPropertyNames() == Query.ALL_NAMES) { new HashSet<String>(Arrays.asList(writeQuery.getPropertyNames()));
if (query.getPropertyNames() == Query.ALL_NAMES) { return ft; SimpleFeatureType sft = (SimpleFeatureType) ft; Set<String> properties = new HashSet<String>(Arrays.asList(query.getPropertyNames())); SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.init(sft);
public void removeFeatures(Filter filter) throws IOException { // are we limiting anything? Query writeQuery = getWriteQuery(policy); if (writeQuery == Query.ALL) { storeDelegate.removeFeatures(filter); } else if (writeQuery.getFilter() == Filter.EXCLUDE || writeQuery.getPropertyNames() == Query.NO_NAMES) { throw unsupportedOperation(); } // get the mixed filter final Query local = new Query(null, filter); Query mixed = mixQueries(local, writeQuery); storeDelegate.removeFeatures(mixed.getFilter()); }
|| writeQuery.getPropertyNames() == Query.NO_NAMES) { throw unsupportedOperation(); } else if (writeQuery == Query.ALL) { if (writeQuery.getPropertyNames() == Query.ALL_NAMES) { return storeDelegate.addFeatures(collection); } else { List<String> writableAttributes = Arrays.asList(writeQuery.getPropertyNames()); CheckAttributesFeatureCollection checker = new CheckAttributesFeatureCollection(
SimpleFeatureType target = SimpleFeatureTypeBuilder.retype( sfc.getSchema(), mixed.getPropertyNames()); ReTypingFeatureCollection retyped = new ReTypingFeatureCollection(sfc, target); return (FeatureCollection) SecuredObjects.secure(retyped, policy);
/** * Creates a sub-schema with only the selected attributes * * @param schema * @param query * @return */ static SimpleFeatureType retypeSchema(SimpleFeatureType schema, Query query) { if (query.getPropertyNames() == Query.ALL_NAMES) { return schema; } else { return SimpleFeatureTypeBuilder.retype(schema, query.getPropertyNames()); } }
SimpleFeatureType getResultSchema(Query q) { if (q.getPropertyNames() == null) { return getSchema(); } else { return SimpleFeatureTypeBuilder.retype(getSchema(), q.getPropertyNames()); } }
boolean isSubQuery(Query query) { // no cached data? if (cachedQuery == null) return false; // do we miss some properties? String[] cachedPropNames = cachedQuery.getPropertyNames(); String[] propNames = query.getPropertyNames(); if (cachedPropNames != Query.ALL_NAMES && (propNames == Query.ALL_NAMES || !Arrays.asList(cachedPropNames).containsAll(Arrays.asList(propNames)))) return false; Filter[] filters = splitFilters(query); Filter[] cachedFilters = splitFilters(cachedQuery); if (!filters[0].equals(cachedFilters[0])) return false; Envelope envelope = getEnvelope(filters[1]); return cachedBounds.contains(envelope); }
@Override public SimpleFeatureCollection getGranules(Query q) throws IOException { Query renamed = renameQuery(q); SimpleFeatureCollection granules = delegate.getGranules(renamed); SimpleFeatureType targetSchema = this.schema; if (q.getPropertyNames() != Query.ALL_NAMES) { targetSchema = SimpleFeatureTypeBuilder.retype(schema, q.getPropertyNames()); } return new ReTypingFeatureCollection(granules, targetSchema); }
private SimpleFeatureCollection getFeatureCollection(Query query, Envelope bounds) throws IOException { try { SimpleFeatureType base = wrapped.getSchema(); SimpleFeatureType alternate = base; if (query.getPropertyNames() != Query.ALL_NAMES) { alternate = SimpleFeatureTypeBuilder.retype(base, query.getPropertyNames()); if (alternate.equals(base)) alternate = base; } return new CachingFeatureCollection(bounds, base, alternate, query); } catch (Exception e) { throw new DataSourceException( "Error occurred extracting features from the spatial index", e); } }
SimpleFeatureType getReadSchema(Query q) { if (q.getPropertyNames() == Query.ALL_NAMES) { return getSchema(); } // Step 1: start with requested property names LinkedHashSet<String> attributes = new LinkedHashSet<String>(); attributes.addAll(Arrays.asList(q.getPropertyNames())); Filter filter = q.getFilter(); if (filter != null && !Filter.INCLUDE.equals(filter)) { // Step 2: Add query attributes (if needed) // Step 3: Fill empty XPath with appropriate property names FilterAttributeExtractor fat = new AbsoluteAttributeExtractor(getSchema()); filter.accept(fat, null); attributes.addAll(fat.getAttributeNameSet()); } return SimpleFeatureTypeBuilder.retype(getSchema(), new ArrayList<String>(attributes)); }
private SimpleFeatureSource getFeatureSourceFor(Query query) throws IOException { Double distance = getRequestedDistance(query); String geomPropertyName = info.getGeomPropertyName(); // the geometry for which we have // generalizations String[] queryProperyNames = query.getPropertyNames(); if (queryProperyNames != null) { for (String prop : queryProperyNames) { // check if geom property name was specified in // the query if (prop.equals(geomPropertyName)) return getFeatureSourceFor(distance); } } else { // we have Query.ALL return getFeatureSourceFor(distance); } // no geometry in the query for which generalizations are present. return getBaseFeatureSource(); }
/** * Hashcode based on all parameters other than the handle. * * @return hascode for this Query */ @Override public int hashCode() { String[] n = getPropertyNames(); return ((n == null) ? (-1) : ((n.length == 0) ? 0 : (n.length | n[0].hashCode()))) | getMaxFeatures() | ((getFilter() == null) ? 0 : getFilter().hashCode()) | ((getTypeName() == null) ? 0 : getTypeName().hashCode()) | ((getVersion() == null) ? 0 : getVersion().hashCode()) | ((getCoordinateSystem() == null) ? 0 : getCoordinateSystem().hashCode()) | ((getCoordinateSystemReproject() == null) ? 0 : getCoordinateSystemReproject().hashCode()) | getStartIndex(); }
/** * Configure expected * * @param origional * @param query * @return */ public static SimpleFeatureType retype(SimpleFeatureType origional, Query query) { CoordinateReferenceSystem crs = null; if (query.getCoordinateSystem() != null) { crs = query.getCoordinateSystem(); } if (query.getCoordinateSystemReproject() != null) { crs = query.getCoordinateSystemReproject(); } return retype(origional, query.getPropertyNames(), crs); }
public SimpleFeatureType getQueryType(Query query) throws IOException { final String typeName = query.getTypeName(); final String propertyNames[] = query.getPropertyNames(); final FeatureTypeInfo typeInfo = typeInfoCache.getFeatureTypeInfo(typeName); final SimpleFeatureType completeSchema = typeInfo.getFeatureType(); SimpleFeatureType featureType = completeSchema; if (!query.retrieveAllProperties() || query.getCoordinateSystem() != null) { try { featureType = DataUtilities.createSubType( featureType, propertyNames, query.getCoordinateSystem()); } catch (SchemaException e) { LOGGER.log(Level.FINEST, e.getMessage(), e); throw new DataSourceException("Could not create Feature Type for query", e); } } return featureType; }
/** Get features based on the query specified. */ @Override public FeatureCollection<FeatureType, Feature> getFeatures(Query query) throws IOException { GetFeatureRequest request = client.createGetFeatureRequest(); FeatureType schema = dataAccess.getSchema(typeName); QName name = dataAccess.getRemoteTypeName(typeName); request.setTypeName(new QName(query.getTypeName())); request.setFullType(schema); request.setFilter(query.getFilter()); request.setPropertyNames(query.getPropertyNames()); request.setSortBy(query.getSortBy()); String srsName = null; request.setSrsName(srsName); return new WFSContentComplexFeatureCollection(request, schema, name); }