Package org.openrdf.repository

Examples of org.openrdf.repository.Repository


        recordManager = RecordManagerFactory.createRecordManager(dataDirectory.getAbsolutePath()+File.separator+"resource_cache.cache");

        cacheEntries = recordManager.treeMap("resources");

        try {
            Repository repository = new SailRepository(new NativeStore(tripleStore));
            repository.initialize();
            setRepository(repository);

        } catch (RepositoryException e) {
            log.error("error initialising connection to Sesame in-memory repository",e);
        }
View Full Code Here



    private Repository parseRDFResponse(final URI resource, InputStream in, String contentType) throws RepositoryException, IOException, RDFParseException {
        RDFFormat format = RDFParserRegistry.getInstance().getFileFormatForMIMEType(contentType, RDFFormat.RDFXML);

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

        InterceptingRepositoryConnection con =
                new InterceptingRepositoryConnectionWrapper(triples,triples.getConnection());

        con.addRepositoryConnectionInterceptor(new RepositoryConnectionInterceptorAdapter() {
            @Override
            public boolean add(RepositoryConnection conn, Resource s, org.openrdf.model.URI p, Value o, Resource... contexts) {
                if(s instanceof org.openrdf.model.URI) {
View Full Code Here

    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

    public void testConvert()
    {
        File testRepo = new File( System.getProperty( "basedir" ), "target/test-repo/repository" );
        testRepo.mkdir();

        Repository repository = this.createRepository();
        ProjectDao dao = this.createProjectDao( repository );

        Project project = new Project();
        project.setGroupId( "npanday.model" );
        project.setArtifactId( "NPanday.Model.Pom" );
View Full Code Here

    sa[2] = VIRTUOSO_USERNAME;
    sa[3] = VIRTUOSO_PASSWORD;
    for (int i = 0; i < sa.length && i < args.length; i++) {
      sa[i] = args[i];
    }
    Repository repository = new VirtuosoRepository("jdbc:virtuoso://" + sa[0] + ":" +
        sa[1]+ "/charset=UTF-8/log_enable=2", sa[2], sa[3]);

    //    extractObjectProperties(repository, "http://europeana.eu", Params.LOD_OBJECT_PROPERIES_FILE);
    //    extractDataProperties(repository, "http://europeana.eu", Params.LOD_DATA_PROPERIES_FILE);
View Full Code Here

        return wrap(exhibit, this);
    }

    public Object jsFunction_createRepository(Object requestO, String repoType, String slug) throws MalformedURLException, Exception {
        HttpServletRequest request = (HttpServletRequest) unwrap(requestO);
        Repository repo = getModule().createRepository(request,repoType,slug);
       
        return wrap(repo, this);
    }
View Full Code Here

        public Sail sail;
    }
   
    static public RepoSailTuple createMemoryRepository(File dir) {
        try {
            Repository r = null;
            Sail s = null;
            if (dir != null) {
                s = new MemoryStore(dir);
                r = new SailRepository(s);
            } else {
                s = new MemoryStore();
                r = new SailRepository(new MemoryStore());
            }
            r.initialize();

            return new RepoSailTuple(r,s);
        } catch (Exception e) {
            _logger.error("Exception caught while creating Sesame in-memory repository", e);
            return null;
View Full Code Here

    static public RepoSailTuple createNativeRepository(File dir) {
        try {
            Sail sail = new NativeStore();
            sail.setDataDir(dir);
            ((NativeStore) sail).setTripleIndexes("spoc,posc,opsc");
            Repository r = new SailRepository(sail);
            r.initialize();
            return new RepoSailTuple(r,sail);
        } catch (Exception e) {
            _logger.error("Exception caught while creating Sesame native repository", e);
            return null;
        }
View Full Code Here

        conn.setRequestProperty("Accept", "application/rdf+xml, text/rdf+n3");
    }

    static public void loadDataFromStream(InputStream stream, String sourceURL, String lang, Sail sail) throws Exception {
        RepoSailTuple rs = createMemoryRepository(null);
        Repository r = rs.repository;

        lang = lang.toLowerCase();
        if ("exhibit/json".equals(lang)) {
            Properties properties = new Properties();
           
            BabelReader reader = new ExhibitJsonReader();
            try {
                if (reader.takesReader()) {
                    InputStreamReader isr = new InputStreamReader(stream);
                    reader.read(isr, sail, properties, Locale.getDefault());
                } else {
                     reader.read(stream, sail, properties, Locale.getDefault());
                }
            } finally {
                stream.close();
            }
        } else {
            RDFParser parser = null;
            if ("rdfxml".equals(lang)) {
                parser = new RDFXMLParser(r.getValueFactory());
            } else if ("n3".equals(lang) || "turtle".equals(lang)) {
                parser = new TurtleParser(r.getValueFactory());
            } else if ("ntriples".equals(lang)) {
                parser = new NTriplesParser(r.getValueFactory());
            }
           
            try {
              SailConnection c = null;
              try {
View Full Code Here

    } catch (IOException e) {
      Global.log().warning("Failed to write result to temporary file");
      return;
    }
   
    Repository tempRepository = new SailRepository(new MemoryStore());
    RepositoryConnection conn = null;
    try {
      tempRepository.initialize();
      conn = tempRepository.getConnection();
    } catch (RepositoryException e1) {
      Global.log().warning("Failed to create repository for merging");
      return;
    }
 
View Full Code Here

TOP

Related Classes of org.openrdf.repository.Repository

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.