public SesameTripleCallback() { this(new GraphImpl()); }
/** * Creates a new BufferedGroupedWriter that wraps the supplied handlers, * using the supplied buffer size. * * @param bufferSize * size of the buffer expressed in number of RDF statements * @param handlers * one or more wrapped RDFHandlers */ public BufferedGroupingRDFHandler(int bufferSize, RDFHandler... handlers) { super(handlers); this.bufferSize = bufferSize; this.bufferedStatements = new GraphImpl(); this.contexts = new HashSet<Resource>(); }
public Iterable<Statement> serialize( final EntityState entityState, final boolean includeNonQueryable ) { Graph graph = new GraphImpl(); serialize( entityState, includeNonQueryable, graph ); return graph; }
/** * Associate the statement with the resource. It is part of the * description of that resource. * * @param describedResource * A resource that is being described. * @param stmt * A statement having that resource as either the subject or * object. */ private void record(final BigdataValue describedResource, final BigdataStatement stmt) { Graph g = graphs.get(describedResource); if(g == null) { graphs.put(describedResource, g = new GraphImpl()); } g.add(stmt); if (log.isDebugEnabled()) log.debug("DESCRIBE: describedResource=" + describedResource + ", statement=" + stmt); }
/** * Associate the statement with the resource. It is part of the * description of that resource. * * @param describedResource * A resource that is being described. * @param stmt * A statement having that resource as either the subject or * object. */ private void record(final BigdataValue describedResource, final BigdataStatement stmt) { Graph g = graphs.get(describedResource); if(g == null) { graphs.put(describedResource, g = new GraphImpl()); } g.add(stmt); if (log.isDebugEnabled()) log.debug("DESCRIBE: describedResource=" + describedResource + ", statement=" + stmt); }
public Iterable<Statement> serialize( final EntityState entityState, final boolean includeNonQueryable ) { Graph graph = new GraphImpl(); serialize( entityState, includeNonQueryable, graph ); return graph; }
/** * Creates a Graph representation of this repository. Note that any changes * on the Graph object will be reflected in this repository immediately! * * @return a Graph object that uses this repository as the backing store. * * @throws AccessDeniedException In case one does not have both read and * write access on this repository. */ public Graph getGraph() throws AccessDeniedException { _ensureReadAccess(); _ensureWriteAccess(); return new GraphImpl(this); }
/** * 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; }
public Graph serialize( Application app ) { Graph graph = new GraphImpl(); SerializerContext context = new SerializerContext( graph ); ApplicationVisitor applicationVisitor = new ApplicationVisitor( context ); app.descriptor().accept( applicationVisitor ); return graph; }
public Graph serialize( Application app ) { Graph graph = new GraphImpl(); SerializerContext context = new SerializerContext( graph ); ApplicationVisitor applicationVisitor = new ApplicationVisitor( context ); ( (Application) app ).descriptor().accept( applicationVisitor ); return graph; }
public void testGraphSerialization() throws Exception { testCon.add(bob, name, nameBob); testCon.add(alice, name, nameAlice); Graph graph; RepositoryResult<Statement> statements = testCon.getStatements(null, null, null, true); try { graph = new GraphImpl(vf, statements.asList()); } finally { statements.close(); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(graph); out.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream in = new ObjectInputStream(bais); Graph deserializedGraph = (Graph)in.readObject(); in.close(); assertFalse(deserializedGraph.isEmpty()); for (Statement st : deserializedGraph) { assertTrue(graph.contains(st)); assertTrue(testCon.hasStatement(st, true)); } }
public Iterable<Statement> serialize( final EntityDescriptor entityDescriptor ) { Graph graph = new GraphImpl(); ValueFactory values = graph.getValueFactory(); URI entityTypeUri = values.createURI( Classes.toURI( entityDescriptor.types().findFirst().orElse( null ) ) ); graph.add( entityTypeUri, Rdfs.TYPE, Rdfs.CLASS ); graph.add( entityTypeUri, Rdfs.TYPE, OWL.CLASS ); graph.add( entityTypeUri, PolygeneEntityType.TYPE, values.createLiteral( entityDescriptor.types().findFirst().get().toString() ) ); graph.add( entityTypeUri, PolygeneEntityType.QUERYABLE, values.createLiteral( entityDescriptor.queryable() ) ); serializeMixinTypes( entityDescriptor, graph, entityTypeUri ); serializePropertyTypes( entityDescriptor, graph, entityTypeUri ); serializeAssociationTypes( entityDescriptor, graph, entityTypeUri ); serializeManyAssociationTypes( entityDescriptor, graph, entityTypeUri ); return graph; }
/** * Convert the Jena Model to a Sesame Graph * @param theModel the model to convert * @return the set of statements in the Jena model saved in a sesame Graph */ public static Graph asSesameGraph(Model theModel) { Graph aGraph = new GraphImpl(); StmtIterator sIter = theModel.listStatements(); while (sIter.hasNext()) { aGraph.add(asSesameStatement(sIter.nextStatement())); } sIter.close(); return aGraph; }
public ObjectRepositoryConfig clone() { try { Object o = super.clone(); ObjectRepositoryConfig clone = (ObjectRepositoryConfig) o; clone.setReadContexts(copy(clone.getReadContexts())); clone.setAddContexts(copy(clone.getAddContexts())); clone.setRemoveContexts(copy(clone.getRemoveContexts())); clone.setArchiveContexts(copy(clone.getArchiveContexts())); clone.datatypes = copy(datatypes); clone.concepts = copy(concepts); clone.behaviours = copy(behaviours); clone.conceptJars = new ArrayList<URL>(conceptJars); clone.behaviourJars = new ArrayList<URL>(behaviourJars); clone.blobStoreParameters = new HashSet<Value>(blobStoreParameters); Graph model = new GraphImpl(); Resource subj = clone.export(model); clone.parse(model, subj); return clone; } catch (RepositoryConfigException e) { throw new AssertionError(e); } catch (CloneNotSupportedException e) { throw new AssertionError(e); } }
private void indexEntityState( final EntityState entityState, final RepositoryConnection connection ) throws RepositoryException { if( entityState.entityDescriptor().queryable() ) { final URI entityURI = stateSerializer.createEntityURI( getValueFactory(), entityState.identity() ); Graph graph = new GraphImpl(); stateSerializer.serialize( entityState, false, graph ); connection.add( graph, entityURI ); } }
private void indexEntityState( final EntityState entityState, final RepositoryConnection connection ) throws RepositoryException { if( entityState.entityDescriptor().queryable() ) { EntityReference reference = entityState.entityReference(); final URI entityURI = stateSerializer.createEntityURI( getValueFactory(), reference); Graph graph = new GraphImpl(); stateSerializer.serialize( entityState, false, graph ); connection.add( graph, entityURI ); } }
private void indexEntityState( final EntityState entityState, final RepositoryConnection connection ) throws RepositoryException { if( entityState.entityDescriptor().queryable() ) { EntityReference reference = entityState.entityReference(); final URI entityURI = stateSerializer.createEntityURI( getValueFactory(), reference); Graph graph = new GraphImpl(); stateSerializer.serialize( entityState, false, graph ); connection.add( graph, entityURI ); } }
public static Graph toGraph(TupleQueryResult tqr) throws QueryEvaluationException { Graph graph = new GraphImpl(); DAWGTestResultSetWriter writer = new DAWGTestResultSetWriter(new StatementCollector(graph)); try { writer.startQueryResult(tqr.getBindingNames()); while (tqr.hasNext()) { writer.handleSolution(tqr.next()); } writer.endQueryResult(); } catch (TupleQueryResultHandlerException e) { // No exceptions expected from DAWGTestResultSetWriter or // StatementCollector, foud a bug? throw new RuntimeException(e); } return graph; }
final Graph g = new GraphImpl();
public Iterable<Statement> serialize( final EntityDescriptor entityDescriptor ) { Graph graph = new GraphImpl(); ValueFactory values = graph.getValueFactory(); URI entityTypeUri = values.createURI( Classes.toURI( first( entityDescriptor.types() ) ) ); graph.add( entityTypeUri, Rdfs.TYPE, Rdfs.CLASS ); graph.add( entityTypeUri, Rdfs.TYPE, OWL.CLASS ); graph.add( entityTypeUri, Qi4jEntityType.TYPE, values.createLiteral( first( entityDescriptor.types() ).toString() ) ); graph.add( entityTypeUri, Qi4jEntityType.QUERYABLE, values.createLiteral( entityDescriptor.queryable() ) ); serializeMixinTypes( entityDescriptor, graph, entityTypeUri ); serializePropertyTypes( entityDescriptor, graph, entityTypeUri ); serializeAssociationTypes( entityDescriptor, graph, entityTypeUri ); serializeManyAssociationTypes( entityDescriptor, graph, entityTypeUri ); return graph; }