GeoReportEngineInstance engineInstance;
IDataSet dataSet;
IDataStore dataStore;
IDataStoreMetaData dataStoreMeta;
logger.debug("IN");
try {
featureSourceType = servletIOManager.getParameterAsString(FEATURE_SOURCE_TYPE);
logger.debug("Parameter [" + FEATURE_SOURCE_TYPE + "] is equal to [" + featureSourceType + "]");
featureSource = servletIOManager.getParameterAsString(FEATURE_SOURCE);
logger.debug("Parameter [" + FEATURE_SOURCE + "] is equal to [" + featureSourceType + "]");
layerName = servletIOManager.getParameterAsString(LAYER_NAME);
logger.debug("Parameter [" + LAYER_NAME + "] is equal to [" + layerName + "]");
businessIdPName = servletIOManager.getParameterAsString(BUSINESSID_PNAME);
logger.debug("Parameter [" + BUSINESSID_PNAME + "] is equal to [" + businessIdPName + "]");
geoIdPName = servletIOManager.getParameterAsString(GEOID_PNAME);
logger.debug("Parameter [" + GEOID_PNAME + "] is equal to [" + geoIdPName + "]");
engineInstance = (GeoReportEngineInstance)servletIOManager.getHttpSession().getAttribute(EngineConstants.ENGINE_INSTANCE);
//DataSet
dataSet = engineInstance.getDataSet();
dataSet.setParamsMap(engineInstance.getEnv());
dataSet.loadData();
//Datastore
dataStore = dataSet.getDataStore();
dataStoreMeta = dataStore.getMetaData();
// # COL NUMBER
int nc = dataStoreMeta.getFieldCount();
//Create Output Collection of Features
Collection outputFeatureCollection = new ArrayList();
// used to avoid multiple creation of the same geographical feature
Set geoIdPValues = new HashSet();
// for each row
Iterator it = dataStore.iterator();
IFeaturesProviderDAO featuresProvider = FeaturesProviderDAOFactory.getFeaturesProviderDAO(featureSourceType);
while(it.hasNext()) {
IRecord record = (IRecord)it.next();
IField field;
field = record.getFieldAt( dataStoreMeta.getFieldIndex(businessIdPName) );
//IDfetaure
geoIdPValue = "" + field.getValue();
if(geoIdPValues.contains(geoIdPValue)) {
continue;
} else {
geoIdPValues.add(geoIdPValue);
}
Map parameters = new HashMap();
parameters.put("layerName", layerName);
parameters.put("geoIdPName", geoIdPName);
parameters.put("geoIdPValue", geoIdPValue);
// geoserver call
try {
MfFeatureCollection featureCollection = featuresProvider.getFeatures(featureSource, parameters);
List featureList = new ArrayList(featureCollection.getCollection());
MfFeature feature = (MfFeature) featureList.get(0);
//Geometry from GeoServer
MfGeometry geom = feature.getMfGeometry();
// JSON creation
JSONObject jsonProperties = new JSONObject();
//for each col
for(int j=0; j<nc; j++){
jsonProperties.accumulate(
dataStoreMeta.getFieldName(j),
record.getFieldAt( dataStoreMeta.getFieldIndex(dataStoreMeta.getFieldName(j)) ).getValue()
);
}
//for each prop
if(feature instanceof SbiFeature) {