public static RDFNode findFirstPropertyFromResource(final Model model, final Resource resource, final Property property) { NodeIterator iterator = model.listObjectsOfProperty(resource, property); if (iterator.hasNext()) return iterator.next(); return null; }
/** * Extract type uris - either RDF type or most specific type - from a Model */ TypeList(Model model, Property property) { NodeIterator iterator = model.listObjectsOfProperty(property); while (iterator.hasNext()) { RDFNode node = iterator.next(); String uri = node.asResource().getURI(); if (!typeUris.contains(uri)) { typeUris.add(uri); } } }
public Set<URI> getCancellationPendingAgreementUris(){ Model cancellations = pendingProposals.getDefaultModel(); if (cancellations == null) { return Collections.EMPTY_SET; } Set ret = new HashSet<URI>(); NodeIterator it = cancellations.listObjectsOfProperty(WONAGR.PROPOSES_TO_CANCEL); while(it.hasNext()) { String uri = it.next().asResource().getURI(); ret.add(URI.create(uri)); } return ret; }
public Collection<Resource> getGoals() { Collection<Resource> goalUris = new LinkedList<>(); NodeIterator iter = getNeedModel().listObjectsOfProperty(getNeedNode(NeedGraphType.NEED), WON.GOAL); while (iter.hasNext()) { goalUris.add(iter.next().asResource()); } return goalUris; }
public static String getSignatureValue(String signatureGraphUri, Model signatureGraph) { String signatureValue = null; Resource resource = signatureGraph.getResource(signatureGraphUri); NodeIterator ni2 = signatureGraph.listObjectsOfProperty(resource, SFSIG.HAS_SIGNATURE_VALUE); if (ni2.hasNext()) { signatureValue = ni2.next().asLiteral().toString(); } return signatureValue; }
public Collection<String> getContentPropertyStringValues(Resource contentNode, Property p, String language) { Collection<String> values = new LinkedList<>(); NodeIterator nodeIterator = getNeedModel().listObjectsOfProperty(contentNode, p); while (nodeIterator.hasNext()) { Literal literalValue = nodeIterator.next().asLiteral(); if (language == null || language.equals(literalValue.getLanguage())) { values.add(literalValue.getString()); } } return values; }
public Collection<String> getFacetUris() { Collection<String> facetUris = new LinkedList<>(); NodeIterator iter = getNeedModel().listObjectsOfProperty(getNeedNode(NeedGraphType.NEED), WON.HAS_FACET); while (iter.hasNext()) { facetUris.add(iter.next().asResource().getURI()); } return facetUris; }
public Collection<String> getMatchingContexts() { Collection<String> matchingContexts = new LinkedList<>(); NodeIterator iter = getNeedModel().listObjectsOfProperty(getNeedNode(NeedGraphType.NEED), WON.HAS_MATCHING_CONTEXT); while (iter.hasNext()) { matchingContexts.add(iter.next().asLiteral().getString()); } return matchingContexts; }
private <E> Collection<E> parseIntoCollection(Container c, Collection<E> l, ClassMeta<?> type, BeanPropertyMeta pMeta) throws Exception { int argIndex = 0; for (NodeIterator ni = c.iterator(); ni.hasNext();) { E e = (E)parseAnything(type.isArgs() ? type.getArg(argIndex++) : type.getElementType(), ni.next(), l, pMeta); l.add(e); } return l; }
public static String getSignedGraphUri(String signatureGraphUri, Model signatureGraph) { String signedGraphUri = null; Resource resource = signatureGraph.getResource(signatureGraphUri); NodeIterator ni = signatureGraph.listObjectsOfProperty(resource, WONMSG.HAS_SIGNED_GRAPH_PROPERTY); if (ni.hasNext()) { signedGraphUri = ni.next().asResource().getURI(); } return signedGraphUri; }
public String getShapesGraphName(Resource goalNode) { if (goalNode != null) { NodeIterator nodeIter = getNeedModel().listObjectsOfProperty(goalNode, WON.HAS_SHAPES_GRAPH); if (nodeIter.hasNext()) { String shapesGraphUri = nodeIter.next().asResource().getURI(); return shapesGraphUri; } } return null; }
public String getDataGraphName(Resource goalNode) { if (goalNode != null) { NodeIterator nodeIter = getNeedModel().listObjectsOfProperty(goalNode, WON.HAS_DATA_GRAPH); if (nodeIter.hasNext()) { String dataGraphUri = nodeIter.next().asResource().getURI(); return dataGraphUri; } } return null; }
private String getObjectOfPropertyAsString(Model model, Property property){ NodeIterator nodeIteratr = model.listObjectsOfProperty(property); if (!nodeIteratr.hasNext()) return null; String ret = nodeIteratr.next().asLiteral().getString(); if (nodeIteratr.hasNext()) { throw new IncorrectPropertyCountException("found more than one property of cnt:bytes", 1, 2); } return ret; }
public Model getDataGraph(Resource goalNode) { if (goalNode != null) { NodeIterator nodeIter = getNeedModel().listObjectsOfProperty(goalNode, WON.HAS_DATA_GRAPH); if (nodeIter.hasNext()) { String dataGraphUri = nodeIter.next().asResource().getURI(); return needDataset.getNamedModel(dataGraphUri); } } return null; }
public Model getShapesGraph(Resource goalNode) { if (goalNode != null) { NodeIterator nodeIter = getNeedModel().listObjectsOfProperty(goalNode, WON.HAS_SHAPES_GRAPH); if (nodeIter.hasNext()) { String shapesGraphUri = nodeIter.next().asResource().getURI(); return needDataset.getNamedModel(shapesGraphUri); } } return null; }
private LocatorIF getTopicIndicator(Resource subject, String property, Model model) throws JenaException, MalformedURLException { Property prop = model.getProperty(property); NodeIterator it = model.listObjectsOfProperty(subject, prop); while (it.hasNext()) { Resource obj = (Resource) it.next(); if (obj.isAnon()) continue; // FIXME: is this really ok? return new URILocator(obj.getURI()); } return null; }
RDFNode getValueOfObjectProperty(RDFNode subject, String predicateURI, String targetURI) { NodeIterator iterator = this.model.listObjectsOfProperty(subject.asResource(), getPropertyFromUri(predicateURI)); while (iterator.hasNext()) { RDFNode next = iterator.next(); if (!next.isLiteral()) { if (targetURI != null && this.model.contains(next.asResource(), getPropertyFromUri(HGQLVocabulary.RDF_TYPE), getResourceFromUri(targetURI))) { return next; } } } return null; }
RDFNode getValueOfObjectProperty(RDFNode subject, String predicateURI, String targetURI) { NodeIterator iterator = this.model.listObjectsOfProperty(subject.asResource(), getPropertyFromUri(predicateURI)); while (iterator.hasNext()) { RDFNode next = iterator.next(); if (!next.isLiteral()) { if (targetURI != null && this.model.contains(next.asResource(), getPropertyFromUri(HGQLVocabulary.RDF_TYPE), getResourceFromUri(targetURI))) { return next; } } } return null; }
public void testListObjectsNoRemove() { final Model m = ModelHelper.modelWithStatements(this, "a P b; b Q c; c R a"); final NodeIterator it = m.listObjects(); it.next(); try { it.remove(); Assert.fail("listObjects should not support .remove()"); } catch (final UnsupportedOperationException e) { JenaTestBase.pass(); } }
public void testListObjectsNoRemove() { final Model m = ModelHelper.modelWithStatements(this, "a P b; b Q c; c R a"); final NodeIterator it = m.listObjects(); it.next(); try { it.remove(); Assert.fail("listObjects should not support .remove()"); } catch (final UnsupportedOperationException e) { JenaTestBase.pass(); } }