Documentation ¶
Index ¶
- Constants
- type ContentKey
- type Count
- type Document
- type DocumentAnalyzer
- type DocumentArchive
- type DocumentGenerator
- type DocumentIndex
- type DocumentNumber
- type DocumentPage
- type DocumentPreprocessor
- type DocumentRegistry
- type DocumentSearchResult
- type DocumentState
- type DocumentType
- type Documents
- type Error
- type Fingerprint
- type Mailbox
- type Name
- type PageNumber
- type PageOffset
- type PageRequest
- type PageSize
- type PageState
- type PageType
- type Password
- type Receiver
- type Text
- type TubeMail
- type TubeMailReceiver
- type User
- type Users
Constants ¶
const ( // DocumentStateEdited marks a document without any pages. DocumentStateEmpty = DocumentState("EMPTY") // DocumentStateEdited marks a document edited. // A document in this state has edited pages but is not ready for // further processing, as not all pages have been processed. DocumentStateEdited = DocumentState("EDITED") // DocumentStateIndexed marks a document as indexed. DocumentStateIndexed = DocumentState("INDEXED") // DocumentStateProcessed marks a document as fully processed (in sync). DocumentStateProcessed = DocumentState("PROCESSED") // DocumentStateArchived marks a document as archived (in sync). DocumentStateArchived = DocumentState("ARCHIVED") )
const ( // PageTypeTIFF PageTypeTIFF = PageType("TIFF") // PageTypeUnknown PageTypeUnknown = PageType("UNKNOWN") )
const ( // PageStateEdited marks a page as edited (out of sync). PageStateEdited = PageState("EDITED") // PageStatePreprocessed marks a page as preprocessed. PageStatePreprocessed = PageState("PREPROCESSED") // PageStateAnalyzed marks a page as analyzed (OCR complete). PageStateAnalyzed = PageState("ANALYZED") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentKey ¶
type ContentKey string
ContentKey represents the type for a key pointing to a documents content.
type Document ¶
type Document struct { DocumentNumber DocumentNumber Title Text Date *time.Time State DocumentState Fingerprint Fingerprint Type DocumentType IsInReview bool CreatedAt time.Time UpdatedAt time.Time Owner *User Pages []DocumentPage }
Document represents a document managed by the system.
func (Document) AreAllPagesInState ¶
AreAllPagesInState returns a boolean value indicating whether all the document's pages are in the given page state.
func (Document) ContentKey ¶
func (d Document) ContentKey() ContentKey
ContentKey returns the content key for the document.
type DocumentAnalyzer ¶
type DocumentAnalyzer interface {
ScanPage(documentNumber DocumentNumber, pageNumber PageNumber) error
}
DocumentAnalyzer defines functionality for obtaining text from pages.
type DocumentArchive ¶
type DocumentArchive interface { // ReadContent returns the content of a document or page from the store. ReadContent(documentNumber DocumentNumber, contentKey ContentKey) (io.ReadCloser, error) // StoreContent stores content for a new document or page. StoreContent(documentNumber DocumentNumber, contentKey ContentKey, content io.Reader) error // MoveContent moves the stored content of one key to another. MoveContent(documentNumber DocumentNumber, sourceContentKey ContentKey, destinationContentKey ContentKey) error // DeleteContent deletes the content for a document or page from the store. DeleteContent(documentNumber DocumentNumber, contentKey ContentKey) error }
DocumentArchive provides an abstraction for document storages. They provide functionality for storing and retreiving document page data.
type DocumentGenerator ¶
type DocumentGenerator interface { // Generate generates the given document and returns a reader // for the generated content. Generate(document *Document) (io.Reader, error) }
DocumentGenerator defines a signature for a component being able to generate actual, human-readable documents.
type DocumentIndex ¶
type DocumentIndex interface { // IndexAllDocuments reinserts all documents into the index. IndexAllDocuments() error // IndexDocument inserts or updates the index entry for the document with the given document number. IndexDocument(documentNumber DocumentNumber) error // Search returns all matching documents with respect to the given query. Search(query string, pr PageRequest) ([]DocumentSearchResult, Count, error) }
DocumentIndex abstracts all functionality required for indexing and searching document and pages.
type DocumentNumber ¶
type DocumentNumber uint
DocumentNumber represents the of a document's unique identifier.
type DocumentPage ¶
type DocumentPage struct { PageNumber PageNumber State PageState Text Text Type PageType Fingerprint Fingerprint IsInReview bool Document *Document }
DocumentPage represents a page of a document managed by the system.
func (DocumentPage) ContentKey ¶
func (d DocumentPage) ContentKey() ContentKey
ContentKey returns the content key for the document.
type DocumentPreprocessor ¶
type DocumentPreprocessor interface { // PreprocessPage applies preprocessing to a document's page. PreprocessPage(documentNumber DocumentNumber, pageNumber PageNumber) error }
DocumentPreprocessor defines the signature of a component being capable of preprocessing a document page to preper for further operations.
type DocumentRegistry ¶
type DocumentRegistry interface {
Review(documentNumber DocumentNumber)
}
DocumentRegistry provides an abstraction for document components taking care of the overall document workflow.
func NewDocumentRegistry ¶
func NewDocumentRegistry( tubeMail TubeMail, documents Documents, preprocessor DocumentPreprocessor, analyzer DocumentAnalyzer, index DocumentIndex, ) DocumentRegistry
type DocumentSearchResult ¶
type DocumentSearchResult struct {
Document *Document
}
type DocumentType ¶
type DocumentType string
DocumentType represents the type of a document.
const ( // DocumentTypePDF represents the type of documents having a PDF as artifact. DocumentTypePDF DocumentType = DocumentType("PDF") )
type Documents ¶
type Documents interface { // Find returns the a subset of all documents with respect to the given page request. Find(pr PageRequest) ([]Document, Count, error) // FindByDocumentNumbers returns the subset of documents matching the set of document IDs. FindByDocumentNumbers(documentNumbers ...DocumentNumber) ([]Document, error) // FindByUsername returns the set of documents owned by the user // with the given username, alongside with the total count with respect to the given // page request. FindByUsername(username Name, pr PageRequest) ([]Document, Count, error) // GetByDocumentNumber returns the document with the given document number // or nil in case no such document exists. GetByDocumentNumber(documentNumber DocumentNumber) (*Document, error) // Add adds the given document without its pages. Add(document *Document) (*Document, error) // Update updates the given document without its pages. Update(document *Document) (*Document, error) // GetPagesByDocumentNumber returns all pages contained in the document for the given document number // alongside the total count of pages with respect to the given page request. GetPagesByDocumentNumber(documentNumber DocumentNumber, pr PageRequest) ([]DocumentPage, Count, error) // GetDocumentPageByDocumentNumberAndPageNumber returns the given document // page with the given page number, part of the document with the given // document number. GetPageByDocumentNumberAndPageNumber( documentNumber DocumentNumber, pageNumber PageNumber, ) (*DocumentPage, error) // AddPage adds the given page to the document with the given document // number. AddPage( document DocumentNumber, page *DocumentPage, ) (*DocumentPage, error) // UpdatePage saves the given document page associated to the given // document. UpdatePage( documentNumber DocumentNumber, page *DocumentPage, ) (*DocumentPage, error) }
Documents defines an interface for managing the collection of all documents.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents an error occurring in the domain logic.
type Fingerprint ¶
type Fingerprint string
Fingerprint represents the type of a document's or page's fingerprint.
type PageRequest ¶
type PageRequest struct { Offset PageOffset Size PageSize Sort string }
PageRequest defines a struct for declaring paging information for requests.
type Receiver ¶
type Receiver = func(...interface{}) error
Receiver defines the signature of an abstract tube mail receiver.
type TubeMail ¶
type TubeMail interface { // RegisterReceiver registers a new document receiver for a given mail box. RegisterReceiver(mailBox Mailbox, receiver TubeMailReceiver) error // SendMessage sends a message to a target mailbox. SendMessage(target Mailbox, message ...interface{}) error }
TubeMail defines an interface for a tube mail system used for sending things around.
type TubeMailReceiver ¶
type TubeMailReceiver = func(message ...interface{}) error
TubeMailReceiver defines the callback for receiving a document.
type User ¶
type User struct { Username Name Password Password Surname Name Forename Name IsAdmin bool IsActive bool }
User represents a user within the system.
type Users ¶
type Users interface { // GetByUsername returns the user with the given username or nil in case // no such user exists. GetByUsername(username Name) (*User, error) // Find returns the set of users and total count // with respect to the given page request. Find(page PageRequest) ([]User, Count, error) // Add adds a new user. Add(user *User) (*User, error) // Update updates the given user. Update(user *User) (*User, error) // Delete deletes the given user. Delete(user *User) error }
Users defines an interface for managing the collection of all users.