public static String reasoningSpec(String repoSpec, String reasoner, Resource inferredGraph) { String reasoningSpec = repoSpec + "[" + reasoner; if (inferredGraph != null) { reasoningSpec += ("#<" + inferredGraph.stringValue() + ">"); } return reasoningSpec + "]"; }
@Override public String toString() { return "<" + val.stringValue() + ">"; }
@Override public int compareTo(ResourceWritable other) { return val.stringValue().compareTo(other.val.stringValue()); }
@Override public int hashCode() { return val != null ? val.stringValue().hashCode() : 0; }
@Override public void handle(Model model, Resource resource, Object instance) { set.accept(instance, resource.stringValue()); }
@Override public void handle(Model model, Resource resource, Object instance) { set.accept(instance, resource.stringValue()); }
private String getResourceValue(Resource subject) { if (subject == null) { return null; } else if (subject instanceof IRI) { return subject.stringValue(); } else if (subject instanceof BNode) { return "_:" + subject.stringValue(); } throw new IllegalStateException("Did not recognise resource type: " + subject.getClass().getName()); }
private String getResourceValue(Resource subject) { if (subject == null) { return null; } else if (subject instanceof IRI) { return subject.stringValue(); } else if (subject instanceof BNode) { return "_:" + subject.stringValue(); } throw new IllegalStateException("Did not recognise resource type: " + subject.getClass().getName()); }
public void receiveTriple(Resource s, IRI p, Value o, IRI g, ExtractionContext context) throws TripleHandlerException { if(!this.resources.contains(s)) { this.resources.add(s); this.printStream.println(s.stringValue()); } if(o instanceof Resource && !this.resources.contains(o)) { this.resources.add((Resource) o); this.printStream.println(o.stringValue()); } }
private boolean matchingGraphContext(Resource subject) { return graphContext == null || subject.equals(graphContext) || subject.stringValue().startsWith(graphContext.stringValue() + "_subject_") || subject.stringValue().startsWith(graphContext.stringValue() + "_property_") || subject.stringValue().startsWith(graphContext.stringValue() + "_object_"); }
public static String filteredSpec(AGAbstractRepository repo, Resource[] contexts) { String[] graphs = new String[contexts.length]; for (int i = 0; i < contexts.length; i++) { if (null == contexts[i]) { graphs[i] = null; } else { graphs[i] = "<" + contexts[i].stringValue() + ">"; } } return filteredSpec(repo.getSpec(), graphs); }
@Override public Node call() { //throws AnyException return graphdb.findNode(RESOURCE, "uri", st.getSubject().stringValue()); } });
public void endRDF() throws RDFHandlerException { for(String uri:resourceLabels.keySet()){ vNodes.put(uri,new VirtualNode(Util.labels(new ArrayList<>(resourceLabels.get(uri))), resourceProps.get(uri), graphdb)); } statements.forEach(st -> vRels.add( new VirtualRelationship(vNodes.get(st.getSubject().stringValue().replace("'", "\'")), vNodes.get(st.getObject().stringValue().replace("'", "\'")), RelationshipType.withName(shorten(st.getPredicate()))))); }
private void extractClassHierarchy(Model model, Resource classResource) { for (Value object: model.filter(classResource, RDFS.SUBCLASSOF, null).objects()){ if (object instanceof IRI){ db.execute(String.format( "MATCH (p:Class { uri:'%s'}), (c { uri:'%s'}) MERGE (p)-[:SCO]->(c)", classResource.stringValue(), object.stringValue())); } } }
private void addRelationForMrefTypeAttribute( Model model, Resource subject, IRI predicate, Iterable<Entity> objectEntities) { for (Entity objectEntity : objectEntities) { model.add( subject, predicate, valueFactory.createIRI(subject.stringValue() + '/' + objectEntity.getIdValue())); } } }
@Override public void handleStatement(Statement st) throws RDFHandlerException { Value object = st.getObject(); StreamedStatement statement = new StreamedStatement(st.getSubject().stringValue(), st.getPredicate().stringValue(), object.stringValue(), (object instanceof Literal), ((object instanceof Literal)? ((Literal) object).getDatatype().stringValue(): null), (object instanceof Literal ? ((Literal) object).getLanguage().orElse(null) : null)); statements.add(statement); }
private void addRelationForXrefTypeAttribute( Model model, Resource subject, IRI predicate, Entity objectEntity) { if (contains(objectEntity.getEntityType().getAttributeNames(), "IRI")) { model.add(subject, predicate, valueFactory.createIRI(objectEntity.getString("IRI"))); } else { model.add( subject, predicate, valueFactory.createIRI(subject.stringValue() + '/' + objectEntity.getIdValue())); } }
private void extractPropertyHierarchy(Model model, Resource propResource, IRI propType) { for (Value object: model.filter(propResource, RDFS.SUBPROPERTYOF, null).objects()){ if (object instanceof IRI && (model.contains((IRI)object,RDF.TYPE, OWL.OBJECTPROPERTY) || model.contains((IRI)object,RDF.TYPE, OWL.DATATYPEPROPERTY) || model.contains((IRI)object,RDF.TYPE, RDF.PROPERTY))){ db.execute(String.format( "MATCH (p:%s { uri:'%s'}), (c { uri:'%s'}) MERGE (p)-[:%s]->(c)", getNeoEquivalentForProp(propType), propResource.stringValue(), object.stringValue(), (propType.equals(OWL.DATATYPEPROPERTY)?"SPO":"SRO"))); } } }
@Test public void testAddUnicodeSubject() throws RepositoryException { IRI s = vf.createIRI("http://franz.com/जुप"); IRI p = vf.createIRI("http://franz.com/p"); Literal o = vf.createLiteral("o"); conn.add(s, p, o); List<Statement> result = Iterations.asList(conn.getStatements(s, p, null, false)); assertThat(result.size(), is(1)); assertThat(result.get(0).getSubject().stringValue(), is("http://franz.com/जुप")); }
public void testAddUnicodeSubject(RDFFormat format) throws RepositoryException { conn.prepareHttpRepoClient().setPreferredRDFFormat(format); IRI s = vf.createIRI("http://franz.com/जुप"); IRI p = vf.createIRI("http://franz.com/p"); Literal o = vf.createLiteral("o"); conn.add(s, p, o); List<Statement> result = Iterations.asList(conn.getStatements(s, p, null, false)); assertThat(result.size(), is(1)); assertThat(result.get(0).getSubject().stringValue(), is("http://franz.com/जुप")); }