@Override public SimpleFeatureCollection subCollection(Filter filter) { SimpleFeatureCollection delegateCollection = delegate.subCollection(filter); return new ReTypingFeatureCollection(delegateCollection, target); }
SimpleFeatureTypeBuilder.retype( sfc.getSchema(), mixed.getPropertyNames()); ReTypingFeatureCollection retyped = new ReTypingFeatureCollection(sfc, target); return (FeatureCollection) SecuredObjects.secure(retyped, policy); } else {
@Override public void addGranules(SimpleFeatureCollection granules) { try { ReTypingFeatureCollection backMapped = new ReTypingFeatureCollection(granules, delegate.getSchema()); store.addGranules(backMapped); } catch (IOException e) { throw new RuntimeException(e); } }
SimpleFeatureType ft = SimpleFeatureTypeBuilder.retype(features.getSchema(), names); if (!(ft.equals(features.getSchema()))) { features = new ReTypingFeatureCollection(features, ft);
@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); }
public void testDelegateAccepts() throws Exception { SimpleFeatureTypeBuilder stb = new SimpleFeatureTypeBuilder(); stb.setName("test"); stb.add("foo", String.class); stb.add("bar", Integer.class); UniqueVisitor vis = new UniqueVisitor("bar"); SimpleFeatureCollection delegate = createMock(SimpleFeatureCollection.class); delegate.accepts(vis, null); expectLastCall().once(); replay(delegate); ReTypingFeatureCollection rtc = new ReTypingFeatureCollection(delegate, stb.buildFeatureType()); rtc.accepts(vis, null); verify(delegate); vis = new UniqueVisitor("baz"); SimpleFeatureIterator it = createNiceMock(SimpleFeatureIterator.class); replay(it); SimpleFeatureType ft = createNiceMock(SimpleFeatureType.class); replay(ft); delegate = createMock(SimpleFeatureCollection.class); expect(delegate.features()).andReturn(it).once(); expect(delegate.getSchema()).andReturn(ft).once(); replay(delegate); rtc = new ReTypingFeatureCollection(delegate, stb.buildFeatureType()); rtc.accepts(vis, null); verify(delegate); }
collection = new ReTypingFeatureCollection(collection, harmonizedType);
new ReTypingFeatureCollection(delegate, stb.buildFeatureType()); rtc.accepts(vis, null); verify(delegate); rtc = new ReTypingFeatureCollection(delegate, stb.buildFeatureType()); rtc.accepts(vis, null); verify(delegate);
SimpleFeatureTypeBuilder.retype(schema, query.getPropertyNames()); if (!target.equals(schema)) { collection = new ReTypingFeatureCollection(collection, target);
public void testSchema() throws Exception { // see http://jira.codehaus.org/browse/GEOT-1616 SimpleFeatureType original = delegate.getSchema(); String newName = original.getTypeName() + "xxx"; SimpleFeatureTypeBuilder stb = new SimpleFeatureTypeBuilder(); stb.init(original); stb.setName(newName); SimpleFeatureType renamed = stb.buildFeatureType(); ReTypingFeatureCollection rtc = new ReTypingFeatureCollection(delegate, renamed); assertEquals(renamed, rtc.getSchema()); }
features = new ReTypingFeatureCollection(features, target);
@DescribeResult(name = "result", description = "The filtered feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features, @DescribeParameter(name = "attribute", description = "Attribute to include in output", collectionType = String.class, min = 0) List<String> attributes, @DescribeParameter(name = "filter", min = 0, description = "The filter to apply") Filter filter) throws ProcessException { // apply filtering if necessary if (filter != null && !filter.equals(Filter.INCLUDE)) { features = new FilteringSimpleFeatureCollection(features, filter); } // apply retyping if necessary if (attributes != null && attributes.size() > 0) { final String[] names = (String[]) attributes.toArray(new String[attributes.size()]); SimpleFeatureType ft = SimpleFeatureTypeBuilder.retype(features.getSchema(), names); if (!(ft.equals(features.getSchema()))) { features = new ReTypingFeatureCollection(features, ft); } } return features; }
resultFc = new ReTypingFeatureCollection(resultFc, ft);
if ( !featureType.equals( target ) ) { LOGGER.fine("Recasting feature type to subtype by using a ReTypeFeatureReader"); features = new ReTypingFeatureCollection(features, target);
public FeatureCollection getVersionedFeatures(Query query) throws IOException { final FeatureType ft = getSchema(); // check the feature type is the right one final String typeName = ft.getTypeName(); if(query.getTypeName() != null && !query.getTypeName().equals(typeName)) throw new IOException("Incompatible type, this class can access only " + typeName); // make sure the view is around if(!Arrays.asList(store.wrapped.getTypeNames()).contains(store.getVFCViewName(typeName))) store.createVersionedFeatureCollectionView(typeName); // we have to hit the view DefaultQuery vq = new DefaultQuery(query); vq.setTypeName(VersionedPostgisDataStore.getVFCViewName(typeName)); vq = store.buildVersionedQuery(vq); FeatureCollection fc = store.wrapped.getFeatureSource(VersionedPostgisDataStore.getVFCViewName(typeName)).getFeatures(vq); try { final FeatureType fcSchema = fc.getSchema(); FeatureType renamedFt = FeatureTypes.newFeatureType(fcSchema.getAttributeTypes(), ft.getTypeName(), ft.getNamespace(), ft.isAbstract(), ft.getAncestors(), fcSchema.getDefaultGeometry()); return new ReTypingFeatureCollection(fc, renamedFt); } catch(SchemaException e) { throw new DataSourceException("Error ranming feature type", e); } }
.getPropertyNames()); if (!target.equals(schema)) { collection = new ReTypingFeatureCollection(collection, target);
features = new ReTypingFeatureCollection(features, target);
FeatureCollection rfc = new ReTypingFeatureCollection(fc, targetFeatureType);