public static String prettyPrint(RepositoryConnection connection, Collection<? extends Resource> ctxs) throws SesameUtilsException { return prettyPrint(connection,toArray(ctxs)); }
public static <T> void load(RepositoryConnection connection, T content, URI ctx) throws SesameUtilsException { Objects.requireNonNull(ctx, "Context URI cannot be null"); loadSource(connection,ctx.toString(),SourceFactory.create(content,Metadata.DEFAULT),ctx); }
@Test public void testCornerCases() throws Exception { RepositoryConnection connection=getConnection(); URI ctx=uri(NS1_NAMESPACE); URI ctx_res=uri(NS2_NAMESPACE); SesameUtils.load(connection, getExamplesResource(), ctx); List<URI> ctxs=new ArrayList<URI>(); ctxs.add(ctx); String result = SesameUtils.prettyPrint(connection, ctxs); dumpTurtle(result); SesameUtils.load(connection, result, ctx_res); } }
private <T> void loadGraph(String graphName, Module<T> module) throws InvalidContentsException { RepositoryConnection connection=getConnection(); try { URI newCtx=null; if(graphName!=null) { newCtx=nextContext(connection,graphName,module.getBase()); } SesameUtils.loadModule(connection,module,newCtx); if(graphName!=null) { URI previousCtx=loadedGraphs.put(graphName, newCtx); if(previousCtx!=null) { connection.clear(previousCtx); } } } catch (ContentProcessingException e) { throw new InvalidContentsException("The contents provided could not be loaded",e,graphName,module); } catch (RepositoryException e) { throw new QueryTemplateSupportFailure(e); } catch (SesameUtilsException e) { throw new QueryTemplateSupportFailure(e); } finally { close(connection); } }
@Test public void shouldPrettyPrint() throws Exception { RepositoryConnection connection=getConnection(); URI ctx=connection.getValueFactory().createURI("http://example.org/one"); URI ctx_res=connection.getValueFactory().createURI("http://example.org/two"); SesameUtils.load(connection, getExamplesResource(), ctx); List<URI> ctxs=new ArrayList<URI>(); ctxs.add(ctx); String result = SesameUtils.prettyPrint(connection, ctxs); dumpTurtle(result); SesameUtils.load(connection, result, ctx_res); }
public static <T> void loadModule(RepositoryConnection connection, Module<T> content, URI ctx) throws SesameUtilsException { loadSource(connection,content.getBase(),content.getSource(),ctx); }