using System;
namespace GB5Shared.DTO.Qualifier
{
// ── Master: Qualifier Bulk Run ───────────────────────────────────
// Maps to TQUALIFIERBULKRUN — one header row per "test this Qualifier against a
// batch of records" run. Mirrors IceImportRunDTO's shape/lifecycle exactly
// (Pending -> Running -> Completed/Failed), see IceImportRunBLL for the sibling
// pattern this was modeled on.
public class QualifierBulkRunDTO
{
public int QualifierBulkRunId { get; set; }
public int QualifierId { get; set; }
/// Joined from MQUALIFIERDEFINITION at read time — not a stored column.
public string? QualifierCode { get; set; }
public string EntityCode { get; set; } = string.Empty;
/// Matches MQUALIFIERENTITY.STAGE — which binding this run is testing.
public byte Stage { get; set; }
/// Matches MQUALIFIERENTITY.SCOPE — which binding this run is testing.
public byte Scope { get; set; }
/// 0=Pending, 1=Running, 2=Completed, 3=Failed.
public byte RunStatus { get; set; }
public int TotalRecords { get; set; }
public int ProcessedRecords { get; set; }
public int ErrorCount { get; set; }
public int WarningCount { get; set; }
public DateTime? StartedOn { get; set; }
public DateTime? CompletedOn { get; set; }
public string? ErrorMessage { get; set; }
public int TenantId { get; set; }
public int CreatedById { get; set; }
public DateTime CreatedOn { get; set; }
}
// ── Log: Qualifier Bulk Finding ───────────────────────────────────
// Maps to LQUALIFIERBULKFINDING — one row per finding a bulk run's per-record
// Qualifier evaluation produced (a record with zero findings simply has zero rows
// here, matching IceImportRunRowResultDTO's own "no error row for a clean record"
// convention). RecordKey is caller-supplied at enqueue time (e.g. "PO-2025-0003")
// so a finding can be traced back to whichever input record produced it.
public class QualifierBulkFindingDTO
{
public long QualifierBulkFindingId { get; set; }
public int QualifierBulkRunId { get; set; }
public int QualifierId { get; set; }
public string QualifierCode { get; set; } = string.Empty;
public string? RecordKey { get; set; }
/// 1=Error, 2=Warning, 3=Info — matches QualifierFinding's own FindingSeverity enum values exactly.
public byte Severity { get; set; }
public string? FindingCode { get; set; }
public string? FindingMessage { get; set; }
public string? DocumentPath { get; set; }
public DateTime CreatedOn { get; set; }
}
// ── Request shape: one record to evaluate ────────────────────────
// Not a DB-mapped DTO -- the caller-supplied input row for EnqueueQualifierBulkRun.
public class QualifierBulkRunRecordDTO
{
public string RecordKey { get; set; } = string.Empty;
/// The record's own fields as a JSON object -- evaluated the same way
/// QualifierExecutionContext.Document is elsewhere (JSONPath field access).
public string DataJson { get; set; } = string.Empty;
}
}