Přeskočit na hlavní obsah

Abstract and Base Extractors

This documentation covers the core abstract classes that form the foundation for all extractors in the AI Parsing module.

Overview

The extractor system is built around two key abstract classes:

  • AbstractExtractor: Provides the fundamental structure and common functionality for all extractors. It handles:

  • Dependency management (EntityManager, FileStorageManager, AiParsingTool)

  • Basic data preparation for AI parsing records

  • URL construction for callbacks and uploads

  • Attachment uploading logic

  • BaseExtractor: Extends AbstractExtractor to add entity-type-specific processing. It implements:

  • The core process() method that coordinates the extraction workflow

  • Entity type determination

  • Attachment handling

  • Parsing record creation

The typical extraction workflow involves:

  • Identifying the entity type
  • Gathering attachments
  • Creating a parsing record
  • Building callback and upload URLs
  • Uploading attachments to the AI service
  • Updating the parsing record status

Technické informace

AbstractExtractor Class

  • Namespace: Espo\Modules\AiParsing\Tools\Parsing\Extractors
  • Dependencies:
  • EntityManagerAware
  • FileStorageManagerAware
  • AiParsingToolAware
  • Key Methods:
  • getDataForAiParsingRecord(Entity $entity): array
  • Prepares basic data structure for new parsing records
  • Throws exception if entity ID is not set
  • buildCallbackUrl(string $entityType, string $transactionId): string
  • Constructs the callback URL for AI service responses
  • buildUploadUrl(string $entityType): string
  • Builds the upload endpoint URL
  • uploadAttachments(EntityCollection $attachments, string $uploadUrl, string $callbackUrl): void
  • Handles multipart file upload to AI service
  • Includes authentication headers
  • Processes response status

BaseExtractor Class

  • Extends: AbstractExtractor
  • Property: protected string $entityType
  • Defines the entity type this extractor processes
  • Key Methods:
  • process(Entity $entity): void
  • Main workflow implementation
  • Validates attachments
  • Creates parsing record
  • Triggers file upload
  • getDataForAiParsingRecord(Entity $entity): array
  • Extends parent method with entity type
  • getEntityType(Entity $entity): ?string
  • Returns the extractor's entity type
  • getAttachmentsIds(Entity $entity): ?array
  • Retrieves attachment IDs from entity