Hello,
i tested out today the vendor parameter support, but, it does not seem
to work for me for 1.1.0, just for 1.0.0.
In the geoserver log, the metadata is null for 1.1.0, but contains valid values
(metadata = {GS_SQL_VIEW_PARAMS=[{ID=2}]}) in a case of 1.0.0. Also
for 1.0.0 the result is ok.
Test code is the following:
(replace url with
http://localhost:8080/geoserver/wfs?request=GetCapabilities&VERSION=1.1.0
to test with
1.1.0)
Any idea?
Thanks,
Zsolti
public class WFSViewDemo {
public static void main(String[] args){
// Datastore
//--------------
URL url = null;
try {
url = new URL(
"http://localhost:8080/geoserver/wfs?request=GetCapabilities&VERSION=1.0.0");
} catch (MalformedURLException e) {
e.printStackTrace();
}
Map<String,Serializable> params = new HashMap<String,Serializable>();
params.put(WFSDataStoreFactory.URL.key, url);
params.put(WFSDataStoreFactory.TIMEOUT.key, new Integer(60000));
params.put(WFSDataStoreFactory.MAXFEATURES.key, new Integer(200000));
params.put(WFSDataStoreFactory.WFS_STRATEGY.key, "geoserver");
DataStore store = null;
try {
store = DataStoreFinder.getDataStore(params);
} catch (IOException e) {
e.printStackTrace();
}
//Layername
//----------------
String typeName = "cite:address";
//WFS Layer
FeatureSource<? extends FeatureType, ? extends Feature>
featureSource = null;
try {
featureSource = store.getFeatureSource(typeName);
System.out.println(typeName);
} catch (IOException e) {
e.printStackTrace();
}
//Query
Map<String, String> vparams = new HashMap<String, String>();
vparams.put("viewparams", "id:2");
Hints hints = new Hints(WFSDataStore.WFS_VENDOR_PARAMETERS,vparams);
Query query = new Query("cite:address");
query.setHints(hints);
//Size of Feature Collection
try {
FeatureCollection<? extends FeatureType, ? extends Feature>
list = featureSource.getFeatures(query);
FeatureIterator<? extends Feature> iterator = list.features();
while (iterator.hasNext()){
Feature f = iterator.next();
System.out.println(f);
}
System.out.println(list.size());
} catch (IOException e) {
e.printStackTrace();
}
}
}
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
GeoTools-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel