<?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 -->

<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>
                        ?role
                        ?subclassLabel
                        ?activity
                        (REPLACE(STR(?activity),"^.*(#)(.*)$", "$2") AS ?activityLocal)
                        ?activityName
                        ?dateTimeStart
                        ?dateTimeEnd
        WHERE {
            ?subject ?property ?role .
            ?role a core:ReviewerRole .

            OPTIONAL {
                <precise-subquery>?subject ?property ?role .
                ?role a core:ReviewerRole .</precise-subquery>
                ?role core:roleContributesTo ?activity .
                ?activity rdfs:label ?activityName .
            }
            OPTIONAL {
                <precise-subquery>?subject ?property ?role .
                ?role a core:ReviewerRole .</precise-subquery>
                ?role core:roleContributesTo ?activity .
                ?activity vitro:mostSpecificType ?subclass .
                ?subclass rdfs:label ?subclassLabel .
            }
            OPTIONAL {
                <precise-subquery>?subject ?property ?role .
                ?role a core:ReviewerRole .</precise-subquery>
                ?role core:dateTimeInterval ?dateTimeInterval .
                ?dateTimeInterval core:start ?dateTimeStartValue .
                ?dateTimeStartValue core:dateTime ?dateTimeStart .
            }
            OPTIONAL {
                <precise-subquery>?subject ?property ?role .
                ?role a core:ReviewerRole .</precise-subquery>
                ?role core:dateTimeInterval ?dateTimeInterval .
                ?dateTimeInterval core:end ?dateTimeEndValue .
                ?dateTimeEndValue core:dateTime ?dateTimeEnd .
            }

        } ORDER BY <collated> ?subclass </collated> DESC(?dateTimeEnd) DESC(?dateTimeStart) ?activityName
    </query-select>

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