Got most of admin panel working. Data issues fixed
This commit is contained in:
9
OpenArchival.DataAccess/Models/ApplicationUser.cs
Normal file
9
OpenArchival.DataAccess/Models/ApplicationUser.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
// Add profile data for application users by adding properties to the ApplicationUser class
|
||||
public class ApplicationUser : IdentityUser
|
||||
{
|
||||
public string PermissionLevel { get; set; } = "";
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ArchiveCategory
|
||||
{
|
||||
[Key]
|
||||
public int? Id { get; set; }
|
||||
public int Id { get; set; }
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Index(IsUnique =true)]
|
||||
public required string Name { get; set; }
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -10,7 +11,9 @@ namespace OpenArchival.DataAccess;
|
||||
public class ArtifactDefect
|
||||
{
|
||||
[Key]
|
||||
public required int Id { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Index(IsUnique = true)]
|
||||
public required string Description { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ArtifactEntry
|
||||
{
|
||||
[Key]
|
||||
public required int Id { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This value gets appended on the end of the contianing ArtifactGrouping's
|
||||
@@ -15,8 +18,8 @@ public class ArtifactEntry
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ParentArtifactGrouping is not null)
|
||||
? ModelHelpers.MakeIdentifier(ParentArtifactGrouping.IdentifierFields.Values, ParentArtifactGrouping.Category.FieldSeparator, ArtifactNumber)
|
||||
return (ArtifactGrouping is not null)
|
||||
? ModelHelpers.MakeIdentifier(ArtifactGrouping.IdentifierFields.Values, ArtifactGrouping.Category.FieldSeparator, ArtifactNumber)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -29,25 +32,64 @@ public class ArtifactEntry
|
||||
|
||||
public required ArtifactStorageLocation StorageLocation { get; set; }
|
||||
|
||||
public List<ArtifactEntryTag>? Tags { get; set; }
|
||||
public List<ArtifactEntryTag>? Tags { get; set; } = [];
|
||||
|
||||
public List<string>? ListedNames { get; set; }
|
||||
public List<ListedName>? ListedNames { get; set; } = [];
|
||||
|
||||
public List<DateTime>? AssociatedDates { get; set; }
|
||||
public List<DateTime>? AssociatedDates { get; set; } = [];
|
||||
|
||||
public List<ArtifactDefect>? Defects { get; set; } = [];
|
||||
|
||||
public List<string>? Links { get; set; } = [];
|
||||
|
||||
public List<string>? Defects { get; set; }
|
||||
public required List<FilePathListing> Files { get; set; } = [];
|
||||
|
||||
public List<string>? Links { get; set; }
|
||||
|
||||
public ArtifactGrouping? ParentArtifactGrouping { get; set; }
|
||||
public string? FileTextContent { get; set; } = null;
|
||||
|
||||
public required List<FilePathListing> Files { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maps the file name to the textual contents of the file
|
||||
/// </summary>
|
||||
public Dictionary<string, 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<ArtifactEntry> RelatedTo { get; set; } = [];
|
||||
|
||||
// Relationships other artifacts have TO this artifact
|
||||
public List<ArtifactEntry> 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -10,9 +11,11 @@ namespace OpenArchival.DataAccess;
|
||||
public class ArtifactEntryTag
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Index(IsUnique = true)]
|
||||
public required string Name { get; set; }
|
||||
|
||||
public List<ArtifactEntry>? ArtifactEntries { get; set; }
|
||||
public List<ArtifactEntry>? ArtifactEntries { get; set; } = [];
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ArtifactGrouping
|
||||
{
|
||||
[Key]
|
||||
public required int Id { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? ArtifactGroupingIdentifier
|
||||
{
|
||||
@@ -32,7 +35,6 @@ public class ArtifactGrouping
|
||||
}
|
||||
}
|
||||
|
||||
public required List<ArtifactEntry> ChildArtifactEntries { get; set; } = new();
|
||||
|
||||
public required string Title { get; set; }
|
||||
|
||||
@@ -40,10 +42,33 @@ public class ArtifactGrouping
|
||||
|
||||
public string? Type { get; set; }
|
||||
|
||||
public List<ArtifactGrouping>? RelatedArtifactGroupings { get; set; }
|
||||
|
||||
public bool IsPublicallyVisible { get; set; }
|
||||
|
||||
public required List<ArtifactEntry> ChildArtifactEntries { get; set; } = new();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine($"Id: {Id}");
|
||||
sb.AppendLine($"Artifact Grouping Identifier: {ArtifactGroupingIdentifier}");
|
||||
sb.AppendLine($"Category:");
|
||||
sb.AppendLine(Category.ToString());
|
||||
sb.AppendLine($"Title: {Title}");
|
||||
sb.AppendLine($"Description: {Description}");
|
||||
sb.AppendLine($"Type:{Type}");
|
||||
sb.AppendLine($"Publically Visible: {IsPublicallyVisible}");
|
||||
sb.AppendLine($"Artifact Entries:");
|
||||
foreach (var artifact in ChildArtifactEntries)
|
||||
{
|
||||
sb.AppendLine(artifact.ToString());
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public IEnumerable<ArtifactEntryTag> ChildTags
|
||||
{
|
||||
get
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ArtifactStorageLocation
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Index(IsUnique =true)]
|
||||
public required string Location { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ArtifactType
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Index(IsUnique =true)]
|
||||
public required string Name { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class FilePathListing
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public ArtifactEntry? ParentArtifactEntry { get; set; }
|
||||
|
||||
public int? ParentArtifactEntryId { get; set; }
|
||||
|
||||
public required string OriginalName { get; set; }
|
||||
|
||||
public required string Path { get; set; }
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ListedName
|
||||
{
|
||||
[Key]
|
||||
public required int Id { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public required ArtifactEntry ParentArtifactEntry { get; set; }
|
||||
|
||||
public string? Title { get; set; }
|
||||
|
||||
public required string FirstName { get; set; }
|
||||
|
||||
public required string LastName { get; set; }
|
||||
public required string Value { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user