Beispiel #1
0
  /**
   * Returns a queryString in the following format:
   *
   * <p>
   *
   * <pre>
   *  select $s $p $o
   *  from <model.getResource()>
   *  where $s $p $o
   *  and $s <id3:uri> <mp3>
   *  and ($p <mulgara:is> <schemaProperty-1>
   *    or $p <mulgara:is> <schemaProperty-2>
   *              ...
   *    or $p <mulgara:is> <schemaProperty-n>) ;
   *  </pre>
   *
   * where <schemaProperty> is a property of the ID3Tags schema.
   *
   * @return String
   * @param mp3 URIReference
   * @param properties Iterator of Triples where the SubjectNode's represent the schemaProperties.
   */
  private String getStatementsQuery(URIReference mp3, Iterator properties) {

    // if there are no properties, there should be no statements.
    if ((properties == null) || !(properties.hasNext())) {
      return ";";
    }

    Node currentProperty = ((Triple) properties.next()).getPredicate();
    StringBuffer query = new StringBuffer("select $s $p $o" + NEWLINE);
    query.append("from <" + model.getResource().getURI() + ">" + NEWLINE);
    query.append("where $s $p $o" + NEWLINE);

    query.append("and $s" + ID3_URI + asString(mp3) + " " + NEWLINE);
    query.append(
        "and ( $p" + MULGARA_IS + asString((URIReference) currentProperty) + " " + NEWLINE);
    while (properties.hasNext()) {
      currentProperty = ((Triple) properties.next()).getSubject();
      query.append(
          "  or $p" + MULGARA_IS + asString((URIReference) currentProperty) + " " + NEWLINE);
    }
    // results must be ordered
    query.append(") order by $s $p $o ; ");
    return query.toString();
  }