-- DESCRIBE
-- Link: https://tinyurl.com/yax4zvaq
SPARQL 

DEFINE get:soft "soft"
DESCRIBE <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> 
FROM <https://kidehen3.solid.openlinksw.com:8444/profile/card>

-- CONSTRUCT 
-- Link: https://tinyurl.com/y9bhy5db

DEFINE get:soft "soft"

CONSTRUCT {
			?s ?p ?o .
		  } 
FROM <https://kidehen3.solid.openlinksw.com:8444/profile/card>
WHERE {
		?s ?p ?o .
	  } ;

SPARQL

-- SELECT 
-- Uses Default Data Brower from Deployment Data Space or POD
-- Link: https://tinyurl.com/ybyons66
-- No Reasoning & Inference Rules applied

DEFINE get:soft "soft"

SELECT DISTINCT <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> AS ?s
                ?p ?o
FROM <https://kidehen3.solid.openlinksw.com:8444/profile/card>
WHERE {
		<https://kidehen3.solid.openlinksw.com:8444/profile/card#me> ?p ?o .
	  } ;


SPARQL

-- SELECT 
-- Link: https://tinyurl.com/y7xv87ug
-- Uses Virtuoso Faceted Browser 
-- No Reasoning & Inference Rules applied


DEFINE get:soft "soft"

SELECT DISTINCT <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> AS ?s
              ?p ?o
FROM <https://kidehen3.solid.openlinksw.com:8444/profile/card>
WHERE {
	<https://kidehen3.solid.openlinksw.com:8444/profile/card#me> ?p ?o .
  } ;

SPARQL

-- INSERT
-- Link: https://tinyurl.com/ydysd5mh
-- No Reasoning & Inference Rules applied

INSERT DATA { 
			GRAPH <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> 
			    { 				 
				  <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> foaf:mbox <mailto:kidehen@openlinksw.com> . 
				}
						
			} ;
			
SPARQL

-- DELETE
-- Link: https://tinyurl.com/y7pldmrg
-- Uses Virtuoso Faceted Browser 
-- No Reasoning & Inference Rules applied

DELETE DATA { 
			GRAPH <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> 
			    { 				 
				  <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> foaf:mbox <mailto:kidehen@openlinksw.com> . 
				}
			
			} ;
			
SPARQL
			
-- UPDATE via INSERT & DELETE
-- Link: https://tinyurl.com/ybzgkatr
-- Uses Virtuoso Faceted Browser 
-- No Reasoning & Inference Rules applied

INSERT DATA { 
			GRAPH <urn:sparql:insert:qa> 
			    { 			
				  ## Email Address
				  <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> foaf:mbox <mailto:kidehen@openlinksw.com> . 
				  <https://kidehen.solid.openlinksw.com:8444/profile/card#me> foaf:mbox <mailto:kidehen@openlinksw.com> . 
				  <https://kidehen.solid.openlinksw.com:8444/profile/card#me> foaf:mbox <mailto:kidehen@openlinksw.com> . 
				  <https://kidehen7.solid.openlinksw.com:8444/profile/card#me> foaf:mbox <mailto:kidehen@openlinksw.com> . 
				  <https://kidehen7.solid.openlinksw.com:8444/profile/card#me> foaf:mbox <mailto:kidehen@gmail.com> . 
				  
				  ## LinkedIn Profile Page			  
				  <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> schema:sameAs <http://www.linkedin.com/in/kidehen> . 
				  <https://kidehen.solid.openlinksw.com:8444/profile/card#me> schema:sameAs <http://www.linkedin.com/in/kidehen> .
				  <https://kidehen.solid.openlinksw.com:8444/profile/card#me> schema:sameAs <http://www.linkedin.com/in/kidehen> .
				  <https://kidehen7.solid.openlinksw.com:8444/profile/card#me> schema:sameAs <http://www.linkedin.com/in/kidehen> .
				  
				  ## Twitter Profile Page 
				  <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> schema:sameAs <https://twitter.com/kidehen> .
				  <https://kidehen.solid.openlinksw.com:8444/profile/card#me> schema:sameAs <https://twitter.com/kidehen> .
				  <https://kidehen.solid.openlinksw.com:8444/profile/card#me> schema:sameAs <https://twitter.com/kidehen> .
				  <https://kidehen7.solid.openlinksw.com:8444/profile/card#me> schema:sameAs <https://twitter.com/kidehen> .
				  
				}

			} ;
			
DELETE DATA { 
			GRAPH <urn:sparql:insert:qa> 
			    { 				 
				  <https://kidehen7.solid.openlinksw.com:8444/profile/card#me> foaf:mbox <mailto:kidehen@gmail.com> . 
				}

			} ;

SPARQL
			
-- Verify effects of UPDATE
-- Using Virtuoso Faceted Browser since data was added to a named graph in 
-- Virtuoso instance associated with /sparql endpoint
-- Query Results Link: https://tinyurl.com/y9kstz4n
-- Faceted Browser Page scoped to relevant named graphs link: https://tinyurl.com/y8wm2xs7

SELECT DISTINCT ?s foaf:mbox ?o
FROM <urn:sparql:insert:qa> 
WHERE {
		?s ?p ?o .
  	  } ;
	  

-- Inverse Functional Relationship Type Semantics for built-in Reasoning and Inference

SPARQL

INSERT DATA { 
				GRAPH <urn:inference:rule:ifp> 
				    { 				 
					  foaf:mbox a owl:InverseFunctionalProperty . 
					  foaf:mbox_sha1sum a owl:InverseFunctionalProperty . 
					  schema:sameAs a owl:InverseFunctionalProperty . 
			 
					}

	  		} ;
			
-- Inference Rule Test 
-- Re owl:InverseFunctionalProperty relationship types

SPARQL

DEFINE input:inference 'urn:ifp:inference:rule'

SELECT DISTINCT <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> AS ?s
              ?o
WHERE {
	<https://kidehen3.solid.openlinksw.com:8444/profile/card#me> owl:sameAs ?o .
  } ;
  

-- Inference Rule Test
-- Re owl:sameAs relationship types

SPARQL

# DEFINE input:inference 'urn:ifp:inference:rule'
DEFINE input:same-as "yes"

SELECT DISTINCT <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> AS ?s
            owl:sameAs as ?relation
            ?o
WHERE {
<https://kidehen3.solid.openlinksw.com:8444/profile/card#me> owl:sameAs ?o .
} ;


-- Inference Rule Test
-- Re owl:sameAs relationship types
-- Named Graph Provenance included

SPARQL

# DEFINE input:inference 'urn:ifp:inference:rule'
DEFINE input:same-as "yes"

SELECT DISTINCT ?g <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> AS ?s
              owl:sameAs as ?relation
              ?o
WHERE {
		GRAPH ?g { <https://kidehen3.solid.openlinksw.com:8444/profile/card#me> owl:sameAs ?o .} 
  } ;
  
-- Manually implement Inverse Functional Relationship Type Inference using SELECT 
-- Note: CONSTRUCT used for Inference Rule using SPIN/SHACL Vocab
-- Email Address

SPARQL 

SELECT ?s owl:sameAs as ?sameAs ?o
# CONSTRUCT {?s owl:sameAs ?o} -- for Custom Inference Rule
WHERE {
       { SELECT DISTINCT ?s ?mbox 
         {
           ?s foaf:mbox ?mbox . 
         }
       }
      { SELECT DISTINCT ?o ?mbox2
         {
           ?o foaf:mbox ?mbox2 . 
         }
       }
     
      FILTER (?s = <https://kidehen.solid.openlinksw.com:8444/profile/card#me>)
      FILTER (?mbox = ?mbox2)
      FILTER (?s != ?o)
 
} ;

-- Based on Profile Pages

SPARQL 

SELECT ?s owl:sameAs as ?sameAs ?o
# CONSTRUCT {?s owl:sameAs ?o} -- for Custom Inference Rule
WHERE {
       { SELECT DISTINCT ?s ?page 
         {
           ?s schema:sameAs ?page . 
         }
       }
      { SELECT DISTINCT ?o ?page2
         {
           ?o schema:sameAs ?page2 . 
         }
       }
     
      FILTER (?s = <https://kidehen.solid.openlinksw.com:8444/profile/card#me>)
      FILTER (?page = ?page2)
      FILTER (?s != ?o)
 
} ;
  
-- Crawling via Sponger Test 1

SPARQL

## Prgama for de-referencing a CONSTANT 

DEFINE input:grab-iri <https://kidehen.solid.openlinksw.com:8444/public/>

## Pragma for de-referencing a designated Variable

DEFINE input:grab-var "o"

# PREFIX pim: <http://www.w3.org/ns/pim/space#> 

SELECT DISTINCT ?p ?o 
WHERE {
		 <https://kidehen.solid.openlinksw.com:8444/public/> ?p ?o .

  	   } ;

-- Crawling via Sponger Test 2

SPARQL

## Prgama for de-referencing a CONSTANT 

DEFINE input:grab-iri <https://kidehen.solid.openlinksw.com:8444/public/>

## Pragma for de-referencing a designated Variable

DEFINE input:grab-var "o"

# PREFIX pim: <http://www.w3.org/ns/pim/space#> 

SELECT DISTINCT ?o ldp:contains AS ?containerOf ?o2
WHERE {
	 <https://kidehen.solid.openlinksw.com:8444/public/> ldp:contains ?o .
         ?o ldp:contains ?o2. 

  } ;
  
  
-- Crawling via Sponger Test 3

SPARQL

DEFINE input:grab-var "o"
DEFINE input:grab-var "o2"
DEFINE input:grab-iri "https://kidehen2.solid.openlinksw.com:8444/public/"

# PREFIX pim: <http://www.w3.org/ns/pim/space#> 

SELECT DISTINCT ?o ?p ?o2
WHERE {
       <https://kidehen2.solid.openlinksw.com:8444/public/> ldp:contains ?o .
       ?o ?p ?o2. 
       FILTER (?p = ldp:contains) . 
	  } ;

-- Crawling Sponger Test 4
-- Using a single pragma to enact de-reference of constants and variables 

SPARQL

# DEFINE input:grab-var "o"
# DEFINE input:grab-var "o2"
# DEFINE input:grab-iri "https://kidehen2.solid.openlinksw.com:8444/public/"

DEFINE input:grab-all "yes"

SELECT DISTINCT ?o ldp:contains AS ?containerOf ?o2 ?p ?o3
WHERE {
	 <https://kidehen.solid.openlinksw.com:8444/public/> ldp:contains ?o .
         ?o ldp:contains ?o2. 
         ?o2 ?p ?o3. 

  } ;

-- Union Crawl over many PODs
SPARQL

# DEFINE input:grab-var "o"
# DEFINE input:grab-var "o2"
# DEFINE input:grab-iri "https://kidehen2.solid.openlinksw.com:8444/public/"

DEFINE input:grab-all "yes"

# PREFIX pim: <http://www.w3.org/ns/pim/space#> 

SELECT DISTINCT ?o ldp:contains AS ?containerOf ?o2 ?p ?o3
WHERE {
 { 
         <https://kidehen.solid.openlinksw.com:8444/public/> ldp:contains ?o .
         ?o ldp:contains ?o2. 
         ?o2 ?p ?o3.
       } 
       UNION 
 { 
         <https://kidehen2.solid.openlinksw.com:8444/public/> ldp:contains ?o .
         ?o ldp:contains ?o2. 
         ?o2 ?p ?o3.
       } 
       UNION
 { 
         <https://kidehen.solid.openlinksw.com:8444/public/> ldp:contains ?o .
         ?o ldp:contains ?o2. 
         ?o2 ?p ?o3.
       } 

} ;

-- Reveal Solid Entities 

SPARQL

# DEFINE input:grab-var "o"
# DEFINE input:grab-var "o2"
# DEFINE input:grab-iri "https://kidehen2.solid.openlinksw.com:8444/public/"

DEFINE input:grab-all "yes"

# PREFIX pim: <http://www.w3.org/ns/pim/space#> 

SELECT DISTINCT ?s as ?solidEntities 
WHERE {
	 { 
           <https://kidehen.solid.openlinksw.com:8444/public/> ldp:contains ?o .
           ?o ldp:contains ?o2. 
           ?o2 owl:sameAs ?s;
                ?p ?o3.
         } 
         UNION 
	 { 
           <https://kidehen2.solid.openlinksw.com:8444/public/> ldp:contains ?o .
           ?o ldp:contains ?o2. 
           ?o2 owl:sameAs ?s;
                ?p ?o3.
      } 
         UNION
	 { 
           <https://kidehen3.solid.openlinksw.com:8444/public/> ldp:contains ?o .
           ?o ldp:contains ?o2. 
           ?o2 owl:sameAs ?s;
                ?p ?o3.
      } 
		 
         UNION
	 { 
           <https://kidehen5.solid.openlinksw.com:8444/public/> ldp:contains ?o .
           ?o ldp:contains ?o2. 
           ?o2 owl:sameAs ?s;
                ?p ?o3.
     } 

  }   ;
  
  -- Different Solid Pods: Doesn't work right now 
  
  -- [1] https://kidehen.solid.openlinksw.com:8444/public/ 
  -- [2] https://solid.turnguard.com:8440/public/ 
  -- [3] https://drive.verborgh.org/public/RWWCrewQA/ 
  -- [4] https://timbl.com/timbl/Public/Test/2018/RWWCrew%20only/ 
  -- [5] https://melvin.solid.live/public/RWWCrew/ doesn't work because it is in OIDC mode

  SPARQL 
  # DEFINE input:grab-var "o"
  # DEFINE input:grab-var "o2"
  # DEFINE input:grab-iri "https://kidehen2.solid.openlinksw.com:8444/public/"

  DEFINE input:grab-all "yes"

  # PREFIX pim: <http://www.w3.org/ns/pim/space#> 

  SELECT DISTINCT ?o as ?solidEntities 
  WHERE {
  	 { 
             <https://kidehen.solid.openlinksw.com:8444/public/> ldp:contains ?o .
             ?o ldp:contains ?o2. 
             ?o2 owl:sameAs ?s;
                  ?p ?o3.
           } 
           UNION 
  	 { 
             <https://solid.turnguard.com:8440/public/> ldp:contains ?o .
             ?o ldp:contains ?o2. 
             ?o2 owl:sameAs ?s;
                  ?p ?o3.
     } 
           UNION
  	 { 
             <https://drive.verborgh.org/public/RWWCrewQA/> ldp:contains ?o .
             ?o ldp:contains ?o2. 
             ?o2 owl:sameAs ?s;
                  ?p ?o3.
           } 
           UNION
  	 { 
             <https://timbl.com/timbl/Public/Test/2018/RWWCrew%20only/> ldp:contains ?o .
             ?o ldp:contains ?o2. 
             ?o2 owl:sameAs ?s;
                  ?p ?o3.
           } 
           UNION
  	 { 
             <https://melvin.solid.live/public/RWWCrew/> ldp:contains ?o .
             ?o ldp:contains ?o2. 
             ?o2 owl:sameAs ?s;
                  ?p ?o3.
           } 

    } ;
	
	
-- Variant that works

SPARQL

# DEFINE input:grab-var "o"
# DEFINE input:grab-var "o2"
# DEFINE input:grab-iri "https://solid.turnguard.com:8440/public/"
# DEFINE input:grab-iri "https://drive.verborgh.org/public/RWWCrewQA/"
# DEFINE input:grab-iri "https://kidehen2.solid.openlinksw.com:8444/public/"
# DEFINE input:grab-iri "https://timbl.com/timbl/Public/Test/2018/"

DEFINE input:grab-all "yes"

SELECT DISTINCT *
WHERE {
		 { <https://solid.turnguard.com:8440/public/> ldp:contains ?o.
	         OPTIONAL { ?o owl:sameAs ?o2 }
		 }
	         UNION
		 { <https://drive.verborgh.org/public/RWWCrewQA/>  ldp:contains ?o.
	         OPTIONAL { ?o owl:sameAs ?o2 }
		 }
	         UNION
		 { <https://timbl.com/timbl/Public/Test/2018/>  ldp:contains ?o.
	         OPTIONAL {?o owl:sameAs ?o2} 
		 }
	         UNION
		 { <https://kidehen2.solid.openlinksw.com:8444/public/> ldp:contains ?o.
	         OPTIONAL { ?o owl:sameAs ?o2 }
		 }
  } ;
  
  -- Alternative 
  
-- Variant that works

SPARQL

# DEFINE input:grab-var "o"
# DEFINE input:grab-var "o2"
# DEFINE input:grab-iri "https://solid.turnguard.com:8440/public/"

DEFINE input:grab-all "yes"

SELECT DISTINCT  ?o2 as ?entity 
WHERE {
	 { <https://solid.turnguard.com:8440/public/> ldp:contains ?o.
         ?o owl:sameAs ?o2 }
         union
	 { <https://kidehen.solid.openlinksw.com:8444/public/> ldp:contains ?o.
         ?o owl:sameAs ?o2 }
         union
	 { <https://kidehen2.solid.openlinksw.com:8444/public/> ldp:contains ?o.
         ?o owl:sameAs ?o2 }
         union
	 { <https://drive.verborgh.org/public/RWWCrewQA/> ldp:contains ?o.
         ?o owl:sameAs ?o2 }
         union
	 { <https://timbl.com/timbl/Public/Test/2018/RWWCrew%20only/> ldp:contains ?o.
         ?o owl:sameAs ?o2 }
       union
	 { <https://melvin.solid.live/public/RWWCrew/> ldp:contains ?o.
         ?o owl:sameAs ?o2 }
  }
;

-- Using optionals 
SPARQL

DEFINE input:grab-all "yes"

SELECT DISTINCT  ?o as ?folder
WHERE {
		 { optional {<https://solid.turnguard.com:8440/public/> ldp:contains ?o} .}
	         union
		 { optional { <https://kidehen.solid.openlinksw.com:8444/public/> ldp:contains ?o} .}
	         union
		 { optional {<https://kidehen2.solid.openlinksw.com:8444/public/> ldp:contains ?o}.}
	         union
		 { optional {<https://drive.verborgh.org/public/RWWCrewQA/> ldp:contains ?o} .}
	         union
		 { optional { <https://timbl.com/timbl/Public/Test/2018/RWWCrew%20only/> ldp:contains ?o} .}
	       union
		 { optional { <https://melvin.solid.live/public/RWWCrew/> ldp:contains ?o} .}
  }
;


-- Plume Blog Post

SPARQL

DEFINE input:grab-var "post"
DEFINE input:grab-iri "https://kidehen2.solid.openlinksw.com:8444/public/blog/posts/"

PREFIX ldp: <http://www.w3.org/ns/ldp#>
PREFIX terms: <http://purl.org/dc/terms/>
PREFIX XML: <http://www.w3.org/2001/XMLSchema#>
PREFIX st: <http://www.w3.org/ns/posix/stat#>
PREFIX tur: <http://www.w3.org/ns/iana/media-types/text/turtle#>
PREFIX sioc: <http://rdfs.org/sioc/ns#>
PREFIX pim: <http://www.w3.org/ns/pim/space#> 

SELECT DISTINCT *
WHERE {
  <https://kidehen2.solid.openlinksw.com:8444/public/blog/posts/> ldp:contains ?post.
  ?post terms:created ?created ;
        terms:modified ?modified ;
        terms:title ?title ;
        sioc:content ?content

}  ;


	
