Package com.hp.hpl.jena.graph

Examples of com.hp.hpl.jena.graph.Node


              break;
            }
            continue; // All is well, keep what we have
          }

          Node nodeVal;
          Resource valType = getObjectType(triple.getPredicate());
          // This attribute points to a ldap node
          if (LdapMap.ObjectProperty.equals(valType))
            nodeVal = createLdapNode((String) val);
          else if (LdapMap.EmailProperty.equals(valType))
View Full Code Here


    Collection<String> toGet = new ArrayList<String>();
    Collection<String> toMatch = new ArrayList<String>();

    /* Prebind subject (if possible) */
    Node theSubject = subject;
    if (subject.isVariable() && binding.contains(subject.getName()))
      theSubject = binding.get(subject.getName());

    for (Triple triple : query)
    {
      String attr = predToAttribute(triple.getPredicate());

      /* Prebind object (if possible) */
      Node theObject = triple.getObject();
      if (theObject.isVariable() && binding.contains(theObject.getName()))
        theObject = binding.get(theObject.getName());

      Resource valType = getObjectType(triple.getPredicate());
      if (theObject.isVariable())
        toGet.add(attr);
      else // TODO if pred is type, map values to ldap equivalent
      {
        toGet.add(attr); /* TODO dump this! stupid! Prebinding work around */
        String match = null;

        if (LdapMap.ObjectProperty.equals(valType))
          match = unldap(theObject.getURI());
        else if (LdapMap.EmailProperty.equals(valType))
          match = unmailto(theObject.getURI());
        else if (theObject.isURI()) // This could occur even if type
          // isn't given
          match = theObject.getURI();
        else
          match = theObject.getLiteralLexicalForm();

        log.info("attr: '" + attr + "' match: '" + match + "'");

        /* TODO Escape 'match' properly */
        toMatch.add("(" + attr + "=" + match + ")");
View Full Code Here

    ProcessedQuery query = new ProcessedQuery();
    Map<Node,Resource> nodeToClass = new HashMap<Node,Resource>(); // for sanity checking
   
    for (Triple triple: triples)
    {
      Node subject = triple.getSubject();
      Node predicate = triple.getPredicate();
      Node object = triple.getObject();
     
      if (predicate.isVariable())
        throw new UnanswerableException("I can't do predicate matches (yet).");
     
      if (predicate.equals(RDF.Nodes.type)) // RDB map is staticly typed, so this is not that useful
      {
        if (object.isConcrete())
        {
          Resource theClass = (Resource) configModel.asRDFNode(object);
          Table table = class2table.get(theClass);
          if (table == null)
            throw new InconsistentException("Unknown class: " + object);
          checkClasses(subject, theClass, nodeToClass);
          nodeToClass.put(subject, theClass);
          query.add(subject, table); // Just add the subject and table to the query.
        }
        else
          throw new UnanswerableException("No type matches (yet)");
        continue;
      }
     
      Resource prop = (Resource) configModel.getRDFNode(predicate);
      if (!prop2col.containsKey(prop))
        throw new InconsistentException("Unknown predicate: " + triple);

      /* Domain / Range checks -- subjects have types specific to tables, objects are literals */
      checkClasses(subject, prop.getProperty(RDFS.domain).getResource(), nodeToClass);
      checkClasses(object, RDFS.Literal, nodeToClass);
     
      //if (subject.isConcrete())
      //  throw new UnanswerableException("Concrete subject given: " + triple);
     
      if (object.isConcrete() && !object.isLiteral())
        throw new UnanswerableException("Object is resource: " + triple);
     
      // Ok, that's all the problem cases out the way (well, mostly)
      Col col = prop2col.get(prop);
     
View Full Code Here

     
      from.add(table.getName() + " AS " + name(subject));
     
     
      // Prebind subj
      Node subj = null;
      if (subject.isConcrete() || binding.contains(subject.getName())) // subj given, or bound?
        subj = subject.isConcrete() ? subject : binding.get(subject.getName());
     
      if (table.hasPrimaryKeys()) // deal with primary keys
      {
View Full Code Here

    objToCol.put(object, name(subject) + "." + col.getName());
  }

  public void addWhere(Collection<String> where, Map<Node, String> objToCol, Binding binding)
  {
    Node theObject = object;
   
    if (object.isVariable() && binding.contains(object.getName())) // Check for existing value
      theObject = binding.get(object.getName());
     
    String thing = name(subject) + "." + col.getName();
    // Phew. This is a test for whether an (object) variable is already
    // bound
    // by another expression in this query.
    if (theObject.isVariable() && objToCol.containsKey(theObject)
        && !thing.equals(objToCol.get(theObject)))
    {
      String otherThing = objToCol.get(theObject);
      String identCond = name(subject) + "." + col.getName() + "="
          + otherThing;
      where.add(identCond);
    }

    // No NULLs -- stick with RDB dream
    if (theObject.isVariable())
    {
      String notNullCond = name(subject) + "." + col.getName() + " IS NOT NULL";
      where.add(notNullCond);
      return;
    }
    else
    // Constraint on value
    {
      String whereBit = name(subject) + "." + col.getName() + "='"
          + theObject.getLiteral().getValue() + "'";
      where.add(whereBit);
    }
  }
View Full Code Here

        return PathLib.pathToTriples(pathBlock) ;
    }

    protected Op compileElementGraph(ElementNamedGraph eltGraph)
    {
        Node graphNode = eltGraph.getGraphNameNode() ;
        Op sub = compileElement(eltGraph.getElement()) ;
        return new OpGraph(graphNode, sub) ;
    }
View Full Code Here

        return new OpGraph(graphNode, sub) ;
    }

    protected Op compileElementService(ElementService eltService)
    {
        Node serviceNode = eltService.getServiceNode() ;
        Op sub = compileElement(eltService.getElement()) ;
        return new OpService(serviceNode, sub, eltService, eltService.getSilent()) ;
    }
View Full Code Here

        return new OpService(serviceNode, sub, eltService, eltService.getSilent()) ;
    }
   
    private Op compileElementFetch(ElementFetch elt)
    {
        Node serviceNode = elt.getFetchNode() ;
       
        // Probe to see if enabled.
        OpExtBuilder builder = OpExtRegistry.builder("fetch") ;
        if ( builder == null )
        {
View Full Code Here

        }
       
        @Override
        public void visit(OpPropFunc opPropFunc)
        {
            Node s = processPropFuncArg(opPropFunc.getSubjectArgs()) ;
            Node o = processPropFuncArg(opPropFunc.getObjectArgs()) ;
            Triple t = new Triple(s, opPropFunc.getProperty(), o) ;
            currentGroup().addElement(process(t)) ;
        }
View Full Code Here

            // List ...
            List<Node> list = args.getArgList() ;
            if ( list.size() == 0 )
                return RDF.Nodes.nil ;
            BasicPattern bgp = new BasicPattern() ;
            Node head = GraphList.listToTriples(list, bgp) ;
            currentGroup().addElement(process(bgp)) ;
            return head ;
        }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.graph.Node

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.