Thellmann / callimachus

Automatically exported from code.google.com/p/callimachus
Other
0 stars 0 forks source link

Nested resources don't show up in search options #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using the below dropzone the lookup dialog allows to search for possible 
matches. However, the organization label is only shown for a matching person if 
the organization *also* matches the prefix.

Since the organization is not a top resource (in this search), its label should 
not be filtered.

The link below will return all person with a label that starts with 'b', but 
only show their organization label if it also starts with a 'b'.

http://localhost:8080/conference/event-edit.xhtml?search&query=edit&element=/1/2
/3/2/5&q=b

<ul rel="agenda:speaker" dropzone="link s:text/uri-list">
  <label>Speakers</label>
  <button type="button" class="dialog" data-dialog="about:blank" />
  <li about="?speaker" typeof="pimo:Person">
    <span property="rdfs:label"/> from 
    <span rel="pimo:isOrganizationMemberOf">
      <span property="rdfs:label"/>
    </span>
    <button type="button" class="remove" />
  </li>
</ul>

PREFIX :<http://www.w3.org/1999/xhtml>
PREFIX agenda:<http://callimachusproject.org/rdf/2010/agenda#>
PREFIX dc:<http://purl.org/dc/terms/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX pimo:<http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
SELECT REDUCED *
WHERE {
 {
  <> agenda:speaker ?speaker .
  ?speaker a pimo:Person .
  OPTIONAL {
   {
    ?speaker rdfs:label ?_speaker_label .
   }
   UNION
   {
    ?speaker pimo:isOrganizationMemberOf ?_speaker_isOrganizationMemberOf .
    OPTIONAL {
     ?_speaker_isOrganizationMemberOf rdfs:label ?_speaker_isOrganizationMemberOf_label .
    }
   }
  }
 }
}
# @origin speaker /1/3
# @origin _speaker_label /1/3/1 !
# @origin _speaker_isOrganizationMemberOf /1/3/2
# @origin _speaker_isOrganizationMemberOf_label /1/3/2/1 !

Callimachus 0.11-SNAPSHOT

Original issue reported on code.google.com by *...@talis.com on 23 Jun 2011 at 7:14

GoogleCodeExporter commented 9 years ago
Revised FormSupport, changing the regex for adding filters from "^(/\\d+){2,}$" 
to "^(/\\d+){2}$" so that only direct properties of a top-level subject are 
filtered (on level 2 only, rather than from level 2 inwards).

However, the remaining filter only selects for rows that contain speaker 
details, not the organizational details. With the UNION form of query these 
appear in different (but contiguous) results. Added option in SPARQLProducer to 
generate non-union, optional-only query which is used in data-search. This 
produces the following query:

PREFIX :<http://www.w3.org/1999/xhtml>
PREFIX agenda:<http://callimachusproject.org/rdf/2010/agenda#>
PREFIX dc:<http://purl.org/dc/terms/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX pimo:<http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#>
PREFIX zdef-612625695:<http://www.w3.org/1999/xhtml>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
SELECT REDUCED *
WHERE {
 OPTIONAL {
  ?speaker a pimo:Person .
  OPTIONAL {
   ?speaker rdfs:label ?_speaker_label .
  }
  OPTIONAL {
   ?speaker pimo:isOrganizationMemberOf ?_speaker_isOrganizationMemberOf .
   ?_speaker_isOrganizationMemberOf rdfs:label ?_speaker_isOrganizationMemberOf_label .
  }
  ?speaker <http://callimachusproject.org/rdf/2009/framework#soundex> "B000" .
 }
 FILTER (regex(str(?_speaker_label), "^b", "i"))
}
# @origin speaker /1/3
# @origin _speaker_label /1/3/1 !
# @origin _speaker_isOrganizationMemberOf /1/3/2
# @origin _speaker_isOrganizationMemberOf_label /1/3/2/1 !

RDFaProducer required modification to handle either kind of result-set.

The moral is:- take care mixing UNIONs with FILTERs.

Original comment by steven.a...@gmail.com on 24 Jun 2011 at 6:40

GoogleCodeExporter commented 9 years ago
If the matched resource refers to multiple resources, both should be show in 
the same result entry. This is demonstrated using the markup below, while 
searching for 'david'. While most pimo:Person resources have one organization, 
some pimo:Person has multiple ^adgenda:speaker.

The patch referenced above will cause the pimo:Person resource to be repeated 
for each event they are a speaker of (the nested <ul> will only every have one 
<li>). This is incorrect, the events should be grouped with the pimo:Person 
that matched the search.

<ul rel="agenda:speaker" dropzone="link s:text/uri-list">
  <label>Speakers</label>
  <button type="button" class="dialog" data-dialog="about:blank" />
  <li about="?speaker" typeof="pimo:Person">
    <span property="rdfs:label"/> from 
    <span rel="pimo:isOrganizationMemberOf">
      <span property="rdfs:label"/>
    </span>
    <ul rev="agenda:speaker">
      <li about="?event">
        <a href="?event" property="dc:title"/>
      </li>
    </ul>
    <button type="button" class="remove" />
  </li>
</ul>

Instead of trying to extract the label variable(s) to filter prefix, create 
another set of joins to filer the label. Below is a query that uses the EXIST 
clause to filter out ?speakers that do not have a label that matched the 
provided prefix "b".

SELECT REDUCED *
WHERE {
  ?speaker a pimo:Person .
  OPTIONAL {
   {
    ?speaker rdfs:label ?_speaker_label .
   }
   UNION
   {
    ?speaker pimo:isOrganizationMemberOf ?_speaker_isOrganizationMemberOf .
    OPTIONAL {
     ?_speaker_isOrganizationMemberOf rdfs:label ?_speaker_isOrganizationMemberOf_label .
    }
   }
  }
  ?speaker <http://callimachusproject.org/rdf/2009/framework#soundex> "B000" .
  FILTER (EXISTS {
    {
      ?speaker rdfs:label ?label
    } UNION {
      ?speaker skos:prefLabel ?label
    } UNION {
      ?speaker skos:altLabel ?label
    } UNION {
      ?speaker skos:hiddenLabel ?label
    } UNION {
      ?speaker skosxl:literalForm ?label
    }
    FILTER (regex(str(?label), "^b", "i"))
  })
}

Original comment by *...@talis.com on 26 Jun 2011 at 5:53

GoogleCodeExporter commented 9 years ago
Removed duplicate results. Added additional FILTER EXISTS to the data-search 
query in FormSupport (via SPARQLPosteditor).

Example from conference app below. Includes skos extended properties. Variables 
introduced within the EXISTS are prefixed with a double underscore to ensure 
there is no confusion with variables generated in the main query.

PREFIX :<http://www.w3.org/1999/xhtml>
PREFIX agenda:<http://callimachusproject.org/rdf/2010/agenda#>
PREFIX dc:<http://purl.org/dc/terms/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX pimo:<http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX zdef1642281865:<http://www.w3.org/1999/xhtml>
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
SELECT REDUCED *
WHERE {
 {
  ?speaker a pimo:Person .
  OPTIONAL {
   {
    ?speaker rdfs:label ?_speaker_label .
   }
   UNION
   {
    ?speaker pimo:isOrganizationMemberOf ?_speaker_isOrganizationMemberOf .
    OPTIONAL {
     ?_speaker_isOrganizationMemberOf rdfs:label ?_speaker_isOrganizationMemberOf_label .
    }
   }
  }
  ?speaker <http://callimachusproject.org/rdf/2009/framework#soundex> "D130" .
 }
 FILTER ( EXISTS {
  {
   ?speaker <http://www.w3.org/2000/01/rdf-schema#label> ?__label .
  }
  UNION
  {
   ?speaker <http://www.w3.org/2004/02/skos/core#prefLabel> ?__label .
  }
  UNION
  {
   ?speaker <http://www.w3.org/2004/02/skos/core#altLabel> ?__label .
  }
  UNION
  {
   ?speaker <http://www.w3.org/2004/02/skos/core#hiddenLabel> ?__label .
  }
  UNION
  {
   ?speaker <http://www.w3.org/2008/05/skos-xl#prefLabel> ?__speaker_prefLabel .
   ?__speaker_prefLabel <http://www.w3.org/2008/05/skos-xl#literalForm> ?__label .
  }
  UNION
  {
   ?speaker <http://www.w3.org/2008/05/skos-xl#altLabel> ?__speaker_altLabel .
   ?__speaker_altLabel <http://www.w3.org/2008/05/skos-xl#literalForm> ?__label .
  }
  UNION
  {
   ?speaker <http://www.w3.org/2008/05/skos-xl#hiddenLabel> ?__speaker_hiddenLabel .
   ?__speaker_hiddenLabel <http://www.w3.org/2008/05/skos-xl#literalForm> ?__label .
  }
  FILTER (regex(str(?__label), "^david", "i"))
 })
}
# @origin speaker /1/3
# @origin _speaker_label /1/3/1 !
# @origin _speaker_isOrganizationMemberOf /1/3/2
# @origin _speaker_isOrganizationMemberOf_label /1/3/2/1 !

Added Exists as an additional RDFEvent, with required changes to SPARQLWriter.
Modified RDFaProducer to cope with result variables that don't originate within 
the template.

Original comment by steven.a...@gmail.com on 27 Jun 2011 at 1:10

GoogleCodeExporter commented 9 years ago
Removed skos-xl:prefLabel/altLabel/hiddenLabel, leaving skos-xl:literalForm. 
EXISTS clause is derived from LABELS defined in SoundexTrait.

Example search "david" now produces the SPARQL query:

PREFIX :<http://www.w3.org/1999/xhtml>
PREFIX agenda:<http://callimachusproject.org/rdf/2010/agenda#>
PREFIX dc:<http://purl.org/dc/terms/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX pimo:<http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#>
PREFIX zdef88785849:<http://www.w3.org/1999/xhtml>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
SELECT REDUCED *
WHERE {
 {
  ?speaker a pimo:Person .
  OPTIONAL {
   {
    ?speaker rdfs:label ?_speaker_label .
   }
   UNION
   {
    ?speaker pimo:isOrganizationMemberOf ?_speaker_isOrganizationMemberOf .
    OPTIONAL {
     ?_speaker_isOrganizationMemberOf rdfs:label ?_speaker_isOrganizationMemberOf_label .
    }
   }
  }
  ?speaker <http://callimachusproject.org/rdf/2009/framework#soundex> "D130" .
 }
 FILTER ( EXISTS {
  {
   ?speaker <http://www.w3.org/2000/01/rdf-schema#label> ?__label .
  }
  UNION
  {
   ?speaker <http://www.w3.org/2004/02/skos/core#prefLabel> ?__label .
  }
  UNION
  {
   ?speaker <http://www.w3.org/2004/02/skos/core#altLabel> ?__label .
  }
  UNION
  {
   ?speaker <http://www.w3.org/2004/02/skos/core#hiddenLabel> ?__label .
  }
  UNION
  {
   ?speaker <http://www.w3.org/2008/05/skos-xl#literalForm> ?__label .
  }
  FILTER (regex(str(?__label), "^david", "i"))
 })
}
# @origin speaker /1/3
# @origin _speaker_label /1/3/1 !
# @origin _speaker_isOrganizationMemberOf /1/3/2
# @origin _speaker_isOrganizationMemberOf_label /1/3/2/1 !

Original comment by steven.a...@gmail.com on 27 Jun 2011 at 1:39