Package de.fuberlin.wiwiss.d2rq.algebra

Examples of de.fuberlin.wiwiss.d2rq.algebra.TripleRelation


    Collection<TripleRelation> results = new ArrayList<TripleRelation>();
    for (Resource property: properties) {
      NodeMaker s = this.belongsToClassMap.nodeMaker();
      NodeMaker p = new FixedNodeMaker(property.asNode(), false);
      NodeMaker o = nodeMaker();
      results.add(new TripleRelation(buildRelation(), s, p, o));
    }
    for (String pattern: dynamicPropertyPatterns) {
      NodeMaker s = this.belongsToClassMap.nodeMaker();
      NodeMaker p = new PropertyMap(pattern, belongsToClassMap.database()).nodeMaker();
      NodeMaker o = nodeMaker();
      results.add(new TripleRelation(buildRelation(), s, p, o));
    }
    return results;
  }
View Full Code Here


  public void testParseAlias() {
    Mapping mapping = MappingHelper.readFromTestFile("parser/alias.ttl");
    MappingHelper.connectToDummyDBs(mapping);
    assertEquals(1, mapping.compiledPropertyBridges().size());
    TripleRelation bridge = (TripleRelation) mapping.compiledPropertyBridges().iterator().next();
    assertTrue(bridge.baseRelation().condition().isTrue());
    AliasMap aliases = bridge.baseRelation().aliases();
    AliasMap expected = new AliasMap(Collections.singleton(SQL.parseAlias("People AS Bosses")));
    assertEquals(expected, aliases);
  }
View Full Code Here

      if (inventoryBridges.isEmpty()) {
        Relation relation = (Relation) this.mapping.classMap(classMapResource).relation();
        NodeMaker typeNodeMaker = new FixedNodeMaker(
            RDF.type.asNode(), false);
        NodeMaker resourceNodeMaker = new FixedNodeMaker(RDFS.Resource.asNode(), false);
        inventoryBridges.add(new TripleRelation(relation,
            resourceMaker, typeNodeMaker, resourceNodeMaker));
      }
      this.classMapInventoryBridges.put(toClassMapName(classMap), inventoryBridges);
    }
  }
View Full Code Here

  public void setUp() {
    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));
View Full Code Here

    URIMakerRuleChecker subjectChecker = rule.createRuleChecker(triplePattern.getSubject());
    URIMakerRuleChecker predicateChecker = rule.createRuleChecker(triplePattern.getPredicate());
    URIMakerRuleChecker objectChecker = rule.createRuleChecker(triplePattern.getObject());
    List<TripleRelation> result = new ArrayList<TripleRelation>();
    for (TripleRelation tripleRelation: sortedTripleRelations) {
      TripleRelation selectedTripleRelation = tripleRelation.selectTriple(triplePattern);
      if (selectedTripleRelation != null
          && subjectChecker.canMatch(tripleRelation.nodeMaker(TripleRelation.SUBJECT))
          && predicateChecker.canMatch(tripleRelation.nodeMaker(TripleRelation.PREDICATE))
          && objectChecker.canMatch(tripleRelation.nodeMaker(TripleRelation.OBJECT))) {
        subjectChecker.addPotentialMatch(tripleRelation.nodeMaker(TripleRelation.SUBJECT));
        predicateChecker.addPotentialMatch(tripleRelation.nodeMaker(TripleRelation.PREDICATE));
        objectChecker.addPotentialMatch(tripleRelation.nodeMaker(TripleRelation.OBJECT));
        TripleRelation r = new JoinOptimizer(selectedTripleRelation).optimize();
        if (limitPerRelation != Relation.NO_LIMIT) {
          r = r.limit(limitPerRelation);
        }
        result.add(r);
      }
    }
    return result;
View Full Code Here

      return 0;
    }
    private List<NodeRelation> findMatchingTripleRelations(Triple triplePattern) {
      List<NodeRelation> results = new ArrayList<NodeRelation>();
      for (TripleRelation tripleRelation: tripleRelations) {
        TripleRelation selected = tripleRelation.selectTriple(triplePattern);
        if (selected == null) continue;
        results.add(selected);
      }
      return results;
    }
View Full Code Here

    classMap.addPropertyBridge(result);
    return result;
  }
 
  public void testAttributesInRefersToClassMapAreRenamed() {
    TripleRelation relation = (TripleRelation) this.managerBridge.toTripleRelations().iterator().next();
    assertEquals("URI(Pattern(http://test/employee@@e.ID@@))",
        relation.nodeMaker(TripleRelation.SUBJECT).toString());
    assertEquals("URI(Pattern(http://test/employee@@m.ID@@))",
        relation.nodeMaker(TripleRelation.OBJECT).toString());
  }
View Full Code Here

    assertEquals("URI(Pattern(http://test/employee@@m.ID@@))",
        relation.nodeMaker(TripleRelation.OBJECT).toString());
  }
 
  public void testJoinConditionsInRefersToClassMapAreRenamed() {
    TripleRelation relation = (TripleRelation) this.managerBridge.toTripleRelations().iterator().next();
    Set<String> joinsToString = new HashSet<String>();
    for (Join join: relation.baseRelation().joinConditions()) {
      joinsToString.add(join.toString());
    }
    assertEquals(new HashSet<String>(Arrays.asList(new String[]{
        "Join(e.manager <=> m.ID)",
        "Join(m.ID <=> foo.bar)",
View Full Code Here

        "Join(e.ID <=> foo.bar)"})),
        joinsToString);
  }
 
  public void testConditionInRefersToClassMapIsRenamed() {
    TripleRelation relation = (TripleRelation) this.managerBridge.toTripleRelations().iterator().next();
    assertEquals("Conjunction(SQL(e.status = 'active'), SQL(m.status = 'active'))",
        relation.baseRelation().condition().toString());
  }
View Full Code Here

    assertEquals("Conjunction(SQL(e.status = 'active'), SQL(m.status = 'active'))",
        relation.baseRelation().condition().toString());
  }

  public void testAliasesInRefersToClassMapAreRenamed() {
    TripleRelation relation = (TripleRelation) this.managerBridge.toTripleRelations().iterator().next();
    assertEquals(
        new AliasMap(Arrays.asList(new Alias[]{
            SQL.parseAlias("employees AS e"),
            SQL.parseAlias("employees AS m")})),
        relation.baseRelation().aliases());
  }
View Full Code Here

TOP

Related Classes of de.fuberlin.wiwiss.d2rq.algebra.TripleRelation

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.