/** * Describe the service end point(s). * * @see #endpoint */ protected void describeServiceEndpoints() { for (String uri : serviceURI) { g.add(aService, SD.endpoint, g.getValueFactory().createURI(uri)); } }
/** * Adds the specified statement and makes sure that no other statements are * present in the Graph with the same subject and predicate. When contexts * are specified, the (subj, pred) pair will occur exactly once in each * context, else the (subj, pred) pair will occur exactly once in the entire * Graph. */ public static void setUniqueObject(Graph graph, Resource subj, URI pred, Value obj, Resource... contexts) { Iterator<Statement> iter = graph.match(subj, pred, null, contexts); while (iter.hasNext()) { iter.next(); iter.remove(); } graph.add(subj, pred, obj, contexts); }
public SerializerContext( Graph graph ) { this.valueFactory = graph.getValueFactory(); this.graph = graph; }
/** * Gets the subject of the statements with the specified predicate, object * and (optionally) contexts from the supplied graph. Calling this method is * equivalent to calling <tt>graph.match(null, pred, obj, contexts)</tt> and * extracting the subjects of the matching statements from the returned * iterator. See {@link Graph#match(Resource, URI, Value, Resource[])} for a * description of the parameter values. */ public static Iterator<Resource> getSubjectIterator(Graph graph, URI pred, Value obj, Resource... contexts) { Iterator<Statement> iter = graph.match(null, pred, obj, contexts); return new ConvertingIterator<Statement, Resource>(iter) { @Override protected Resource convert(Statement st) throws RuntimeException { return st.getSubject(); } }; }
ValueFactory factory = graph.getValueFactory(); StatementIterator sti = graph.getStatements(null,resRdfType,resUser); while ( sti.hasNext() ) { Resource resCUser = sti.next().getSubject(); int id = Integer.parseInt( graph.getStatements(resCUser,proId,null).next().getObject().toString()); User user = new UserImpl(id,"","",""); StatementIterator rui = graph.getStatements(resCUser,proHasRule,null); Set rulzSet = new HashSet(); while (rui.hasNext()){ if ( null == rule ) { rule = new RuleImpl( Integer.parseInt(graph.getStatements(rul,proId,null) .next().getObject().toString()) ,"",""); = graph.getStatements(resCUser,proHasRole,null); Set rolzSet = new HashSet(); while (roi.hasNext()){ if ( null == role ) { role = new RoleImpl( Integer.parseInt(graph.getStatements(rol,proId,null).next(). getObject().toString()) ,"","");
Iterator<Statement> typeStatements = bufferedStatements.match(subject, RDF.TYPE, null, context); while (typeStatements.hasNext()) { Statement typeStatement = typeStatements.next(); Iterator<Statement> subjectStatements = bufferedStatements.match(subject, null, null, context); while (subjectStatements.hasNext()) { Statement subjectStatement = subjectStatements.next(); IRI predicate = subjectStatement.getPredicate(); if (!processedPredicates.contains(predicate)) { Iterator<Statement> toWrite = bufferedStatements.match(subject, predicate, null, context); while (toWrite.hasNext()) { Statement toWriteSt = toWrite.next(); bufferedStatements.clear(); contexts.clear();
/** * Compare two graphs for equality. * <p> * Note: This is not very efficient if the {@link Graph} implementations are * not indexed. * <p> * Note: This does not handle equality testing with blank nodes (it does not * test for isomorphic graphs). * * @param expected * @param actual */ static protected void assertSameGraph(final Graph expected, final Graph actual) { for (Statement s : expected) { if (!actual.contains(s)) fail("Expecting: " + s); } assertEquals("size", expected.size(), actual.size()); }
/** * call this method if you need the RDF Graph * that represents the R2RML mappings * @return an RDF Graph */ @Deprecated public Graph getGraph() { OBDAMappingTransformer transformer = new OBDAMappingTransformer(); transformer.setOntology(ontology); List<Statement> statements = new ArrayList<Statement>(); for (OBDAMappingAxiom axiom: this.mappings) { List<Statement> statements2 = transformer.getStatements(axiom,prefixmng); statements.addAll(statements2); } @SuppressWarnings("deprecation") Graph g = new GraphImpl(); g.addAll(statements); return g; }
case DESCRIBE: case CONSTRUCT: nresults = buildGraph(conn).size(); break; case ASK: // I think that there are some alternative mime types for ask...
@Override public void handleStatement(Statement st) throws RDFHandlerException { graph.add(st); }
public SerializerContext( Graph graph ) { this.valueFactory = graph.getValueFactory(); this.graph = graph; }
/** * Gets the objects of the statements with the specified subject, predicate * and (optionally) contexts from the supplied graph. Calling this method is * equivalent to calling <tt>graph.match(subj, pred, null, contexts)</tt> and * extracting the objects of the matching statements from the returned * iterator. See {@link Graph#match(Resource, URI, Value, Resource[])} for a * description of the parameter values. */ public static Iterator<Value> getObjectIterator(Graph graph, Resource subj, URI pred, Resource... contexts) { Iterator<Statement> iter = graph.match(subj, pred, null, contexts); return new ConvertingIterator<Statement, Value>(iter) { @Override protected Value convert(Statement st) throws RuntimeException { return st.getObject(); } }; }
/** * Compare two graphs for equality. * <p> * Note: This is not very efficient if the {@link Graph} implementations are * not indexed. * <p> * Note: This does not handle equality testing with blank nodes (it does not * test for isomorphic graphs). * * @param expected * @param actual */ static protected void assertSameGraph(final Graph expected, final Graph actual) { for (Statement s : expected) { if (!actual.contains(s)) fail("Expecting: " + s); } assertEquals("size", expected.size(), actual.size()); }
g.addAll(rdfHandler.getStatements());
case DESCRIBE: case CONSTRUCT: nresults = buildGraph(conn).size(); break; case ASK: // I think that there are some alternative mime types for ask...
/** * Describe the service end point(s). * * @see #endpoint */ protected void describeServiceEndpoints() { for (String uri : serviceURI) { g.add(aService, SD.endpoint, g.getValueFactory().createURI(uri)); } }