Package org.openrdf.model

Examples of org.openrdf.model.ValueFactory


    {
      CloseableIteration<? extends BindingSet, QueryEvaluationException> bindingsIter = getWrappedConnection().evaluate(
          query.getTupleExpr(), null, EmptyBindingSet.getInstance(), true);

      try {
        ValueFactory vf = getValueFactory();

        while (bindingsIter.hasNext()) {
          BindingSet bindings = bindingsIter.next();

          Value subj = bindings.getValue("subject");
          Value pred = bindings.getValue("predicate");
          Value obj = bindings.getValue("object");

          if (subj instanceof Resource && pred instanceof URI && obj != null) {
            statements.add(vf.createStatement((Resource)subj, (URI)pred, obj));
          }
        }
      }
      finally {
        bindingsIter.close();
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.

        List<String> bindingNames = new ArrayList<String>();
        List<BindingSet> bindingSets = new ArrayList<BindingSet>();

        TupleQueryResult queryResult = con.prepareTupleQuery(QueryLanguage.SERQL, REPOSITORY_LIST_QUERY).evaluate();
        try {
          // Determine the repository's URI
          StringBuffer requestURL = request.getRequestURL();
          if (requestURL.charAt(requestURL.length() - 1) != '/') {
            requestURL.append('/');
          }
          String namespace = requestURL.toString();

          while (queryResult.hasNext()) {
            QueryBindingSet bindings = new QueryBindingSet(queryResult.next());

            String id = bindings.getValue("id").stringValue();
            bindings.addBinding("uri", vf.createURI(namespace, id));

            bindingSets.add(bindings);
          }

          bindingNames.add("uri");
View Full Code Here

      HttpServletRequest request, HttpServletResponse response)
    throws ClientHTTPException
  {
    ProtocolUtil.logRequestParameters(request);

    ValueFactory vf = repository.getValueFactory();

    Resource subj = ProtocolUtil.parseResourceParam(request, SUBJECT_PARAM_NAME, vf);
    URI pred = ProtocolUtil.parseURIParam(request, PREDICATE_PARAM_NAME, vf);
    Value obj = ProtocolUtil.parseValueParam(request, OBJECT_PARAM_NAME, vf);
    Resource[] contexts = ProtocolUtil.parseContextParam(request, CONTEXT_PARAM_NAME, vf);
View Full Code Here

    RDFFormat rdfFormat = Rio.getParserFormatForMIMEType(mimeType);
    if (rdfFormat == null) {
      throw new ClientHTTPException(SC_UNSUPPORTED_MEDIA_TYPE, "Unsupported MIME type: " + mimeType);
    }

    ValueFactory vf = repository.getValueFactory();

    Resource[] contexts = ProtocolUtil.parseContextParam(request, CONTEXT_PARAM_NAME, vf);
    URI baseURI = ProtocolUtil.parseURIParam(request, BASEURI_PARAM_NAME, vf);

    if (baseURI == null) {
      baseURI = vf.createURI("foo:bar");
      logger.info("no base URI specified, using dummy '{}'", baseURI);
    }

    InputStream in = request.getInputStream();
    try {
View Full Code Here

      HttpServletRequest request, HttpServletResponse response)
    throws ClientHTTPException, ServerHTTPException
  {
    ProtocolUtil.logRequestParameters(request);

    ValueFactory vf = repository.getValueFactory();

    Resource subj = ProtocolUtil.parseResourceParam(request, SUBJECT_PARAM_NAME, vf);
    URI pred = ProtocolUtil.parseURIParam(request, PREDICATE_PARAM_NAME, vf);
    Value obj = ProtocolUtil.parseValueParam(request, OBJECT_PARAM_NAME, vf);
    Resource[] contexts = ProtocolUtil.parseContextParam(request, CONTEXT_PARAM_NAME, vf);
View Full Code Here

    ProtocolUtil.logRequestParameters(request);

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

    ValueFactory vf = repository.getValueFactory();
    Resource[] contexts = ProtocolUtil.parseContextParam(request, Protocol.CONTEXT_PARAM_NAME, vf);

    long size = -1;

    try {
View Full Code Here

      metaDataRepository = new SailRepository(new NativeStore(new File(getAbsolutePath(config.getInitParameter("metadataStore"), context))));
      metaDataRepository.initialize();
     
      RepositoryConnection ontoConn = ontoRepository.getConnection();
      ValueFactory ontoValueFactory = ontoRepository.getValueFactory();
     
      /* Load ontologies */
      File ontoDir = new File(dataRoot + "/" + ontologiesDirectory);
      for (File f : ontoDir.listFiles(new RDFFilenameFilter())) {
        URI ontoResource = ontoValueFactory.createURI("file://" + f.getName());

        /* Only load new ontologies */
        if (!ontoConn.hasStatement(null, null, null, false, ontoResource)) {
          try {
            loadTriples(ontoRepository, f, null /* parameters */, ontoResource);
View Full Code Here

  }*/
 
 
  public void saveUserRecommendationPrefs(String user) {
    Graph gToAdd = SesameUtils.createGraph()
    ValueFactory vf = gToAdd.getValueFactory();
   
    Resource r = vf.createURI(user);
    BNode bn = vf.createBNode();
    URI uint = vf.createURI("http://www.w3.org/2001/XMLSchema#integer");
   
    try {
      bn.addProperty(Concepts.HAS_TYPE.get(gToAdd), vf.createLiteral(this.name.getName(), vf.createURI("http://www.w3.org/2001/XMLSchema#string")));
      bn.addProperty(Concepts.HAS_LIMIT.get(gToAdd), vf.createLiteral(String.valueOf(this.limit), uint));
      if(this.weight != null)
        bn.addProperty(Concepts.HAS_WEIGHT.get(gToAdd), vf.createLiteral(String.valueOf(this.weight), uint));
     
      r.addProperty(Concepts.HAS_RECOMMENDATION.get(gToAdd), bn);

      SesameWrapper.addGraph(Repository.FOAFREALM_REPOSITORY.getLocalRepository(), gToAdd);
    } catch (GraphException e) {
View Full Code Here

    AxisPath axisPath = new AxisPath(spathAxis);
   
    LocalRepository globalLr = Repository.MAIN_REPOSITORY.getLocalRepository();
   
    Graph g = lr.getGraph();
    ValueFactory vf = g.getValueFactory();
    URI context = vf.createURI(url);
   
    Graph g1 = SesameUtils.getEmptyGraph();
    Graph g2 = SesameUtils.getEmptyGraph();
   
    axisPath.getLastOnList(globalLr, context, g1, true, _usedPath);
View Full Code Here

    AxisPath axisPath = new AxisPath(spathAxis);
   
    LocalRepository globalLr = Repository.MAIN_REPOSITORY.getLocalRepository();
   
    Graph g = lr.getGraph();
    ValueFactory vf = g.getValueFactory();
    URI context = vf.createURI(url);
    Resource action = axisPath.getLastOnList(globalLr, context, lr.getGraph(), true, _usedPath);
   
    //--inferr isFollowedBy properties
    Graph ginf = SesameWrapper.performGraphQuery(lr, QueryLanguage.SERQL, RDFQuery.RDFQ_INFER_ISFOLLOWEDBY.toString());
    lr.getGraph().add(ginf);
View Full Code Here

TOP

Related Classes of org.openrdf.model.ValueFactory

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.