use of org.opensextant.util.GeonamesUtility in project Xponents by OpenSextant.
the class GazetteerUpdateProcessorFactory method init.
/**
* NamedList? in Solr. What a horror. Okay, they work, but...
*
* items found in solrconfig under the gaz update processor script:
*
* include_category -- Tells the update processor which flavors of data to
* keep category_field -- the field name where a row of data is categorized.
* countries -- a list of countries to use. stopterms -- a list of terms
* used to mark rows of data as "search_only"
*
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void init(NamedList params) {
/*
* Load the exclusion names -- these are terms that are gazeteer
* entries, e.g., gazetteer.name = <exclusion term>, that will be marked
* as search_only = true.
*
*/
try {
termFilter = new TagFilter();
termFilter.enableCaseSensitive(false);
helper = new GeonamesUtility();
} catch (Exception err) {
logger.error("Init failure", err);
}
String logTag = "GAZ UPR////////////// ";
logger.debug("Parameters for Gaz Updater {}, size={}, Country Filter?{}", params, params.size(), params.getAll("countries"));
if (params.size() == 0) {
logger.debug(logTag + "Zero parameters found.");
return;
}
NamedList p = (NamedList) params.getVal(0);
logger.debug(logTag + "Found p={}", p);
logger.debug(logTag + "P={}, V={}", p.getName(0), p.getVal(0));
// array of
List<String> ic = (List<String>) p.get("include_category");
// String
if (ic != null) {
logger.debug(logTag + "Found CAT={}", ic);
includeCategorySet = new HashSet<String>();
List<String> val = TextUtils.string2list(ic.get(0), ",");
includeCategorySet.addAll(val);
if (includeCategorySet.contains("all")) {
includeAll = true;
}
} else {
logger.error(logTag + "No category found.");
}
/* Optional: filter entries with a country list
*
*/
List<String> cc = (List<String>) p.get("countries");
if (cc != null) {
logger.debug("Found CO={}", ic);
includeCountrySet = new HashSet<>();
List<String> val = TextUtils.string2list(cc.get(0), ",");
includeCountrySet.addAll(val);
} else {
logger.debug("No country filter found");
}
if (params.get("category_field") != null) {
catField = (String) p.get("category_field");
}
logger.debug(logTag + " DONE. CAT={}, CO={}", includeCategorySet, includeCountrySet);
}
Aggregations