use of ddf.catalog.solr.offlinegazetteer.GazetteerConstants.COUNTRY_CODE in project ddf by codice.
the class CatalogGazetteerForwardingPlugin method convert.
protected static SolrInputDocument convert(Metacard metacard) {
SolrInputDocument solrDoc = new SolrInputDocument();
Consumer<String> getAttrAndAdd = (attributeName) -> Optional.ofNullable(getStringAttribute(metacard, attributeName)).ifPresent(attributeValue -> solrDoc.addField(GAZETTEER_TO_CATALOG.inverse().get(attributeName), attributeValue));
getAttrAndAdd.accept(GAZETTEER_TO_CATALOG.get(DESCRIPTION));
getAttrAndAdd.accept(GAZETTEER_TO_CATALOG.get(FEATURE_CODE));
getAttrAndAdd.accept(GAZETTEER_TO_CATALOG.get(NAME));
getAttrAndAdd.accept(GAZETTEER_TO_CATALOG.get(ID));
getAttrAndAdd.accept(GAZETTEER_TO_CATALOG.get(COUNTRY_CODE));
Optional.of(metacard).map(m -> getStringAttribute(m, GAZETTEER_TO_CATALOG.get(LOCATION))).ifPresent(v -> solrDoc.addField(LOCATION, v));
Optional.of(metacard).map(m -> m.getAttribute(GAZETTEER_TO_CATALOG.get(POPULATION))).map(Attribute::getValue).filter(Long.class::isInstance).map(Long.class::cast).ifPresent(v -> solrDoc.addField(POPULATION, v));
Optional.of(metacard).map(m -> m.getAttribute(GAZETTEER_TO_CATALOG.get(SORT_VALUE))).map(Attribute::getValue).filter(Integer.class::isInstance).map(Integer.class::cast).ifPresent(v -> solrDoc.addField(SORT_VALUE, v));
return solrDoc;
}
Aggregations