use of org.apache.jena.rdf.model.ResIterator in project jena by apache.
the class GeoSPARQLOperations method applySubPropertyDefaultGeometry.
/**
* Every subProperty of hasGeometry is made a subProperty of
* hasDefaultGeometry.<br>
* Assumption that each Feature has a single hasGeometry property.<br>
* Requires RDFS inferencing to propagate through the data.
*
* @param model
*/
public static final void applySubPropertyDefaultGeometry(Model model) {
try {
ResIterator resIt = model.listResourcesWithProperty(RDFS.subPropertyOf, Geo.HAS_GEOMETRY_PROP);
while (resIt.hasNext()) {
Resource res = resIt.nextResource();
res.addProperty(RDFS.subPropertyOf, Geo.HAS_DEFAULT_GEOMETRY_PROP);
}
} catch (Exception ex) {
LOGGER.error("Inserting GeoSPARQL predicates error: {}", ex.getMessage());
}
}
use of org.apache.jena.rdf.model.ResIterator in project jena by apache.
the class TestReasoners method doTestTransitiveReduction.
/**
* Test that a transitive reduction is complete.
* Assumes test graph has no cycles (other than the trivial
* identity ones).
*/
public void doTestTransitiveReduction(Model model, Property dp) {
InfModel im = ModelFactory.createInfModel(ReasonerRegistry.getTransitiveReasoner(), model);
for (ResIterator i = im.listSubjects(); i.hasNext(); ) {
Resource base = i.nextResource();
List<RDFNode> directLinks = new ArrayList<>();
for (NodeIterator j = im.listObjectsOfProperty(base, dp); j.hasNext(); ) {
directLinks.add(j.next());
}
for (int n = 0; n < directLinks.size(); n++) {
Resource d1 = (Resource) directLinks.get(n);
for (int m = n + 1; m < directLinks.size(); m++) {
Resource d2 = (Resource) directLinks.get(m);
if (im.contains(d1, dp, d2) && !base.equals(d1) && !base.equals(d2)) {
assertTrue("Triangle discovered in transitive reduction", false);
}
}
}
}
}
Aggregations