...
In this tutorial, the tag handling is explained by following one object with the arbitrary objectId
=1234567812345678
through the processing chain of the import management. The code snippets can be executed in the same order as they are shown if the requirements are met and at least one document was imported. Replace the example objectId
in the code snippets by the actual objectId
of your imported document.
...
Code Block |
---|
language | java |
---|
linenumbers | true |
---|
|
String objectId = "1234567812345678";
String tagName = "analysis";
String tagValue = "1";
RequestBody addTagBody = RequestBody.create(null, new byte[]{});
Request addTagRequest = new Request.Builder()
.header("Authorization", auth)
.header("X-ID-TENANT-NAME", tenant)
.url(baseUrl + "/api/dms/objects/" + objectId + "/tags/" + tagName + "/state/" + tagValue)
.post(addTagBody)
.build();
Response addTagResponse = client.newCall(addTagRequest).execute();
String addTagResponseString = addTagResponse.body().string();
System.out.println(addTagResponseString); |
Code Block |
---|
language | yml |
---|
title | Response |
---|
linenumbers | true |
---|
collapse | true |
---|
|
{"objects": [{
"properties": {
"system:tags": {
"value": [
["analysis",1,"2021-06-30T15:19:25.370Z","0ff83b2d8c17b704"]
]
}
}
}]
} |
...
Code Block |
---|
language | java |
---|
title | Adding tag 'testtag' in addition to tag 'analysis'. |
---|
linenumbers | true |
---|
collapse | true |
---|
|
String objectId = "1234567812345678";
String tagName = "testtag";
String tagValue = "7";
RequestBody addTagBody = RequestBody.create(null, new byte[]{});
Request addTagRequest = new Request.Builder()
.header("Authorization", auth)
.header("X-ID-TENANT-NAME", tenant)
.url(baseUrl + "/api/dms/objects/" + objectId + "/tags/" + tagName + "/state/" + tagValue)
.post(addTagBody)
.build();
Response addTagResponse = client.newCall(addTagRequest).execute();
String addTagResponseString = addTagResponse.body().string();
System.out.println(addTagResponseString); |
Code Block |
---|
language | yml |
---|
title | Response |
---|
linenumbers | true | collapse | true |
---|
|
{"objects": [{
"properties": {
"system:tags": {
"value": [
["analysis",1,"2021-06-30T15:19:25.370Z","0ff83b2d8c17b704"],
["testtag",7,"2021-06-30T15:19:26.700Z","4b2448d66e4d02eb"]
]
}
}
}]
} |
...
Code Block |
---|
language | java |
---|
linenumbers | true |
---|
|
String objectId = "1234567812345678";
Request getTagRequest = new Request.Builder()
.header("Authorization", auth)
.header("X-ID-TENANT-NAME", tenant)
.url(baseUrl+ "/api/dms/objects/" + objectId + "/tags")
.get().build();
Response tagResponse = client.newCall(getTagRequest).execute();
String tagResponseString = tagResponse.body().string();
System.out.println(tagResponseString); |
Code Block |
---|
language | yml |
---|
title | Response |
---|
linenumbers | true | collapse | true |
---|
|
{"objects": [{
"properties": {
"system:tags": {
"columnNames": ["name","state","creationDate","traceId"],
"value": [
["analysis",1,"2021-06-30T15:19:25.370Z","0ff83b2d8c17b704"],
["testtag",7,"2021-06-30T15:19:26.700Z","4b2448d66e4d02eb"]
]
}
}
}]
} |
...
At this point in the import management context, there are several objects in the system having a newly added analysis
tag with the state
1
. They are all waiting for a time-consuming processing step, but only one of them can be handled at the same time. In order to select one individual object for further processing, a search query is used, which returns a limited result list of objects having an analysis
tag with the state
1
that was created/modified today or yesterday. The first result in this list is updated to state=2
which means processing started. In the code snippet of the Adding Tags to Objects section, only one object was flagged with the tag and thus the following code snippet will continue with exactly this object.
Code Block |
---|
language | java |
---|
linenumbers | true |
---|
|
String statement = "SELECT * FROM document WHERE system:tags[analysis].(state=1 AND (creationDate=YESTERDAY() OR creationDate=TODAY()))";
String tagName = "analysis";
String newTagValue = "2";
Request queryTagRequest = new Request.Builder()
.header("Authorization", auth)
.header("X-ID-TENANT-NAME", tenant)
.url(baseUrl + "/api/dms/objects/tags/" + tagName + "/state/" + newTagValue + "?query=" + statement)
.post(RequestBody.create(null, new byte[0]))
.build();
Response queryTagResponse = client.newCall(queryTagRequest).execute();
String queryTagResponseString = queryTagResponse.body().string();
System.out.println(queryTagResponseString); |
Code Block |
---|
language | yml |
---|
title | Excerpt from the response body |
---|
linenumbers | true |
---|
collapse | true |
---|
|
{"objects": [{
"properties": {
"system:objectId": {
"value": "1234567812345678"
},
...
"system:versionNumber": {
"value": 1
},
...
...
"system:tags": {
"value": [
["analysis",2,"2021-06-30T15:19:27.950Z","0ff83b2d8c17b704"],
["testtag",7,"2021-06-30T15:19:26.700Z","4b2448d66e4d02eb"]
]
},
...
},
...
}]
} |
...
Code Block |
---|
language | java |
---|
linenumbers | true |
---|
|
String objectId = "1234567812345678";
String tagName = "analysis";
String newTagValue = "3";
Request updateTagRequest = new Request.Builder()
.header("Authorization", auth)
.header("X-ID-TENANT-NAME", tenant)
.url(baseUrl + "/api/dms/objects/" + objectId + "/tags/" + tagName + "/state/" + newTagValue + "?overwrite=true")
.post(RequestBody.create(null, new byte[0]))
.build();
Response updateTagResponse = client.newCall(updateTagRequest).execute();
String updateTagResponseString = updateTagResponse.body().string();
System.out.println(updateTagResponseString); |
Code Block |
language |
---|
yml | title | Response |
---|
linenumbers | true | collapse | true |
---|
|
{"objects": [{
"properties": {
"system:tags": {
"columnNames": ["name","state","creationDate","traceId"],
"value": [
["analysis",3,"2021-06-30T15:19:28.530Z","faa0cdae5008d7e0"],
["testtag",7,"2021-06-30T15:19:26.700Z","4b2448d66e4d02eb"]
]
}
}
}]
} |
...
Code Block |
---|
language | java |
---|
linenumbers | true |
---|
|
String objectId = "1234567812345678";
String tagName = "tracingprocess";
String tagValue = "1";
String traceId = "1122334455667788";
Request addTagRequest = new Request.Builder()
.header("Authorization", auth)
.header("X-ID-TENANT-NAME", tenant)
.header("X-B3-TraceId", traceId)
.url(baseUrl + "/api/dms/objects/" + objectId + "/tags/" + tagName + "/state/" + tagValue)
.post(RequestBody.create(null, new byte[0]))
.build();
Response addTagResponse = client.newCall(addTagRequest).execute();
String addTagResponseString = addTagResponse.body().string();
System.out.println(addTagResponseString); |
Code Block |
language |
---|
yml | title | Response |
---|
linenumbers | true |
---|
collapse | true |
---|
|
{"objects": [{
"properties": {
"system:tags": {
"columnNames": ["name","state","creationDate","traceId"],
"value": [
["analysis",3,"2021-06-30T15:19:28.530Z","faa0cdae5008d7e0"],
["testtag",7,"2021-06-30T15:19:26.700Z","4b2448d66e4d02eb"],
["tracingprocess",1,"2021-06-30T15:19:30.250Z","1122334455667788"]
]
}
}
}]
} |
...
Updating Tags with Specified 'traceId'
Similar as in Adding Tags with Specified 'traceId', also in a tag update request, the query parameter traceIdMustMatch=true
can be set if a traceId
is specified in the header. The update operation will be performed only if the values are matching. Thus, the tag can only be updated if the previous traceId
is known to the caller. Furthermore, the update operation will appear with the same traceId
in the audit trail and can thus be summarized with the tag creation operation in one overall process trace.
...
Code Block |
---|
language | java |
---|
linenumbers | true |
---|
|
String objectId = "1234567812345678";
String tagName = "tracingprocess";
String newTagValue = "2";
String traceId = "1122334455667788";
Request updateTagRequest = new Request.Builder()
.header("Authorization", auth)
.header("X-ID-TENANT-NAME", tenant)
.header("X-B3-TraceId", traceId)
.url(baseUrl + "/api/dms/objects/" + objectId + "/tags/" + tagName + "/state/" + newTagValue + "?overwrite=true&traceIdMustMatch=true")
.post(RequestBody.create(null, new byte[0]))
.build();
Response updateTagResponse = client.newCall(updateTagRequest).execute();
String updateTagResponseString = updateTagResponse.body().string();
System.out.println(updateTagResponseString); |
Code Block |
---|
language | yml |
---|
title | Response |
---|
linenumbers | true | collapse | true |
---|
|
{"objects": [{
"properties": {
"system:tags": {
"columnNames": ["name","state","creationDate","traceId"],
"value": [
["analysis",3,"2021-06-30T15:19:28.530Z","faa0cdae5008d7e0"],
["testtag",7,"2021-06-30T15:19:26.700Z","4b2448d66e4d02eb"],
["tracingprocess",2,"2021-06-30T15:19:30.780Z","1122334455667788"]
]
}
}
}]
} |
...
Code Block |
---|
language | yml |
---|
linenumbers | true |
---|
|
{
"objects": [{
"properties": {
"Name": {
"value": "Test 3"
},
"system:tags": {
"value": [
["analysis",4],
["contentprocessing:resistant",13]
]
}
}
}]
} |
Code Block |
---|
language | yml |
---|
title | Excerpt from the response body |
---|
linenumbers | true | collapse | true |
---|
|
{"objects": [{
"properties": {
"system:objectId": {
"value": "1234567812345678"
},
...
"system:versionNumber": {
"value": 2
},
...
"system:traceId": {
"value": "118343a3fbc940e6"
},
"system:tags": {
"value": [
["analysis",4,"2021-06-30T15:19:32.560Z","118343a3fbc940e6"],
["contentprocessing:resistant",13,"2021-06-30T15:19:32.560Z","118343a3fbc940e6"]
]
},
"Name": {
"value": "Test 3"
},
},
...
}]
} |
...
From our example object, the tag analysis is removed, but the resistant tag contentprocessing:resistant
is kept for the new object version. The values of the tag properties remain unchanged. The code block below shows an excerpt of the response including the system:tags
tag table after the update of the binary content file.
Code Block |
---|
language | yml |
---|
title | Excerpt from the response body |
---|
linenumbers | true |
---|
collapse | true |
---|
|
{"objects": [{
"properties": {
"system:objectId": {
"value": "1234567812345678"
},
...
"system:versionNumber": {
"value": 3
},
...
...
"system:tags": {
"value": [
["contentprocessing:resistant",13,"2021-06-30T15:19:32.560Z","118343a3fbc940e6"]
]
},
"Name": {
"value": "Test 3"
},
},
...
}]
} |
...
See how to prepare a POST update of the metadata in the Updating Documents via Core API tutorial. The update replaces all the metadata of the object with the values specified in the request body. If a property is missing in the request body, it will be removed from the object (except automatically determined system properties). Also the entire table with the tag information has to be explicitly specified as already described in the Tag Behavior in PATCH Metadata Update section. If the system:tags
table is not specified in the request body, all tags will be removed from the object.
The code block below shows an example request body where no tags are specified. Thus, the analysis
tag and especially also the contentprocessing:resistant
tag are deleted.
Code Block |
---|
language | yml |
---|
title | Excerpt from the response body |
---|
linenumbers | true | collapse | true |
---|
|
{"objects": [{
"properties": {
"system:objectId": {
"value": "1234567812345678"
},
...
"system:versionNumber": {
"value": 4
},
...
"system:tags": {
"value": null
},
"Name": {
"value": "Test 2"
},
},
...
}]
} |
...