Examples of RepositoryConnection


Examples of com.volantis.mcs.repository.RepositoryConnection

     * @throws RepositoryException if there was a problem.
     */
    private void initialiseDevicePatternCache(Repository repository,
            DeviceRepositoryAccessor accessor) throws RepositoryException {

        RepositoryConnection connection = null;
        try {
            connection = repository.connect();
            accessor.initializeDevicePatternCache(connection);
            connection.disconnect();
            connection = null;
        } finally {
            if (connection != null) {
                connection.disconnect();
            }
        }
    }

Examples of org.jboss.dna.graph.connector.RepositoryConnection

        if (systemSourceNameValue != null) {
            // Find an existing source with the given name containing the named workspace ...
            try {
                SourceWorkspacePair pair = new SourceWorkspacePair(systemSourceNameValue);
                // Look for a source with the given name ...
                RepositoryConnection conn = connectionFactory.createConnection(pair.getSourceName());
                if (conn != null) {
                    // We found a source that we can use for the system ...
                    systemSourceName = pair.getSourceName();
                    if (pair.getWorkspaceName() != null) {
                        // There should be the named workspace ...

Examples of org.jboss.dna.graph.connectors.RepositoryConnection

        // Find the repository ...
        FederatedRepository repository = getRepository();
        // Authenticate the user ...
        String username = this.username;
        Object credentials = this.password;
        RepositoryConnection connection = repository.createConnection(this, username, credentials);
        if (connection == null) {
            I18n msg = FederationI18n.unableToAuthenticateConnectionToFederatedRepository;
            throw new RepositorySourceException(msg.text(this.repositoryName, username));
        }
        // Return the new connection ...

Examples of org.openrdf.repository.RepositoryConnection

  }

  private void removeProtectedStatement()
    throws StoreException
  {
    RepositoryConnection con = repository.getConnection();
    try {
      ValueFactory vf = con.getValueFactory();
      con.removeMatch(vf.createURI(RNA_RECYCLE), null, null);
    }
    finally {
      con.close();
    }
  }

Examples of org.openrdf.repository.RepositoryConnection

  }

  private boolean hasProtectedStatement()
    throws StoreException
  {
    RepositoryConnection con = repository.getConnection();
    try {
      ValueFactory vf = con.getValueFactory();
      return con.hasMatch(vf.createURI(RNA_RECYCLE), RDF.TYPE, vf.createURI(SKOS_CONCEPT), true);
    }
    finally {
      con.close();
    }
  }

Examples of org.openrdf.repository.RepositoryConnection

  private List<String> evaluate(String name, String query)
    throws Exception
  {
    List<String> labels = new ArrayList<String>();
    RepositoryConnection con = repository.getConnection();
    try {
      assertTrue(con.size() > 0);
      TupleQuery qry = con.prepareTupleQuery(SPARQL, query);
      TupleResult result = qry.evaluate();
      try {
        while (result.hasNext()) {
          Value value = result.next().getValue(name);
          if (value == null) {
            labels.add(null);
          } else {
            labels.add(value.stringValue());
          }
        }
      }
      finally {
        result.close();
      }
    }
    finally {
      con.close();
    }
    return labels;
  }

Examples of org.openrdf.repository.RepositoryConnection

  }

  private void load(String resource)
    throws Exception
  {
    RepositoryConnection con = repository.getConnection();
    try {
      ClassLoader cl = getClass().getClassLoader();
      URL url = cl.getResource(resource);
      con.add(url, "", RDFFormat.forFileName(resource));
    } finally {
      con.close();
    }
  }

Examples of org.openrdf.repository.RepositoryConnection

    TestSuite suite = new TestSuite(TriGParserTestCase.class.getName());

    // Add the manifest for positive test cases to a repository and query it
    Repository repository = new SailRepository(new MemoryStore());
    repository.initialize();
    RepositoryConnection con = repository.getConnection();

    URL url = TriGParserTestCase.class.getResource(MANIFEST_GOOD_URL);
    con.add(url, base(url.toExternalForm()), RDFFormat.TURTLE);

    String query = "SELECT testName, inputURL, outputURL " + "FROM {} mf:name {testName}; "
        + "        mf:result {outputURL}; " + "        mf:action {} qt:data {inputURL} "
        + "USING NAMESPACE " + "  mf = <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>, "
        + "  qt = <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>";

    TupleResult queryResult = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();

    // Add all positive parser tests to the test suite
    while (queryResult.hasNext()) {
      BindingSet bindingSet = queryResult.next();
      String testName = bindingSet.getValue("testName").toString();
      String inputURL = bindingSet.getValue("inputURL").toString();
      String outputURL = bindingSet.getValue("outputURL").toString();

      String baseURL = BASE_URL + testName + ".ttl";

      suite.addTest(new PositiveParserTest(testName, inputURL, outputURL, baseURL));
    }

    queryResult.close();

    // Add the manifest for negative test cases to a repository and query it
    con.clear();
    url = TriGParserTestCase.class.getResource(MANIFEST_BAD_URL);
    con.add(url, base(url.toExternalForm()), RDFFormat.TURTLE);

    query = "SELECT testName, inputURL " + "FROM {} mf:name {testName}; "
        + "        mf:action {} qt:data {inputURL} " + "USING NAMESPACE "
        + "  mf = <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>, "
        + "  qt = <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>";
    queryResult = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();

    // Add all negative parser tests to the test suite
    while (queryResult.hasNext()) {
      BindingSet bindingSet = queryResult.next();
      String testName = bindingSet.getValue("testName").toString();
      String inputURL = bindingSet.getValue("inputURL").toString();

      String baseURL = BASE_URL + testName + ".ttl";

      suite.addTest(new NegativeParserTest(testName, inputURL, baseURL));
    }

    queryResult.close();
    con.close();
    repository.shutDown();

    return suite;
  }

Examples of org.openrdf.repository.RepositoryConnection

    throws StoreException, RDFParseException, IOException, RDFHandlerException
  {
    Repository rep1 = new SailRepository(new MemoryStore());
    rep1.initialize();

    RepositoryConnection con1 = rep1.getConnection();

    URL ciaScheme = this.getClass().getResource("/cia-factbook/CIA-onto-enhanced.rdf");
    URL ciaFacts = this.getClass().getResource("/cia-factbook/CIA-facts-enhanced.rdf");

    con1.add(ciaScheme, ciaScheme.toExternalForm(), RDFFormat.forFileName(ciaScheme.toExternalForm()));
    con1.add(ciaFacts, ciaFacts.toExternalForm(), RDFFormat.forFileName(ciaFacts.toExternalForm()));

    StringWriter writer = new StringWriter();
    RDFWriter rdfWriter = rdfWriterFactory.getWriter(writer);
    con1.export(rdfWriter);

    long before = con1.size();
    con1.close();

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

    RepositoryConnection con2 = rep2.getConnection();

    con2.add(new StringReader(writer.toString()), "foo:bar", rdfWriterFactory.getRDFFormat());
    long after = con2.size();
    con2.close();

    assertEquals("result of serialization and re-upload should be equal to original", before, after);

    assertTrue("result of serialization and re-upload should be equal to original", RepositoryUtil.equals(
        rep1, rep2));

Examples of org.openrdf.repository.RepositoryConnection

    throws StoreException, RDFParseException, IOException, RDFHandlerException
  {
    Repository rep1 = new SailRepository(new MemoryStore());
    rep1.initialize();

    RepositoryConnection con1 = rep1.getConnection();

    URL ciaScheme = this.getClass().getResource("/cia-factbook/CIA-onto-enhanced.rdf");
    URL ciaFacts = this.getClass().getResource("/cia-factbook/CIA-facts-enhanced.rdf");

    con1.add(ciaScheme, ciaScheme.toExternalForm(), RDFFormat.forFileName(ciaScheme.toExternalForm()));
    con1.add(ciaFacts, ciaFacts.toExternalForm(), RDFFormat.forFileName(ciaFacts.toExternalForm()));

    StringWriter writer = new StringWriter();
    RDFWriter rdfWriter = rdfWriterFactory.getWriter(writer);
    rdfWriter.setBaseURI(ciaFacts.toExternalForm());
    con1.export(rdfWriter);

    long before = con1.size();
    con1.close();

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

    RepositoryConnection con2 = rep2.getConnection();

    con2.add(new StringReader(writer.toString()), ciaFacts.toExternalForm(),
        rdfWriterFactory.getRDFFormat());
    long after = con2.size();
    con2.close();

    assertEquals("result of serialization and re-upload should be equal to original", before, after);

    assertTrue("result of serialization and re-upload should be equal to original", RepositoryUtil.equals(
        rep1, rep2));
TOP
Copyright © 2018 www.massapi.com. 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.