Enhance event occurrence parsing with detailed issue reporting and location configuration
This commit introduces a new structure for handling parsing issues in the EventOccurrenceParser, allowing for detailed reporting of parsing problems such as unmatched lines, missing event definitions, and parsing failures for time, date, and location. A new ParsingIssue class has been added to encapsulate these details. Additionally, a LocationParsingConfiguration class has been implemented to support customizable location patterns, enhancing the flexibility of the parser. The EventOccurrenceParserService has been updated to utilize this configuration, and new tests have been added to ensure robust issue detection and reporting. Furthermore, the UI has been updated to display parsing issues, improving user feedback during the import process.
This commit is contained in:
@@ -25,6 +25,11 @@ public class EventOccurrenceParseResult
|
||||
/// </summary>
|
||||
public List<string> Warnings { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// List of detailed parsing issues with line numbers and specific problem descriptions.
|
||||
/// </summary>
|
||||
public List<ParsingIssue> Issues { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Total number of event occurrences successfully parsed.
|
||||
/// </summary>
|
||||
@@ -36,3 +41,65 @@ public class EventOccurrenceParseResult
|
||||
public bool IsSuccess => Errors.Count == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a detailed parsing issue encountered during event occurrence parsing.
|
||||
/// </summary>
|
||||
public class ParsingIssue
|
||||
{
|
||||
/// <summary>
|
||||
/// The line number where the issue occurred (1-based).
|
||||
/// </summary>
|
||||
public int LineNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The actual line content where the issue occurred.
|
||||
/// </summary>
|
||||
public string LineContent { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The type of parsing issue.
|
||||
/// </summary>
|
||||
public ParsingIssueType IssueType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Human-readable description of the issue.
|
||||
/// </summary>
|
||||
public string Message { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Types of parsing issues that can occur during event occurrence parsing.
|
||||
/// </summary>
|
||||
public enum ParsingIssueType
|
||||
{
|
||||
/// <summary>
|
||||
/// Line doesn't match the expected format pattern.
|
||||
/// </summary>
|
||||
UnmatchedLine,
|
||||
|
||||
/// <summary>
|
||||
/// Line matches format but event definition cannot be determined.
|
||||
/// </summary>
|
||||
MissingEventDefinition,
|
||||
|
||||
/// <summary>
|
||||
/// Time parsing failed (regex doesn't match or parse errors).
|
||||
/// </summary>
|
||||
TimeParseFailure,
|
||||
|
||||
/// <summary>
|
||||
/// Date parsing failed (invalid day of month, etc.).
|
||||
/// </summary>
|
||||
DateParseFailure,
|
||||
|
||||
/// <summary>
|
||||
/// Invalid format or other parsing issue.
|
||||
/// </summary>
|
||||
InvalidFormat,
|
||||
|
||||
/// <summary>
|
||||
/// Location parsing failed (no matching pattern found).
|
||||
/// </summary>
|
||||
LocationParseFailure
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace Core.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Configuration for location parsing patterns used in event occurrence parsing.
|
||||
/// Supports venue-specific room naming conventions.
|
||||
/// </summary>
|
||||
public class LocationParsingConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// List of location prefix patterns (e.g., ["Room *", "Hall *", "Conference Room *"]).
|
||||
/// Patterns use "*" as wildcard to match any text after the prefix.
|
||||
/// </summary>
|
||||
public List<string> LocationPatterns { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Default location parsing configuration with common patterns.
|
||||
/// </summary>
|
||||
public static LocationParsingConfiguration Default => new()
|
||||
{
|
||||
LocationPatterns = new List<string>
|
||||
{
|
||||
"Room *",
|
||||
"Hall *",
|
||||
"Conference Room *",
|
||||
"Building *",
|
||||
"Auditorium *"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user