<?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 foaf:  &lt;http://xmlns.com/foaf/0.1/&gt;

        PREFIX bibo:  &lt;http://purl.org/ontology/bibo/&gt;
        PREFIX core:  &lt;http://vivoweb.org/ontology/core#&gt;
        PREFIX owl:   &lt;http://www.w3.org/2002/07/owl#&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 ?issuedCredential
                        ?issuedCredentialLocal
                        ?issuedCredentialLabel
                        ?credential
                        ?credentialLabel
                        ?credentialLocal
                        ?dateTimeStart
                        ?dateTimeEnd
                        ?dateTime

        WHERE {
            ?subject ?property ?issuedCredential .
            ?issuedCredential a core:IssuedCredential .
            LET (?issuedCredentialLocal := REPLACE(STR(?issuedCredential),"^.*(#)(.*)$", "$2"))
            OPTIONAL {
                <precise-subquery>?subject ?property ?issuedCredential .
                ?issuedCredential a core:IssuedCredential .</precise-subquery>
                ?issuedCredential rdfs:label ?issuedCredentialLabel .
            }
            OPTIONAL {
                <precise-subquery>?subject ?property ?issuedCredential .
                ?issuedCredential a core:IssuedCredential .</precise-subquery>
                ?issuedCredential core:relates ?credential .
                ?credential a core:Credential .
                ?credential core:relatedBy ?issuedCredential .
                ?credential rdfs:label ?credentialLabel .
                LET (?credentialLocal := REPLACE(STR(?credential),"^.*(#)(.*)$", "$2"))
            }
             OPTIONAL {
                <precise-subquery>?subject ?property ?issuedCredential .
                ?issuedCredential a core:IssuedCredential .</precise-subquery>
                ?issuedCredential core:dateTimeInterval ?dateTimeInterval .
                ?dateTimeInterval core:start ?dateTimeStartValue .
                ?dateTimeStartValue core:dateTime ?dateTimeStart .
             }
             OPTIONAL {
                <precise-subquery>?subject ?property ?issuedCredential .
                ?issuedCredential a core:IssuedCredential .</precise-subquery>
                ?issuedCredential core:dateTimeInterval ?dateTimeInterval .
                ?dateTimeInterval core:end ?dateTimeEndValue .
                ?dateTimeEndValue core:dateTime ?dateTimeEnd .
             }
             OPTIONAL {
                <precise-subquery>?subject ?property ?issuedCredential .
                ?issuedCredential a core:IssuedCredential .</precise-subquery>
                ?issuedCredential core:dateIssued ?dateTimeValue .
                ?dateTimeValue core:dateTime ?dateTime .
             }
        }  ORDER BY  DESC(?dateTime) DESC(?dateTimeEnd)
  </query-select>

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