Refine search
private BlankNodeOrIRI getPlatformInstanceRDFTerm() { Lock l = systemGraph.getLock().readLock(); l.lock(); try { Iterator<Triple> instances = systemGraph.filter(null, RDF.type, PLATFORM.Instance); if (!instances.hasNext()) { throw new RuntimeException("No Platform:Instance in system graph."); } return instances.next().getSubject(); } finally { l.unlock(); } }
private static Triple map(Triple triple, Map<BlankNode, BlankNode> map) { final BlankNodeOrIRI oSubject = triple.getSubject(); BlankNodeOrIRI subject = oSubject instanceof BlankNode ? map.get((BlankNode)oSubject) : oSubject; RDFTerm oObject = triple.getObject(); RDFTerm object = oObject instanceof BlankNode ? map.get((BlankNode)oObject) : oObject; return new TripleImpl(subject, triple.getPredicate(), object); }
private static boolean isGrounded(Triple triple) { if (triple.getSubject() instanceof BlankNode) { return false; } if (triple.getObject() instanceof BlankNode) { return false; } return true; }
@Override public boolean matches(Triple t) { return objectUri != null && t.getPredicate().equals(predicateUri) && t.getObject().equals(objectUri) ; } }
ci.getLock().readLock().lock(); try{ Graph em = ExecutionMetadataHelper.getExecutionMetadata(ci); Iterator<Triple> engineExecutions = em.filter(null, ExecutionPlan.ENGINE, new PlainLiteralImpl(engine.getName())); BlankNodeOrIRI engineExecution = engineExecutions.next().getSubject(); if(em.contains(new TripleImpl(executionPlanNode, ExecutionPlan.HAS_EXECUTION_NODE, engineExecution))){ extractEnhancementProperties(engineExProps,em, engineExecution, "Engine Execution"); log.debug(" - no ExecutionMetadata are present ..."); } finally { ci.getLock().readLock().unlock();
Graph systemGraph = getSystemGraph(); Literal javaPermEntry = new PlainLiteralImpl(permissionString); Lock readLock = systemGraph.getLock().readLock(); readLock.lock(); try { Iterator<Triple> javaPermTriples = systemGraph.filter(null, PERMISSION.javaPermissionEntry, javaPermEntry); if (javaPermTriples.hasNext()) { return javaPermTriples.next().getSubject(); readLock.unlock(); Lock writeLock = systemGraph.getLock().writeLock(); writeLock.lock(); try { BlankNode result = new BlankNode(); systemGraph.add(new TripleImpl(result, PERMISSION.javaPermissionEntry, javaPermEntry)); return result;
Lock l = mGraph.getLock().writeLock(); l.lock(); try { for (Iterator<Triple> it = mGraph.iterator(); it.hasNext();) { final Triple triple = it.next(); final BlankNodeOrIRI subject = triple.getSubject(); BlankNodeOrIRI subjectReplacement = current2ReplacementMap.get(subject); final RDFTerm object = triple.getObject(); @SuppressWarnings(value = "element-type-mismatch") RDFTerm objectReplacement = current2ReplacementMap.get(object); objectReplacement = object; newTriples.add(new TripleImpl(subjectReplacement, triple.getPredicate(), objectReplacement)); mGraph.add(triple); mGraph.addAll(owlSameAsGraph); } finally { l.unlock();
BlankNodeOrIRI userNode = agents.next().getSubject(); Triple userTriple = null; Lock writeLock = systemGraph.getLock().writeLock(); writeLock.lock(); try { GraphNode systemUserNode = new GraphNode(userNode, systemGraph); while (userTriples.hasNext()) { userTriple = userTriples.next(); systemGraph.add(userTriple); userName = ((Literal) userTriple.getObject()).getLexicalForm(); } finally { writeLock.unlock();
@Override public Collection<RDFTerm> listSubjects(RDFTerm property, RDFTerm object) { if (!(property instanceof IRI)) { throw new IllegalArgumentException("Property needs to be a URI node"); } Collection<RDFTerm> result = new ArrayList<RDFTerm>(); Lock readLock = readLockGraph(); try { Iterator<Triple> triples = graph.filter(null, (IRI) property, object); while (triples.hasNext()) { result.add(triples.next().getSubject()); } } finally { if(readLock != null){ //will be null if #graph is a read-only graph instance readLock.unlock(); } } return result; }
@Override public Collection<RDFTerm> listObjects(RDFTerm subject, RDFTerm property) { if (!(property instanceof IRI) || !(subject instanceof BlankNodeOrIRI)) { throw new IllegalArgumentException("Subject needs to be a URI or blank node, property a URI node"); } Collection<RDFTerm> result = new ArrayList<RDFTerm>(); Lock readLock = readLockGraph(); try { Iterator<Triple> triples = graph.filter((BlankNodeOrIRI) subject, (IRI) property, null); while (triples.hasNext()) { result.add(triples.next().getObject()); } } finally { if(readLock != null){ //will be null if #graph is a read-only graph instance readLock.unlock(); } } return result; }
/** * Adds triples that point from the bundle resource to its documentations. * * @param bundle * @param docGraph */ private void addAdditionalTriples(Bundle bundle, Graph docGraph) { IRI bundleUri = new IRI(bundle.getLocation()); Triple triple = new TripleImpl(bundleUri, RDF.type, OSGI.Bundle); docGraph.add(triple); Iterator<Triple> titledContents = docGraph.filter(null, RDF.type, DISCOBITS.TitledContent); Set<Triple> newTriples = new HashSet<Triple>(); for (Iterator<Triple> it = titledContents; it.hasNext();) { BlankNodeOrIRI titledContent = it.next().getSubject(); if (docGraph.filter(null, DISCOBITS.holds, titledContent).hasNext()) { continue; } triple = new TripleImpl(bundleUri, DOCUMENTATION.documentation, titledContent); newTriples.add(triple); } docGraph.addAll(newTriples); }
List<Triple> newImports = new LinkedList<Triple>(); synchronized (o) { it = o.filter(null, OWL.imports, null); String s = ((IRI) (t.getObject())).getUnicodeString(); IRI target = new IRI((managed ? universalPrefix + "/" + tid + "/" : URIUtils.upOne(universalPrefix) + "/") + s); o.remove(t); newImports.add(new TripleImpl(t.getSubject(), OWL.imports, target)); o.add(t);
OWLOntologyID getReverseMapping(IRI graphName) { // Logical mappings first. Iterator<Triple> it = graph.filter(null, MAPS_TO_GRAPH_URIREF, graphName); while (it.hasNext()) { RDFTerm obj = it.next().getSubject(); if (obj instanceof IRI) return buildPublicKey((IRI) obj); } Literal litloc = LiteralFactory.getInstance().createTypedLiteral( new IRI(graphName.getUnicodeString())); // Logical mappings failed, try physical mappings. it = graph.filter(null, RETRIEVED_FROM_URIREF, litloc); while (it.hasNext()) { RDFTerm subj = it.next().getSubject(); if (subj instanceof IRI) return buildPublicKey((IRI) subj); } return null; }
@Test public void testUseTypedLiterals() { Graph graph = getEmptyGraph(); Assert.assertEquals(0, graph.size()); Literal value = new TypedLiteralImpl("<elem>value</elem>",xmlLiteralType); final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value); graph.add(triple1); Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null); Assert.assertTrue(tripleIter.hasNext()); RDFTerm gotValue = tripleIter.next().getObject(); Assert.assertEquals(value, gotValue); }
void mapLocator(org.semanticweb.owlapi.model.IRI locator, IRI graphName) { if (graphName == null) throw new IllegalArgumentException("A null graph name is not allowed."); // Null locator is a legal argument, will remove all locator mappings from the supplied graph Set<Triple> remove = new HashSet<Triple>(); for (Iterator<Triple> nodes = graph.filter(graphName, null, null); nodes.hasNext();) { Triple t = nodes.next(); // isOntology |= RDF.type.equals(t.getPredicate()) && OWL.Ontology.equals(t.getObject()); if (RETRIEVED_FROM_URIREF.equals(t.getPredicate())) remove.add(t); } graph.removeAll(remove); if (locator != null) { Literal litloc = LiteralFactory.getInstance().createTypedLiteral( new IRI(locator.toString())); graph.add(new TripleImpl(graphName, RETRIEVED_FROM_URIREF, litloc)); } }
Graph add = new SimpleGraph(); for (Triple t: model) { BlankNodeOrIRI subj = t.getSubject(); RDFTerm obj = t.getObject(); IRI pred = t.getPredicate(); boolean match = false; if (subj instanceof BlankNode) { remove.add(t); add.add(new TripleImpl(subj,pred,obj)); model.removeAll(remove); model.addAll(add);
else if (collector instanceof OntologySpace) colltype = OntologySpace.shortName + "/"; else if (collector instanceof Session) colltype = Session.shortName + "/"; IRI c = new IRI(_NS_STANBOL_INTERNAL + colltype + collector.getID()); Set<OWLOntologyID> aliases = listAliases(removedOntology); aliases.add(removedOntology); for (Iterator<Triple> it = meta.filter(c, null, u); it.hasNext();) { IRI property = it.next().getPredicate(); if (collector instanceof OntologySpace || collector instanceof Session) { if (property.equals(MANAGES_URIREF)) badState = false; for (Iterator<Triple> it = meta.filter(u, null, c); it.hasNext();) { IRI property = it.next().getPredicate(); if (collector instanceof OntologySpace || collector instanceof Session) { if (property.equals(IS_MANAGED_BY_URIREF)) badState = false; meta.remove(new TripleImpl(c, MANAGES_URIREF, u)); meta.remove(new TripleImpl(u, IS_MANAGED_BY_URIREF, c));
@Override public boolean contains(Object o) { if (!(o instanceof Triple)) { return false; } Triple t = (Triple) o; return filter(t.getSubject(), t.getPredicate(), t.getObject()).hasNext(); }
private Set<IRI> getIfps(Graph tBox) { final Iterator<Triple> ifpDefinitions = tBox.filter(null, RDF.type, OWL.InverseFunctionalProperty); final Set<IRI> ifps = new HashSet<IRI>(); while (ifpDefinitions.hasNext()) { final Triple triple = ifpDefinitions.next(); ifps.add((IRI) triple.getSubject()); } return ifps; }
Set<OWLOntologyID> getVersions(org.semanticweb.owlapi.model.IRI ontologyIri) { if (ontologyIri == null) throw new IllegalArgumentException("Cannot get versions for a null IRI."); Set<OWLOntologyID> keys = new HashSet<OWLOntologyID>(); LiteralFactory lf = LiteralFactory.getInstance(); Literal iri = lf.createTypedLiteral(new IRI(ontologyIri.toString())); // Exclude aliases. for (Iterator<Triple> it = graph.filter(null, HAS_ONTOLOGY_IRI_URIREF, iri); it.hasNext();) { RDFTerm sub = it.next().getSubject(); if (sub instanceof IRI) keys.add(buildPublicKey((IRI) sub)); } // Also check for physical locations for (Iterator<Triple> it = graph.filter(null, RETRIEVED_FROM_URIREF, iri); it.hasNext();) { RDFTerm sub = it.next().getSubject(); if (sub instanceof IRI) keys.add(buildPublicKey((IRI) sub)); } return keys; }