Package de.fuberlin.wiwiss.d2rq.nodes

Examples of de.fuberlin.wiwiss.d2rq.nodes.TypedNodeMaker


    Relation base = new RelationImpl(null, AliasMap.NO_ALIASES,
        Expression.TRUE, Expression.TRUE,
        Collections.<Join>emptySet(), Collections.<ProjectionSpec>emptySet(),
        false, OrderSpec.NONE, Relation.NO_LIMIT, Relation.NO_LIMIT);
    this.withURIPatternSubject = new TripleRelation(base,
        new TypedNodeMaker(TypedNodeMaker.URI,
            new Pattern("http://test/person@@employees.ID@@"), true),
        new FixedNodeMaker(RDF.type.asNode(), false),
        new FixedNodeMaker(FOAF.Person.asNode(), false));
    this.withURIPatternSubjectAndObject = new TripleRelation(base,
        new TypedNodeMaker(TypedNodeMaker.URI,
            new Pattern("http://test/person@@employees.ID@@"), true),
        new FixedNodeMaker(FOAF.knows.asNode(), false),
        new TypedNodeMaker(TypedNodeMaker.URI,
            new Pattern("http://test/person@@employees.manager@@"), true));
    this.withURIColumnSubject = new TripleRelation(base,
        new TypedNodeMaker(TypedNodeMaker.URI,
            new Column(new Attribute(null, "employees", "homepage")), false),
        new FixedNodeMaker(RDF.type.asNode(), false),
        new FixedNodeMaker(FOAF.Document.asNode(), false));
    this.withURIPatternSubjectAndURIColumnObject = new TripleRelation(base,
        new TypedNodeMaker(TypedNodeMaker.URI,
            new Pattern("http://test/person@@employees.ID@@"), true),
        new FixedNodeMaker(FOAF.homepage.asNode(), false),
        new TypedNodeMaker(TypedNodeMaker.URI,
            new Column(new Attribute(null, "employees", "homepage")), false));
    this.employeeChecker = new URIMakerRule().createRuleChecker(
        Node.createURI("http://test/person1"));
    this.foobarChecker = new URIMakerRule().createRuleChecker(
        Node.createURI("http://test/foobar"));
View Full Code Here


    if (this.nodeRelation != null && exprVar != null)
    {
      // get the nodemaker for the expr-var
      NodeMaker nodeMaker = nodeRelation.nodeMaker(exprVar.asVar());
      if (nodeMaker instanceof TypedNodeMaker) {
        TypedNodeMaker typedNodeMaker = (TypedNodeMaker) nodeMaker;
        Iterator<ProjectionSpec> it = typedNodeMaker.projectionSpecs().iterator();
        if (!it.hasNext()) {
          logger.debug("no projection spec for " + exprVar + ", assuming constant");
          Node node = typedNodeMaker.makeNode(null);
          result.add(new ConstantEx(NodeValue.makeNode(node).asString(), node));
        }
        while (it.hasNext()) {
          ProjectionSpec projectionSpec = it.next();
         
View Full Code Here

   
    if (arg instanceof AttributeExprEx) {
      // make a new AttributeExprEx with changed NodeMaker, which returns plain literal
      // TODO this seems to work, but needs more testing.
      AttributeExprEx attribute = (AttributeExprEx) arg;
      TypedNodeMaker nodeMaker = (TypedNodeMaker) attribute.getNodeMaker();
      TypedNodeMaker newNodeMaker = new TypedNodeMaker(TypedNodeMaker.PLAIN_LITERAL, nodeMaker.valueMaker(), nodeMaker.isUnique());
      logger.debug("changing nodemaker " + nodeMaker + " to " + newNodeMaker);
      expression.push(new AttributeExprEx((Attribute) attribute.attributes().iterator().next(), newNodeMaker));
    } else if (arg instanceof ConstantEx) {
      ConstantEx constant = (ConstantEx) arg;
      Node node = constant.getNode();
View Full Code Here

 
  static NodeMaker cast(NodeMaker nodeMaker, RDFDatatype datatype)
  {
    if (nodeMaker instanceof TypedNodeMaker)
      return new TypedNodeMaker(TypedNodeMaker.typedLiteral(datatype), ((TypedNodeMaker) nodeMaker).valueMaker(), nodeMaker.isUnique());
   
    if (nodeMaker instanceof FixedNodeMaker) {
      Node node = nodeMaker.makeNode(null);
     
      return new FixedNodeMaker(XSD.cast(node, datatype), nodeMaker.isUnique());
View Full Code Here

    }
    return new ValueDecorator(values, constraints, this.translateWith.translator());
  }
 
  private NodeMaker buildNodeMaker(ValueMaker values, boolean isUnique) {
    return new TypedNodeMaker(nodeType(), values, isUnique);
  }
View Full Code Here

        new Attribute(alias, "value")}));
    Relation rel = new RelationImpl(
        null, aliases, Expression.TRUE, Expression.TRUE,
        Collections.<Join>emptySet(), projections, false, OrderSpec.NONE, Relation.NO_LIMIT, Relation.NO_LIMIT);
    TripleRelation t = new TripleRelation(rel,
        new TypedNodeMaker(TypedNodeMaker.URI, new Pattern("http://example.org/original/@@original.id@@"), true),
        new FixedNodeMaker(Node.createURI("http://example.org/property"), false),
        new TypedNodeMaker(TypedNodeMaker.PLAIN_LITERAL, new Column(new Attribute(alias, "value")), false));
    assertEquals("URI(Pattern(http://example.org/original/@@original.id@@))",
        t.nodeMaker(TripleRelation.SUBJECT).toString());
    assertEquals("Literal(Column(alias.value))",
        t.nodeMaker(TripleRelation.OBJECT).toString());
    assertEquals("AliasMap(original AS alias)",
View Full Code Here

    NodeRelation intvalue = search("table2", "intvalue", rels);
 
    Expr disjunction = new E_LogicalOr(new E_Equals(new ExprVar("o"),  NodeValue.makeNode("1", XSDDatatype.XSDint)), new E_Equals(new ExprVar("o"), NodeValue.makeNode("2", XSDDatatype.XSDint)));
   
    Expression result = TransformExprToSQLApplyer.convert(disjunction, intvalue);
    TypedNodeMaker nm = (TypedNodeMaker) intvalue.nodeMaker(Var.alloc("o"));
    Expression e1 = nm.valueMaker().valueExpression("1");
    Expression e2 = nm.valueMaker().valueExpression("2");
    Expression expected = e1.or(e2);
   
    assertEquals("?o = \"1\"^^xsd:int || ?o = \"2\"^^xsd:int", expected, result);
  }
View Full Code Here

    NodeRelation intvalue = search("table2", "intvalue", rels);
 
    Expr sameTerm = new E_SameTerm(new ExprVar("o"),  NodeValue.makeNode("1", XSDDatatype.XSDint));
   
    Expression result = TransformExprToSQLApplyer.convert(sameTerm, intvalue);
    TypedNodeMaker nm = (TypedNodeMaker) intvalue.nodeMaker(Var.alloc("o"));
    Expression expected = nm.valueMaker().valueExpression("1");
   
    assertEquals("sameTerm(?o, \"1\"^^xsd:int)", expected, result);
   
    sameTerm = new E_SameTerm(new ExprVar("o"),  NodeValue.makeNode("1", XSDDatatype.XSDdecimal));
   
View Full Code Here

  }
 
  public void testCombineDifferentConditions() {
    Attribute id = SQL.parseAttribute("TABLE.ID");
    db.setNullable(id, false);
    NodeMaker x = new TypedNodeMaker(TypedNodeMaker.PLAIN_LITERAL, new Column(id), true);
    Map<Var,NodeMaker> map = Collections.singletonMap(Var.alloc("x"), x);
    BindingMaker bm = new BindingMaker(map, null);
    RelationBuilder b1 = new RelationBuilder(db);
    RelationBuilder b2 = new RelationBuilder(db);
    b1.addProjection(id);
View Full Code Here

  }
 
  public void testCombineConditionAndNoCondition() {
    Attribute id = SQL.parseAttribute("TABLE.ID");
    db.setNullable(id, false);
    NodeMaker x = new TypedNodeMaker(TypedNodeMaker.PLAIN_LITERAL, new Column(id), true);
    Map<Var,NodeMaker> map = Collections.singletonMap(Var.alloc("x"), x);
    BindingMaker bm = new BindingMaker(map, null);
    RelationBuilder b1 = new RelationBuilder(db);
    RelationBuilder b2 = new RelationBuilder(db);
    b1.addProjection(id);
View Full Code Here

TOP

Related Classes of de.fuberlin.wiwiss.d2rq.nodes.TypedNodeMaker

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.