Got the new ui flow working and the models updated. Need to get changes written to the database.
This commit is contained in:
19
OpenArchival.DataAccess/Models/ArchiveCategory.cs
Normal file
19
OpenArchival.DataAccess/Models/ArchiveCategory.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ArchiveCategory
|
||||
{
|
||||
[Key]
|
||||
public int? Id { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public required string FieldSeparator { get; set; } = "-";
|
||||
|
||||
public List<string> FieldNames { get; set; } = [];
|
||||
|
||||
public List<string> FieldDescriptions { get; set; } = [];
|
||||
}
|
||||
16
OpenArchival.DataAccess/Models/ArtifactDefect.cs
Normal file
16
OpenArchival.DataAccess/Models/ArtifactDefect.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ArtifactDefect
|
||||
{
|
||||
[Key]
|
||||
public required int Id { get; set; }
|
||||
|
||||
public required string Description { get; set; }
|
||||
}
|
||||
53
OpenArchival.DataAccess/Models/ArtifactEntry.cs
Normal file
53
OpenArchival.DataAccess/Models/ArtifactEntry.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ArtifactEntry
|
||||
{
|
||||
[Key]
|
||||
public required int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This value gets appended on the end of the contianing ArtifactGrouping's
|
||||
/// Category value
|
||||
/// </summary>
|
||||
public string? ArtifactIdentifier
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ParentArtifactGrouping is not null)
|
||||
? ModelHelpers.MakeIdentifier(ParentArtifactGrouping.IdentifierFields.Values, ParentArtifactGrouping.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<ArtifactEntryTag>? Tags { get; set; }
|
||||
|
||||
public List<string>? ListedNames { get; set; }
|
||||
|
||||
public List<DateTime>? AssociatedDates { get; set; }
|
||||
|
||||
public List<string>? Defects { get; set; }
|
||||
|
||||
public List<string>? Links { get; set; }
|
||||
|
||||
public ArtifactGrouping? ParentArtifactGrouping { get; set; }
|
||||
|
||||
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 bool IsPubliclyVisible { get; set; }
|
||||
}
|
||||
|
||||
18
OpenArchival.DataAccess/Models/ArtifactEntryTag.cs
Normal file
18
OpenArchival.DataAccess/Models/ArtifactEntryTag.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ArtifactEntryTag
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public List<ArtifactEntry>? ArtifactEntries { get; set; }
|
||||
}
|
||||
75
OpenArchival.DataAccess/Models/ArtifactGrouping.cs
Normal file
75
OpenArchival.DataAccess/Models/ArtifactGrouping.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ArtifactGrouping
|
||||
{
|
||||
[Key]
|
||||
public required int Id { get; set; }
|
||||
|
||||
public string? ArtifactGroupingIdentifier
|
||||
{
|
||||
get
|
||||
{
|
||||
return ModelHelpers.MakeIdentifier(_identifierFields.Values, Category.FieldSeparator, null);
|
||||
}
|
||||
}
|
||||
|
||||
public required ArchiveCategory Category { get; set; }
|
||||
|
||||
private IdentifierFields _identifierFields;
|
||||
public required IdentifierFields IdentifierFields {
|
||||
get => _identifierFields;
|
||||
set
|
||||
{
|
||||
if (value.Values.Count != Category.FieldNames.Count)
|
||||
{
|
||||
throw new ArgumentException(nameof(IdentifierFields), $"The number of field values must be equal to the field count of the {nameof(ArchiveCategory)}");
|
||||
}
|
||||
|
||||
_identifierFields = value;
|
||||
}
|
||||
}
|
||||
|
||||
public required List<ArtifactEntry> ChildArtifactEntries { get; set; } = new();
|
||||
|
||||
public required string Title { get; set; }
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public string? Type { get; set; }
|
||||
|
||||
public List<ArtifactGrouping>? RelatedArtifactGroupings { get; set; }
|
||||
|
||||
public bool IsPublicallyVisible { get; set; }
|
||||
|
||||
public IEnumerable<ArtifactEntryTag> ChildTags
|
||||
{
|
||||
get
|
||||
{
|
||||
HashSet<ArtifactEntryTag> seenTags = [];
|
||||
for (int index = 0; index < ChildArtifactEntries.Count; ++index)
|
||||
{
|
||||
// Get the tags for this entry, skip if no tags
|
||||
List<ArtifactEntryTag>? tags = ChildArtifactEntries[index].Tags;
|
||||
if (tags is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only yield a tag if we have not yielded it yet
|
||||
foreach (ArtifactEntryTag tag in tags)
|
||||
{
|
||||
if (seenTags.Contains(tag))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
seenTags.Add(tag);
|
||||
yield return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
OpenArchival.DataAccess/Models/ArtifactStorageLocation.cs
Normal file
11
OpenArchival.DataAccess/Models/ArtifactStorageLocation.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ArtifactStorageLocation
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public required string Location { get; set; }
|
||||
}
|
||||
11
OpenArchival.DataAccess/Models/ArtifactType.cs
Normal file
11
OpenArchival.DataAccess/Models/ArtifactType.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ArtifactType
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
}
|
||||
17
OpenArchival.DataAccess/Models/FilePathListing.cs
Normal file
17
OpenArchival.DataAccess/Models/FilePathListing.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class FilePathListing
|
||||
{
|
||||
[Key]
|
||||
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; }
|
||||
}
|
||||
6
OpenArchival.DataAccess/Models/IdentifierFields.cs
Normal file
6
OpenArchival.DataAccess/Models/IdentifierFields.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class IdentifierFields
|
||||
{
|
||||
public List<string> Values { get; set; } = [];
|
||||
}
|
||||
17
OpenArchival.DataAccess/Models/ListedName.cs
Normal file
17
OpenArchival.DataAccess/Models/ListedName.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ListedName
|
||||
{
|
||||
[Key]
|
||||
public required 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; }
|
||||
}
|
||||
11
OpenArchival.DataAccess/Models/ModelHelpers.cs
Normal file
11
OpenArchival.DataAccess/Models/ModelHelpers.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace OpenArchival.DataAccess;
|
||||
|
||||
public class ModelHelpers
|
||||
{
|
||||
public static string? MakeIdentifier(List<string>? values, string fieldSeperator, string? archiveEntryNumber)
|
||||
{
|
||||
if (values is null || values.Count == 0) return null;
|
||||
|
||||
return (archiveEntryNumber is not null) ? $"{string.Join(fieldSeperator, values)}{archiveEntryNumber}" : string.Join(fieldSeperator, values);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user