use of won.protocol.exception.IncorrectPropertyCountException in project webofneeds by researchstudio-sat.
the class RdfUtils method findOnePropertyFromResource.
public static RDFNode findOnePropertyFromResource(final Model model, final Resource resource, final Property property) {
List<RDFNode> foundNodes = new ArrayList<RDFNode>();
NodeIterator iterator = model.listObjectsOfProperty(resource, property);
while (iterator.hasNext()) {
foundNodes.add(iterator.next());
}
if (foundNodes.size() == 0)
return null;
else if (foundNodes.size() == 1)
return foundNodes.get(0);
else if (foundNodes.size() > 1) {
RDFNode n = foundNodes.get(0);
for (RDFNode node : foundNodes) {
if (!node.equals(n))
throw new IncorrectPropertyCountException(1, 2);
}
return n;
} else
return null;
}
Aggregations