using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text; namespace OpenArchival.DataAccess; public class ArtifactEntry { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } /// /// This value gets appended on the end of the contianing ArtifactGrouping's /// Category value /// public string? ArtifactIdentifier { get { return (ArtifactGrouping is not null) ? ModelHelpers.MakeIdentifier(ArtifactGrouping.IdentifierFields.Values, ArtifactGrouping.Category.FieldSeparator, ArtifactNumber) : null; } } public string? ArtifactNumber { get; set; } public required string Title { get; set; } public string? Description { get; set; } public required ArtifactStorageLocation StorageLocation { get; set; } public List? Tags { get; set; } = []; public List? ListedNames { get; set; } = []; public List? AssociatedDates { get; set; } = []; public List? Defects { get; set; } = []; public List? Links { get; set; } = []; public required List Files { get; set; } = []; public string? FileTextContent { get; set; } = null; public required ArtifactType Type { get; set; } public bool IsPubliclyVisible { get; set; } // Relationships this artifact has TO other artifacts public List RelatedTo { get; set; } = []; // Relationships other artifacts have TO this artifact public List RelatedBy { get; set; } = []; public int ArtifactGroupingId { get; set; } public required ArtifactGrouping ArtifactGrouping { get; set; } public override string ToString() { var sb = new StringBuilder(); sb.AppendLine($"--- ArtifactEntry (ID: {Id}) ---"); sb.AppendLine($" Title: {Title}"); sb.AppendLine($" ArtifactIdentifier: {ArtifactIdentifier ?? "N/A"}"); sb.AppendLine($" ArtifactNumber: {ArtifactNumber ?? "N/A"}"); sb.AppendLine($" StorageLocation: {StorageLocation}"); // Assumes ArtifactStorageLocation has a useful ToString() sb.AppendLine($" IsPubliclyVisible: {IsPubliclyVisible}"); // Handle Description (it could be long, so you might truncate it if needed) sb.AppendLine($" Description: {(string.IsNullOrWhiteSpace(Description) ? "N/A" : Description)}"); // Handle Lists sb.AppendLine($" Tags: {(Tags is not null && Tags.Any() ? string.Join(", ", Tags) : "None")}"); sb.AppendLine($" ListedNames: {(ListedNames is not null && ListedNames.Any() ? string.Join(", ", ListedNames) : "None")}"); sb.AppendLine($" AssociatedDates: {(AssociatedDates is not null && AssociatedDates.Any() ? string.Join(", ", AssociatedDates.Select(d => d.ToShortDateString())) : "None")}"); sb.AppendLine($" Defects: {(Defects is not null && Defects.Any() ? string.Join(", ", Defects) : "None")}"); sb.AppendLine($" Links: {(Links is not null && Links.Any() ? string.Join(", ", Links) : "None")}"); sb.AppendLine($" Files: {(Files is not null && Files.Any() ? string.Join(", ", Files) : "None")}"); // Handle potentially very large text content sb.AppendLine($" FileTextContent: {(string.IsNullOrEmpty(FileTextContent) ? "Not Present" : $"Present (Length: {FileTextContent.Length})")}"); sb.Append("--------------------------"); return sb.ToString(); } }