/** * Extracts data from the parent of ontClass that is a {@link Restriction} of type * {@link org.apache.jena.ontology.SomeValuesFromRestriction}. Updates the {@link SolrInputDocument} for ontClass. * * @param doc the input Solr document * @param restriction the restriction */ private void extractSomeValuesFromRestriction(@Nonnull final SolrInputDocument doc, @Nonnull final Restriction restriction) { // someValuesFrom restrictions refer to the other "modifier" classes such as inheritance, geography, etc. // If a disease is part of a group of disorders, it will also be indicated here under a "part_of" property. final String fieldName = getOnPropertyFromRestriction(restriction); final String fieldValue = getSomeValuesFromRestriction(restriction); if (StringUtils.isNotBlank(fieldName) && StringUtils.isNotBlank(fieldValue)) { if ("present_in".equals(fieldName)) { this.region = fieldValue; addMultivaluedField(doc, fieldName, fieldValue); return; } if (!this.isIntersection) { addMultivaluedField(doc, fieldName, fieldValue); } else { writeWorldwideDataFromRestriction(doc, fieldName, fieldValue); } } else { this.logger.warn("Could not extract data from someValuesFrom restriction {}, onProperty {}, in class {}", restriction.getId(), fieldName, doc.getFieldValue(ID_FIELD_NAME)); } }
/** * Extracts data from the parent of ontClass that is a {@link Restriction} and updates the{@link SolrInputDocument} * for ontClass. * * @param doc the Solr input document * @param parent the parent class that contains restriction data for the ontologyClass */ private void extractRestrictionData(@Nonnull final SolrInputDocument doc, @Nonnull final OntClass parent) { final Restriction restriction = parent.asRestriction(); // Restrictions can be someValuesFrom, hasValue, allValuesFrom, etc. ORDO appears to only use the first two. if (restriction.isSomeValuesFromRestriction()) { extractSomeValuesFromRestriction(doc, restriction); } else if (restriction.isHasValueRestriction()) { extractHasValueRestriction(doc, restriction); } else { this.logger .warn("Restriction {} in class {} is neither someValuesFrom nor hasValue type.", restriction.getId(), doc.getFieldValue(ID_FIELD_NAME)); } }
/** * Extracts data from the parent of ontClass that is a {@link Restriction} of type * {@link org.apache.jena.ontology.HasValueRestriction}. Updates the {@link SolrInputDocument} for ontClass. * * @param doc the input Solr document * @param restriction the restriction */ private void extractHasValueRestriction(@Nonnull final SolrInputDocument doc, @Nonnull final Restriction restriction) { // Not all of these have pretty names. Re-map these via managed-schema.xml field configurations. final String fieldName = getOnPropertyFromRestriction(restriction); final String fieldValue = restriction.asHasValueRestriction().getHasValue().asLiteral().getLexicalForm(); if (StringUtils.isNotBlank(fieldName) && StringUtils.isNotBlank(fieldValue)) { if (!this.isIntersection) { addMultivaluedField(doc, fieldName, fieldValue); } else { writeWorldwideDataFromRestriction(doc, fieldName, fieldValue); } } else { this.logger.warn("Could not extract data from hasValue restriction {}, onProperty {}, in class {}", restriction.getId(), fieldName, doc.getFieldValue(ID_FIELD_NAME)); } }