jeff-zucker / solid-ui-components

generate high level HTML widgets from RDF data
MIT License
10 stars 3 forks source link

Ontology Questions : ui:DataSource #15

Open jeff-zucker opened 2 years ago

jeff-zucker commented 2 years ago

Components are expressed in this form :

   [] a ui:Component; ui:dataSource [a ui:DataSource].

The ui:Component is a possibly interactive UI feature that includes subclasses such as ui:Menu, ui:Table, etc. Each component can be linked to a ui:DataSource. Some components require specific DataSources, others can use any DataSource. Those relationships will be described in the section of the ontology dealing with ui:Component.

ui:DataSource

A ui:DataSource is anything that can be used to retrieve data including :

DataSource is an rdf:Collection

[] a ui:Menu; ui:dataSource ( :option1 :option2 ).

DataSource is a ui:SparqlQuery

[] ui:Table; ui:dataSource [a ui:SparqlQuery; ui:endpoint <e1>, <e2>; ui:query "SELECT ?foo ..."].

DataSource is an RDF subject

[] a ui:ConceptTree; ui:dataSource <bookmarks.ttl#TopTopic>.

DataSource is a ui:Link

[] a ui:Link; ui:href <foo.html>.     # fetch
[] a ui:Link; ui:transform <bar.md>.  # fetch & modify based on content-type
[] a ui:Link; ui:solidOS <baz.ttl>.   # fetch & display with outliner.GotoSubject()

# Note : `ui:needsProxy` and `ui:hasIframeBlocker` are booleans & can be used with any ui:Link

DataSource is a ui:HardCoded

[] a ui:Hardcoded; ui:content "some <b>bold</b> content".
[] a ui:Hardcoded; ui:script "()=>{...}".
timbl commented 2 years ago

A DataSource is used by the Autocomplete Field to pull in possible instances of things as the user types in the name of the thing, like a Language, or an Organization, or a Occupation, and so on.

timbl commented 2 years ago

For example

    :WikidataLanguageField a ui:AutocompleteField;
          ui:label "Language"; ui:size 30;
          ui:property solid:publicId; # @@
          ui:dataSource :WikidataLanguageDataSource;
           ui:targetClass schema:Language .

    :WikidataLanguageDataSource
        schema:name "Wikidata languages";
        ui:endpoint "https://query.wikidata.org/sparql" ;
        ui:objectURIBase <https://www.w3.org/ns/iana/language-code/>;
        # Add this to any literal string returned as ?subject

         ui:searchByNameQuery """SELECT ?item ?subject ?name
WHERE
{ ?item wdt:P305 ?subject .
  OPTIONAL {?item rdfs:label ?name}
  OPTIONAL {?item wdt:P1705 ?name}
  FILTER regex(?name, "$(name)", "i")
  FILTER regex(?subject, "^..$", "i")
}""" .

There is a convention that the query template must have specific variables subject, item, and name

jeff-zucker commented 2 years ago

Other than me using ui:query and the autocomplete using ui:searchByNameQuery, my propoesed ui:SparqlQuery as a sub-class of ui:DataSource seems compatible with the autocomplete.

By extending the DataSource to include other things than SPARQL queries, we can create auto-completes from a turtle file or hard-coded data or results of a script.

timbl commented 2 years ago

another example:

        :escoSkillField a ui:AutocompleteField;
              ui:label "skill"; ui:size 30;
              ui:property solid:publicId;
              ui:dataSource :ESCO_Skill_DataSource;
               ui:targetClass schema:Skill .

        :ESCO_Skill_DataSource a ui:DataSource;
           schema:name "ESCO Skill";
           ui:targetClass esco:Skill ;
           schema:logo <https://ec.europa.eu/esco/portal/static_resource2/images/logo/logo_en.gif>;
           ui:searchByNameURI "https://ec.europa.eu/esco/api/search?language=$(language)&limit=$(limit)&type=skill&text=$(name)".
timbl commented 2 years ago

"Other than me using ui:query and the autocomplete using ui:searchByNameQuery, my proposed ui:SparqlQuery as a sub-class of ui:DataSource seems compatible with the autocomplete." - yes. The ui:searchByNameURI is a non-sparql. example. Yes, using a local data table could be a DataSource too.

jeff-zucker commented 2 years ago

Great, glad we are thinking along the same lines about DataSource. It isn't AFAIK in the ontology. Do you have a definition for it somewhere or should I create one along the lines of what we've said above? If I should create it, any hints appreciated :-).