Package de.fuberlin.wiwiss.d2rq.values

Examples of de.fuberlin.wiwiss.d2rq.values.Pattern$URLifyFunction


    if (this.constantValue != null && this.constantValue.isLiteral()) {
      throw new D2RQException(
          "d2rq:constantValue for class map " + toString() + " must be a URI or blank node",
          D2RQException.CLASSMAP_INVALID_CONSTANTVALUE);
    }
    if (this.uriPattern != null && new Pattern(uriPattern).attributes().size() == 0) {
      this.log.warn(toString() + " has an uriPattern without any column specifications. This usually happens when no primary keys are defined for a table. If the configuration is left as is, all table rows will be mapped to a single instance. " +
          "If this is not what you want, please define the keys in the database and re-run the mapping generator, or edit the mapping to provide the relevant keys.");
    }
    for (PropertyBridge bridge: propertyBridges) {
      bridge.validate();
View Full Code Here


        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"));
View Full Code Here

        translated.add(Equality.createAttributeEquality(first, it.next()));
      }
    }
    if (patterns.size() >= 2) {
      Iterator<Pattern> it = patterns.iterator();
      Pattern first = it.next();
      while (it.hasNext()) {
        translated.addAll(matchPatterns(first, it.next()));
      }
    }
    if (expressions.size() >= 2) {
      Iterator<Expression> it = expressions.iterator();
      Expression first = it.next();
      while (it.hasNext()) {
        translated.add(Equality.create(first, it.next()));
      }
    }
    if (blankNodeIDs.size() >= 2) {
      Iterator<BlankNodeID> it = blankNodeIDs.iterator();
      BlankNodeID first = it.next();
      while (it.hasNext()) {
        translated.addAll(matchBlankNodeIDs(first, it.next()));
      }
    }
    if (constantValue != null) {
      if (!attributes.isEmpty()) {
        Attribute first = attributes.iterator().next();
        translated.add(Equality.createAttributeValue(first, constantValue));
      }
      if (!blankNodeIDs.isEmpty()) {
        BlankNodeID first = blankNodeIDs.iterator().next();
        translated.add(first.valueExpression(constantValue));
      }
      if (!patterns.isEmpty()) {
        Pattern first = patterns.iterator().next();
        translated.add(first.valueExpression(constantValue));
      }
      if (!expressions.isEmpty()) {
        Expression first = expressions.iterator().next();
        translated.add(Equality.createExpressionValue(first, constantValue));
      }
    } else if (!attributes.isEmpty()) {
      AttributeExpr attribute = new AttributeExpr(attributes.iterator().next());
      if (!blankNodeIDs.isEmpty()) {
        BlankNodeID first = blankNodeIDs.iterator().next();
        translated.add(Equality.create(attribute, first.toExpression()));
      }
      if (!patterns.isEmpty()) {
        Pattern first = patterns.iterator().next();
        translated.add(Equality.create(attribute, first.toExpression()));
        checkUsesColumnFunctions(first);
      }
      if (!expressions.isEmpty()) {
        Expression first = expressions.iterator().next();
        translated.add(Equality.create(attribute, first));
      }
    } else if (!expressions.isEmpty()) {
      Expression expression = expressions.iterator().next();
      if (!blankNodeIDs.isEmpty()) {
        BlankNodeID first = blankNodeIDs.iterator().next();
        translated.add(Equality.create(expression, first.toExpression()));
      }
      if (!patterns.isEmpty()) {
        Pattern first = patterns.iterator().next();
        translated.add(Equality.create(expression, first.toExpression()));
        checkUsesColumnFunctions(first);
      }
    } else if (!patterns.isEmpty() && !blankNodeIDs.isEmpty()) {
      Pattern firstPattern = patterns.iterator().next();
      BlankNodeID firstBNodeID = blankNodeIDs.iterator().next();
      translated.add(Equality.create(firstPattern.toExpression(), firstBNodeID.toExpression()));
      checkUsesColumnFunctions(firstPattern);
    }
    // FIXME: Actually handle this properly, see https://github.com/d2rq/d2rq/issues/22
    if (translators.size() > 1) {
      log.warn("Join involving multiple translators (d2rq:translateWith) is not supported");
View Full Code Here

    }
    if (this.uriColumn != null) {
      return new Column(SQL.parseAttribute(this.uriColumn));
    }
    if (this.uriPattern != null) {
      Pattern p = new Pattern(this.uriPattern);
      if (!p.literalPartsMatchRegex(MapParser.IRI_CHAR_REGEX)) {
        throw new D2RQException("d2rq:uriPattern '"
            + this.uriPattern + "' contains characters not allowed in URIs",
            D2RQException.RESOURCEMAP_ILLEGAL_URIPATTERN);
      }
      return p;
    }
    if (this.column != null) {
      return new Column(SQL.parseAttribute(this.column));
    }
    if (this.pattern != null) {
      return new Pattern(this.pattern);
    }
    if (this.sqlExpression != null) {
      return new SQLExpressionValueMaker(SQLExpression.create(sqlExpression));
    }
    if (this.uriSqlExpression != null) {
View Full Code Here

    if (this.constantValue != null && !this.constantValue.isURIResource()) {
      throw new D2RQException(
          "d2rq:constantValue for download map " + toString() + " must be a URI",
          D2RQException.DOWNLOADMAP_INVALID_CONSTANTVALUE);
    }
    if (this.uriPattern != null && new Pattern(uriPattern).attributes().size() == 0) {
      log.warn(toString() + " has an uriPattern without any column specifications. This usually happens when no primary keys are defined for a table. If the configuration is left as is, all table rows will be mapped to a single instance. " +
          "If this is not what you want, please define the keys in the database and re-run the mapping generator, or edit the mapping to provide the relevant keys.");
    }
  }
View Full Code Here

    return buildRelation();
  }
 
  public ValueMaker getMediaTypeValueMaker() {
    if (mediaType == null) return ValueMaker.NULL;
    Pattern pattern = new Pattern(mediaType);
    if (pattern.attributes().isEmpty()) {
      return new ConstantValueMaker(mediaType);
    }
    return pattern;
  }
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))",
View Full Code Here

    nodes.limitTo(RDF.Nodes.type);
    assertFalse(nodes.isEmpty());
  }
 
  public void testPatternDifferentColumnFunctionsUnsupported() {
    nodes.limitValuesToPattern(new Pattern("test/@@table1.foo|urlify@@"));
    nodes.limitValuesToPattern(new Pattern("test/@@table1.bar|urlencode@@"));
    assertFalse(nodes.isEmpty());
    assertTrue(nodes.isUnsupported());
  }
View Full Code Here

    assertTrue(nodes.isUnsupported());
  }
 
  public void testPatternWithColumnFunctionAndColumnUnsupported() {
    nodes.limitValuesToAttribute(table1foo);
    nodes.limitValuesToPattern(new Pattern("@@table2.bar|urlify@@"));
    assertEquals("Equality(AttributeExpr(@@table1.foo@@), AttributeExpr(@@table2.bar@@))",
        nodes.constraint().toString());
    assertTrue(nodes.isUnsupported());
  }
View Full Code Here

TOP

Related Classes of de.fuberlin.wiwiss.d2rq.values.Pattern$URLifyFunction

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.