<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $This file is distributed under the terms of the license in LICENSE$ -->

<!-- See guidelines at https://wiki.duraspace.org/x/eYXVAw
     This list view used for both roleContributesTo and BFO_0000054, which
     is for events.
-->

<list-view-config>
    <query-select>
        PREFIX core:  &lt;http://vivoweb.org/ontology/core#&gt;
        PREFIX rdfs:  &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
        PREFIX vitro: &lt;http://vitro.mannlib.cornell.edu/ns/vitro/0.7#&gt;

        SELECT DISTINCT <collated>?subclass</collated>
                        # send the property to the template, since this view supports multiple role properties
                        ?property
                        ?role
                        ?roleLabel
                        ?activity ?activityName
                        ?activityLabel
                        ?dateTimeStart ?dateTimeEnd
                        ?hideThis
                        ?objectType
        WHERE {
            ?subject ?property ?role .
            ?role a ?objectType .

            OPTIONAL {
                <precise-subquery>?subject ?property ?role .
                ?role a ?objectType .</precise-subquery>
                ?role core:roleContributesTo ?activity .
                ?activity rdfs:label ?activityLabel .

                <collated>
                ?activity vitro:mostSpecificType ?subclass .
                </collated>
            }
            OPTIONAL {
                <precise-subquery>?subject ?property ?role .
                ?role a ?objectType .</precise-subquery>
                ?role &lt;http://purl.obolibrary.org/obo/BFO_0000054&gt; ?activity .
                ?activity rdfs:label ?activityLabel .

                <collated>
                ?activity vitro:mostSpecificType ?subclass .
                </collated>
            }
            OPTIONAL {
                <precise-subquery>?subject ?property ?role .
                ?role a ?objectType .</precise-subquery>
                ?role rdfs:label ?roleLabel .
            }
            OPTIONAL {
                <precise-subquery>?subject ?property ?role .
                ?role a ?objectType .</precise-subquery>
                ?role core:dateTimeInterval ?dateTimeInterval .
                ?dateTimeInterval core:start ?dateTimeStartValue .
                ?dateTimeStartValue core:dateTime ?dateTimeStart .
            }
            OPTIONAL {
                <precise-subquery>?subject ?property ?role .
                ?role a ?objectType .</precise-subquery>
                ?role core:dateTimeInterval ?dateTimeInterval .
                ?dateTimeInterval core:end ?dateTimeEndValue .
                ?dateTimeEndValue core:dateTime ?dateTimeEnd .
            }
        } ORDER BY <collated>?subclass</collated> DESC(?dateTimeEnd) DESC(?dateTimeStart) ?activityLabel ?activityName
    </query-select>

    <template>propStatement-hasRole.ftl</template>
</list-view-config>
