Bug #19187 added a map to read WFS to view/export config

This commit is contained in:
Francesco Mangiacrapa 2020-05-04 10:02:04 +02:00
parent 54be2034b5
commit ec30dd7f25
1 changed files with 21 additions and 46 deletions

View File

@ -24,54 +24,45 @@ import org.json.JSONException;
import org.json.JSONObject;
// TODO: Auto-generated Javadoc
/**
* The Class WFSExporter.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* Apr 22, 2020
* May 4, 2020
*/
public class WFSExporter {
private static Logger log = Logger.getLogger(WFSExporter.class);
// public static final String WFS_DATA_EXPORT_CONFIG_FILE = "wfs_data_export_config.csv";
// public static final String WFS_DATA_VIEW_CONFIG_FILE = "wfs_data_view_config.csv";
/**
* The Enum WFSGetFeatureFields.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* Apr 23, 2020
*/
public static enum WFSGetFeatureFields{type,id,geometry_type,geometry_coordinates,geometry_name};
private FeatureExporterFileConfig toWFSViewFileConfig;
private FeatureExporterFileConfig toWFSExportFileConfig;
public static enum WFS_TO {VIEW, EXPORT};
public Map<WFS_TO,FeatureExporterFileConfig> mapWFSConfig = new HashMap<WFSExporter.WFS_TO, FeatureExporterFileConfig>();
/**
* Instantiates a new WFS exporter.
*/
public WFSExporter() {
WFSExporterSystemDir wfsSystemDir = new WFSExporterSystemDir();
FeatureExporterFileConfig toWFSFileConfig;
try {
CSVReader toWFSExport = wfsSystemDir.getCSVFileConfig(WFS_TO.EXPORT);
toWFSExportFileConfig = getConfig(toWFSExport);
toWFSExportFileConfig.setWfsTo(WFS_TO.EXPORT);
log.info("To WFS export file config has the map: "+toWFSExportFileConfig.getMap());
toWFSFileConfig = getConfig(toWFSExport);
toWFSFileConfig.setWfsTo(WFS_TO.EXPORT);
mapWFSConfig.put(WFS_TO.EXPORT, toWFSFileConfig);
log.info("To WFS export file config has the map: "+toWFSFileConfig.getMap());
} catch (FileNotFoundException e) {
log.error("Error on reading WFS config for "+WFS_TO.EXPORT, e);
}
try {
CSVReader toWFSView = wfsSystemDir.getCSVFileConfig(WFS_TO.VIEW);
toWFSViewFileConfig = getConfig(toWFSView);
toWFSViewFileConfig.setWfsTo(WFS_TO.VIEW);
log.info("To WFS export file config has the map: "+toWFSViewFileConfig.getMap());
toWFSFileConfig = getConfig(toWFSView);
toWFSFileConfig.setWfsTo(WFS_TO.VIEW);
mapWFSConfig.put(WFS_TO.VIEW, toWFSFileConfig);
log.info("To WFS view file config has the map: "+toWFSFileConfig.getMap());
} catch (FileNotFoundException e) {
log.error("Error on reading WFS config for "+WFS_TO.VIEW, e);
}
@ -123,33 +114,16 @@ public class WFSExporter {
toViewExport = toViewExport == null ? WFS_TO.VIEW : toViewExport; //default is to VIEW
switch (toViewExport) {
case EXPORT: {
return getTableFromJsonToExport(layerItem, bbox, maxWFSFeature, toWFSExportFileConfig);
}
case VIEW:
default: {
return getTableFromJsonToExport(layerItem, bbox, maxWFSFeature, toWFSViewFileConfig);
}
}
FeatureExporterFileConfig toWFSFileConfig = mapWFSConfig.get(toViewExport); //reading the right config
return getTableFromJsonToExport(layerItem, bbox, maxWFSFeature, toWFSFileConfig);
}
/*
private static void printMap(Map<String, FeatureExportViewConfig> theMap) {
for (String key : theMap.keySet()) {
System.out.println("Key: "+key + " - value: "+theMap.get(key));
}
}*/
/**
* Gets the table from json to export.
*
* @param layerItem the layer item
* @param bbox the bbox
* @param maxWFSFeature the max WFS feature
* @param toViewExport the to view export
* @param exporterConfig the exporter config
* @return the table from json to export
*/
@ -302,12 +276,13 @@ public class WFSExporter {
return tableFile;
}
public FeatureExporterFileConfig getToWFSExportFileConfig() {
return toWFSExportFileConfig;
}
/*
private static void printMap(Map<String, FeatureExportViewConfig> theMap) {
for (String key : theMap.keySet()) {
System.out.println("Key: "+key + " - value: "+theMap.get(key));
}
}*/
public FeatureExporterFileConfig getToWFSViewFileConfig() {
return toWFSViewFileConfig;
}
}