use of org.eol.globi.domain.TaxonomyProvider in project eol-globi-data by jhpoelen.
the class GlobalNamesService method parseResultNode.
private void parseResultNode(TermMatchListener termMatchListener, JsonNode jsonNode) {
JsonNode dataList = jsonNode.get("data");
if (dataList != null && dataList.isArray()) {
for (JsonNode data : dataList) {
JsonNode results = data.get("results");
if (results == null) {
if (dataList.size() > 0) {
JsonNode firstDataElement = dataList.get(0);
firstDataElement.get("supplied_name_string");
if (firstDataElement.has("is_known_name") && firstDataElement.has("supplied_name_string") && !firstDataElement.get("is_known_name").asBoolean(false)) {
noMatch(termMatchListener, data);
}
}
} else if (results.isArray()) {
for (JsonNode aResult : results) {
TaxonomyProvider provider = getTaxonomyProvider(aResult);
if (provider == null) {
LOG.warn("found unsupported data_source_id");
} else {
if (aResult.has("classification_path") && aResult.has("classification_path_ranks")) {
parseClassification(termMatchListener, data, aResult, provider);
} else {
noMatch(termMatchListener, data);
}
}
}
}
}
}
}
use of org.eol.globi.domain.TaxonomyProvider in project eol-globi-data by jhpoelen.
the class EOLService method getEOLPageId.
private Long getEOLPageId(String name, String externalId) throws PropertyEnricherException {
Long eolPageId = null;
TaxonomyProvider taxonomyProvider = ExternalIdUtil.taxonomyProviderFor(externalId);
if (taxonomyProvider != null) {
String idNoPrefix = ExternalIdUtil.stripPrefix(taxonomyProvider, externalId);
if (taxonomyProvider == TaxonomyProvider.EOL) {
try {
eolPageId = Long.parseLong(idNoPrefix);
} catch (NumberFormatException ex) {
throw new PropertyEnricherException("failed to parse eol id [" + idNoPrefix + "]");
}
} else if (EOL_TAXON_PROVIDER_MAP.containsKey(taxonomyProvider)) {
eolPageId = getPageIdFromProvider(EOL_TAXON_PROVIDER_MAP.get(taxonomyProvider), idNoPrefix);
}
} else if (StringUtils.isNotBlank(name) && !PropertyAndValueDictionary.NO_NAME.equals(name)) {
eolPageId = getPageId(name, true);
}
return eolPageId;
}
use of org.eol.globi.domain.TaxonomyProvider in project eol-globi-data by jhpoelen.
the class GlobalNamesService method getTaxonomyProvider.
private TaxonomyProvider getTaxonomyProvider(JsonNode aResult) {
TaxonomyProvider provider = null;
if (aResult.has("data_source_id")) {
int sourceId = aResult.get("data_source_id").getIntValue();
GlobalNamesSources[] values = GlobalNamesSources.values();
for (GlobalNamesSources value : values) {
if (value.getId() == sourceId) {
provider = value.getProvider();
break;
}
}
}
return provider;
}
Aggregations