Package org.openrdf.repository

Examples of org.openrdf.repository.Repository


      Iterator<Map.Entry<String, Repository>> iter = repositories.entrySet().iterator();

      while (iter.hasNext()) {
        Map.Entry<String, Repository> entry = iter.next();
        String repositoryID = entry.getKey();
        Repository repository = entry.getValue();

        if (!SystemRepository.ID.equals(repositoryID)) {
          iter.remove();

          try {
            repository.shutDown();
          }
          catch (RepositoryException e) {
            logger.error("Failed to shut down repository", e);
          }
View Full Code Here


  @Override
  public void stop()
    throws Exception
  {
    Repository systemRepo = new HTTPRepository(Protocol.getRepositoryLocation(SERVER_URL,
        SystemRepository.ID));
    RepositoryConnection con = systemRepo.getConnection();
    try {
      con.clear();
    }
    finally {
      con.close();
View Full Code Here

   * @throws RepositoryException
   */
  private void createTestRepositories()
    throws RepositoryException, RepositoryConfigException
  {
    Repository systemRep = new HTTPRepository(Protocol.getRepositoryLocation(SERVER_URL,
        SystemRepository.ID));

    // create a (non-inferencing) memory store
    MemoryStoreConfig memStoreConfig = new MemoryStoreConfig();
    SailRepositoryConfig sailRepConfig = new SailRepositoryConfig(memStoreConfig);
View Full Code Here

    Map<String, Object> model = (Map<String, Object>)errors.getModel();
    model.put(getCommandName(), exploration);

    if (resource != null) {
      HttpSession session = request.getSession();
      Repository repo = (Repository)session.getAttribute(SessionKeys.REPOSITORY_KEY);

      try {
        RepositoryConnection con = repo.getConnection();
        try {
          model.put("asSubject", con.getStatements(resource, null, null, true).asList());

          if (resource instanceof URI) {
            model.put("asPredicate", con.getStatements(null, (URI)resource, null, true).asList());
View Full Code Here

      // TODO: verify shutting down the repos is the right thing to do here
      // (could/should queries still be running when switching to another
      // server in the same session?)

      // shutdown the "current" repository, if any
      Repository repo = (Repository)session.getAttribute(SessionKeys.REPOSITORY_KEY);
      if (repo != null) {
        repo.shutDown();
        session.removeAttribute(SessionKeys.REPOSITORY_KEY);
        session.removeAttribute(SessionKeys.REPOSITORY_INFO_KEY);
      }
     
      // insert the new Server into the session
View Full Code Here

  {
    // Create test suite
    TestSuite suite = new TestSuite();

    // 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 = TriGParserTest.class.getResource(MANIFEST_GOOD_URL);
    con.add(url, 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#>";

    TupleQueryResult 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 = TriGParserTest.class.getResource(MANIFEST_BAD_URL);
    con.add(url, 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;
  }
View Full Code Here

  public static Test suite()
    throws Exception
  {
    // Create an RDF repository for the manifest data
    Repository repository = new SailRepository(new MemoryStore());
    repository.initialize();
    RepositoryConnection con = repository.getConnection();

    // Add W3C's manifest
    URL w3cManifest = resolveURL(W3C_MANIFEST_FILE);
    con.add(w3cManifest, W3C_MANIFEST_FILE, RDFFormat.RDFXML);

    // Add our own manifest
    URL localManifest = resolveURL(OPENRDF_MANIFEST_FILE);
    con.add(localManifest, localManifest.toString(), RDFFormat.RDFXML);

    // Create test suite
    TestSuite suite = new TestSuite();

    // Add all positive parser tests
    String query = "select TESTCASE, INPUT, OUTPUT "
        + "from {TESTCASE} rdf:type {test:PositiveParserTest}; "
        + "                test:inputDocument {INPUT}; "
        + "                test:outputDocument {OUTPUT}; "
        + "                test:status {\"APPROVED\"} "
        + "using namespace test = <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#>";
    TupleQueryResult queryResult = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();
    while (queryResult.hasNext()) {
      BindingSet bindingSet = queryResult.next();
      String caseURI = bindingSet.getValue("TESTCASE").toString();
      String inputURL = bindingSet.getValue("INPUT").toString();
      String outputURL = bindingSet.getValue("OUTPUT").toString();
      suite.addTest(new PositiveParserTest(caseURI, inputURL, outputURL));
    }

    queryResult.close();

    // Add all negative parser tests
    query = "select TESTCASE, INPUT " + "from {TESTCASE} rdf:type {test:NegativeParserTest}; "
        + "                test:inputDocument {INPUT}; " + "                test:status {\"APPROVED\"} "
        + "using namespace test = <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#>";
    queryResult = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();
    while (queryResult.hasNext()) {
      BindingSet bindingSet = queryResult.next();
      String caseURI = bindingSet.getValue("TESTCASE").toString();
      String inputURL = bindingSet.getValue("INPUT").toString();
      suite.addTest(new NegativeParserTest(caseURI, inputURL));
    }

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

    return suite;
  }
View Full Code Here

  @Override
  protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Repository systemRepository = repositoryManager.getSystemRepository();
    ValueFactory vf = systemRepository.getValueFactory();

    try {
      RepositoryConnection con = systemRepository.getConnection();
      try {
        // FIXME: The query result is cached here as we need to close the
        // connection before returning. Would be much better to stream the
        // query result directly to the client.
View Full Code Here

  protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView result;

    Repository repository = RepositoryInterceptor.getRepository(request);
    RepositoryConnection repositoryCon = RepositoryInterceptor.getRepositoryConnection(request);

    String reqMethod = request.getMethod();

    if (METHOD_GET.equals(reqMethod)) {
View Full Code Here

  @Override
  protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Repository repository = RepositoryInterceptor.getRepository(request);
    RepositoryConnection repositoryCon = RepositoryInterceptor.getRepositoryConnection(request);

    String reqMethod = request.getMethod();
    if (METHOD_GET.equals(reqMethod)) {
      logger.info("GET query");
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.