mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 17:25:32 +00:00
Further developed collections
This commit is contained in:
@@ -11,6 +11,7 @@ public class CollectedItem : ISearchable {
|
|||||||
public IDictionary<string, string>? Fields { get; private set; }
|
public IDictionary<string, string>? Fields { get; private set; }
|
||||||
public XElement ELement { get; private set; }
|
public XElement ELement { get; private set; }
|
||||||
public IXMLCollection Collection { get; private set; }
|
public IXMLCollection Collection { get; private set; }
|
||||||
|
public IDictionary<string, CollectedItem>? Items { get; set; }
|
||||||
|
|
||||||
public CollectedItem(
|
public CollectedItem(
|
||||||
string index,
|
string index,
|
||||||
|
|||||||
@@ -39,4 +39,12 @@ public class ItemsCollection {
|
|||||||
if (Collection.SortingsGeneration != null && this.Items.Any())
|
if (Collection.SortingsGeneration != null && this.Items.Any())
|
||||||
this.Sortings = Collection.SortingsGeneration(this.Items.Values.ToList());
|
this.Sortings = Collection.SortingsGeneration(this.Items.Values.ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CollectedItem? this[string v] {
|
||||||
|
get {
|
||||||
|
if (Items != null && Items.ContainsKey(v))
|
||||||
|
return Items[v];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ using System.Xml.Linq;
|
|||||||
public class BackLinkCollection : HaWeb.XMLParser.IXMLCollection {
|
public class BackLinkCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
private static readonly Random _random = new Random();
|
private static readonly Random _random = new Random();
|
||||||
public string Key { get; } = "backlinks";
|
public string Key { get; } = "backlinks";
|
||||||
public string[] xPath { get; } = new string[] { "/opus/data/marginalien/marginal/link", "/opus/marginalien/marginal/link" };
|
public string[] xPath { get; } = new string[] { "/opus/data/marginalien/marginal/link", "/opus/marginalien/marginal/link" };
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = GetDataFields;
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = GetDataFields;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = GetLookups;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
||||||
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
|
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
|
||||||
public bool Searchable { get; } = true;
|
public bool Searchable { get; } = true;
|
||||||
@@ -33,8 +33,8 @@ public class BackLinkCollection : HaWeb.XMLParser.IXMLCollection {
|
|||||||
else res.Add("ref", refere!);
|
else res.Add("ref", refere!);
|
||||||
res.Add("index", index);
|
res.Add("index", index);
|
||||||
res.Add("letter", letter);
|
res.Add("letter", letter);
|
||||||
if(page != null) res.Add("page", page);
|
if (page != null) res.Add("page", page);
|
||||||
if(line != null) res.Add("line", line);
|
if (line != null) res.Add("line", line);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,8 @@ namespace HaWeb.Settings.XMLCollections;
|
|||||||
using HaWeb.Models;
|
using HaWeb.Models;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
public class BibleCommentCollection : HaWeb.XMLParser.IXMLCollection {
|
|
||||||
public string Key { get; } = "bible-comments";
|
|
||||||
public string[] xPath { get; } = new string[] { "/opus/data/kommentare/kommcat[@value='bibel']/kommentar", "/opus/kommentare/kommcat[@value='bibel']/kommentar" };
|
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = GetDataFields;
|
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = GetLookups;
|
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
|
||||||
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
|
|
||||||
public bool Searchable { get; } = false;
|
|
||||||
|
|
||||||
|
public static class CommentCollectionHelpers {
|
||||||
public static Func<XElement, string?> GetKey { get; } = (elem) => {
|
public static Func<XElement, string?> GetKey { get; } = (elem) => {
|
||||||
var index = elem.Attribute("id");
|
var index = elem.Attribute("id");
|
||||||
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
|
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
|
||||||
@@ -42,119 +34,74 @@ public class BibleCommentCollection : HaWeb.XMLParser.IXMLCollection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class BibleCommentCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
|
public string Key { get; } = "bible-comments";
|
||||||
|
public string[] xPath { get; } = new string[] { "/opus/data/kommentare/kommcat[@value='bibel']/kommentar", "/opus/kommentare/kommcat[@value='bibel']/kommentar" };
|
||||||
|
public Func<XElement, string?> GenerateKey { get; } = CommentCollectionHelpers.GetKey;
|
||||||
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = CommentCollectionHelpers.GetDataFields;
|
||||||
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = CommentCollectionHelpers.GetLookups;
|
||||||
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
||||||
|
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
|
||||||
|
public bool Searchable { get; } = false;
|
||||||
|
}
|
||||||
|
|
||||||
public class EditionCommentCollection : HaWeb.XMLParser.IXMLCollection {
|
public class EditionCommentCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
public string Key { get; } = "edition-comments";
|
public string Key { get; } = "edition-comments";
|
||||||
public string[] xPath { get; } = new string[] { "/opus/data/kommentare/kommcat[@value='editionen']/kommentar", "/opus/kommentare/kommcat[@value='editionen']/kommentar" };
|
public string[] xPath { get; } = new string[] { "/opus/data/kommentare/kommcat[@value='editionen']/kommentar", "/opus/kommentare/kommcat[@value='editionen']/kommentar" };
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
public Func<XElement, string?> GenerateKey { get; } = CommentCollectionHelpers.GetKey;
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = GetDataFields;
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = CommentCollectionHelpers.GetDataFields;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = GetLookups;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = CommentCollectionHelpers.GetLookups;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
||||||
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
|
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
|
||||||
public bool Searchable { get; } = true;
|
public bool Searchable { get; } = true;
|
||||||
|
|
||||||
public static Func<XElement, string?> GetKey { get; } = (elem) => {
|
|
||||||
var index = elem.Attribute("id");
|
|
||||||
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
|
|
||||||
return index.Value;
|
|
||||||
else return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
public static IDictionary<string, string>? GetDataFields(XElement element) {
|
|
||||||
var res = new Dictionary<string, string>();
|
|
||||||
var lemma = element.Descendants("lemma");
|
|
||||||
if (!lemma.Any() || String.IsNullOrWhiteSpace(lemma.First().Value)) return null;
|
|
||||||
res.Add("lemma", lemma.First().Value);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IDictionary<string, ILookup<string, CollectedItem>>? GetLookups(IEnumerable<CollectedItem> items) {
|
|
||||||
var res = new Dictionary<string, ILookup<string, CollectedItem>>();
|
|
||||||
var lemmas = items.Where(x => !String.IsNullOrWhiteSpace(x.Index));
|
|
||||||
if (lemmas != null && lemmas.Any())
|
|
||||||
res.Add("lemma", lemmas.ToLookup(x => x.Index.Substring(0, 1).ToUpper()));
|
|
||||||
// If we use lemmas
|
|
||||||
// var lemmas = items.Where(x => x.Fields != null && x.Fields.ContainsKey("lemma"));
|
|
||||||
// if (lemmas != null && lemmas.Any())
|
|
||||||
// res.Add("lemma", lemmas.ToLookup(x => x.Fields["lemma"][0].First().ToString()));
|
|
||||||
if (!res.Any()) return null;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RegisterCommentCollection : HaWeb.XMLParser.IXMLCollection {
|
public class RegisterCommentCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
public string Key { get; } = "register-comments";
|
public string Key { get; } = "register-comments";
|
||||||
public string[] xPath { get; } = new string[] { "/opus/data/kommentare/kommcat[@value='neuzeit']/kommentar", "/opus/kommentare/kommcat[@value='neuzeit']/kommentar" };
|
public string[] xPath { get; } = new string[] { "/opus/data/kommentare/kommcat[@value='neuzeit']/kommentar", "/opus/kommentare/kommcat[@value='neuzeit']/kommentar" };
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
public Func<XElement, string?> GenerateKey { get; } = CommentCollectionHelpers.GetKey;
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = GetDataFields;
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = CommentCollectionHelpers.GetDataFields;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = GetLookups;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = CommentCollectionHelpers.GetLookups;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
||||||
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
|
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = new XMLParser.IXMLCollection[] { new SubCommentCollection() };
|
||||||
public bool Searchable { get; } = true;
|
public bool Searchable { get; } = true;
|
||||||
|
|
||||||
public static Func<XElement, string?> GetKey { get; } = (elem) => {
|
|
||||||
var index = elem.Attribute("id");
|
|
||||||
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
|
|
||||||
return index.Value;
|
|
||||||
else return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
public static IDictionary<string, string>? GetDataFields(XElement element) {
|
|
||||||
var res = new Dictionary<string, string>();
|
|
||||||
var lemma = element.Descendants("lemma");
|
|
||||||
if (!lemma.Any() || String.IsNullOrWhiteSpace(lemma.First().Value)) return null;
|
|
||||||
res.Add("lemma", lemma.First().Value);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IDictionary<string, ILookup<string, CollectedItem>>? GetLookups(IEnumerable<CollectedItem> items) {
|
|
||||||
var res = new Dictionary<string, ILookup<string, CollectedItem>>();
|
|
||||||
var lemmas = items.Where(x => !String.IsNullOrWhiteSpace(x.Index));
|
|
||||||
if (lemmas != null && lemmas.Any())
|
|
||||||
res.Add("lemma", lemmas.ToLookup(x => x.Index.Substring(0, 1).ToUpper()));
|
|
||||||
// If we use lemmas
|
|
||||||
// var lemmas = items.Where(x => x.Fields != null && x.Fields.ContainsKey("lemma"));
|
|
||||||
// if (lemmas != null && lemmas.Any())
|
|
||||||
// res.Add("lemma", lemmas.ToLookup(x => x.Fields["lemma"][0].First().ToString()));
|
|
||||||
if (!res.Any()) return null;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ForschungCommentCollection : HaWeb.XMLParser.IXMLCollection {
|
public class ForschungCommentCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
public string Key { get; } = "forschung-comments";
|
public string Key { get; } = "forschung-comments";
|
||||||
public string[] xPath { get; } = new string[] { "/opus/data/kommentare/kommcat[@value='forschung']/kommentar", "/opus/kommentare/kommcat[@value='forschung']/kommentar" };
|
public string[] xPath { get; } = new string[] { "/opus/data/kommentare/kommcat[@value='forschung']/kommentar", "/opus/kommentare/kommcat[@value='forschung']/kommentar" };
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
public Func<XElement, string?> GenerateKey { get; } = CommentCollectionHelpers.GetKey;
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = GetDataFields;
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = CommentCollectionHelpers.GetDataFields;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = GetLookups;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = CommentCollectionHelpers.GetLookups;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
||||||
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
|
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
|
||||||
public bool Searchable { get; } = true;
|
public bool Searchable { get; } = true;
|
||||||
|
}
|
||||||
|
|
||||||
public static Func<XElement, string?> GetKey { get; } = (elem) => {
|
|
||||||
var index = elem.Attribute("id");
|
public class SubCommentCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
|
public string Key { get; } = "subcomments";
|
||||||
return index.Value;
|
public string[] xPath { get; } = new string[] { "/opus/data/kommentare/kommcat/kommentar/subsection", "/opus/kommentare/kommcat/kommentar/subsection" };
|
||||||
else return null;
|
public Func<XElement, string?> GenerateKey { get; } = CommentCollectionHelpers.GetKey;
|
||||||
};
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = GetDataFields;
|
||||||
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = CommentCollectionHelpers.GetLookups;
|
||||||
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
||||||
|
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
|
||||||
|
public bool Searchable { get; } = true;
|
||||||
|
|
||||||
public static IDictionary<string, string>? GetDataFields(XElement element) {
|
public static IDictionary<string, string>? GetDataFields(XElement element) {
|
||||||
var res = new Dictionary<string, string>();
|
var res = new Dictionary<string, string>();
|
||||||
var lemma = element.Descendants("lemma");
|
var lemma = element.Descendants("lemma");
|
||||||
if (!lemma.Any() || String.IsNullOrWhiteSpace(lemma.First().Value)) return null;
|
if (!lemma.Any() || String.IsNullOrWhiteSpace(lemma.First().Value)) return null;
|
||||||
res.Add("lemma", lemma.First().Value);
|
res.Add("lemma", lemma.First().Value);
|
||||||
return res;
|
var comment = element.Ancestors("kommcat").First();
|
||||||
}
|
var type = (string?)comment.Attribute("value");
|
||||||
|
if (String.IsNullOrWhiteSpace(type)) return null;
|
||||||
public static IDictionary<string, ILookup<string, CollectedItem>>? GetLookups(IEnumerable<CollectedItem> items) {
|
res.Add("type", type);
|
||||||
var res = new Dictionary<string, ILookup<string, CollectedItem>>();
|
var parent = element.Ancestors("kommentar").First();
|
||||||
var lemmas = items.Where(x => !String.IsNullOrWhiteSpace(x.Index));
|
var parentid = (string?)parent.Attribute("id");
|
||||||
if (lemmas != null && lemmas.Any())
|
if (String.IsNullOrWhiteSpace(parentid)) return null;
|
||||||
res.Add("lemma", lemmas.ToLookup(x => x.Index.Substring(0, 1).ToUpper()));
|
res.Add("parent", parentid);
|
||||||
// If we use lemmas
|
|
||||||
// var lemmas = items.Where(x => x.Fields != null && x.Fields.ContainsKey("lemma"));
|
|
||||||
// if (lemmas != null && lemmas.Any())
|
|
||||||
// res.Add("lemma", lemmas.ToLookup(x => x.Fields["lemma"][0].First().ToString()));
|
|
||||||
if (!res.Any()) return null;
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ using System.Xml.Linq;
|
|||||||
|
|
||||||
public class EditCollection : HaWeb.XMLParser.IXMLCollection {
|
public class EditCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
public string Key { get; } = "edits";
|
public string Key { get; } = "edits";
|
||||||
public string[] xPath { get; } = new string[] { "/opus/edits/editreason", "/opus/data/edits/editreason" };
|
public string[] xPath { get; } = new string[] { "/opus/edits/editreason", "/opus/data/edits/editreason" };
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Xml.Linq;
|
|||||||
|
|
||||||
public class LetterCollection : HaWeb.XMLParser.IXMLCollection {
|
public class LetterCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
public string Key { get; } = "letters";
|
public string Key { get; } = "letters";
|
||||||
public string[] xPath { get; } = new string[] { "/opus/data/document/letterText", "/opus/document/letterText" };
|
public string[] xPath { get; } = new string[] { "/opus/data/document/letterText", "/opus/document/letterText" };
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ using System.Xml.Linq;
|
|||||||
|
|
||||||
public class MarginalCollection : HaWeb.XMLParser.IXMLCollection {
|
public class MarginalCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
public string Key { get; } = "marginals";
|
public string Key { get; } = "marginals";
|
||||||
public string[] xPath { get; } = new string[] { "/opus/data/marginalien/marginal", "/opus/marginalien/marginal" };
|
public string[] xPath { get; } = new string[] { "/opus/data/marginalien/marginal", "/opus/marginalien/marginal" };
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = GetDataFields;
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = GetDataFields;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = GetLookups;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
|
||||||
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
|
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
|
||||||
public bool Searchable { get; } = true;
|
public bool Searchable { get; } = true;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Xml.Linq;
|
|||||||
|
|
||||||
public class MetaCollection : HaWeb.XMLParser.IXMLCollection {
|
public class MetaCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
public string Key { get; } = "metas";
|
public string Key { get; } = "metas";
|
||||||
public string[] xPath { get; } = new string[] { "/opus/descriptions/letterDesc", "/opus/data/descriptions/letterDesc" };
|
public string[] xPath { get; } = new string[] { "/opus/descriptions/letterDesc", "/opus/data/descriptions/letterDesc" };
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
||||||
@@ -18,4 +18,17 @@ public class MetaCollection : HaWeb.XMLParser.IXMLCollection {
|
|||||||
return index.Value;
|
return index.Value;
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static IDictionary<string, string>? GetDataFields(XElement element) {
|
||||||
|
var res = new Dictionary<string, string>();
|
||||||
|
// TODO
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IDictionary<string, ILookup<string, CollectedItem>>? GetLookups(IEnumerable<CollectedItem> items) {
|
||||||
|
var res = new Dictionary<string, ILookup<string, CollectedItem>>();
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ using System.Xml.Linq;
|
|||||||
|
|
||||||
public class HandPersonCollection : HaWeb.XMLParser.IXMLCollection {
|
public class HandPersonCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
public string Key { get; } = "handpersons";
|
public string Key { get; } = "handpersons";
|
||||||
public string[] xPath { get; } = new string[] { "/opus/data/definitions/handDefs/handDef", "/opus/definitions/handDefs/handDef" };
|
public string[] xPath { get; } = new string[] { "/opus/data/definitions/handDefs/handDef", "/opus/definitions/handDefs/handDef" };
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
||||||
@@ -22,7 +22,7 @@ public class HandPersonCollection : HaWeb.XMLParser.IXMLCollection {
|
|||||||
|
|
||||||
public class PersonCollection : HaWeb.XMLParser.IXMLCollection {
|
public class PersonCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
public string Key { get; } = "persons";
|
public string Key { get; } = "persons";
|
||||||
public string[] xPath { get; } = new string[] { "/opus/data/definitions/personDefs/personDef", "/opus/definitions/personDefs/personDef" };
|
public string[] xPath { get; } = new string[] { "/opus/data/definitions/personDefs/personDef", "/opus/definitions/personDefs/personDef" };
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
||||||
@@ -40,7 +40,7 @@ public class PersonCollection : HaWeb.XMLParser.IXMLCollection {
|
|||||||
|
|
||||||
public class LocationCollection : HaWeb.XMLParser.IXMLCollection {
|
public class LocationCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
public string Key { get; } = "locations";
|
public string Key { get; } = "locations";
|
||||||
public string[] xPath { get; } = new string[] { "/opus/data/definitions/locationDefs/locationDef", "/opus/definitions/locationDefs/locationDef" };
|
public string[] xPath { get; } = new string[] { "/opus/data/definitions/locationDefs/locationDef", "/opus/definitions/locationDefs/locationDef" };
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Xml.Linq;
|
|||||||
|
|
||||||
public class TraditionCollection : HaWeb.XMLParser.IXMLCollection {
|
public class TraditionCollection : HaWeb.XMLParser.IXMLCollection {
|
||||||
public string Key { get; } = "traditions";
|
public string Key { get; } = "traditions";
|
||||||
public string[] xPath { get; } = new string[] { "/opus/data/traditions/letterTradition", "/opus/traditions/letterTradition" };
|
public string[] xPath { get; } = new string[] { "/opus/data/traditions/letterTradition", "/opus/traditions/letterTradition" };
|
||||||
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
public Func<XElement, string?> GenerateKey { get; } = GetKey;
|
||||||
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
|
||||||
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ public interface IXMLCollection {
|
|||||||
abstract Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; }
|
abstract Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; }
|
||||||
abstract Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; }
|
abstract Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; }
|
||||||
abstract Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; }
|
abstract Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; }
|
||||||
|
// TODO Not implemented yet
|
||||||
abstract IXMLCollection[]? SubCollections { get; }
|
abstract IXMLCollection[]? SubCollections { get; }
|
||||||
abstract bool Searchable { get; }
|
abstract bool Searchable { get; }
|
||||||
|
|
||||||
|
// Override with false if collection should not be read in and available globally (useful for SubCollections)
|
||||||
|
bool IsGlobal() => true;
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ public class XMLService : IXMLService {
|
|||||||
collectiontypes.ForEach( x => {
|
collectiontypes.ForEach( x => {
|
||||||
if (this._Collections == null) this._Collections = new Dictionary<string, IXMLCollection>();
|
if (this._Collections == null) this._Collections = new Dictionary<string, IXMLCollection>();
|
||||||
var instance = (IXMLCollection)Activator.CreateInstance(x)!;
|
var instance = (IXMLCollection)Activator.CreateInstance(x)!;
|
||||||
if (instance != null) this._Collections.Add(instance.Key, instance);
|
if (instance != null && instance.IsGlobal()) this._Collections.Add(instance.Key, instance);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (_Roots == null || !_Roots.Any())
|
if (_Roots == null || !_Roots.Any())
|
||||||
|
|||||||
Reference in New Issue
Block a user