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

<!-- VIVO-specific default list view config file for object properties

     See guidelines at https://wiki.duraspace.org/x/eYXVAw -->

<list-view-config>
    <query-select>

        PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt;
        PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&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;
        PREFIX obo: &lt;http://purl.obolibrary.org/obo/&gt;
        PREFIX vcard: &lt;http://www.w3.org/2006/vcard/ns#&gt;

        SELECT <collated> ?subclass </collated>
            ?object
            ?label
            ?localName
            ?type
            ?specificObjectType
            ?title
        WHERE
        {
            ?subject ?property ?object .
            LET (?localName := REPLACE(STR(?object), "^.*(#)(.*)$", "$2"))

            OPTIONAL {
                <precise-subquery>?subject ?property ?object .</precise-subquery>
                ?object rdfs:label ?label .
            }

            OPTIONAL {
                <precise-subquery>?subject ?property ?object .</precise-subquery>
                ?object vitro:mostSpecificType ?specificObjectType .
            }

            OPTIONAL {
                <precise-subquery>?subject ?property ?object .</precise-subquery>

                # Get mostSpecificType only for Persons
                ?object vitro:mostSpecificType ?subclass .
                ?subclass rdfs:label ?type .

                # Display only a mostSpecificType that belongs to a classgroup.
                ?subclass vitro:inClassGroup ?classGroup .
                ?classGroup a vitro:ClassGroup .
            }

            OPTIONAL {
                <precise-subquery>?subject ?property ?object .</precise-subquery>
                ?object obo:ARG_2000028 ?vcard .
                ?vcard vcard:hasTitle ?titleObj .
                ?titleObj vcard:title ?title .
            }

        <collated>
            FILTER ( REPLACE(STR(?subclass),"^(.*)(#)(.*)$", "$1$2") != "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#" )
        </collated>

        # Order by ?type is important, because if the object has more than one mostSpecificType,
        # they all get returned, but postprocessing culls out all but one. Ordering by ?type
        # will ensure that at least we'll get the same one every time.
        } ORDER BY <collated> ?subclass </collated> ASC( ?label ) ASC( ?localName ) ?type
    </query-select>

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