KEW provides an option for linking documents and BOs that are functionally related. The link between related documents is created and removed in a double link double delete fashion, which means: when a link is added/deleted from 1 document to another document, a link in the reverse direction is also added/deleted, this feature will garuantee that searching for linked documents can be done from either side of the link. Using this option, client applications can link documents by using document link API.
Document link API is exposed to the client through WorkflowDocument interface, below is the summary of the api:
get all links to orgn doc
public List<DocumentLinkDTO> getLinkedDocumentsByDocId(Long id) throws WorkflowException
get the link from orgn doc to a specifc doc
public DocumentLinkDTO getLinkedDocument(DocumentLinkDTO docLinkVO) throws WorkflowException
add a link by id
public void addLinkedDocument(DocumentLinkDTO docLinkVO) throws WorkflowException
remove all links to this doc as orgn doc
public void removeLinkedDocuments(Long docId) throws WorkflowException
remove the link to the specific doc
public void removeLinkedDocument(DocumentLinkDTO docLinkVO) throws WorkflowException
It is pretty straightforward to use this api, below are some examples:
To add a link
WorkflowDocument doc = new WorkflowDocument(…); DocumentLinkDTO testDocLinkVO = new DocumentLinkDTO() testDocLinkVO.setOrgnDocId(Long.valueOf(5000)); testDocLinkVO.setDestDocId(Long.valueOf(6000)); doc.addLinkedDocument(testDocLinkVO);
To retrieve all links to a document
List<DocumentLinkDTO> links2 = doc.getLinkedDocumentsByDocId(Long.valueOf(5000));
To remove a link
doc.removeLinkedDocument(testDocLinkVO);