@prefix : <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
 
:vivodocumentModifier_excerptsInArticles
    a   <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SelectQueryDocumentModifier> ,
        <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
    rdfs:label "Elenph article excerpts" ;
    :hasTargetField "ALLTEXT" ;
    :hasSelectQuery """
        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 ?elenphExcerpt ?property ?value
        WHERE {
              ?uri rdf:type ts_:elenphArticle .
              ?uri  ts_:hasTOC ?toc .
              ?toc (ts_:hasTOCItem/ts_:pointsTo)+/ts_:hasText ?elenphExcerpt .
              ?elenphExcerpt ?property ?value .
        } 
        """ .
        
:vivodocumentModifier_PopulateText
    a   <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SelectQueryDocumentModifier> ,
        <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
    rdfs:label "Html text to text field" ;
    :hasTargetField "text" ;
    :hasSelectQuery """
        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 ?htmlExcerpt
        WHERE {
        	    {
                 ?uri rdf:type ts_:textExcerpt .
                 ?uri ts_:htmlExcerpt ?htmlExcerpt .
                } 
                 UNION
                {
                 ?uri rdf:type ts_:publication .
                 ?uri ts_:hasTOC ?toc .
                 ?toc (ts_:hasTOCItem/ts_:pointsTo)+/ts_:hasText ?artExcerpt .
                 ?artExcerpt ts_:htmlExcerpt ?htmlExcerpt .
                }
        } 
        """ .
        
:vivodocumentModifier_rubrics
    a   <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SelectQueryDocumentModifier> ,
        <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
    rdfs:label "Add rubrics in rubrics field" ;
    :hasTargetField "rubrics" ;
    :hasSelectQuery """
        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#>
        PREFIX pr:   <https://iph.ras.ru/relationships#>
        SELECT DISTINCT ?rubric
        WHERE {
                {
                 ?uri rdf:type ts_:elenphExcerpt .
                 ?uri pr:belongsTo ?assignedRubric .
                 ?assignedRubric (pr:hasParent)* ?rubric .
                } 
                 UNION
                {
                 ?uri rdf:type ts_:elenphArticle .
                 ?uri ts_:hasTOC ?toc .
                 ?toc (ts_:hasTOCItem/ts_:pointsTo)+/ts_:hasText ?artExcerpt .
                 ?artExcerpt pr:belongsTo ?assignedRubric .
                 ?assignedRubric (pr:hasParent)* ?rubric .
                }
        } 
        """ .

:vivodocumentModifier_titles
    a   <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SelectQueryDocumentModifier> ,
        <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
    rdfs:label "Add titles to special field" ;
    :hasTargetField "titles" ;
    :hasSelectQuery """
        PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
        PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
        SELECT DISTINCT ?title
        WHERE {
              ?uri rdfs:label ?title .
        } 
        """ .


:vivodocumentModifier_keywordsElenph
    a   <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SelectQueryDocumentModifier> ,
        <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
    rdfs:label "Keywords for articles and excerpts" ;
    :hasTargetField "keywords" ;
    :hasSelectQuery """
        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 ?keywords
		WHERE {
		  {
		  ?uri rdf:type ts_:elenphArticle .
		  ?uri ts_:hasTOC ?toc .
          ?toc (ts_:hasTOCItem/ts_:pointsTo)+/ts_:hasText ?elenphExcerpt .
		  ?elenphExcerpt ts_:keywords ?keywords .
		  }
		  UNION
		  {
		  ?uri rdf:type ts_:elenphExcerpt .
		  ?uri ts_:keywords ?keywords .
		  }
		} 
        """ .

:vivodocumentModifier_bibliographyElenph
    a   <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SelectQueryDocumentModifier> ,
        <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
    rdfs:label "Bibliography for articles and excerpts" ;
    :hasTargetField "bibliography" ;
    :hasSelectQuery """
        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 ?bibliography
		WHERE {
		  {
		  ?uri rdf:type ts_:elenphArticle .
		  ?uri ts_:hasTOC ?toc .
          ?toc (ts_:hasTOCItem/ts_:pointsTo)+/ts_:hasText ?elenphExcerpt .
		  ?elenphExcerpt ts_:bibliography ?bibliography .
		  }
		  UNION
		  {
		  ?uri rdf:type ts_:elenphExcerpt .
		  ?uri ts_:bibliography ?bibliography .
		  }
		} 
        """ .

