protected void importDataProperty(OWLOntology o, OWLDataProperty dataTypeProperty) { String propertyIRI = dataTypeProperty.getIRI().toString(); String propertyDisplayName = getLabel(o, dataTypeProperty); PropertyType propertyType = getPropertyType(o, dataTypeProperty); boolean userVisible = getUserVisible(o, dataTypeProperty); boolean searchable = getSearchable(o, dataTypeProperty); Boolean displayTime = getDisplayTime(o, dataTypeProperty); Double boost = getBoost(o, dataTypeProperty); if (propertyType == null) { throw new LumifyException("Could not get property type on data property " + propertyIRI); } for (OWLClassExpression domainClassExpr : dataTypeProperty.getDomains(o)) { OWLClass domainClass = domainClassExpr.asOWLClass(); String domainClassUri = domainClass.getIRI().toString(); Concept domainConcept = getConceptByIRI(domainClassUri); checkNotNull(domainConcept, "Could not find class with uri: " + domainClassUri); LOGGER.info("Adding data property " + propertyIRI + " to class " + domainConcept.getTitle()); ArrayList<PossibleValueType> possibleValues = getPossibleValues(o, dataTypeProperty); Collection<TextIndexHint> textIndexHints = getTextIndexHints(o, dataTypeProperty); addPropertyTo( domainConcept, propertyIRI, propertyDisplayName, propertyType, possibleValues, textIndexHints, userVisible, searchable, displayTime, boost); } }
public boolean contains(OWLDataProperty prop) { if (prop.equals(owlOntologyManager.getOWLDataFactory().getOWLThing())) { return true; } else if (prop.equals(owlOntologyManager.getOWLDataFactory().getOWLNothing())) { return true; } return owlDataProperty2DataPropertyPointerMap.containsKey(prop); }
private void runWithSeparateFiles() { if (owlFile == null) { throw new NullPointerException("You have to specify an ontology file!"); } OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLOntology ontology = null; OBDADataFactory obdaDataFactory = OBDADataFactoryImpl.getInstance(); try { ontology = manager.loadOntologyFromOntologyDocument((new File(owlFile))); if (disableReasoning) { /* * when reasoning is disabled, we extract only the declaration assertions for the vocabulary */ ontology = extractDeclarations(manager, ontology); } Collection<Predicate> predicates = new ArrayList<>(); for (OWLClass owlClass : ontology.getClassesInSignature()) { Predicate predicate = obdaDataFactory.getClassPredicate(owlClass.getIRI().toString()); predicates.add(predicate); } for (OWLDataProperty owlDataProperty : ontology.getDataPropertiesInSignature()) { Predicate predicate = obdaDataFactory.getDataPropertyPredicate(owlDataProperty.getIRI().toString()); predicates.add(predicate); } for (OWLObjectProperty owlObjectProperty : ontology.getObjectPropertiesInSignature()) { Predicate predicate = obdaDataFactory.getObjectPropertyPredicate(owlObjectProperty.getIRI().toString()); predicates.add(predicate); } OBDAModel obdaModel = loadMappingFile(mappingFile); Ontology inputOntology = OWLAPI3TranslatorUtility.translate(ontology); obdaModel.declareAll(inputOntology.getVocabulary()); int numPredicates = predicates.size(); int i = 1; for (Predicate predicate : predicates) { System.err.println(String.format("Materializing %s (%d/%d)", predicate, i, numPredicates)); serializePredicate(ontology, inputOntology, obdaModel, predicate, outputFile, format); i++; } } catch (OWLOntologyCreationException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
protected PropertyType getPropertyType(OWLOntology o, OWLDataProperty dataTypeProperty) { Set<OWLDataRange> ranges = dataTypeProperty.getRanges(o); if (ranges.size() == 0) { return null; } if (ranges.size() > 1) { throw new LumifyException( "Unexpected number of ranges on data property " + dataTypeProperty.getIRI().toString()); } for (OWLDataRange range : ranges) { if (range instanceof OWLDatatype) { OWLDatatype datatype = (OWLDatatype) range; return getPropertyType(datatype.getIRI().toString()); } } throw new LumifyException( "Could not find range on data property " + dataTypeProperty.getIRI().toString()); }
public void visit(OWLDataProperty owlDataProperty) { try { lastDataPropertyPointer = owlDataProperty2DataPropertyPointerMap.get(owlDataProperty); if (lastDataPropertyPointer == null) { lastDataPropertyPointer = faCTPlusPlus.getDataProperty(owlDataProperty.getURI().toString()); dataPropertyPointerMap.put(lastDataPropertyPointer, owlDataProperty); owlDataProperty2DataPropertyPointerMap.put(owlDataProperty, lastDataPropertyPointer); } } catch (Exception e) { throw new FaCTPlusPlusRuntimeException(e); } }
// this method retrieves all the geometric properties that have been // pre-designated as "house setable" or "room setable", // that is, if a geometric property is available for houses, it has been // annotated as "houseSetable", for rooms, "roomSetable" and for both it // has been designated with both annotations. public void retrieveGeometricPropertiesMaps() { OWLDataProperty geometricProperty = OWLFactory.getOWLDataProperty(":GeometricProperty", topIxPrefixManager); OWLAnnotationProperty propertyID = OWLFactory.getOWLAnnotationProperty(":propertyID", topIxPrefixManager); logger.info(propertyID); OWLAnnotationProperty houseSetable = OWLFactory.getOWLAnnotationProperty(":houseSetable", topIxPrefixManager); OWLAnnotationProperty roomSetable = OWLFactory.getOWLAnnotationProperty(":roomSetable", topIxPrefixManager); Set<OWLSubDataPropertyOfAxiom> tempGeometricDataPropertiesSet = topIxOnt.getDataSubPropertyAxiomsForSuperProperty(geometricProperty); for (OWLSubDataPropertyOfAxiom tempGeomPropAxiom : tempGeometricDataPropertiesSet) { OWLDataProperty tempDataProperty = tempGeomPropAxiom.getSubProperty().asOWLDataProperty(); // the following two local vars will become an entry for geometricPropertiesMap String tempString = tempDataProperty.getAnnotations(topIxOnt, propertyID).toString(); tempString = tempString.substring(tempString.indexOf('"') + 1, tempString.indexOf("^") - 1); IRI tempIRI = tempGeomPropAxiom.getSubProperty().asOWLDataProperty().getIRI(); geometricPropertiesMap.put(tempString, tempIRI); // the following code decides whether the above entry should also be contained // in the houseSetableGeometricPropertiesMap Set<OWLAnnotation> tempDataPropAnnotationSet = tempDataProperty.getAnnotations(topIxOnt); for (OWLAnnotation tempDataPropAnnotation : tempDataPropAnnotationSet) { if (tempDataPropAnnotation.getProperty() == houseSetable && tempDataPropAnnotation.getValue().toString().equals("\"true\"^^xsd:boolean")) { houseSetableGeometricPropertiesMap.put(tempString, tempIRI); } if (tempDataPropAnnotation.getProperty() == roomSetable && tempDataPropAnnotation.getValue().toString().equals("\"true\"^^xsd:boolean")) { roomSetableGeometricPropertiesMap.put(tempString, tempIRI); } } } }
public OntologicDataType getDataType() { if (getProperty() != null) { return property.getDataType(); } return null; }