Skip to content

PacketGenerator

PacketGenerator evaluates a single PacketDefinition against one group of candidate documents, applying the definition's filters (required policy period, same effective date, included document codes, primary/secondary document requirements, market type, policy relationship, source-key text) to decide whether a packet can be formed, and if so building the resulting PolicyDocument packet entry (DOM-BR-202). It is the per-definition worker PacketManager instantiates once per group per definition.

Purpose

  • Filters a working document list down through a fixed sequence of rules driven by the packet definition (period requirement, same-effective-date requirement, included document codes, primary-document selection, source-key-text matching, child-document inclusion) before deciding whether a packet can be created (DOM-BR-202).
  • Builds and appends a new PolicyDocument packet entry — carrying policy, agency, release, and document-type information from the resolved primary document and definition — into the caller's packet list, and removes the consumed documents from the caller's working document list, only when every eligibility check (minimum document count, valid policy, valid secondary document, required parent document) passes.
  • Selects, from a candidate document list and a known primary document, exactly the subset that would belong in this definition's packet, without mutating any external packet list — the read-only counterpart used by PacketManager.GetDocumentsForPacket.

Context

  • Namespace: SAIF.Domain.Tasks.Documents.Packets
  • Assembly/package: SAIF.Domain (packaged in SAIF.SAIFCode.Core)

Public members

Member Signature Purpose
PacketGenerator (constructor) public PacketGenerator(PacketDefinition definition) Binds this generator instance to definition, the packet definition whose filters and requirements it will evaluate.
CreatePacket public void CreatePacket(IList<PolicyDocument> packetList, IList<PolicyOutputDocument> documentsList, IPolicyOutputDocumentRepository policyOutputDocRepository) Filters documentsList per the bound definition; if the filtered set meets the minimum document count and passes policy/secondary-document/parent-document validation, appends a new packet entry to packetList and removes the consumed documents from documentsList (DOM-BR-202).
GetPacketDocuments public IEnumerable<PolicyOutputDocument> GetPacketDocuments(IEnumerable<PolicyOutputDocument> documentsList, PolicyOutputDocument primaryDocument) Filters documentsList around primaryDocument per the bound definition and returns the subset matching the primary document's document date and release date, when the filtered set is eligible (minimum count, valid policy, valid secondary document); an empty sequence otherwise.

Behavioral notes

  • CreatePacket silently returns without adding anything when any eligibility check fails (empty working list, below minimum count, invalid policy, no resolved packet document, invalid secondary document, missing required parent document) — callers cannot distinguish which check failed from the return value alone*.
  • RequiredParentDocument passes automatically whenever the definition has no PrimaryParentCode configured, so the parent-document check only applies to definitions that declare one.
  • FilterChildDocuments only restricts the working list to the policy's relationship-parent documents when the definition does not explicitly IncludeChildDocuments and the packet's policy has a relationship policy; otherwise child documents remain eligible.

Constraints and usage notes

  • A PacketGenerator instance is scoped to a single PacketDefinition and a single call to CreatePacket/GetPacketDocuments per document group; PacketManager constructs a fresh instance for every definition/group combination rather than reusing one.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

Sources

  • Domain/SAIF.Domain/Tasks/Documents/Packets/PacketGenerator.cs
  • Domain/SAIF.Domain/Tasks/Documents/Packets/PacketDefinition.cs
  • Domain/SAIF.Domain/Tasks/Documents/Packets/PacketManager.cs