Module org.unidata.mdm.rest.v2.draft¶
General Info¶
The module provides access via REST API to work with drafts.
Operations:
Get a list of all available draft providers;
Get the states of existing drafts;
Find drafts by request;
Create/update a draft;
Publish a draft;
Delete a draft.
Dependencies¶
org.unidata.mdm.rest.v2.core
org.unidata.mdm.rest.system
org.unidata.mdm.draft
Configuration Options¶
No external parameters
Pipeline Points¶
None
Classes and Interfaces of Module¶
DraftRestService is a REST service for working with drafts.
Operations:
Get a list of all available draft providers;
Get the states of existing drafts;
Find drafts by request;
Create/update a draft;
Publish a draft;
Delete a draft.
REST services¶
REST service for working with drafts
org.unidata.mdm.rest.v2.draft.service.DraftRestService
/api/v2/draft
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
@Path("/")
public class DraftRestService extends AbstractRestService {
private static final String SERVICE_TAG = "Draft";
/**
* Returns list of draft provider types, currently known to the system.
*/
@GET
@Path("types")
@Operation(
summary = "Get list of draft provider types, currently known to the system",
description = "Returns list of draft provider types, currently known to the system"
)
public GetDraftTypesResultRO types();
/**
* Returns list of known draft states.
*/
@GET
@Path("states")
@Operation(
summary = "Get list of draft states, currently known to the system",
description = "Returns list of draft states, currently known to the system"
)
public GetDraftStatesResultRO states();
/**
* Find drafts for request
*
* @return List of drafts
*/
@POST
@Path("drafts")
@Operation(summary = "Find drafts for request", description = "Find drafts for request"
)
public GetDraftResultRO drafts(GetDraftRequestRO request);
/**
* Upsert draft
*
* @return List of drafts
*/
@POST
@Path("upsert")
@Operation(
summary = "Upsert draft",
description = "Upsert draft, create or update display name if draft exists"
)
public UpsertDraftResultRO upsert(UpsertDraftRequestRO request);
/**
* Publish draft
*
* @return result
*/
@POST
@Path("publish")
@Operation(
summary = "Publish draft",
description = "Publish draft"
)
public PublishDraftResultRO publish(PublishDraftRequestRO request);
/**
* Remove drafts
*
* @return result
*/
@POST
@Path("remove")
@Operation(
summary = "Remove draft",
description = "Remove draft"
)
public RemoveDraftResultRO remove(RemoveDraftRequestRO request);
}
Swagger UI¶
/api/v2/draft/api-docs
List of examples:
Searching Drafts¶
POST /universe-backend/api/v2/draft/drafts
Searches by any available fields.
Takes GetDraftRequestRO.
Returns GetDraftResultRO.
Request
{
"query": {
"type": "string", //ID of provider, e.g. "record", for entity records
"owner": "string", //Owner of the draft, e.g., "admin"
"subjectId": "string", //ID of the object for which the draft was created, e.g., Etalon record ID
"draftId": 0, //ID of the draft being searched for.
"parentDraftId": 0, //ID of the parent draft.
"tags": [ //Tags, e.g., "namespace:register" to search drafts for entity records or "entity-name:TestReg" to search drafts for "TestReg" entity records
"string"
],
"state": "string" //State of the draft, e.g., "RUNNING" to find drafts that are being worked on
},
"offset": 0,
"limit": 0 //More than zero or none
}
Response
{
"details": { //Errors
"info": [],
"warning": [],
"error": []
},
"drafts": [ //Drafts
{
"type": "string",
"subjectId": "string",
"description": "string",
"owner": "string",
"ownerFullName": "string",
"createdBy": "string",
"updatedBy": "string",
"draftId": 0,
"parentDraftId": 0,
"editionsCount": 0,
"createDate": "2023-07-17T07:51:37.259Z",
"updateDate": "2023-07-17T07:51:37.259Z",
"tags": [
"string"
],
"state": "CREATED" //Draft status
}
],
"totalCount": 0 //Total number of drafts found
}
Request example to search for all drafts
{
}
Request example to find all drafts of a data model
{
"query": {
"type": "data-model"
}
}
Request example to find all drafts of the entity records with etalon ID "5d909a39-1fea-11ee-8704-19e62a84c1f0" that are being worked with ("RUNNING")
{
"query": {
"type": "record",
"subjectId": "5d909a39-1fea-11ee-8704-19e62a84c1f0",
"state": "RUNNING"
}
}
Response example for the request above
{
"details": {
"info": [],
"warning": [],
"error": []
},
"drafts": [
{
"type": "record",
"subjectId": "5d909a39-1fea-11ee-8704-19e62a84c1f0",
"description": "Черновик от 11.07.2023 15:56:06",
"owner": "admin",
"ownerFullName": "Admin Root",
"createdBy": "admin",
"updatedBy": "admin",
"draftId": 2,
"parentDraftId": null,
"editionsCount": 2,
"createDate": "2023-07-11T15:56:06.990655+03:00",
"updateDate": "2023-07-11T15:57:11.674683+03:00",
"tags": [
"record-external-id:4d39b560-1fea-11ee-addc-e31a630bec40\u001fTestReg\u001funidata",
"namespace:register",
"operation-code:UPSERT_DATA",
"entity-name:TestReg"
],
"state": "RUNNING"
}
],
"totalCount": 1
}
Creating / Updating Draft¶
POST /api/v2/draft/upsert
Takes UpsertDraftRequestRO
Returns UpsertDraftResultRO
See. Draft Search
Request
{
"type": "string", //Specifies the provider ID, e.g. "record" to create a draft record
"owner": "string", //If not present, the name of the user who sent the request will be used
"subjectId": "string", //Can be empty if, for example, the entity record has not yet been created
"draftId": 0, //Specified for update
"parentDraftId": 0, //Specified if there is a parent.
"tags": [ //For a registry entry, for example, "namespace:register" and "entity-name:entity_name" are specified
"string" //Can be optional, set automatically based on the rest of the data and parameters, e.g. for an entity record
],
"description": "string", //Displayed name of the draft.
}, "parameters": { "parameters": "string", //Draft parameters, if any
"additionalProp1": "string", //Example, "entity-name" : "entity_name" to create a draft for a entity entry
"additionalProp2": "string",
"additionalProp3": "string"
}
}
Response
{
"details": {
"info": [],
"warning": [],
"error": []
},
"draft": {
"type": "string",
"subjectId": "string",
"description": "string",
"owner": "string",
"ownerFullName": "string",
"createdBy": "string",
"updatedBy": "string",
"draftId": 0,
"parentDraftId": 0,
"editionsCount": 0,
"createDate": "2023-07-17T07:21:26.482Z",
"updateDate": "2023-07-17T07:21:26.482Z",
"tags": [
"string"
],
"state": "CREATED"
}
}
Example of creating a draft for record (record) of the entity (register) "TestReg" (system name) with etalon ID "5d909a39-1fea-11ee-8704-19e62a84c1f0"
{
"type": "record", //Provider for records
"subjectId": "5d909a39-1fea-11ee-8704-19e62a84c1f0", //For records of Etalon ID
"description": "example draft",
"parameters": {
"namespace" : "register", //Entity namespace
"entity-name" : "TestReg" //Entity name
}
}
Response
{
"details": {
"info": [],
"warning": [],
"error": []
},
"draft": {
"type": "record",
"subjectId": "5d909a39-1fea-11ee-8704-19e62a84c1f0",
"description": "example draft",
"owner": "admin",
"ownerFullName": "Admin Root",
"createdBy": "admin",
"updatedBy": null,
"draftId": 14,
"parentDraftId": null,
"editionsCount": 0,
"createDate": "2023-07-17T11:00:58.451+03:00",
"updateDate": null,
"tags": [
"namespace:register",
"entity-name:TestReg"
],
"state": "CREATED"
}
}
Example of creating a draft to add a record (record) to the "TestReg" (system name) entity. There is no record yet, so there is no benchmark ID
{
"type": "record", //Provider for records
"subjectId": "", //Not yet an object
"description": { "example draft",
"parameters": {
"namespace" : "register", //Entity namespace
"entity-name" : "TestReg" //Entity name
}
}
Response
{
"details": {
"info": [],
"warning": [],
"error": []
},
"draft": {
"type": "record",
"subjectId": "",
"description": "example draft to add record to entity",
"owner": "admin",
"ownerFullName": "Admin Root",
"createdBy": "admin",
"updatedBy": null,
"draftId": 15,
"parentDraftId": null,
"editionsCount": 0,
"createDate": "2023-07-17T11:05:20.678+03:00",
"updateDate": null,
"tags": [
"namespace:register",
"entity-name:TestReg"
],
"state": "CREATED"
}
}
Request example for creating a draft data model for working with entity and reference set models
{
"type": "data-model",
"subjectId": "",
"description": "example draft to update data-model",
"parameters": {
}
}
Response
{
"details": {
"info": [],
"warning": [],
"error": []
},
"draft": {
"type": "data-model",
"subjectId": "",
"description": "example draft to update data-model",
"owner": "admin",
"ownerFullName": "Admin Root",
"createdBy": "admin",
"updatedBy": null,
"draftId": 16,
"parentDraftId": null,
"editionsCount": 0,
"createDate": "2023-07-17T11:06:31.562+03:00",
"updateDate": null,
"tags": [],
"state": "RUNNING"
}
}
Publishing Draft¶
POST /api/v2/draft/publish
Takes UpsertDraftRequestRO
Returns UpsertDraftResultRO
Request
{
"draftId": 0, //ID of the draft
"force": true, //Force publication
"delete": true //Delete draft after publication
}
Response
{
"details": {
"info": [],
"warning": [],
"error": []
},
"draft": {
"type": "string",
"subjectId": "string",
"description": "string",
"owner": "string",
"ownerFullName": "string",
"createdBy": "string",
"updatedBy": "string",
"draftId": 0,
"parentDraftId": 0,
"editionsCount": 0,
"createDate": "2023-07-17T07:20:07.706Z",
"updateDate": "2023-07-17T07:20:07.706Z",
"tags": [
"string"
],
"state": "CREATED"
}
}
Example of a request to publish a draft of a data model that was created in another example, with draftId = 16, with force publishing (force) and without deleting the published draft (delete)
{
"draftId": 16,
"force": true,
"delete": false
}
Response
{
"details": {
"info": [],
"warning": [],
"error": []
},
"draft": {
"type": "data-model",
"subjectId": "",
"description": "example draft to update data-model",
"owner": "admin",
"ownerFullName": "Admin Root",
"createdBy": "admin",
"updatedBy": "admin",
"draftId": 16,
"parentDraftId": null,
"editionsCount": 1,
"createDate": "2023-07-17T11:06:31.729904+03:00",
"updateDate": "2023-07-17T11:06:31.729904+03:00",
"tags": [],
"state": "PUBLISHED"
}
}
Deleting Draft¶
POST /api/v2/draft/publish
Takes UpsertDraftRequestRO
Returns UpsertDraftResultRO
Searches by any available fields. See Searching Drafts
Request
{
"type": "string",
"owner": "string",
"subjectId": "string",
"draftId": 0,
"parentDraftId": 0,
"tags": [
"string"
],
"state": "string"
}
Response
{
"details": {
"info": [],
"warning": [],
"error": []
},
"success": true //Success of the request
}
Request to delete a draft with draftId = 15
{
"draftId": 15
}
Response
{
"details": {
"info": [],
"warning": [],
"error": []
},
"success": true
}
Request example to delete all drafts that have been published
{
"state" : "PUBLISHED"
}
Request example to delete all drafts of "admin" and the record (record) of the entity (register) "TestReg" (system name) with etalon ID "5d909a39-1fea-11ee-8704-19e62a84c1f0" that were created but not worked on.
{
"type": "record",
"owner": "admin",
"subjectId": "5d909a39-1fea-11ee-8704-19e62a84c1f0",
"tags": [
"entity-name:TestReg"
],
"state": "CREATED"
}
Getting List of Possible Draft States¶
POST /api/v2/draft/states
Request is sent without parameters
Response
{
"details": {
"info": [],
"warning": [],
"error": []
},
"states": [
{
"name": "string", //System name of the state, which is used in the search in the "state" parameter
"moduleId": "string", //Module in which the state is defined
"displayName": "string",
"description": "string"
}
]
}
Request Example
{
"details": {
"info": [],
"warning": [],
"error": []
},
"states": [
{
"name": "CREATED",
"moduleId": "org.unidata.mdm.draft",
"displayName": "Initial draft state",
"description": "Exposed when a draft has just been created and does not yet have any edits"
},
{
"name": "PUBLISHED",
"moduleId": "org.unidata.mdm.draft",
"displayName": "Draft published",
"description": "Draft successfully published"
},
{
"name": "DELAYED_BY_WORKFLOW",
"moduleId": "com.unidata.mdm.workflow.core", { "moduleId": "com.unidata.mdm.workflow.core",
"displayName": "Publication of draft delayed",
"description": "The actual publication of the draft has been delayed until after the approval process."
},
{
"displayName": "FAILED",
"moduleId": "org.unidata.mdm.draft", { "moduleId": "org.unidata.mdm.draft",
"displayName": "FAILED",
"description": "The publishing process ended with errors in additional post-publishing actions"
},
{
"name": "RUNNING",
"moduleId": "org.unidata.mdm.draft", { "moduleId": "org.unidata.mdm.draft",
"displayName": "Normal draft state",
"description": "The draft is available for editing and has one or more edits", "description".
}
]
}
Getting List of Possible Provider Types¶
POST GET /api/v2/draft/types
Request is sent without parameters
Response
{
"details": {
"info": [],
"warning": [],
"error": []
},
"types": [
{
"id": "string",
"description": "string",
"tags": [
"string"
]
}
]
}
Request Example
{
"details": {
"info": [],
"warning": [],
"error": []
},
"types": [
{
"id": "bpmn-model",
"description": "com.unidata.mdm.workflow.core.bpmn.model.draft.provider.description",
"tags": []
},
{
"id": "matching-model",
"description": "app.matching.draft.model.provider.description",
"tags": []
},
{
"id": "classifier-model",
"description": "com.unidata.mdm.classifiers.draft.classifier.provider.description",
"tags": []
},
{
"id": "record",
{ "description": "Draft support for the \"records\" data type",
"tags": [
"entity-name",
"operation-code",
"namespace",
"record-external-id"
]
},
{
"id": "data-model",
"description": "",
"tags": []
},
{
"id": "classifier-version",
"description": "com.unidata.mdm.classifiers.draft.version.provider.description",
"tags": []
},
{
"id": "quality-model",
"description": "app.dq.draft.model.provider.description",
"tags": []
},
{
"id": "workflow-model",
{ "description": "Workflow Model Draft Provider",
"tags": []
},
{
"id": "classifier-node",
"description": "com.unidata.mdm.classifiers.draft.node.provider.description",
"tags": []
},
{
"id": "classification",
"description": "com.unidata.mdm.classifiers.draft.classification.provider.description",
"tags": [
"classified-origin-id",
"namespace",
"classified-id",
"operation-code",
"node-name",
"version-name",
"classifier-name"
]
},
{
"id": "relation",
{ "description": "Draft support for data type \"connections\"",
"tags": [
"relation-from-etalon-id",
"namespace",
"relation-to-external-id",
"entity-name",
"operation-code",
"relation-to-etalon-id",
"relation-from-external-id"
]
}
]
}