Package org.openrdf.repository.sail

Examples of org.openrdf.repository.sail.SailRepository


    private Repository parseSparqlResponse(final URI resource, InputStream in, String contentType) throws RepositoryException, IOException, QueryResultParseException, TupleQueryResultHandlerException {
        TupleQueryResultFormat format = QueryResultIO.getParserFormatForMIMEType(contentType, TupleQueryResultFormat.SPARQL);


        final Repository triples = new SailRepository(new MemoryStore());
        triples.initialize();

        QueryResultIO.parse(in,format,
                new TupleQueryResultHandler() {

                    RepositoryConnection con;
                    URI subject;

                    @Override
                    public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException {
                        subject = triples.getValueFactory().createURI(resource.stringValue());
                        try {
                            con = triples.getConnection();
                        } catch (RepositoryException e) {
                            throw new TupleQueryResultHandlerException("error while creating repository connection",e);
                        }
                    }

                    @Override
                    public void endQueryResult() throws TupleQueryResultHandlerException   {
                        try {
                            con.commit();
                            con.close();
                        } catch (RepositoryException e) {
                            throw new TupleQueryResultHandlerException("error while closing repository connection",e);
                        }
                    }

                    @Override
                    public void handleSolution(BindingSet bindingSet) throws TupleQueryResultHandlerException {

                        try {
                            Value predicate = bindingSet.getValue("p");
                            Value object    = bindingSet.getValue("o");

                            if(predicate instanceof URI) {
                                con.add(triples.getValueFactory().createStatement(subject,(URI)predicate,object));
                            } else {
                                log.error("ignoring binding as predicate {} is not a URI",predicate);
                            }
                        } catch (RepositoryException e) {
                            throw new TupleQueryResultHandlerException("error while adding triple to repository connection",e);
                        }
                    }
                },
                triples.getValueFactory());

        return triples;


    }
View Full Code Here


    @BeforeClass
    public static final void initYard() throws RepositoryException{
        SesameYardConfig config = new SesameYardConfig("testYardId");
        config.setName("Sesame Yard Test");
        config.setDescription("The Sesame Yard instance used to execute the Unit Tests defined for the Yard Interface");
        repo = new SailRepository(new MemoryStore());
        repo.initialize();
        yard = new SesameYard(repo,config);
    }
View Full Code Here

    }

    private ProjectDao createProjectDao()
    {
        dataDir = new File( basedir, ( "/target/rdf-repos/rdf-repo-" + System.currentTimeMillis() ) );
        rdfRepository = new SailRepository( new MemoryStoreRDFSInferencer( new MemoryStore( dataDir ) ) );
        try
        {
            rdfRepository.initialize();
        }
        catch ( RepositoryException e )
View Full Code Here

    private Repository createRepository()
    {
        File dataDir = new File( basedir, ( "/target/rdf-repos/rdf-repo-" + System.currentTimeMillis() ) );
        org.openrdf.repository.Repository rdfRepository =
            new SailRepository( new MemoryStoreRDFSInferencer( new MemoryStore( dataDir ) ) );
        try
        {
            rdfRepository.initialize();
        }
        catch ( RepositoryException e )
        {
            return null;
        }
View Full Code Here

        File dataDir = new File( System.getProperty( "user.home" ), ".m2/repository" );
        MemoryStore store = new MemoryStore( dataDir );
        store.setPersist( true );
        store.setSyncDelay( 0 );
        org.openrdf.repository.Repository rdfRepository = new SailRepository( store );
        try
        {
            rdfRepository.initialize();
        }
        catch ( RepositoryException e )
        {
            throw new NPandayRepositoryException("NPANDAY-080-005: Failed to initialized repository. Message = " + e.getMessage(), e );
        }
View Full Code Here

        if ( localRepository == null )
        {
            localRepository = new File( System.getProperty( "user.home" ), ".m2/repository" );
        }
       
        org.openrdf.repository.Repository rdfRepository = new SailRepository( new MemoryStore( localRepository ) );
        try
        {
            rdfRepository.initialize();
        }
        catch ( RepositoryException e )
        {
            throw new MojoExecutionException( e.getMessage() );
        }

        RDFHandler rdfxmlWriter;
        try
        {
            rdfxmlWriter = new RDFXMLWriter( new FileOutputStream( localRepository+"/rdf-repository-export.xml" ) );
        }
        catch ( IOException e )
        {
            throw new MojoExecutionException( e.getMessage() );
        }

        try
        {
            RepositoryConnection repositoryConnection = rdfRepository.getConnection();
            repositoryConnection.export( rdfxmlWriter );
        }
        catch ( RepositoryException e )
        {
            throw new MojoExecutionException( e.getMessage() );
View Full Code Here

        }

        String artifactValue = System.getProperty( "artifact" );
        String[] tokens = artifactValue.split( "[:]" );

        org.openrdf.repository.Repository rdfRepository = new SailRepository( new MemoryStore( localRepository ) );
        try
        {
            rdfRepository.initialize();
        }
        catch ( RepositoryException e )
        {
            throw new MojoExecutionException( e.getMessage() );
        }
View Full Code Here

        if ( localRepository == null )
        {
            localRepository = new File( System.getProperty( "user.home" ), ".m2/repository" );
        }
       
        org.openrdf.repository.Repository rdfRepository = new SailRepository( new MemoryStore( localRepository ) );
       
        try
        {
            rdfRepository.initialize();
        }
        catch ( RepositoryException e )
        {
            throw new MojoExecutionException( "NPANDAY-1700-007: Message = " + e.getMessage() );
        }
View Full Code Here

  protected Repository rdfRep;
  private String label;

  public RDFSingleDataSet() {
    try {
      rdfRep = new SailRepository(new ForwardChainingRDFSInferencer(new MemoryStore()));
      rdfRep.initialize();
     
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
View Full Code Here

  public JSONArray loadHistory(String filename) throws Exception {
    File file = new File(filename);
//    String encoding = EncodingDetector.detect(file);
//    String contents = EncodingDetector.getString(file, encoding);
   
    SailRepository myRepository = new SailRepository(new MemoryStore());
    myRepository.initialize();
    SailRepositoryConnection con = myRepository.getConnection();
    con.add(file, "", RDFFormat.TURTLE);
   
    RepositoryResult<Statement> result = con.getStatements(null, new URIImpl("http://isi.edu/integration/karma/dev#hasWorksheetHistory"), null, false);
    if(result.hasNext()) {
      Statement stmt = result.next();
View Full Code Here

TOP

Related Classes of org.openrdf.repository.sail.SailRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.