List<PropertyName> userProperties = userQuery.getProperties(); if (userProperties == null) { result.setProperties(securityProperties); } else { for (PropertyName pn : userProperties) { result.setProperties(userProperties);
Query q = new Query(nativeQuery); if (nativeProperties == Query.ALL_PROPERTIES) { q.setProperties(new ArrayList<>(sortProperties)); } else { List<PropertyName> allProperties = new ArrayList<>(nativeProperties); q.setProperties(allProperties);
private void buildIndexQuery() { Query idsQuery = new Query(query); idsQuery.setFilter(buildIndexFilter()); idsQuery.setProperties(Query.NO_PROPERTIES); indexQuery = idsQuery; }
/** * Convert query to retrieve only id field, no other fields * * @return converted Query */ protected Query transformQueryToIdsOnly() { Query idsQuery = new Query(unrollIndexes(query)); idsQuery.setProperties(getIndexQueryProperties()); idsQuery.setTypeName(mapping.getIndexSource().getSchema().getTypeName()); return idsQuery; }
targetQuery.setProperties(null);
/** * Build the query for execute on index source partial Implementation manages pagination by * itself, so remove bounds from query * * @return Query */ @Override protected Query transformQueryToIdsOnly() { Query idsQuery = new Query(unrollIndexes(partialIQM.getIndexQuery())); idsQuery.setProperties(getIndexQueryProperties()); idsQuery.setTypeName(mapping.getIndexSource().getSchema().getTypeName()); idsQuery.setStartIndex(null); idsQuery.setMaxFeatures(Integer.MAX_VALUE); return idsQuery; }
/** Test of set/getProperties method, of class org.geotools.data.Query. */ public void testProperties() { final FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); // System.out.println("testProperties"); Query query = new Query(); assertNull(query.getProperties()); List<PropertyName> properties = new ArrayList<PropertyName>(); NamespaceSupport nsContext = new NamespaceSupport(); nsContext.declarePrefix("foo", "FooNamespace"); PropertyName fooProp = ff.property("foo", nsContext); PropertyName barProp = ff.property("bar", nsContext); properties.add(fooProp); properties.add(barProp); query.setProperties(properties); List<PropertyName> properties2 = query.getProperties(); assertNotNull(properties); assertEquals(fooProp, properties2.get(0)); assertEquals(barProp, properties2.get(1)); assertEquals(nsContext, properties2.get(0).getNamespaceContext()); // test compatibility with getPropertyNames method String[] names = query.getPropertyNames(); assertEquals("foo", names[0]); assertEquals("bar", names[1]); query.setProperties(Query.ALL_PROPERTIES); assertNull(query.getProperties()); query = new Query("Test", Filter.INCLUDE, properties); assertNotNull(query.getProperties()); }
/** Test of retrieveAllProperties method, of class org.geotools.data.Query. */ public void testRetrieveAllProperties() { // System.out.println("testRetrieveAllProperties"); Query query = new Query(); assertTrue(query.retrieveAllProperties()); query.setPropertyNames(new String[] {"foo", "bar"}); assertFalse(query.retrieveAllProperties()); query.setPropertyNames(Query.ALL_NAMES); assertTrue(query.retrieveAllProperties()); query.setProperties(Query.ALL_PROPERTIES); assertTrue(query.retrieveAllProperties()); query.setPropertyNames(new String[] {"foo", "bar"}); query.setProperties(Query.ALL_PROPERTIES); assertTrue(query.retrieveAllProperties()); }
query.setProperties(selectedProperties);
query.setProperties(attributes); processRuleForQuery(styleList, query); query.setProperties(attributes); Envelope bounds = source.getBounds(); if (bounds != null && envelope.intersects(bounds)) {
targetQuery.setProperties(null);
properties.add(propertyName1); Query query = new Query(); query.setProperties(properties); query.setProperties(properties);
newQuery.setTypeName(name); newQuery.setFilter(unrolledFilter); newQuery.setProperties(propNames); newQuery.setCoordinateSystem(query.getCoordinateSystem()); newQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject());
private Query namedQuery(Query query) { Query namedQuery = namedQuery( query.getFilter(), query.getMaxFeatures(), query instanceof JoiningQuery); namedQuery.setProperties(query.getProperties()); namedQuery.setCoordinateSystem(query.getCoordinateSystem()); namedQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject()); namedQuery.setHandle(query.getHandle()); namedQuery.setMaxFeatures(query.getMaxFeatures()); namedQuery.setStartIndex(query.getStartIndex()); namedQuery.setSortBy(query.getSortBy()); namedQuery.setHints(query.getHints()); if (query instanceof JoiningQuery) { ((JoiningQuery) namedQuery).setQueryJoins(((JoiningQuery) query).getQueryJoins()); ((JoiningQuery) namedQuery).setRootMapping(((JoiningQuery) query).getRootMapping()); } return namedQuery; }
@GetMapping( path = "{collection}/ogcLinks", produces = {MediaType.APPLICATION_JSON_VALUE} ) @ResponseBody public OgcLinks getCollectionOgcLinks( HttpServletRequest request, @PathVariable(name = "collection", required = true) String collection) throws IOException { // query one collection and grab its OGC links Feature feature = queryCollection( collection, q -> { q.setProperties( Collections.singletonList( FF.property(OpenSearchAccess.OGC_LINKS_PROPERTY_NAME))); }); OgcLinks links = buildOgcLinksFromFeature(feature, true); return links; }
@GetMapping( path = "{collection}/layer", produces = {MediaType.APPLICATION_JSON_VALUE} ) @ResponseBody public CollectionLayer getCollectionLayer( HttpServletRequest request, @PathVariable(name = "collection", required = true) String collection) throws IOException { // query one collection and grab its OGC links final Name layerPropertyName = getCollectionLayerPropertyName(); final PropertyName layerProperty = FF.property(layerPropertyName); Feature feature = queryCollection( collection, q -> { q.setProperties(Collections.singletonList(layerProperty)); }); CollectionLayer layer = buildCollectionLayerFromFeature(feature, true); return layer; }
private CollectionLayer getCollectionLayer(String collection) throws IOException { final Name layerPropertyName = getCollectionLayerPropertyName(); final PropertyName layerProperty = FF.property(layerPropertyName); Feature feature = queryCollection( collection, q -> { q.setProperties(Collections.singletonList(layerProperty)); }); CollectionLayer layer = buildCollectionLayerFromFeature(feature, false); return layer; }
@Override public FeatureCollection getFeatures(Query query) throws IOException { Query q = new Query(query); if (propertyNames == null || propertyNames.length == 0) { // no property selection, we return them all q.setProperties(Query.ALL_PROPERTIES); } else { // properties got selected, mix them with the ones needed by the renderer if (query.getPropertyNames() == null || query.getPropertyNames().length == 0) { q.setPropertyNames(propertyNames); } else { Set<String> names = new LinkedHashSet<>(Arrays.asList(propertyNames)); names.addAll(Arrays.asList(q.getPropertyNames())); String[] newNames = names.toArray(new String[names.size()]); q.setPropertyNames(newNames); } } return super.getFeatures(q); } }
private Query namedQuery(Query query) { Query namedQuery = namedQuery(query.getFilter(), query.getMaxFeatures(), query instanceof JoiningQuery); namedQuery.setProperties(query.getProperties()); namedQuery.setCoordinateSystem(query.getCoordinateSystem()); namedQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject()); namedQuery.setHandle(query.getHandle()); namedQuery.setMaxFeatures(query.getMaxFeatures()); namedQuery.setSortBy(query.getSortBy()); namedQuery.setHints(query.getHints()); if (query instanceof JoiningQuery) { ((JoiningQuery) namedQuery).setQueryJoins(((JoiningQuery) query).getQueryJoins()); } return namedQuery; }
@Test public void testCollectionLayerRemoval() throws Exception { // read it FeatureStore<FeatureType, Feature> store = (FeatureStore<FeatureType, Feature>) osAccess.getCollectionSource(); Query q = new Query(); q.setProperties(Arrays.asList(FF.property(LAYER_NAME))); final PropertyIsEqualTo filter = FF.equal( FF.property(new NameImpl(OpenSearchAccess.EO_NAMESPACE, "identifier")), FF.literal("SENTINEL2"), false); q.setFilter(filter); // update the feature to remove the layer information store.modifyFeatures(new Name[] {LAYER_NAME}, new Object[] {null}, filter); // read it back and check it's not set Feature collection = DataUtilities.first(store.getFeatures(q)); assertNotNull(collection); Property layerProperty = collection.getProperty(LAYER_NAME); assertNull(layerProperty); } }