Document Link

Document Link Features

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

Document link API is exposed to the client through WorkflowDocument interface, below is the summary of the api:

  1. get all links to orgn doc

    public List<DocumentLinkDTO> getLinkedDocumentsByDocId(Long id) throws WorkflowException

  2. get the link from orgn doc to a specifc doc

    public DocumentLinkDTO getLinkedDocument(DocumentLinkDTO docLinkVO) throws WorkflowException

  3. add a link by id

    public void addLinkedDocument(DocumentLinkDTO docLinkVO) throws WorkflowException

  4. remove all links to this doc as orgn doc

    public void removeLinkedDocuments(Long docId) throws WorkflowException

  5. remove the link to the specific doc

    public void removeLinkedDocument(DocumentLinkDTO docLinkVO) throws WorkflowException

Document Link API Example

It is pretty straightforward to use this api, below are some examples:

  1. 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);                                                             
  2. To retrieve all links to a document

    List<DocumentLinkDTO> links2 = doc.getLinkedDocumentsByDocId(Long.valueOf(5000));    
  3. To remove a link

    doc.removeLinkedDocument(testDocLinkVO);