Package org.openrdf.query

Examples of org.openrdf.query.BindingSet


          Namespace ns = iter.next();

          Literal prefix = new LiteralImpl(ns.getPrefix());
          Literal namespace = new LiteralImpl(ns.getName());

          BindingSet bindingSet = new ListBindingSet(columnNames, prefix, namespace);
          namespaces.add(bindingSet);
        }
      }
      finally {
        iter.close();
View Full Code Here


    String codeListURI="";
    try {
         RepositoryConnection con = _repository.getConnection();
         try
         {
           BindingSet bindingSet;

           TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, String.format(SELECT_CodeList_TEMPLATE,codeList));
           TupleQueryResult result = tupleQuery.evaluate();
              
           if(result.hasNext())
             {                
               bindingSet = result.next();
               codeListURI = bindingSet.getValue("sub").toString();
               codeListURI = codeListURI.substring(codeListURI.indexOf("#")+1);
              
             }
              
             result.close();              
View Full Code Here

      if ((Boolean) result)
        qr.add(new BindingsCollection());
    } else if (result instanceof TupleQueryResult) {
      qr = QueryResult.createInstance();
      while (((TupleQueryResult) result).hasNext()) {
        final BindingSet bs = ((TupleQueryResult) result).next();
        final Bindings binding = new BindingsMap();
        for (final Binding b : bs) {
          // Bindings bb = Bindings.createNewInstance();
          final Value v = b.getValue();
          if (v instanceof org.openrdf.model.Literal) {
View Full Code Here

      return hasNext;
    }
  }

  public QueryRow next() {
    BindingSet nextBindingSet = null;

    try {
      nextBindingSet = this.queryResult.next();

      if (!this.queryResult.hasNext()) {
View Full Code Here

            RepositoryConnection connection = dataRepo.getConnection();
            TupleQuery compiledQuery = connection.prepareTupleQuery(QueryLanguage.SPARQL, query);
            TupleQueryResult results = compiledQuery.evaluate()
           
         
            BindingSet set;
            Resource r;
            String variable = results.getBindingNames().get(0);
            while (results.hasNext()){
              //resources ++;
              set = results.next();
              r = (Resource) set.getValue(variable);
              // Don't render resource twice
              if (resSet.containsKey(r))
                continue;
              resSet.put(r, null);
              Element eR = createResourceElement(fd, dataRepo, doc, sl, null, r, Constants.DEFAULT_MAX_DEPTH);
View Full Code Here

                getConfig().getMaxQueryResultNumber());
            results = executeSparqlFieldQuery(con, query, limit, false);
            //parse the results
            List<String> ids = limit > 0 ? new ArrayList<String>(limit) : new ArrayList<String>();
            while(results.hasNext()){
                BindingSet result = results.next();
                Value value = result.getValue(query.getRootVariableName());
                if(value instanceof Resource){
                    ids.add(value.stringValue());
                }
            }
            con.commit();
View Full Code Here

            Model model = new TreeModel();
            RdfValueFactory valueFactory = new RdfValueFactory(model, sesameFactory);
            List<Representation> representations = limit > 0 ?
                    new ArrayList<Representation>(limit) : new ArrayList<Representation>();
            while(results.hasNext()){
                BindingSet result = results.next();
                Value value = result.getValue(query.getRootVariableName());
                if(value instanceof URI){
                    //copy all data to the model and create the representation
                    RdfRepresentation rep = createRepresentationGraph(con, valueFactory, (URI)value);
                    model.add(queryRoot, queryResult, value); //link the result with the query result
                    representations.add(rep);
View Full Code Here

            Map<String,URI> bindings = new HashMap<String,URI>(query.getFieldVariableMappings().size());
            for(Entry<String,String> mapping : query.getFieldVariableMappings().entrySet()){
                bindings.put(mapping.getValue(), sesameFactory.createURI(mapping.getKey()));
            }
            while(results.hasNext()){
                BindingSet result = results.next();
                Value value = result.getValue(query.getRootVariableName());
                if(value instanceof URI){
                    URI subject = (URI) value;
                    //link the result with the query result
                    model.add(queryRoot, queryResult, subject);
                    //now copy over the other selected data
                    for(String binding : result.getBindingNames()){
                        URI property = bindings.get(binding);
                        if(property != null){
                            model.add(subject, property, result.getValue(binding));
                        } //else no mapping for the query.getRootVariableName()
                    }
                    //create a representation and add it to the results
                    representations.add(valueFactory.createRdfRepresentation(subject));
                } //ignore non URI results
View Full Code Here

        {
            TupleQuery tupleQuery = repositoryConnection.prepareTupleQuery( QueryLanguage.SERQL, projectQuery );
            result = tupleQuery.evaluate();
            while ( result.hasNext() )
            {
                BindingSet set = result.next();

                String groupId = set.getBinding( ProjectUri.GROUP_ID.getObjectBinding() ).getValue().toString();
                String version = set.getBinding( ProjectUri.VERSION.getObjectBinding() ).getValue().toString();
                String artifactId = set.getBinding( ProjectUri.ARTIFACT_ID.getObjectBinding() ).getValue().toString();
                String artifactType =
                    set.getBinding( ProjectUri.ARTIFACT_TYPE.getObjectBinding() ).getValue().toString();
                String classifier = null;
                if ( set.hasBinding( ProjectUri.CLASSIFIER.getObjectBinding() ) )
                {
                    classifier = set.getBinding( ProjectUri.CLASSIFIER.getObjectBinding() ).getValue().toString();
                }

                // Project project = getProjectFor( groupId, artifactId, version, artifactType, null );
                /*
                 * for ( Iterator<Binding> i = set.iterator(); i.hasNext(); ) { Binding b = i.next();
View Full Code Here

                    + ", Artifact ID =  " + artifactId + ", Version = " + version + ", Artifact Type = " + artifactType );
            }

            while ( result.hasNext() )
            {
                BindingSet set = result.next();
                /*
                 * for ( Iterator<Binding> i = set.iterator(); i.hasNext(); ) { Binding b = i.next();
                 * System.out.println( b.getName() + ":" + b.getValue() ); }
                 */
                if ( set.hasBinding( ProjectUri.IS_RESOLVED.getObjectBinding() )
                    && set.getBinding( ProjectUri.IS_RESOLVED.getObjectBinding() ).getValue().toString().equalsIgnoreCase(
                                                                                                                           "true" ) )
                {
                    project.setResolved( true );
                }

                project.setArtifactType( set.getBinding( ProjectUri.ARTIFACT_TYPE.getObjectBinding() ).getValue().toString() );
                /*
                 * if ( set.hasBinding( ProjectUri.PARENT.getObjectBinding() ) ) { String pid = set.getBinding(
                 * ProjectUri.PARENT.getObjectBinding() ).getValue().toString(); String[] tokens = pid.split( "[:]" );
                 * Project parentProject = getProjectFor( tokens[0], tokens[1], tokens[2], null, null );
                 * project.setParentProject( parentProject ); }
                 */
                if ( set.hasBinding( ProjectUri.DEPENDENCY.getObjectBinding() ) )
                {
                    Binding binding = set.getBinding( ProjectUri.DEPENDENCY.getObjectBinding() );
                    addDependenciesToProject( project, repositoryConnection, binding.getValue() );
                }

                if ( set.hasBinding( ProjectUri.CLASSIFIER.getObjectBinding() ) )
                {
                    Binding binding = set.getBinding( ProjectUri.CLASSIFIER.getObjectBinding() );
                    addClassifiersToProject( project, repositoryConnection, binding.getValue() );
                }
            }
        }
        catch ( QueryEvaluationException e )
View Full Code Here

TOP

Related Classes of org.openrdf.query.BindingSet

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.