Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Steps to replace an authoritative label via SPARQL:

Find all the subjects with the matching triple pattern, 
and replace the matched triples with the INSERT triple pattern.

...

Code Block
INSERT { 
    <lcsh:sh123456> madsrdf:hasVariant _:v .
    _:v a madsrdf:Variant .
    _:v madsrdf:variantLabel "Dog catcher" .
}
WHERE { 
    <lcsh:sh123456> madsrdf:authoritativeLabel "Dog snatcher"
}


Delete an LCSH resource:

1) Delete related component list.  Thanks to:  https://afs.github.io/rdf-lists-sparql

...

Code Block
DELETE { 
    ?z rdf:first ?head ; rdf:rest ?tail . 
}
WHERE { 
      <lcsh:sh123456> madsrdf:elementList ?list 
      ?list rdf:rest* ?z .
      ?z rdf:first ?head ;
         rdf:rest ?tail .
};

3)
# Delete related variant elements list.
# Thanks to:  https://afs.github.io/rdf-lists-sparql

Code Block

DELETE 

...


    ?z rdf:first ?head ; rdf:rest ?tail 

...


}

...


WHERE 

...


      <lcsh:sh123456> madsrdf:hasVariant ?v .

...


      ?v madsrdf:elementList ?list 

...


      ?list rdf:rest* ?z .

...


      ?z rdf:first ?head ;

...


         rdf:rest ?tail .

...


};

4)  
# Delete related resources identified with blank nodes.

Code Block
DELETE {

...


    ?o ?p1 ?o1 .

...


    ?o1 ?p2 ?o2 .

...


...


WHERE {

...


    <lcsh:sh123456> ?p ?o .

...


    FILTER( isBlank(?o) ) .    

...


    ?o ?p1 ?o1 .

...


    OPTIONAL {

...


        FILTER( isBlank(?o1) ) .    

...


        ?o1 ?p2 ?o2 .

...


    }

...


}

5) 
# Delete triples that link to deleted resource
# .  NB: If ?s is a blank node, it may be because this Thing is a member of a list.  That's just a plain problem.

Code Block
DELETE {

...


    ?s ?p <lcsh:sh123456> .

...


...


WHERE {

...


    ?s ?p <lcsh:sh123456> .

...


    FILTER( isIRI(?s) ) .

...


}

56
# Delete triples where the subject is the resource's URI.

Code Block
DELETE {

...


    <lcsh:sh123456> ?p ?o .

...


...


WHERE {

...


    <lcsh:sh123456> ?p ?o .

...


}


Deprecate a resource.Removes the Authority type and replaces it with Deprecated.

By rights, there are so many changes that it would be better 
probably be better, in reality, to delete the resource and replace it.

1) Removes the Authority type and replaces it with Deprecated.

Code Block
DELETE {

...


    <lcsh:sh123456> a madsrdf:Authority .

...


}

...


INSERT {

...


    <lcsh:sh123456> a madsrdf:DeprecatedAuthority .

...


}

...


WHERE {

...


    <lcsh:sh123456> a madsrdf:Authority .

...


}

2) Removes the authLabel and replaces with depLabel.2)

Code Block
DELETE {

...


    <lcsh:sh123456> madsrdf:authoritativeLabel ?label .

...


}

...


INSERT {

...


    <lcsh:sh123456> madsrdf:deprecatedLabel ?label .

...


}

...


WHERE {

...


    <lcsh:sh123456> madsrdf:authoritativeLabel ?label .

...


}


Resource deprecated, but we have a replacement URI.

1)
Find where the old URI is used, replace it with the new one.
Not sure this can be done in one step; might need two steps.  THe   The first to add the new triple, the second to delete the old one.

Code Block
INSERT {

...


    ?s ?p <lcsh:new>

...


}

...


DELETE {

...


    ?s ?p <lcsh:old>

...


}

...


WHERE {

...


    ?s ?p <lcsh:old>

...


}

If "Deprecate a resource" above would better involve deleting the existing resource first, it would be best to replace the old URI with the new one in relationships first.

...