@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix vitro:   <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix ts_:    <https://litvinovg.pro/text_structures#> .
@prefix display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> .

 
<https://litvinovg.pro/text_structures#elenphExcerpt> display:hasDataGetter display:getExcerptAssignedArticlesDataGetter .
<https://litvinovg.pro/text_structures#elenphExcerpt> display:hasDataGetter display:getExcerptAuthorsDataGetter .


display:getExcerptAssignedArticlesDataGetter
    a <java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter>;
    display:saveToVar "articles";
    display:query
        """
        PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
        PREFIX ts_:  <https://litvinovg.pro/text_structures#> 
        PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
        SELECT DISTINCT ?articleName ?articleUri
        WHERE {
              ?articleUri rdf:type ts_:elenphArticle .
              ?articleUri ts_:hasTOC ?toc .
              ?toc (ts_:hasTOCItem/ts_:pointsTo)+/ts_:hasText ?individualURI .
              ?articleUri rdfs:label ?articleName .
        } ORDER BY ?articleName
        """ .

display:getExcerptAuthorsDataGetter
    a <java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter>;
    display:saveToVar "authors";
    display:query
        """
		PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
		PREFIX ts_:  <https://litvinovg.pro/text_structures#> 
		PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
        SELECT DISTINCT ?authorInitials ?authorFamily ?authorGivenName ?orgName ?orgPostalCode ?orgAddress
		       WHERE {
                       ?individualURI ts_:hasAuthor ?participant .
                       ?participant ts_:participantFamily ?authorFamily .
                       ?participant ts_:participantInitials ?authorInitials .
                       ?participant ts_:participantGivenName ?authorGivenName .
                  OPTIONAL { ?participant ts_:affiliatedWith ?organization .
                    OPTIONAL { ?organization ts_:officialOrganizationName ?orgName } .
                    OPTIONAL { ?organization ts_:organizationPostalCode ?orgPostalCode } .
                    OPTIONAL { ?organization ts_:organizationAddress ?orgAddress } .
                  }
                
		} ORDER BY ?authorFamily
        """ .
