Package com.veeva.vault.sdk.api.edl


package com.veeva.vault.sdk.api.edl
This package provides interfaces to batch save and remove matched documents.

Overview

This service is used to batch save documents that are matched to specified EDL Item or remove manual matches from EDL Items.

Example: Batch Save

The following example uses MatchedDocumentService to insert and update matched documents to multiple EDL Items, with a combination of locking and unlocking document versions and including and excluding matched documents.

     MatchedDocumentService matchedDocumentService = ServiceLocator.locate(MatchedDocumentService.class);

     // Provide only the document ID to match the latest version and unlock the document if its locked
     SaveMatchedDocument includeDocument1 = matchedDocumentService.newSaveMatchedDocumentBuilder()
         .withEdlItemId("0EI00000002001")
         .withDocumentVersionId("1")
         .excludeInTotal(false)
         .build();

     // Provide the full document version ID to match and lock to it if the version is valid and lockable
     SaveMatchedDocument includeAndLockDocument2 = matchedDocumentService.newSaveMatchedDocumentBuilder()
         .withEdlItemId("0EI00000002002")
         .withDocumentVersionId("2_1_0")
         .excludeInTotal(false)
         .build();

     // Exclude the match from the total count of matched documents
     SaveMatchedDocument excludeAndUnlockDocument3 = matchedDocumentService.newSaveMatchedDocumentBuilder()
         .withEdlItemId("0EI00000002001")
         .withDocumentVersionId("3")
         .excludeInTotal(true)
         .build();

     // Build the request
     List<SaveMatchedDocument> documentList =
         VaultCollections.asList(includeDocument1, includeAndLockDocument2, excludeAndUnlockDocument3);
     BatchSaveMatchedDocumentsRequest request = matchedDocumentService.newBatchSaveMatchedDocumentsRequestBuilder()
         .withMatchedDocuments(documentList)
         .build();

     // Run the request
     List<MatchedDocumentSuccess> successes = new ArrayList<>();
     List<MatchedDocumentError> errors = new ArrayList<>();
     matchedDocumentService.batchSaveMatchedDocumentsRequest(request)
         .onSuccesses(successes::addAll)
         .onErrors(errors::addAll)
         .execute();
 

Example: Batch Remove

The following example uses MatchedDocumentService to remove manually matched documents from multiple EDL Items.

     MatchedDocumentService matchedDocumentService = ServiceLocator.locate(MatchedDocumentService.class);

     // Remove a document that is not locked on a specific version
     RemoveMatchedDocument document1 = matchedDocumentService.newRemoveMatchedDocumentBuilder()
         .withEdlItemId("0EI00000002001")
         .withDocumentVersionId("1")
         .build();

     // Remove a document that is locked on a specific version
     RemoveMatchedDocument document2 = matchedDocumentService.newRemoveMatchedDocumentBuilder()
         .withEdlItemId("0EI00000002002")
         .withDocumentVersionId("2_1_0")
         .build();

     // Build the request
     List<SaveMatchedDocumentRequest> documentList = VaultCollections.asList(document1, document2);
     BatchRemoveMatchedDocumentsRequest request = matchedDocumentService.newBatchRemoveMatchedDocumentsRequestBuilder()
         .withMatchedDocuments(documentList)
         .build();

     // Run the request
     List<MatchedDocumentSuccess> successes = new ArrayList<>();
     List<MatchedDocumentError> errors = new ArrayList<>();
     matchedDocumentService.batchRemoveMatchedDocumentsRequest(request)
         .onSuccesses(successes::addAll)
         .onErrors(errors::addAll)
         .execute();
 

Best Practices & Gotchas

  • Locked Documents: Using MatchedDocumentService to match documents while specifying the full document version ID (e.g. "3_1_0") will lock the match to said document version. Similarly, removing the match will require the full document version ID to be specified. Specifying only the document id (e.g. "3") will unlock the document if it's locked, and will require only the document ID to remove the match.
  • Manually Matched Documents: MatchedDocumentService can only remove manually matched documents.