Package org.openrdf.repository

Examples of org.openrdf.repository.RepositoryConnection


    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));
    con.add(a, RDFS.SUBPROPERTYOF, c);
    Assert.assertTrue(con.hasStatement(a, RDFS.SUBPROPERTYOF, c, true,
        defaultContext));
  }
View Full Code Here


    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) );
    assertTrue("expect inferred stmt: q-hasInv-p",
        con.hasStatement(q, nrlInverse, p, true, defaultContext) );
   
    // add (redundant) inverse stmt: q-hasInv-p
    con.add(q, nrlInverse, p, defaultContext);
    assertTrue("added p-haInv-q, should stil be there",
        con.hasStatement(p, nrlInverse, q, true, defaultContext) );
    assertTrue( con.hasStatement(p, nrlInverse, q, true, defaultContext) );
    assertTrue("added q-hasInv-p, should still be there",
        con.hasStatement(q, nrlInverse, p, true, defaultContext) );

  }
View Full Code Here

    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

 
  public QueryResultTable sparqlSelect(String endpointURL, String sparqlQuery) {
    HTTPRepository endpoint = new HTTPRepository(endpointURL, "");
    try {
      endpoint.initialize();
      RepositoryConnection connection = endpoint.getConnection();
     
      return new RepositoryQueryResultTable(sparqlQuery, connection);
    } catch(RepositoryException e) {
      throw new ModelRuntimeException(e);
    }
View Full Code Here

     */
    private void assertEncodingDetection(String encoding, File input, String expectedContent)
    throws Exception {
        FileDocumentSource fileDocumentSource;
        Any23 any23;
        RepositoryConnection conn;
        RepositoryWriter repositoryWriter;

        fileDocumentSource = new FileDocumentSource(input);
        any23 = new Any23();
        Sail store = new MemoryStore();
        store.initialize();
        conn = new SailRepository(store).getConnection();
        repositoryWriter = new RepositoryWriter(conn);
        Assert.assertTrue( any23.extract(fileDocumentSource, repositoryWriter, encoding).hasMatchingExtractors() );

        RepositoryResult<Statement> statements = conn.getStatements(null, vDCTERMS.title, null, false);
        try {
            while (statements.hasNext()) {
                Statement statement = statements.next();
                printStatement(statement);
                org.junit.Assert.assertTrue(statement.getObject().stringValue().contains(expectedContent));
            }
        } finally {
            statements.close();
        }

        fileDocumentSource = null;
        any23 = null;
        conn.close();
        repositoryWriter.close();
    }
View Full Code Here

    HashMap resSet = new HashMap();

    for (int j = 0; j < cd.length; j++)
    {
      try {
        RepositoryConnection connection = dataRepo.getConnection();
        RepositoryResult<Statement> si = connection.getStatements(null, RDF.TYPE, f.createURI(cd[j]), true);
        Statement s;
        Resource r;
        while (si.hasNext()){
          s = si.next();
          r = s.getSubject();
View Full Code Here

        Lens[] sublens = fd.getLenses(pdp.sublens);

        // Target resource is object from original
        // resource : fresnel:property : object statements
      try {
        RepositoryConnection connection = dataRepo.getConnection();
        RepositoryResult<Statement> msl = connection.getStatements(r, null, null, true);
        Statement sr;
        while (msl.hasNext()){
          sr = msl.next();
          URI pr = sr.getPredicate();
          if (pr.toString().equals(pdp.property)) {
View Full Code Here

   * @param files
   * @param repository
   */
  private void addFilesToRepository(File[] files, Repository repository) {     
    try {
      RepositoryConnection con = repository.getConnection();
     
        String baseURI = "http://example.org/example/local";
        for (int i = 0; i < files.length; i++) {
          System.out.println("File Name: "+ files[i].getPath() + " File Index:"+i);
          try {
            con.add(files[i].toURI().toURL(), baseURI, RDFFormat.TRIX);
            System.out.println("Read File: "+ files[i].getPath());
            con.commit();
            } catch (Exception e) {             
              try{
                con.add(files[i].toURI().toURL(), baseURI, RDFFormat.RDFXML);
                System.out.println("Read File: "+ files[i].getPath());
                con.commit();
              }catch (Exception e1) {
                try{
                  con.add(files[i].toURI().toURL(), baseURI, RDFFormat.TURTLE);
                  System.out.println("Read File: "+ files[i].getPath());
                  con.commit();
                }catch (Exception e2) {
                  try{
                    con.add(files[i].toURI().toURL(), baseURI, RDFFormat.N3);
                    System.out.println("Read File: "+ files[i].getPath());
                    con.commit();
                  }catch (Exception e3) {
                    try{
                      con.add(files[i].toURI().toURL(), baseURI, RDFFormat.NTRIPLES);
                      System.out.println("Read File: "+ files[i].getPath());
                      con.commit();
                    }catch (Exception e4) {
                      try{
                        con.add(files[i].toURI().toURL(), baseURI, RDFFormat.TRIG);
                        System.out.println("Read File: "+ files[i].getPath());
                        con.commit();
                      }catch (Exception e5) {
                        e5.printStackTrace();
                      }
                    }
                  }
                }
              }
            }
        }
        con.close();
      
    } catch (RepositoryException e) {
      e.printStackTrace();
    }
     
View Full Code Here

              }
             
            }
          }else{
            //return values without metadata
            RepositoryConnection connection = dataRepo.getConnection();
            TupleQuery compiledQuery = connection.prepareTupleQuery(QueryLanguage.SPARQL, query);
            TupleQueryResult results = compiledQuery.evaluate()
           
         
            BindingSet set;
            Resource r;
View Full Code Here

          Lens[] sublens = fd.getLenses(pdp.sublens);

          // Target resource is object from original
          // resource : fresnel:property : object statements
        try {
          RepositoryConnection connection = dataRepo.getConnection();
          RepositoryResult<Statement> msl = connection.getStatements(r, null, null, true);
          Statement sr;
          while (msl.hasNext()){
            sr = msl.next();
            URI pr = sr.getPredicate();
            if (pr.toString().equals(pdp.property)) {
View Full Code Here

TOP

Related Classes of org.openrdf.repository.RepositoryConnection

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.