@Override public Object getProperty(Object object, QName name) throws Exception { if (GML.featureMember.equals(name)) { FeatureCollectionType fc = (FeatureCollectionType) object; if (fc.getFeature().size() == 1 && fc.getFeature().get(0) instanceof SimpleFeatureCollection && encoder.getConfiguration() .hasProperty(GMLConfiguration.OPTIMIZED_ENCODING)) { return new GML2FeatureCollectionEncoderDelegate( (SimpleFeatureCollection) fc.getFeature().get(0), encoder); } } return super.getProperty(object, name); }
/** * Allows subclasses to alter the result generation * @param count * @param results * @param lockId * @return */ protected FeatureCollectionType buildResults(int count, List results, String lockId) { VersionedFeatureCollectionType result = WfsvFactory.eINSTANCE.createVersionedFeatureCollectionType(); result.setNumberOfFeatures(BigInteger.valueOf(count)); result.setTimeStamp(Calendar.getInstance()); result.setLockId(lockId); result.getFeature().addAll(results); result.setVersion("xxx"); return result; }
@SuppressWarnings({"unchecked", "rawtypes"}) private FeatureCollectionType buildResults(List<FeatureCollection> results) { FeatureCollectionType result = WfsFactory.eINSTANCE.createFeatureCollectionType(); result.setTimeStamp(Calendar.getInstance()); result.getFeature().addAll(results); return result; }
@Override public Object unadapt(Class target) { if (target.equals(FeatureCollectionType.class)) { return adaptee; } else if (target.equals(net.opengis.wfs20.FeatureCollectionType.class)) { FeatureCollectionType source = (FeatureCollectionType) adaptee; net.opengis.wfs20.FeatureCollectionType result = Wfs20Factory.eINSTANCE.createFeatureCollectionType(); result.getMember().addAll(source.getFeature()); result.setNumberReturned(source.getNumberOfFeatures()); result.setLockId(source.getLockId()); result.setTimeStamp(source.getTimeStamp()); return result; } else { throw new WFSException( "Cannot transform " + adaptee + " to the specified target class " + target); } } }
result.getFeature().add(logs); result.setNumberOfFeatures(BigInteger.valueOf(residual)); result.setTimeStamp(Calendar.getInstance());
@Override public Object getProperty(Object object, QName name) throws Exception { if (GML.featureMember.equals(name)) { FeatureCollectionType fc = (FeatureCollectionType) object; if (fc.getFeature().size() == 1 && fc.getFeature().get(0) instanceof SimpleFeatureCollection && encoder.getConfiguration() .hasProperty(GMLConfiguration.OPTIMIZED_ENCODING)) { return new GML3FeatureCollectionEncoderDelegate( (SimpleFeatureCollection) fc.getFeature().get(0), encoder); } } return super.getProperty(object, name); } }
@Override public Object unadapt(Class target) { if (target.equals(net.opengis.wfs20.FeatureCollectionType.class)) { return adaptee; } else if (target.equals(FeatureCollectionType.class)) { net.opengis.wfs20.FeatureCollectionType source = (net.opengis.wfs20.FeatureCollectionType) adaptee; FeatureCollectionType result = WfsFactory.eINSTANCE.createFeatureCollectionType(); result.getFeature().addAll(source.getMember()); result.setNumberOfFeatures(source.getNumberReturned()); result.setLockId(source.getLockId()); result.setTimeStamp(source.getTimeStamp()); return result; } else { throw new WFSException( "Cannot transform " + adaptee + " to the specified target class " + target); } } }
@Override public Object getProperty(Object object, QName name) throws Exception { FeatureCollectionType fc = (FeatureCollectionType) object; if (!fc.getFeature().isEmpty()) { Object val = WFSParsingUtils.FeatureCollectionType_getProperty(fc, name); if (val != null) { return val; } } return super.getProperty(object, name); }
for (Object entry : collectionType.getFeature()) { SimpleFeatureCollection collection = toFeatureCollection(entry); if (entry != null) {
featureCollectionType.getFeature().add(collection); featureCollectionType.getFeature().add(collection);
@Override public Object getProperty(Object object, QName name) throws Exception { FeatureCollectionType fc = (FeatureCollectionType) object; if ( !fc.getFeature().isEmpty() ) { Object val = WFSParsingUtils.FeatureCollectionType_getProperty(fc, name); if (val != null) { return val; } } return super.getProperty(object, name); }
private Object handleFeatureCollection(FeatureCollectionType featureCollection) { FeatureCollection result = null; if (featureCollection.getFeature().size() > 1) { // wrap in a single result = new CompositeFeatureCollection(featureCollection.getFeature()); } else { // just return the single result = (FeatureCollection) featureCollection.getFeature().iterator().next(); } if (isSimpleFeatureCollection(result) && encoder.getConfiguration().hasProperty(GMLConfiguration.OPTIMIZED_ENCODING)) { return new GML3FeatureCollectionEncoderDelegate( (SimpleFeatureCollection) result, encoder); } else { return result; } }
public void write(Object value, OutputStream output, Operation operation) throws IOException, ServiceException { FeatureCollectionType fct = (FeatureCollectionType) value; FeatureCollection fc = (FeatureCollection) fct.getFeature().get(0); // setup template subsystem GeoServerTemplateLoader templateLoader = new GeoServerTemplateLoader(getClass()); templateLoader.setFeatureType(fc.getSchema()); Template template = null; synchronized (templateConfig) { templateConfig.setTemplateLoader(templateLoader); template = templateConfig.getTemplate("wfsvGetLog.ftl"); } try { template.setOutputEncoding("UTF-8"); template.process(fc, new OutputStreamWriter(output, Charset.forName("UTF-8"))); } catch (TemplateException e) { String msg = "Error occured processing template."; throw (IOException) new IOException(msg).initCause(e); } } }
public void write(Object value, OutputStream output, Operation getFeature) throws ServiceException, IOException { VersionedFeatureCollectionType results = (VersionedFeatureCollectionType) value; List featureCollections = results.getFeature();
public void testSimpleMIF() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-MIF"); ogr.write(fct, bos, op); // read back ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(bos.toByteArray())); // we should get two files at least, a .mif and a .mid Set<String> fileNames = new HashSet<String>(); ZipEntry entry = null; while((entry = zis.getNextEntry()) != null) { fileNames.add(entry.getName()); } assertTrue(fileNames.contains("Buildings.mif")); assertTrue(fileNames.contains("Buildings.mid")); }
if (!featureCollection.getFeature().isEmpty()) { return handleFeatureCollection(featureCollection); if (!featureCollection.getFeature().isEmpty()) { return handleFeatureCollection(featureCollection); for (Iterator it = featureCollection.getFeature().iterator(); it.hasNext(); ) { FeatureCollection fc = (FeatureCollection) it.next(); if (env == null) {
List<FeatureCollection> collections = results.getFeature(); if (collections.size() == 1) { header =
@Override public void encode(Object object, ContentHandler handler) throws Exception { FeatureCollection features = (FeatureCollection) object; SimpleFeatureType featureType = (SimpleFeatureType) features.getSchema(); FeatureCollectionType fc = WfsFactory.eINSTANCE.createFeatureCollectionType(); fc.getFeature().add(features); Encoder e = new Encoder(configuration); e.getNamespaces().declarePrefix("feature", featureType.getName().getNamespaceURI()); e.encode(fc, getElement(), handler); }
@Test public void testSimpleMIF() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-MIF"); ogr.write(fct, bos, op); // read back ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(bos.toByteArray())); // we should get two files at least, a .mif and a .mid Set<String> fileNames = new HashSet<String>(); ZipEntry entry = null; while ((entry = zis.getNextEntry()) != null) { fileNames.add(entry.getName()); } assertTrue(fileNames.contains("Buildings.mif")); assertTrue(fileNames.contains("Buildings.mid")); }
final List collections = results.getFeature(); final int size = collections.size(); FeatureCollection fr;