Date: Fri, 29 Mar 2024 05:34:54 -0400 (EDT) Message-ID: <48803814.926.1711704894597@prodopencatalystconfluence.catalyst> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_925_2089724757.1711704894594" ------=_Part_925_2089724757.1711704894594 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This page gives examples of using the curl (documentation= here) command on a Unix/Linux or MacOSX system to test the Data Reposi= tory. Curl is a very powerful, flexible, command-line HTTP client wel= l-suited to interacting with RESTful Web service APIs like the eagle-i data= repository. It has a lot of options, so read the doc to understan= d what they all mean. See the Repository Design Specification and API = Manual for the closest thing to an API reference manual there is.The commands shown here were tested on Ubuntu Linux 9.10 (Karmic= Koala) with the system-provided curl 7.19.5.
In the following examples, the login credentials are given as "use=
rname:password"
=E2=80=93 when trying these commands on your own rep=
ository, replace those with the real username and password. These examples assume:
http://localhost/
username
password
..So please adjust as necessary to accomodate your real environment.&nbs= p; For example, you may wish to run the curl commands on your MacOS laptop,= testing a remote server on http://qa.harvard.eagle-i.net/
curl -G -s -S -u username:password 'http://localhost/repository/whoami= ?format=3Dtext/plain'
curl -s -u username:password -d format=3Dtext/plain http://localhost/r= epository/new (output looks like) new http://lcs14.intranet.med.harvard.edu/i/cf8c5f48-cd4d-45be-8245-81931c7= 151f5
curl -s -u username:password -F action=3Dcreate -F 'insert=3D@-;type= =3Dtext/rdf+n3' \ -F 'workspace=3Dhttp://eagle-i.org/ont/repo/1.0/NG_DefaultWorkspace' \ -F uri=3Dhttp://lcs14.intranet.med.harvard.edu/i/cf8c5f48-cd4d-45be-8245-81= 931c7151f5 \ http://localhost/repository/update <<. <http://lcs14.intranet.med.harvard.edu/i/cf8c5f48-cd4d-45be-8245-81931c7= 151f5> a <http://eagle-i.org/onto/#human>; <http://www.w3.org/2000/01/rdf-schema#label> "Frank N. Furter, PhD";&= nbsp; <http://eagle-i.org/onto/height> "179 cm"; <http://eagle-i.org/onto/mass> "82 kg"; <http://eagle-i.org/onto/hair> "black"; <http://eagle-i.org/onto/eyes> "brown"; <http://eagle-i.org/onto/driversLicense> "MA 12345678". .
http://l=
cs14.intranet.med.harvard.edu/i/cf8c5f48-cd4d-45be-8245-81931c7151f5
curl -u username:password \ -d format=3Dtext/plain http://lcs14.intranet.med.harvard.edu/i/cf8c5f48-cd4= d-45be-8245-81931c7151f5
curl -s -u username:password -F action=3Dgettoken -F format=3Dtext/pla= in \ -F uri=3Dhttp://lcs14.intranet.med.harvard.edu/i/cf8c5f48-cd4d-45be-8245-81= 931c7151f5 \ http://localhost/repository/update
token created creator new http://lcs14.intranet.med.harvard.edu/i/00000128-a7b5-5e0d-82b3-62428000000= 0 "2010-05-17T15:20:00.773-04:00"^^<http://www.w3.org/2001/XMLSchema#dateT= ime> http://serenity/i/0b4565a1-98de-4b3f-9874-7f68e07326b8 "true"^^<http://www.w3.org/2001/XMLSchema#boolean>
h=
ttp://eagle-i.org/ont/repo/1.0/MatchAnything
, we can use this be=
cause we know (or assume) there is only one value that we want to replace.=
=20
curl -s -u username:password -F action=3Dupdate -F 'insert=3D@-;type= =3Dtext/rdf+n3' \ --form-string 'token=3Dhttp://lcs14.intranet.med.harvard.edu/i/00000128-a7b= 5-5e0d-82b3-624280000000' \ --form-string 'format=3Dtext/rdf+n3' \ --form-string 'delete=3D<http://lcs14.intranet.med.harvard.edu/i/cf8c5f4= 8-cd4d-45be-8245-81931c7151f5> \ <http://eagle-i.org/onto/mass> <http://eagle-i.org/ont/repo/1.0/Ma= tchAnything> .' \ -F uri=3Dhttp://lcs14.intranet.med.harvard.edu/i/cf8c5f48-cd4d-45be-8245-81= 931c7151f5 \ http://localhost/repository/update <<. <http://lcs14.intranet.med.harvard.edu/i/cf8c5f48-cd4d-45be-8245-81931c7= 151f5> \ <http://eagle-i.org/onto/mass> "91 kg"; <http://eagle-i.org/onto/favoriteColor> "red". .
The /repository/graph service gives you control over th= e contents of an entire named graph. See the last section of the Admin Manu= al for an example of how to use this to backup and restore the contents of = the entire repository.
load-ontology.sh
script in the repository installa=
tion kit for an illustration of adding files of serialized RDF to a graph. =
It has the effect of merging all those files into one graph.curl -X GET -G -s -S -u root:password \ --data-urlencode 'format=3Dtext/rdf+n3' \ --data-urlencode 'name=3Dhttp://eagle-i.org/ont/repo/1.0/NG_Sandbox' \ "http://localhost/repository/graph"
curl -s -S -u root:password -F 'content=3D@-;type=3Dtext/rdf+n3' \ -F 'name=3Dhttp://eagle-i.org/ont/repo/1.0/' \ -F 'action=3Ddelete' "http://localhost/repository/graph" <<. <http://eagle-i.org/ont/repo/1.0/NG_Users> <http://eagle-i.org/ont= /repo/1.0/ngType> <http://eagle-i.org/ont/repo/1.0/NGType_Published> . .
curl -s -S -u root:password -F 'content=3D@-;type=3Dtext/rdf+n3' \ -F 'name=3Dhttp://eagle-i.org/ont/repo/1.0/' \ -F 'action=3Dadd' "http://localhost/repository/graph" <<. <http://eagle-i.org/ont/repo/1.0/NG_Users> <http://eagle-i.org/on= t/repo/1.0/ngType> <http://eagle-i.org/ont/repo/1.0/NGType_Metadata> . .
You can script a SPARQL query too, of course. See the API manual f= or the full range of arguments in the extended SPARQL Protocol the repo sup= ports. Here is an example query that gets a list of all subjects that= have a value of the "editor preferred term" predicate, listing each subjec= t once for every predicate so if there are multiple values the subject appe= ars multiple times. This list is used to check for the error of multi= ple EPTs. Note how curl's form-file-upload mechanism is used to let you ent= er the lengthy SPARQL query in plain text as an immediate input stream, whi= ch is simpler than encoding it as an arg value.
curl -s -S -u root:password -F 'query=3D@-' -F view=3Dontology -F for= mat=3Dtext/plain \ http://localhost/repository/sparql <<. > terms.txt SELECT ?subject WHERE {?subject <http://purl.obolibrary.org/obo/IAO_0000= 111> ?pterm} order by ?subject .
The repository contains its own internal ontology. Since this is l= ikely to change with each minor release while the repo is under development= , and the code depends on those changes, you may easily f= ind yourself needing to load a new version of the ontology into an existing= repo. For example, while upgrading the webapp of a repo while wishin= g to keep its data intact.The solution is this command that replaces the co= ntents of the named graph containing its ontology. It grovels the ont= ology right out of the webapp's war file (where it is normally used to boot= strap a new repo). Be sure to replace "ROOT.war" wit= h the path to your repo's webapp war file.
unzip -p ROOT.war WEB-INF/classes/repository-ont.n3 | curl -s -S -u ro= ot:password \ -F 'content=3D@-;type=3Dtext/rdf+n3' \ -F 'name=3Dhttp://eagle-i.org/ont/repo/1.0/' \ -F 'action=3Dreplace' "http://localhost/repository/graph"