Added collection classes. Will not do extra collection for subcomments rn.

This commit is contained in:
schnulller
2022-06-26 22:48:25 +02:00
parent 056ab77888
commit 0fa0ff6a88
22 changed files with 490 additions and 226 deletions

View File

@@ -0,0 +1,48 @@
namespace HaWeb.Settings.XMLCollections;
using HaWeb.Models;
using System.Xml.Linq;
public class BackLinkCollection : HaWeb.XMLParser.IXMLCollection {
private static readonly Random _random = new Random();
public string Key { get; } = "backlinks";
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, IDictionary<string, string>?>? GenerateDataFields { get; } = GetDataFields;
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
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 Func<XElement, string?> GetKey { get; } = (elem) => {
var margid = (string?)elem.Ancestors("marginal").First().Attribute("index");
if (String.IsNullOrWhiteSpace(margid)) return null;
return margid + _random.Next().ToString();
};
public static IDictionary<string, string>? GetDataFields(XElement element) {
var res = new Dictionary<string, string>();
var marg = element.Ancestors("marginal").First();
var index = (string?)marg.Attribute("index");
var letter = (string?)marg.Attribute("letter");
var page = (string?)marg.Attribute("page");
var line = (string?)marg.Attribute("line");
var refere = (string?)element.Attribute("ref");
var subref = (string?)element.Attribute("subref");
if (index == null || letter == null || (refere == null && subref == null)) return null;
if (subref != null) res.Add("ref", subref);
else res.Add("ref", refere!);
res.Add("index", index);
res.Add("letter", letter);
if(page != null) res.Add("page", page);
if(line != null) res.Add("line", line);
return res;
}
public static IDictionary<string, ILookup<string, CollectedItem>>? GetLookups(IEnumerable<CollectedItem> items) {
var res = new Dictionary<string, ILookup<string, CollectedItem>>();
var refs = items.Where(x => x["ref"] != null);
if (refs == null || !refs.Any()) return null;
res.Add("ref", refs.ToLookup(x => x["ref"])!);
return res;
}
}

View File

@@ -0,0 +1,160 @@
using System.Xml;
namespace HaWeb.Settings.XMLCollections;
using HaWeb.Models;
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 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 EditionCommentCollection : HaWeb.XMLParser.IXMLCollection {
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 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; } = 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 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 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; } = 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 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 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; } = 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;
}
}

View File

@@ -0,0 +1,21 @@
namespace HaWeb.Settings.XMLCollections;
using HaWeb.Models;
using System.Xml.Linq;
public class EditCollection : HaWeb.XMLParser.IXMLCollection {
public string Key { get; } = "edits";
public string[] xPath { get; } = new string[] { "/opus/edits/editreason", "/opus/data/edits/editreason" };
public Func<XElement, string?> GenerateKey { get; } = GetKey;
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, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
public bool Searchable { get; } = true;
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
else return null;
};
}

View File

@@ -0,0 +1,21 @@
namespace HaWeb.Settings.XMLCollections;
using HaWeb.Models;
using System.Xml.Linq;
public class LetterCollection : HaWeb.XMLParser.IXMLCollection {
public string Key { get; } = "letters";
public string[] xPath { get; } = new string[] { "/opus/data/document/letterText", "/opus/document/letterText" };
public Func<XElement, string?> GenerateKey { get; } = GetKey;
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, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
public bool Searchable { get; } = true;
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
else return null;
};
}

View File

@@ -0,0 +1,41 @@
namespace HaWeb.Settings.XMLCollections;
using HaWeb.Models;
using System.Xml.Linq;
public class MarginalCollection : HaWeb.XMLParser.IXMLCollection {
public string Key { get; } = "marginals";
public string[] xPath { get; } = new string[] { "/opus/data/marginalien/marginal", "/opus/marginalien/marginal" };
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; } = null;
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 Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
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 letter = (string?)element.Attribute("letter");
var page = (string?)element.Attribute("page");
var line = (string?)element.Attribute("line");
if (letter == null || page == null || line == null) return null;
res.Add("letter", letter);
res.Add("page", page);
res.Add("line", line);
return res;
}
public static IDictionary<string, ILookup<string, CollectedItem>>? GetLookups(IEnumerable<CollectedItem> items) {
var res = new Dictionary<string, ILookup<string, CollectedItem>>();
var letters = items.Where(x => x["letter"] != null && x["letter"]!.Count() > 0);
if (letters == null || !letters.Any()) return null;
res.Add("letter", letters.ToLookup(x => x["letter"]!));
return res;
}
}

View File

@@ -0,0 +1,21 @@
namespace HaWeb.Settings.XMLCollections;
using HaWeb.Models;
using System.Xml.Linq;
public class MetaCollection : HaWeb.XMLParser.IXMLCollection {
public string Key { get; } = "metas";
public string[] xPath { get; } = new string[] { "/opus/descriptions/letterDesc", "/opus/data/descriptions/letterDesc" };
public Func<XElement, string?> GenerateKey { get; } = GetKey;
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, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
public bool Searchable { get; } = false;
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("ref");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
return null;
};
}

View File

@@ -0,0 +1,57 @@
namespace HaWeb.Settings.XMLCollections;
using HaWeb.Models;
using System.Xml.Linq;
public class HandPersonCollection : HaWeb.XMLParser.IXMLCollection {
public string Key { get; } = "handpersons";
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, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
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 Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
return null;
};
}
public class PersonCollection : HaWeb.XMLParser.IXMLCollection {
public string Key { get; } = "persons";
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, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
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 Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
return null;
};
}
public class LocationCollection : HaWeb.XMLParser.IXMLCollection {
public string Key { get; } = "locations";
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, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
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 Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
return null;
};
}

View File

@@ -0,0 +1,21 @@
namespace HaWeb.Settings.XMLCollections;
using HaWeb.Models;
using System.Xml.Linq;
public class TraditionCollection : HaWeb.XMLParser.IXMLCollection {
public string Key { get; } = "traditions";
public string[] xPath { get; } = new string[] { "/opus/data/traditions/letterTradition", "/opus/traditions/letterTradition" };
public Func<XElement, string?> GenerateKey { get; } = GetKey;
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, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
public bool Searchable { get; } = true;
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("ref");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
return null;
};
}

View File

@@ -7,41 +7,12 @@ public class CommentRoot : HaWeb.XMLParser.IXMLRoot {
public string Type { get; } = "Register";
public string Prefix { get; } = "register";
public string[] XPathContainer { get; } = { ".//data//kommentare/kommcat", ".//kommentare/kommcat" };
public (
string Key,
string xPath,
Func<XElement, string?> GenerateKey,
Func<XElement, Dictionary<string, string[]>?>? GenerateDataFields,
Func<List<CollectedItem>, Dictionary<string, Lookup<string, CollectedItem>>?>? GroupingsGeneration,
Func<List<CollectedItem>, Dictionary<string, List<CollectedItem>>?>? SortingsGeneration,
bool Searchable
)[]? Collections { get; } = {
("comments-register", "/opus/data/kommentare/kommcat[@value='neuzeit']/kommentar", GetKey, null, null, null, true),
("comments-register", "/opus/kommentare/kommcat[@value='neuzeit']/kommentar", GetKey, null, null, null, true),
("subcomments-register", "/opus/data/kommentare/kommcat[@value='neuzeit']/kommentar/subsection", GetKey, null, null, null, true),
("subcomments-register", "/opus/kommentare/kommcat[@value='neuzeit']/kommentar/subsection", GetKey, null, null, null, true),
("comments-edition", "/opus/data/kommentare/kommcat[@value='editionen']/kommentar", GetKey, null, null, null, true),
("comments-edition", "/opus/kommentare/kommcat[@value='editionen']/kommentar", GetKey, null, null, null, true),
("comments-forschung", "/opus/data/kommentare/kommcat[@value='forschung']/kommentar", GetKey, null, null, null, true),
("comments-forschung", "/opus/kommentare/kommcat[@value='forschung']/kommentar", GetKey, null, null, null, true),
("comments-bibel", "/opus/data/kommentare/kommcat[@value='bibel']/kommentar", GetKey, null, null, null, false),
("comments-bibel", "/opus/kommentare/kommcat[@value='bibel']/kommentar", GetKey, null, null, null, false),
("subcomments-bibel", "/opus/data/kommentare/kommcat[@value='bibel']/kommentar/subsection", GetKey, null, null, null, false),
("subcomments-bibel", "/opus/kommentare/kommcat[@value='bibel']/kommentar/subsection", GetKey, null, null, null, false),
};
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "kommentar") return true;
else return false;
};
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 List<(string, string?)>? GenerateFields(XMLRootDocument document) {
return null;
}

View File

@@ -7,31 +7,12 @@ public class DescriptionsRoot : HaWeb.XMLParser.IXMLRoot {
public string Type { get; } = "Metadaten";
public string Prefix { get; } = "metadaten";
public string[] XPathContainer { get; } = { ".//data/descriptions", ".//descriptions" };
public (
string Key,
string xPath,
Func<XElement, string?> GenerateKey,
Func<XElement, Dictionary<string, string[]>?>? GenerateDataFields,
Func<List<CollectedItem>, Dictionary<string, Lookup<string, CollectedItem>>?>? GroupingsGeneration,
Func<List<CollectedItem>, Dictionary<string, List<CollectedItem>>?>? SortingsGeneration,
bool Searchable
)[]? Collections { get; } = {
("metas", "/opus/descriptions/letterDesc", GetKey, null, null, null, false),
("metas", "/opus/data/descriptions/letterDesc", GetKey, null, null, null, false)
};
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "letterDesc") return true;
return false;
};
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("ref");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
return null;
};
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
return null;
}

View File

@@ -8,31 +8,12 @@ public class DocumentRoot : HaWeb.XMLParser.IXMLRoot {
public string Type { get; } = "Brieftext";
public string Prefix { get; } = "brieftext";
public string[] XPathContainer { get; } = { ".//data/document", ".//document" };
public (
string Key,
string xPath,
Func<XElement, string?> GenerateKey,
Func<XElement, Dictionary<string, string[]>?>? GenerateDataFields,
Func<List<CollectedItem>, Dictionary<string, Lookup<string, CollectedItem>>?>? GroupingsGeneration,
Func<List<CollectedItem>, Dictionary<string, List<CollectedItem>>?>? SortingsGeneration,
bool Searchable
)[]? Collections { get; } = {
("letters", "/opus/data/document/letterText", GetKey, null, null, null, true),
("letters", "/opus/document/letterText", GetKey, null, null, null, true)
};
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "letterText") return true;
else return false;
};
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
else return null;
};
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
return null;
}

View File

@@ -7,31 +7,12 @@ public class EditsRoot : HaWeb.XMLParser.IXMLRoot {
public string Type { get; } = "Texteingriffe";
public string Prefix { get; } = "texteingriffe";
public string[] XPathContainer { get; } = { ".//data/edits", ".//edits" };
public (
string Key,
string xPath,
Func<XElement, string?> GenerateKey,
Func<XElement, Dictionary<string, string[]>?>? GenerateDataFields,
Func<List<CollectedItem>, Dictionary<string, Lookup<string, CollectedItem>>?>? GroupingsGeneration,
Func<List<CollectedItem>, Dictionary<string, List<CollectedItem>>?>? SortingsGeneration,
bool Searchable
)[]? Collections { get; } = {
("edits", "/data/edits/editreason", GetKey, null, null, null, true),
("edits", "/edits/editreason", GetKey, null, null, null, true)
};
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "editreason") return true;
else return false;
};
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
else return null;
};
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
return null;
}

View File

@@ -7,31 +7,12 @@ public class MarginalsRoot : HaWeb.XMLParser.IXMLRoot {
public string Type { get; } = "Stellenkommentar";
public string Prefix { get; } = "stellenkommentar";
public string[] XPathContainer { get; } = { ".//data/marginalien", ".//marginalien" };
public (
string Key,
string xPath,
Func<XElement, string?> GenerateKey,
Func<XElement, Dictionary<string, string[]>?>? GenerateDataFields,
Func<List<CollectedItem>, Dictionary<string, Lookup<string, CollectedItem>>?>? GroupingsGeneration,
Func<List<CollectedItem>, Dictionary<string, List<CollectedItem>>?>? SortingsGeneration,
bool Searchable
)[]? Collections { get; } = {
("marginals", "/data/marginalien/marginal", GetKey, null, null, null, true),
("marginals", "/marginalien/marginal", GetKey, null, null, null, true)
};
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "marginal") return true;
else return false;
};
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
else return null;
};
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
return null;
}

View File

@@ -7,33 +7,13 @@ public class ReferencesRoot : HaWeb.XMLParser.IXMLRoot {
public string Type { get; } = "Personen / Orte";
public string Prefix { get; } = "personenorte";
public string[] XPathContainer { get; } = { ".//data/definitions", ".//definitions" };
public (
string Key,
string xPath,
Func<XElement, string?> GenerateKey,
Func<XElement, Dictionary<string, string[]>?>? GenerateDataFields,
Func<List<CollectedItem>, Dictionary<string, Lookup<string, CollectedItem>>?>? GroupingsGeneration,
Func<List<CollectedItem>, Dictionary<string, List<CollectedItem>>?>? SortingsGeneration,
bool Searchable
)[]? Collections { get; } = {
("person-definitions", "/opus/data/definitions/personDefs/personDef", GetKey, null, null, null, false),
("person-definitions", "/opus/definitions/personDefs/personDef", GetKey, null, null, null, false),
("hand-definitions", "/opus/data/definitions/handDefs/handDef", GetKey, null, null, null, false),
("hand-definitions", "/opus/definitions/handDefs/handDef", GetKey, null, null, null, false),
("location-definitions", "/opus/data/definitions/locationDefs/locationDef", GetKey, null, null, null, false),
("location-definitions", "/opus/definitions/locationDefs/locationDef", GetKey, null, null, null, false)
};
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "personDefs" || elem.Name == "structureDefs" || elem.Name == "handDefs" || elem.Name == "locationDefs")
return true;
return false;
};
public static Func<XElement, string?> GetKey { get; } = (elem) => {
return elem.Attribute("index") != null ? elem.Attribute("index")!.Value : null;
};
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
return null;
}

View File

@@ -7,31 +7,12 @@ public class TraditionsRoot : HaWeb.XMLParser.IXMLRoot {
public string Type { get; } = "Überlieferung";
public string Prefix { get; } = "ueberlieferung";
public string[] XPathContainer { get; } = { ".//data/traditions", ".//traditions" };
public (
string Key,
string xPath,
Func<XElement, string?> GenerateKey,
Func<XElement, Dictionary<string, string[]>?>? GenerateDataFields,
Func<List<CollectedItem>, Dictionary<string, Lookup<string, CollectedItem>>?>? GroupingsGeneration,
Func<List<CollectedItem>, Dictionary<string, List<CollectedItem>>?>? SortingsGeneration,
bool Searchable
)[]? Collections { get; } = {
("tradition", "/opus/data/traditions/letterTradition", GetKey, null, null, null, true),
("tradition", "/opus/traditions/letterTradition", GetKey, null, null, null, true)
};
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "letterTradition") return true;
else return false;
};
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("ref");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
return null;
};
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
return null;
}