Attachments
The Attachments resource provides a mechanism for locating all records that refer to a given record. When a request is submitted all reference columns that refer to the supplied record type are searched for the supplied IRN (Internal Record Number). A list is built up for each resource searched containing each reference column and the number of records that contain the supplied IRN. A list of each referring record by each column may optionally be included. The list is returned as a JSON structure.
The format of an attachment URI is emu:/{tenant}/attachments/{attachmentid}
. The attachmentid consists for two parts, namely {irn}:{resource}
with the following meaning:
irn
- the Internal Record Number (IRN) of the record whose attachments are to be retrievedresource
- the resource (table) containing theirn
For example the attachment URI emu:/museum/attachments/12:eparties
will locate all records that have a reference to the eparties record with IRN number 12. The output for such a request with no markup may look like:
{
"id": "emu:/museum/attachments/12:eparties",
"version": 1,
"data": {
"id": "emu:/museum/eparties/12",
"attachments": [
{
"resource": "eaccessionlots",
"columns": [
{
"column": "AcqAuthorisedByRef",
"count": 3
},
{
"column": "AcqSourceRef_tab",
"count": 3
}
]
},
{
"resource": "ecatalogue",
"columns": [
{
"column": "AssRelatedPartiesRef_tab",
"count": 1
}
]
}
]
}
}
The attachments
property is a JSON array containing an entry for each resource
that contains references. Within a resource
there is an array of the columns
that contain references. For each column
there is a count
indicating the number of records containing a reference. So from the above we can see that the eparties record with IRN 12 has seven references, six in eaccessionlots and one in ecatalogue. For eaccessionlots there are two columns containing references, AcqAuthorisedByRef and AcqSourceRef_tab, each containing references from three records.
It is possible to list the records which are attachments. The output for this request without markup may look like:
{
"id": "emu:/museum/attachments/12:eparties",
"version": 1,
"data": {
"id": "emu:/museum/eparties/12",
"attachments": [
{
"resource": "eaccessionlots",
"columns": [
{
"column": "AcqAuthorisedByRef",
"count": 3,
"keys": [
"emu:/museum/eaccessionlots/33",
"emu:/museum/eaccessionlots/110010",
"emu:/museum/eaccessionlots/1000086"
]
},
{
"column": "AcqSourceRef_tab",
"count": 3,
"keys": [
"emu:/museum/eaccessionlots/33",
"emu:/museum/eaccessionlots/110010",
"emu:/museum/eaccessionlots/1000086"
]
}
]
},
{
"resource": "ecatalogue",
"columns": [
{
"column": "AssRelatedPartiesRef_tab",
"count": 1,
"keys": [
"emu:/museum/ecatalogue/1000086"
]
}
]
}
]
}
}
The keys
property has been added to each column
. It is a JSON array containing a URI for each of the matching records. So we can see that for ecatalogue the matching record has IRN 1000086.
The following requests are available for the attachments resource.
Retrieve
GET /{tenant}/attachments/{attachmentid}[?keys&security&all]
The GET method returns a JSON document containing details about the number of records on a resource/column basis referencing the supplied attachmentid. The default listing will provide a count for each resource/column pair containing at least one reference. There is no payload to send when making a request. A 200
status is returned when the JSON document containing the attachments is returned successfully.
The acceptable query parameters are:
keys
The default report only gives a count of the number of records attached for each resource/column pair. By adding the keys query parameter the report will also contain a list of URIs for each record with a reference. If Markup is enabled then each URI will also have an associated href allowing the record to be accessed.
security
Record level security is disabled by default when the system is searching for attachments. The reason for disabling security is that the attachments resource is generally used for referential integrity checks. In this case it is important to know if any records are attached regardless of security settings. This is not a security issue as permission is still required to access any record provided as a match. If the security query parameter is supplied then record level security is enabled, meaning only records that can be viewed by the user are included in the report. In this case the report may not list all attachments depending on the security settings.
all
Only resource/column pairs with a count greater than zero are listed by default. If the all query parameter is specified then all resource/column pairs are listed, even those with a count of zero. The all query parameter allows you to find all resource/column pairs that refer to the supplied attachmentid resource.
A 200
status is returned along with the attachment details for successful requests.
Example URI
GET /tenant/attachments/12:eparties?keys
Headers
Authorization: Bearer {token}
Prefer: representation=minimal
Response 200
{
"id": "emu:/museum/attachments/12:eparties",
"version": 1,
"data": {
"id": {
"id": "emu:/museum/eparties/12",
"@controls": {
"self": {
"href": "http://dorrit.melbourne.axiell.com:8079/museum/eparties/12"
}
}
},
"attachments": [
{
"resource": "eaccessionlots",
"columns": [
{
"column": "AcqAuthorisedByRef",
"count": 3,
"keys": [
{
"id": "emu:/museum/eaccessionlots/33",
"@controls": {
"self": {
"href": "http://dorrit.melbourne.axiell.com:8079/museum/eaccessionlots/33"
}
}
},
{
"id": "emu:/museum/eaccessionlots/110010",
"@controls": {
"self": {
"href": "http://dorrit.melbourne.axiell.com:8079/museum/eaccessionlots/110010"
}
}
},
{
"id": "emu:/museum/eaccessionlots/1000086",
"@controls": {
"self": {
"href": "http://dorrit.melbourne.axiell.com:8079/museum/eaccessionlots/1000086"
}
}
}
]
},
{
"column": "AcqSourceRef_tab",
"count": 3,
"keys": [
{
"id": "emu:/museum/eaccessionlots/33",
"@controls": {
"self": {
"href": "http://dorrit.melbourne.axiell.com:8079/museum/eaccessionlots/33"
}
}
},
{
"id": "emu:/museum/eaccessionlots/110010",
"@controls": {
"self": {
"href": "http://dorrit.melbourne.axiell.com:8079/museum/eaccessionlots/110010"
}
}
},
{
"id": "emu:/museum/eaccessionlots/1000086",
"@controls": {
"self": {
"href": "http://dorrit.melbourne.axiell.com:8079/museum/eaccessionlots/1000086"
}
}
}
]
}
]
},
{
"resource": "ecatalogue",
"columns": [
{
"column": "AssRelatedPartiesRef_tab",
"count": 1,
"keys": [
{
"id": "emu:/museum/ecatalogue/1000086",
"@controls": {
"self": {
"href": "http://dorrit.melbourne.axiell.com:8079/museum/ecatalogue/1000086"
}
}
}
]
}
]
}
]
},
"@namespaces": {
"emu": {
"name": "http://axiell.com/emu#"
}
},
"@controls": {
"self": {
"href": "http://dorrit.melbourne.axiell.com:8079/museum/attachments/12:eparties"
},
"start": {
"method": "GET",
"href": "http://dorrit.melbourne.axiell.com:8079/"
}
}
}
Response Headers
Content-Type: application/vnd.mason+json; charset=UTF-8
Authorization: Bearer {token}