Named question about pod
Which files are out of place
A file is out of place when it holds a thing that the pod's layout, read beside it with the pod's root as its base, files somewhere else. A thing that states the property an entry files with goes in the folder of that property's value; else an entry for its class narrowed to the things that state a property places it; else an entry for its class alone, unless the layout says another class of the thing is a subclass of it and places that one. A file that says it is a view is checked only against the entries at or under the views folder, and every other file only against the rest. A folder's fan-out is how many leading characters of a file's name make the subfolder it is in. A file holding nothing the layout places is never out of place, and the stored documents, which are not RDF, are not seen here. Only the layout's own placements are read, never a type registration a pod holds. Each row is a file, a thing in it, and the file or folder the layout gives that thing.
The query
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX solid: <http://www.w3.org/ns/solid/terms#>
SELECT ?file ?thing ?place
WHERE {
{ SELECT DISTINCT ?file ?thing ?place ?isFile ?fanOut
WHERE {
{ GRAPH ?file { ?thing ?with ?value }
?entry a cascade:Placement ; cascade:filedWith ?with .
OPTIONAL { ?entry cascade:subfolderPrefixLength ?fanOut }
?value a ?valueClass .
?valueEntry a cascade:Placement ; solid:forClass ?valueClass ; solid:instanceContainer ?place .
?views a cascade:Placement ; solid:forClass cascade:View ; solid:instanceContainer ?viewsFolder .
FILTER (isIRI(?thing) && !STRSTARTS(STR(?place), STR(?viewsFolder)))
FILTER NOT EXISTS { ?valueEntry cascade:forSubjectsOf ?narrowing }
FILTER NOT EXISTS { ?file a cascade:View }
BIND (false AS ?isFile) }
UNION
{ GRAPH ?file { ?thing a ?class ; ?narrowing ?anything }
?entry a cascade:Placement ; solid:forClass ?class ; cascade:forSubjectsOf ?narrowing .
OPTIONAL { ?entry solid:instance ?instance }
OPTIONAL { ?entry solid:instanceContainer ?folder }
OPTIONAL { ?entry cascade:subfolderPrefixLength ?fanOut }
BIND (COALESCE(?instance, ?folder) AS ?place)
BIND (BOUND(?instance) AS ?isFile)
FILTER (isIRI(?thing) && BOUND(?place))
FILTER NOT EXISTS { ?file a cascade:View }
FILTER NOT EXISTS { ?filing a cascade:Placement ; cascade:filedWith ?with . ?thing ?with [] } }
UNION
{ GRAPH ?file { ?thing a ?class }
?entry a cascade:Placement ; solid:forClass ?class .
?views a cascade:Placement ; solid:forClass cascade:View ; solid:instanceContainer ?viewsFolder .
OPTIONAL { ?entry solid:instance ?instance }
OPTIONAL { ?entry solid:instanceContainer ?folder }
OPTIONAL { ?entry cascade:subfolderPrefixLength ?fanOut }
BIND (COALESCE(?instance, ?folder) AS ?place)
BIND (BOUND(?instance) AS ?isFile)
FILTER (isIRI(?thing) && BOUND(?place))
FILTER (STRSTARTS(STR(?place), STR(?viewsFolder)) = EXISTS { ?file a cascade:View })
FILTER NOT EXISTS { ?entry cascade:forSubjectsOf ?narrowing }
MINUS { ?filing a cascade:Placement ; cascade:filedWith ?with . ?thing ?with [] }
MINUS { ?narrowed a cascade:Placement ; solid:forClass ?class ; cascade:forSubjectsOf ?stated . ?thing ?stated [] }
MINUS { ?thing a ?subclass . ?subclass rdfs:subClassOf ?class .
?subclassEntry a cascade:Placement ; solid:forClass ?subclass } }
} }
BIND (STRAFTER(STR(?file), STR(?place)) AS ?rest)
BIND (STRBEFORE(?rest, "/") AS ?fan)
FILTER (IF(?isFile, ?file != ?place,
!STRSTARTS(STR(?file), STR(?place))
|| IF(BOUND(?fanOut),
STRLEN(?fan) != ?fanOut || !STRSTARTS(STRAFTER(?rest, "/"), ?fan) || CONTAINS(STRAFTER(?rest, "/"), "/"),
CONTAINS(?rest, "/"))))
}
ORDER BY ?file ?thing ?place
Terms it reads
cascade:Placement · cascade:View · cascade:filedWith · cascade:forSubjectsOf · cascade:subfolderPrefixLength · solid:forClass · solid:instance · solid:instanceContainer
Rules and decision notes that name it
No rule or decision note writes its path.
Its rows on Alex Rivera's pod
Alex Rivera's pod gives this question no rows. Open it in Alex Rivera's explorer.
queries/questions/pod/Which files are out of place.rq on GitHub ↗