Package org.openrdf.repository

Examples of org.openrdf.repository.Repository


    URI defaultContext = null;
    // create a Sail stack
    Sail sail = new MemoryStore();
    sail = new ForwardChainingRDFSInferencer(sail);
    // create a Repository
    Repository repository = new SailRepository(sail);
    repository.initialize();

    RepositoryConnection con = repository.getConnection();

    con.add(a, RDFS.SUBPROPERTYOF, b, defaultContext);
    con.add(b, RDFS.SUBPROPERTYOF, c, defaultContext);
    Assert.assertTrue(con.hasStatement(a, RDFS.SUBPROPERTYOF, c, true,
        defaultContext));
View Full Code Here


    // create a Sail stack
    Sail sail = new MemoryStore();
    sail = new ForwardChainingRDFSPlusInverseInferencer(sail);

    // create a Repository
    Repository repository = new SailRepository(sail);
    try {
      repository.initialize();
    } catch (RepositoryException e) {
      throw new RuntimeException(e);
    }

    URI a = new URIImpl("urn:test:a");
    URI b = new URIImpl("urn:test:b");
    URI c = new URIImpl("urn:test:c");
    URI d = new URIImpl("urn:test:d");
    URI nrlInverse = ForwardChainingRDFSPlusInverseInferencerConnection.NRL_InverseProperty;

    repository.getConnection().add(a, b, c, new Resource[0]);

    Assert.assertFalse(repository.getConnection().hasStatement(c, d, a,
        true, new Resource[0]));

    repository.getConnection().add(b, nrlInverse, d, new Resource[0]);

    Assert.assertTrue(repository.getConnection().hasStatement(c, d, a,
        true, new Resource[0]));

  }
View Full Code Here

    // create a Sail stack
    Sail sail = new MemoryStore();
    sail = new ForwardChainingRDFSPlusInverseInferencer(sail);

    // create a Repository
    Repository repository = new SailRepository(sail);
    try {
      repository.initialize();
    } catch (RepositoryException e) {
      throw new RuntimeException(e);
    }

    org.openrdf.model.URI a = new org.openrdf.model.impl.URIImpl(
        "urn:test:a");
    org.openrdf.model.URI b = new org.openrdf.model.impl.URIImpl(
        "urn:test:b");
    org.openrdf.model.URI c = new org.openrdf.model.impl.URIImpl(
        "urn:test:c");
    org.openrdf.model.URI d = new org.openrdf.model.impl.URIImpl(
        "urn:test:d");
    org.openrdf.model.URI nrlInverse = new org.openrdf.model.impl.URIImpl(
        "http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#inverseProperty");

    repository.getConnection().add(a, b, c, new Resource[0]);
    Assert.assertTrue("added [a] [b] [c]", repository.getConnection()
        .hasStatement(a, b, c, true, new Resource[0]));

    Assert.assertFalse("expect not [c] [d] [a]", repository.getConnection()
        .hasStatement(c, d, a, true, new Resource[0]));

    // add [b] hasInverse [d]
    repository.getConnection().add(b, nrlInverse, d, new Resource[0]);
    Assert.assertTrue("added [b] nrlInverse [d]", repository
        .getConnection().hasStatement(b, nrlInverse, d, true,
            new Resource[0]));

    Assert.assertTrue("expect [c] [d] [a]", repository.getConnection()
        .hasStatement(c, d, a, true, new Resource[0]));

  }
View Full Code Here

    // create a Sail stack
    Sail sail = new MemoryStore();
    sail = new ForwardChainingRDFSPlusInverseInferencer(sail);

    // create a Repository
    Repository repository = new SailRepository(sail);
    try {
      repository.initialize();
    } catch (RepositoryException e) {
      throw new RuntimeException(e);
    }
   
    URI p = new URIImpl("urn:rel:p");
    URI q = new URIImpl("urn:rel:q");
    URI nrlInverse = ForwardChainingRDFSPlusInverseInferencerConnection.NRL_InverseProperty;
    URI defaultContext = null; // new Resource[0]

    RepositoryConnection con = repository.getConnection();

    // add p-hasInverse-q
    con.add(p, nrlInverse, q, defaultContext);
    assertTrue("just added p-haInv-q, should stil be there",
        con.hasStatement(p, nrlInverse, q, true, defaultContext) );
View Full Code Here

    // create a Sail stack
    Sail sail = new MemoryStore();
    sail = new ForwardChainingRDFSPlusInverseInferencer(sail);

    // create a Repository
    Repository repository = new SailRepository(sail);
    try {
      repository.initialize();
    } catch (RepositoryException e) {
      throw new RuntimeException(e);
    }
   
    URI a1 = new URIImpl("urn:name:a1");
    URI b1 = new URIImpl("urn:name:b1");
    URI relA = new URIImpl("urn:rel:A");
    URI relAinv= new URIImpl("urn:rel:Ainv");
    URI nrlInverse = ForwardChainingRDFSPlusInverseInferencerConnection.NRL_InverseProperty;
    URI defaultContext = null; // new Resource[0]

    RepositoryConnection con = repository.getConnection();
    con.add(a1,relA,b1);
    assert con.hasStatement(a1,relA,b1, true, defaultContext);
    con.add(relA,nrlInverse,relAinv);
    assert con.hasStatement(b1, relAinv, a1, true, defaultContext);
  }
View Full Code Here

    if(reasoning) {
      sail = new ForwardChainingRDFSInferencer((MemoryStore)sail);
    }
   
    // create a Repository
    Repository repository = new SailRepository(sail);
    try {
      repository.initialize();
    } catch(RepositoryException e) {
      throw new ModelRuntimeException(e);
    }
   
    return repository;
View Full Code Here

  public String getClassInfo(String uri, String location) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
    String out = "";
    boolean isLensAvailable = false;
    int i = 0;
    RepositoryConnection con=null;
    Repository repository=null;

    if (location == "remote") {
      repository =lenaConfig.getRemoteRepository();
      con = repository.getConnection();
    } else if (location == "local") {
      repository = lenaConfig.getLocalRepository();
      con = repository.getConnection();
    }
    try {

      String query = "prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?s WHERE { ?s rdf:type <" + uri + "> }";
View Full Code Here

    } else {
      classGiven=false;
    }
   
 
    Repository repository = null;
    Document document=null;
    try {
      if (!remoteRepo) {
        repository = lenaConfig.getLocalRepository();
        //System.out.println("SET REMOTE");
View Full Code Here

                }


                InputStream in = entity.getContent();
                try {
                    Repository triples;

                    if(endpoint != null) {
                        switch (endpoint.getType()) {
                            case SPARQL:
                                triples = parseSparqlResponse(resource,in,contentType);
                                break;
                            default:
                                triples = parseRDFResponse(resource,in,contentType);
                        }
                    } else {
                        triples = parseRDFResponse(resource,in,contentType);
                    }



                    ClientResponse result = new ClientResponse(triples);

                    Header expires = response.getFirstHeader("Expires");
                    if(expires != null) {
                        try {
                            Date expiresDate = DateUtils.parseDate(expires.getValue());
                            result.setExpires(expiresDate);
                        } catch (DateParseException e) {
                            log.warn("could not parse Expires: header, using default expiry settings");
                            Date expiresDate = new Date(System.currentTimeMillis()+defaultExpires*1000);
                            result.setExpires(expiresDate);
                        }
                    } else {
                        Date expiresDate = new Date(System.currentTimeMillis()+defaultExpires*1000);
                        result.setExpires(expiresDate);
                    }

                    if(log.isInfoEnabled()) {
                        RepositoryConnection con = triples.getConnection();
                        log.info("retrieved {} triples for resource {}; expiry date: {}",new Object[] {con.size(),resource.stringValue(),result.getExpires()});
                        con.close();
                    }

                    return result;
View Full Code Here

        super();

        cacheEntries = new HashMap<String,CacheEntry>();

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

        } catch (RepositoryException e) {
            log.error("error initialising connection to Sesame in-memory repository",e);
        }
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.