-
- All Implemented Interfaces:
public abstract class DocumentManager<DR extends DocumentRepository<E>, E extends ExtractionsContainer>The DocumentManager is a high level API on top of the Gini API, which is used via the DocumentRepository. It provides high level methods to handle document related tasks easily.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumDocumentManager.DocumentType
-
Constructor Summary
Constructors Constructor Description DocumentManager(DR documentRepository)
-
Method Summary
Modifier and Type Method Description final Resource<Document>createPartialDocument(ByteArray document, String contentType, String filename, DocumentManager.DocumentType documentType, DocumentMetadata documentMetadata)Uploads raw data and creates a new Gini partial document. final Resource<Unit>deletePartialDocumentAndParents(String documentId)Deletes a Gini partial document and all its parent composite documents. final Resource<Unit>deleteDocument(String documentId)Deletes a Gini document. final Resource<Document>createCompositeDocument(List<Document> documents, DocumentManager.DocumentType documentType)Creates a new Gini composite document. final Resource<Document>createCompositeDocument(LinkedHashMap<Document, Integer> documentRotationMap, DocumentManager.DocumentType documentType)Creates a new Gini composite document. final Resource<Document>getDocument(String id)Get the document with the given unique identifier. final Resource<Document>getDocument(Uri uri)Get the document with the given unique identifier. final Resource<Document>pollDocument(Document document)Continually checks the document status (via the Gini API) until the document is fully processed. final Resource<JSONObject>getLayout(Document document)Gets the layout of a document. final Resource<E>getAllExtractions(Document document)Get all extractions (specific and compound) for the given document. final Resource<E>getAllExtractionsWithPolling(Document document)Poll the document and get all extractions (specific and compound) once processing has completed. final Resource<Unit>sendFeedbackForExtractions(Document document, Map<String, SpecificExtraction> specificExtractions, Map<String, CompoundExtraction> compoundExtractions)Sends approved and conceivably corrected extractions for the given document. final Resource<Unit>sendFeedbackForExtractions(Document document, Map<String, SpecificExtraction> specificExtractions)Sends approved and conceivably corrected extractions for the given document. final Resource<PaymentRequest>getPaymentRequest(String id)final Resource<List<PaymentRequest>>getPaymentRequests()-
-
Constructor Detail
-
DocumentManager
DocumentManager(DR documentRepository)
-
-
Method Detail
-
createPartialDocument
final Resource<Document> createPartialDocument(ByteArray document, String contentType, String filename, DocumentManager.DocumentType documentType, DocumentMetadata documentMetadata)
Uploads raw data and creates a new Gini partial document.
- Parameters:
document- A byte array representing an image, a pdf or UTF-8 encoded textcontentType- The media type of the uploaded datafilename- Optional the filename of the given documentdocumentType- Optional a document type hint.
-
deletePartialDocumentAndParents
final Resource<Unit> deletePartialDocumentAndParents(String documentId)
Deletes a Gini partial document and all its parent composite documents.
Partial documents can be deleted only, if they don't belong to any composite documents and this method deletes the parents before deleting the partial document.
- Parameters:
documentId- The id of an existing partial document
-
deleteDocument
final Resource<Unit> deleteDocument(String documentId)
Deletes a Gini document.
For deleting partial documents use deletePartialDocumentAndParents instead.
- Parameters:
documentId- The id of an existing document
-
createCompositeDocument
final Resource<Document> createCompositeDocument(List<Document> documents, DocumentManager.DocumentType documentType)
Creates a new Gini composite document.
- Parameters:
documents- A list of partial documents which should be part of a multi-page documentdocumentType- Optional a document type hint.
-
createCompositeDocument
final Resource<Document> createCompositeDocument(LinkedHashMap<Document, Integer> documentRotationMap, DocumentManager.DocumentType documentType)
Creates a new Gini composite document. The input Map must contain the partial documents as keys. These will be part of the multi-page document. The value for each partial document key is the amount in degrees the document has been rotated by the user.
- Parameters:
documentRotationMap- A map of partial documents and their rotation in degreesdocumentType- Optional a document type hint.
-
getDocument
final Resource<Document> getDocument(String id)
Get the document with the given unique identifier.
- Parameters:
id- The unique identifier of the document.
-
getDocument
final Resource<Document> getDocument(Uri uri)
Get the document with the given unique identifier.
Please note that this method may use a slightly corrected URI from which it gets the document (e.g. if the URI's host does not conform to the base URL of the Gini API). Therefore it is not possibly to use this method to get a document from an arbitrary URI.
- Parameters:
uri- The URI of the document.
-
pollDocument
final Resource<Document> pollDocument(Document document)
Continually checks the document status (via the Gini API) until the document is fully processed. To avoid flooding the network, there is a pause of at least DocumentRepository.POLLING_INTERVAL and a timeout of DocumentRepository.POLLING_TIMEOUT.
- Parameters:
document- The document which will be polled.
-
getLayout
final Resource<JSONObject> getLayout(Document document)
Gets the layout of a document. The layout of the document describes the textual content of a document with positional information, based on the processed document.
- Parameters:
document- The document for which the layouts is requested.
-
getAllExtractions
final Resource<E> getAllExtractions(Document document)
Get all extractions (specific and compound) for the given document.
- Parameters:
document- The Document instance for whose document the extractions are returned.
-
getAllExtractionsWithPolling
final Resource<E> getAllExtractionsWithPolling(Document document)
Poll the document and get all extractions (specific and compound) once processing has completed.
- Parameters:
document- The Document instance for whose document the extractions are returned.
-
sendFeedbackForExtractions
final Resource<Unit> sendFeedbackForExtractions(Document document, Map<String, SpecificExtraction> specificExtractions, Map<String, CompoundExtraction> compoundExtractions)
Sends approved and conceivably corrected extractions for the given document. This is called "submitting feedback on extractions" in the Gini API documentation.
- Parameters:
document- The document for which the extractions should be updated.specificExtractions- A Map where the key is the name of the specific extraction and the value is the SpecificExtraction object.compoundExtractions- A Map where the key is the name of the compound extraction and the value is the CompoundExtraction object.
-
sendFeedbackForExtractions
final Resource<Unit> sendFeedbackForExtractions(Document document, Map<String, SpecificExtraction> specificExtractions)
Sends approved and conceivably corrected extractions for the given document. This is called "submitting feedback on extractions" in the Gini API documentation.
- Parameters:
document- The document for which the extractions should be updated.specificExtractions- A Map where the key is the name of the specific extraction and the value is the SpecificExtraction object.
-
getPaymentRequest
final Resource<PaymentRequest> getPaymentRequest(String id)
-
getPaymentRequests
final Resource<List<PaymentRequest>> getPaymentRequests()
-
-
-
-