@@ -36,7 +36,7 @@ We must first convert this into a SNAC-compatible JSON Resource object:
"operation":"insert"
}
```
The data type *is* case sensitive, which has caused some trouble in the past. We're working on either removing that or clearing up the case sensitivity issue. We used the ArchivalResource type for the document and provided the link, title, abstract, and extent. The display entry is a human-readable and distinguishable field, so we added the author's name to the beginning. The repository link is a minimalistic Constellation with the ID of the holding institution we found above. Lastly, we include an "operation" field that will tell the server we want to insert this resource (rather than update it).
The data type *is* case sensitive, which has caused some trouble in the past. We're working on either removing that or clearing up the case sensitivity issue. We used the ArchivalResource type for the document and provided the link, title, abstract, and extent. The display entry is a human-readable and distinguishable field, so we added the author's name to the beginning. The repository link is a minimalistic Constellation with the ID of the holding institution we found above. Lastly, we include an "operation" field that will tell the REST API we want to insert this resource (rather than update it).
That Resource object can be inserted into SNAC by using the `insert_resource` command at the REST API endpoint. We can PUT the following JSON object to `http://snac-dev.iath.virginia.edu/api/` to insert the resource:
```json
...
...
@@ -65,7 +65,7 @@ That Resource object can be inserted into SNAC by using the `insert_resource` co
}
```
The REST API will return the full written Resource object with IDs and Version numbers from the SNAC server. Hang on to this object, since we'll use it when we update a Constellation later to connect with this resource.
The REST API will return the full written Resource object with IDs and Version numbers from the SNAC REST API. Hang on to this object, since we'll use it when we update a Constellation later to connect with this resource.
```json
{
"resource":{
...
...
@@ -109,7 +109,224 @@ The REST API will return the full written Resource object with IDs and Version n
"timing":109.63
}
```
One thing to notice in this response is that the system filled out the repository information, giving us the preferred name entry, entity type, and ark of the holding repository. If there were place information, including latitude, longitude, and address, that would have been included as well. At the bottom of our Resource object, we can see it now has an id: `11612940`. We can now view our resource online at `http://snac-dev.iath.virginia.edu/vocab_administrator/resource/11612940`.
One thing to notice in this response is that the system filled out the repository information, giving us the preferred name entry, entity type, and ark of the holding repository. If there were place information, including latitude, longitude, and address, that would have been included as well. At the bottom of our Resource object, we can see it now has an id: `11612940`. We can now view our resource online at http://snac-dev.iath.virginia.edu/vocab_administrator/resource/11612940.
## Adding the Resource Relation
Now, let's say we want to say that Sherlock Holmes, http://snac-dev.iath.virginia.edu/view/50447072, was referenced in our new Resource. We will go through the following steps to make that connection:
1. Check out Sherlock Holmes for editing
2. Update Sherlock Holmes to add the resource relation
3. Publish Sherlock Holmes to make the change public
### Checking Out Sherlock Holmes
We first must reserve Sherlock Holmes for editing. We can do this by issuing the following PUT request to the REST API.
```json
{
"command":"edit",
"constellationid":50447072,
"user":{"...":"YOUR API INFO"}
}
```
The REST API will respond with the ENTIRE constellation so that you will have a baseline from which to make edits. Since it is so large, the full response is available in the `sherlock_example.json` file in this directory. Here is the most relevent subset of the response:
Since we did not get an error, we are now in "possession" of the Constellation to make edits. We must note down the id and version above, as we will need that to make our updates.
### Update Sherlock Holmes to Add the Resource Relation
Now, let us construct a partial Constellation for Holmes using the response we just got from the REST API and our new Resource object from above:
This Constellation only has the minimal amount of information we need to add a resource relation. We must identify the Constellation, so we must include the id and correct version number. Also note that the dataType is case sensitive. We also only need a minimal resource that includes the ID and Version from the Resource object that we created above, since the system has all of the other information stored. We have asserted by the role value that Sherlock was "referenced in" this resource, and lastly, we've added the "operation" to the Resource Relation so that the system will know to insert it as new.
We can then submit the update call as a PUT to the REST API as follows:
If the command succeeds, we will receive a success message and a new updated mini-Constellation with the IDs and Version numbers filled out. Also notice that the Constellation's version number has increased to match.
To make our new changes public, and remove the Constellation from our editing queue (that is, "check it back in"), we will need to publish it. *If you don't have publishing privileges, you will need to send the Constellation for Review. That can most easily be done from the Dashboard online, but we will describe the API calls in another tutorial.*
In order to publish, we may make use of the response from the update command above. We can reuse that exact Constellation object which has the correct, current, id and version. We must PUT the following command to the REST API to initiate the publish:
If the publish succeeds, we will receive a JSON response with "result" set to "success" with another copy of the mini-Constellation. Everything will look the same, except the version number will be higher. In this example, we can see that the version number was only incremented by 1 to 11254457. *In cases of heavy server activity, the version numbers will not be sequential.*
"source":"<objectXMLWrap>\n <did xmlns=\"urn:isbn:1-931666-22-9\">\n <repository>\n <corpname>Lilly Library (Indiana University, Bloomington)</corpname>\n <address>\n <addressline>Lilly Library</addressline>\n <addressline>Indiana University</addressline>\n <addressline>1200 E. Seventh St.</addressline>\n <addressline>Bloomington, IN 47405-5500</addressline>\n <addressline>Phone: 812-855-2452</addressline>\n <addressline>Fax: 812-855-3143</addressline>\n <addressline>Email: liblilly@indiana.edu</addressline>\n </address>\n </repository>\n <origination>\n <persname>MacCarthy, Desmond,\n 1877-1952.</persname>\n </origination>\n <unittitle>MacCarthy mss.</unittitle>\n <unitdate>1863-1991</unitdate>\n <unitid>LMC 1684</unitid>\n <physdesc>\n <extent>10,000 items</extent>\n </physdesc>\n <langmaterial>Materials are in <language>English</language>\n </langmaterial>\n <abstract>Consists of the papers of drama and\n literary critic Desmond MacCarthy, 1877-1952, and his wife, author Mary\n (Warre-Cornish) MacCarthy, 1882-1953.</abstract>\n </did>\n </objectXMLWrap>",
"title":"MacCarthy mss. 1863-1991",
"abstract":"Consists of the papers of drama and literary critic Desmond MacCarthy, 1877-1952, and his wife, author Mary (Warre-Cornish) MacCarthy, 1882-1953.",
"text":"Lilly Library Indiana University 1200 E. Seventh St. Bloomington, IN 47405-5500 Phone: 812-855-2452 Fax: 812-855-3143 Email: liblilly@indiana.edu",