mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-28 16:55:32 +00:00
IDs: string -> int
This commit is contained in:
25
;
Normal file
25
;
Normal file
@@ -0,0 +1,25 @@
|
||||
package xmlmodels
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
type Inhalte struct {
|
||||
XMLName xml.Name `xml:"dataroot"`
|
||||
Inhalte []Inhalt `xml:"Inhalte"`
|
||||
}
|
||||
|
||||
type Inhalt struct {
|
||||
ID int `xml:"ID"`
|
||||
Titelangabe string `xml:"TITEL"`
|
||||
Urheberangabe string `xml:"AUTOR"`
|
||||
Band int `xml:"BAND"`
|
||||
Objektnummer string `xml:"OBJEKTNUMMER"`
|
||||
Incipit string `xml:"INCIPIT"`
|
||||
Paginierung string `xml:"PAGINIERUNG"`
|
||||
Typ Typ `xml:"TYP"`
|
||||
Anmerkungen string `xml:"ANMERKUNGEN"`
|
||||
Seite string `xml:"SEITE"`
|
||||
}
|
||||
|
||||
type Typ struct {
|
||||
Value []string `xml:"Value"`
|
||||
}
|
||||
@@ -92,11 +92,11 @@ func (a *Agent) SetAnnotation(annotation string) {
|
||||
a.Set(ANNOTATION_FIELD, annotation)
|
||||
}
|
||||
|
||||
func (a *Agent) MusenalmID() string {
|
||||
return a.GetString(MUSENALMID_FIELD)
|
||||
func (a *Agent) MusenalmID() int {
|
||||
return a.GetInt(MUSENALMID_FIELD)
|
||||
}
|
||||
|
||||
func (a *Agent) SetMusenalmID(id string) {
|
||||
func (a *Agent) SetMusenalmID(id int) {
|
||||
a.Set(MUSENALMID_FIELD, id)
|
||||
}
|
||||
|
||||
|
||||
@@ -173,11 +173,11 @@ func (c *Content) SetEntry(entry string) {
|
||||
c.Set(ENTRIES_TABLE, entry)
|
||||
}
|
||||
|
||||
func (c *Content) MusenalmID() string {
|
||||
return c.GetString(MUSENALMID_FIELD)
|
||||
func (c *Content) MusenalmID() int {
|
||||
return c.GetInt(MUSENALMID_FIELD)
|
||||
}
|
||||
|
||||
func (c *Content) SetMusenalmID(musenalmID string) {
|
||||
func (c *Content) SetMusenalmID(musenalmID int) {
|
||||
c.Set(MUSENALMID_FIELD, musenalmID)
|
||||
}
|
||||
|
||||
|
||||
@@ -200,11 +200,11 @@ func (e *Entry) SetDeprecated(deprecated Deprecated) {
|
||||
e.Set(MUSENALM_DEPRECATED_FIELD, deprecated)
|
||||
}
|
||||
|
||||
func (e *Entry) MusenalmID() string {
|
||||
return e.GetString(MUSENALMID_FIELD)
|
||||
func (e *Entry) MusenalmID() int {
|
||||
return e.GetInt(MUSENALMID_FIELD)
|
||||
}
|
||||
|
||||
func (e *Entry) SetMusenalmID(musenalmID string) {
|
||||
func (e *Entry) SetMusenalmID(musenalmID int) {
|
||||
e.Set(MUSENALMID_FIELD, musenalmID)
|
||||
}
|
||||
|
||||
|
||||
@@ -220,7 +220,6 @@ func FTS5ValuesContent(content *Content, entry *Entry, agents []*Agent) []string
|
||||
entrystring += "; [o.J.]"
|
||||
}
|
||||
|
||||
strconv.Itoa(entry.Year())
|
||||
return []string{
|
||||
content.PreferredTitle(),
|
||||
content.VariantTitle(),
|
||||
@@ -237,7 +236,7 @@ func FTS5ValuesContent(content *Content, entry *Entry, agents []*Agent) []string
|
||||
strconv.FormatFloat(content.Numbering(), 'f', 3, 64),
|
||||
entrystring,
|
||||
agentstring,
|
||||
content.MusenalmID(),
|
||||
strconv.Itoa(content.MusenalmID()),
|
||||
datatypes.DeleteTags(content.Annotation()),
|
||||
datatypes.DeleteTags(content.Comment()),
|
||||
}
|
||||
@@ -291,7 +290,7 @@ func FTS5ValuesEntry(entry *Entry, places []*Place, agents []*Agent, series []*S
|
||||
placestring,
|
||||
agentstring,
|
||||
seriesstring,
|
||||
entry.MusenalmID(),
|
||||
strconv.Itoa(entry.MusenalmID()),
|
||||
datatypes.DeleteTags(entry.Annotation()),
|
||||
datatypes.DeleteTags(entry.Comment()),
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ func SetCreatedUpdatedFields(fieldlist *core.FieldsList) {
|
||||
}
|
||||
|
||||
func SetMusenalmIDField(fieldlist *core.FieldsList) {
|
||||
fieldlist.Add(&core.TextField{Name: MUSENALMID_FIELD, Max: 64, Required: false})
|
||||
fieldlist.Add(&core.NumberField{Name: MUSENALMID_FIELD, Required: true})
|
||||
}
|
||||
|
||||
func SetEditorStateField(fieldlist *core.FieldsList) {
|
||||
|
||||
@@ -58,11 +58,11 @@ func (p *Place) SetAnnotation(annotation string) {
|
||||
p.Set(ANNOTATION_FIELD, annotation)
|
||||
}
|
||||
|
||||
func (p *Place) MusenalmID() string {
|
||||
return p.GetString(MUSENALMID_FIELD)
|
||||
func (p *Place) MusenalmID() int {
|
||||
return p.GetInt(MUSENALMID_FIELD)
|
||||
}
|
||||
|
||||
func (p *Place) SetMusenalmID(id string) {
|
||||
func (p *Place) SetMusenalmID(id int) {
|
||||
p.Set(MUSENALMID_FIELD, id)
|
||||
}
|
||||
|
||||
|
||||
@@ -56,11 +56,11 @@ func (s *Series) SetAnnotation(annotation string) {
|
||||
s.Set(ANNOTATION_FIELD, annotation)
|
||||
}
|
||||
|
||||
func (s *Series) MusenalmID() string {
|
||||
return s.GetString(MUSENALMID_FIELD)
|
||||
func (s *Series) MusenalmID() int {
|
||||
return s.GetInt(MUSENALMID_FIELD)
|
||||
}
|
||||
|
||||
func (s *Series) SetMusenalmID(id string) {
|
||||
func (s *Series) SetMusenalmID(id int) {
|
||||
s.Set(MUSENALMID_FIELD, id)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,15 +21,15 @@ func init() {
|
||||
|
||||
adb.Reihen = xmlmodels.SanitizeReihen(adb.Reihen, adb.Relationen_Bände_Reihen)
|
||||
|
||||
var agentsmap map[string]*dbmodels.Agent
|
||||
var agentsmap map[int]*dbmodels.Agent
|
||||
var placesmap map[string]*dbmodels.Place
|
||||
var placesmapid map[string]*dbmodels.Place
|
||||
var seriesmap map[string]*dbmodels.Series
|
||||
var entriesmap map[string]*dbmodels.Entry
|
||||
var seriesmap map[int]*dbmodels.Series
|
||||
var entriesmap map[int]*dbmodels.Entry
|
||||
var entriesmapid map[string]*dbmodels.Entry
|
||||
var seriesmapid map[string]*dbmodels.Series
|
||||
var agentsmapid map[string]*dbmodels.Agent
|
||||
var contentsmap map[string]*dbmodels.Content
|
||||
var contentsmap map[int]*dbmodels.Content
|
||||
var r_entries_series map[string][]*dbmodels.REntriesSeries
|
||||
var r_entries_agents map[string][]*dbmodels.REntriesAgents
|
||||
var r_contents_agents map[string][]*dbmodels.RContentsAgents
|
||||
@@ -50,7 +50,7 @@ func init() {
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
agentsmap = datatypes.MakeMap(agents, func(record *dbmodels.Agent) string { return record.MusenalmID() })
|
||||
agentsmap = datatypes.MakeMap(agents, func(record *dbmodels.Agent) int { return record.MusenalmID() })
|
||||
agentsmapid = datatypes.MakeMap(agents, func(record *dbmodels.Agent) string { return record.Id })
|
||||
wg.Done()
|
||||
}()
|
||||
@@ -79,7 +79,7 @@ func init() {
|
||||
app.Logger().Error("Error saving record", "error", err, "record", record)
|
||||
}
|
||||
}
|
||||
seriesmap = datatypes.MakeMap(series, func(record *dbmodels.Series) string { return record.MusenalmID() })
|
||||
seriesmap = datatypes.MakeMap(series, func(record *dbmodels.Series) int { return record.MusenalmID() })
|
||||
seriesmapid = datatypes.MakeMap(series, func(record *dbmodels.Series) string { return record.Id })
|
||||
wg.Done()
|
||||
}()
|
||||
@@ -96,7 +96,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
entriesmap = datatypes.MakeMap(entries, func(record *dbmodels.Entry) string { return record.MusenalmID() })
|
||||
entriesmap = datatypes.MakeMap(entries, func(record *dbmodels.Entry) int { return record.MusenalmID() })
|
||||
entriesmapid = datatypes.MakeMap(entries, func(record *dbmodels.Entry) string { return record.Id })
|
||||
|
||||
wg.Add(2)
|
||||
@@ -125,7 +125,7 @@ func init() {
|
||||
app.Logger().Error("Error saving record", "error", err, "record", record)
|
||||
}
|
||||
}
|
||||
contentsmap = datatypes.MakeMap(contents, func(record *dbmodels.Content) string { return record.MusenalmID() })
|
||||
contentsmap = datatypes.MakeMap(contents, func(record *dbmodels.Content) int { return record.MusenalmID() })
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package seed
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@@ -19,7 +20,7 @@ const NO_TITLE = "[No Title]"
|
||||
func RecordsFromInhalte(
|
||||
app core.App,
|
||||
inhalte xmlmodels.Inhalte,
|
||||
entries map[string]*dbmodels.Entry,
|
||||
entries map[int]*dbmodels.Entry,
|
||||
) ([]*dbmodels.Content, error) {
|
||||
collection, err := app.FindCollectionByNameOrId(dbmodels.CONTENTS_TABLE)
|
||||
records := make([]*dbmodels.Content, 0, len(inhalte.Inhalte))
|
||||
@@ -127,9 +128,9 @@ func commatizeArray(array []string) string {
|
||||
return array[0]
|
||||
}
|
||||
|
||||
func getImages(path string) map[string][]string {
|
||||
func getImages(path string) map[int][]string {
|
||||
/// FIXED: there is a bug somewhere, where files ending with numbers after a comma (",001") etc dont get added
|
||||
ret := make(map[string][]string)
|
||||
ret := make(map[int][]string)
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
return ret
|
||||
}
|
||||
@@ -142,10 +143,15 @@ func getImages(path string) map[string][]string {
|
||||
if len(basesplit) >= 3 {
|
||||
commaseperatorsplit := strings.Split(basesplit[2], ",")
|
||||
id := commaseperatorsplit[0]
|
||||
if _, ok := ret[id]; !ok {
|
||||
ret[id] = make([]string, 0)
|
||||
no, err := strconv.Atoi(id)
|
||||
if err != nil {
|
||||
slog.Error("Error parsing id", "error", err, "id", id)
|
||||
return nil
|
||||
}
|
||||
ret[id] = append(ret[id], path)
|
||||
if _, ok := ret[no]; !ok {
|
||||
ret[no] = make([]string, 0)
|
||||
}
|
||||
ret[no] = append(ret[no], path)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
func RecordsFromBände(
|
||||
app core.App,
|
||||
adb xmlmodels.AccessDB,
|
||||
// INFO: this is a string map, bc it's not by ID but by place name
|
||||
places map[string]*dbmodels.Place,
|
||||
) ([]*dbmodels.Entry, error) {
|
||||
collection, err := app.FindCollectionByNameOrId(dbmodels.ENTRIES_TABLE)
|
||||
@@ -31,12 +32,12 @@ func RecordsFromBände(
|
||||
}
|
||||
|
||||
// INFO: lets make some maps to speed this up
|
||||
omap := datatypes.MakeMap(adb.Orte.Orte, func(o xmlmodels.Ort) string { return o.ID })
|
||||
omap := datatypes.MakeMap(adb.Orte.Orte, func(o xmlmodels.Ort) int { return o.ID })
|
||||
relmap := datatypes.MakeMultiMap(
|
||||
adb.Relationen_Bände_Reihen.Relationen,
|
||||
func(r xmlmodels.Relation_Band_Reihe) string { return r.Band },
|
||||
func(r xmlmodels.Relation_Band_Reihe) int { return r.Band },
|
||||
)
|
||||
rmap := datatypes.MakeMap(adb.Reihen.Reihen, func(r xmlmodels.Reihe) string { return r.ID })
|
||||
rmap := datatypes.MakeMap(adb.Reihen.Reihen, func(r xmlmodels.Reihe) int { return r.ID })
|
||||
|
||||
for i := 0; i < len(adb.Bände.Bände); i++ {
|
||||
band := adb.Bände.Bände[i]
|
||||
@@ -86,8 +87,8 @@ func RecordsFromBände(
|
||||
func handlePreferredTitleEntry(
|
||||
record *dbmodels.Entry,
|
||||
band xmlmodels.Band,
|
||||
rmap map[string]xmlmodels.Reihe,
|
||||
rrelmap map[string][]xmlmodels.Relation_Band_Reihe,
|
||||
rmap map[int]xmlmodels.Reihe,
|
||||
rrelmap map[int][]xmlmodels.Relation_Band_Reihe,
|
||||
) {
|
||||
rels := rrelmap[band.ID]
|
||||
if len(rels) == 0 {
|
||||
@@ -120,7 +121,7 @@ func handlePreferredTitleEntry(
|
||||
func handleOrte(
|
||||
record *dbmodels.Entry,
|
||||
band xmlmodels.Band,
|
||||
orte map[string]xmlmodels.Ort,
|
||||
orte map[int]xmlmodels.Ort,
|
||||
app core.App,
|
||||
ocollection *core.Collection,
|
||||
places map[string]*dbmodels.Place,
|
||||
|
||||
@@ -16,7 +16,7 @@ func ItemsFromBändeAndBIBLIO(
|
||||
app core.App,
|
||||
entries xmlmodels.Bände,
|
||||
biblio map[int]xmlmodels.BIBLIOEintrag,
|
||||
entriesmap map[string]*dbmodels.Entry,
|
||||
entriesmap map[int]*dbmodels.Entry,
|
||||
) ([]*dbmodels.Item, error) {
|
||||
collection, err := app.FindCollectionByNameOrId(dbmodels.ITEMS_TABLE)
|
||||
records := make([]*dbmodels.Item, 0, len(entries.Bände))
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
func RecordsFromRelationInhalteAkteure(
|
||||
app core.App,
|
||||
relations xmlmodels.Relationen_Inhalte_Akteure,
|
||||
contents map[string]*dbmodels.Content,
|
||||
agents map[string]*dbmodels.Agent,
|
||||
contents map[int]*dbmodels.Content,
|
||||
agents map[int]*dbmodels.Agent,
|
||||
) ([]*dbmodels.RContentsAgents, error) {
|
||||
records := make([]*dbmodels.RContentsAgents, 0, len(relations.Relationen))
|
||||
collection, err := app.FindCollectionByNameOrId(dbmodels.RelationTableName(dbmodels.CONTENTS_TABLE, dbmodels.AGENTS_TABLE))
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
func RecordsFromRelationBändeAkteure(
|
||||
app core.App,
|
||||
relations xmlmodels.Relationen_Bände_Akteure,
|
||||
entries map[string]*dbmodels.Entry,
|
||||
agents map[string]*dbmodels.Agent,
|
||||
entries map[int]*dbmodels.Entry,
|
||||
agents map[int]*dbmodels.Agent,
|
||||
) ([]*dbmodels.REntriesAgents, error) {
|
||||
records := make([]*dbmodels.REntriesAgents, 0, len(relations.Relationen))
|
||||
collection, err := app.FindCollectionByNameOrId(dbmodels.RelationTableName(dbmodels.ENTRIES_TABLE, dbmodels.AGENTS_TABLE))
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
func RecordsFromRelationBändeReihen(
|
||||
app core.App,
|
||||
relations xmlmodels.Relationen_Bände_Reihen,
|
||||
series map[string]*dbmodels.Series,
|
||||
entries map[string]*dbmodels.Entry,
|
||||
series map[int]*dbmodels.Series,
|
||||
entries map[int]*dbmodels.Entry,
|
||||
) ([]*dbmodels.REntriesSeries, error) {
|
||||
records := make([]*dbmodels.REntriesSeries, 0, len(relations.Relationen))
|
||||
collection, err := app.FindCollectionByNameOrId(dbmodels.RelationTableName(dbmodels.ENTRIES_TABLE, dbmodels.SERIES_TABLE))
|
||||
|
||||
@@ -8,7 +8,7 @@ type Akteure struct {
|
||||
}
|
||||
|
||||
type Akteur struct {
|
||||
ID string `xml:"ID"`
|
||||
ID int `xml:"ID"`
|
||||
Name string `xml:"NAME"`
|
||||
Körperschaft bool `xml:"ORGANISATION"`
|
||||
Beruf string `xml:"BERUF"`
|
||||
|
||||
@@ -8,7 +8,7 @@ type Bände struct {
|
||||
}
|
||||
|
||||
type Band struct {
|
||||
ID string `xml:"ID"`
|
||||
ID int `xml:"ID"`
|
||||
BiblioID int `xml:"BIBLIO-ID"`
|
||||
Titelangabe string `xml:"TITEL"`
|
||||
Ortsangabe string `xml:"ORT-ALT"`
|
||||
@@ -26,7 +26,7 @@ type Band struct {
|
||||
}
|
||||
|
||||
type Ortverweis struct {
|
||||
Value string `xml:"Value"`
|
||||
Value int `xml:"Value"`
|
||||
}
|
||||
|
||||
type Status struct {
|
||||
|
||||
@@ -8,10 +8,10 @@ type Inhalte struct {
|
||||
}
|
||||
|
||||
type Inhalt struct {
|
||||
ID string `xml:"ID"`
|
||||
ID int `xml:"ID"`
|
||||
Titelangabe string `xml:"TITEL"`
|
||||
Urheberangabe string `xml:"AUTOR"`
|
||||
Band string `xml:"BAND"`
|
||||
Band int `xml:"BAND"`
|
||||
Objektnummer string `xml:"OBJEKTNUMMER"`
|
||||
Incipit string `xml:"INCIPIT"`
|
||||
Paginierung string `xml:"PAGINIERUNG"`
|
||||
|
||||
@@ -8,7 +8,7 @@ type Orte struct {
|
||||
}
|
||||
|
||||
type Ort struct {
|
||||
ID string `xml:"ID"`
|
||||
ID int `xml:"ID"`
|
||||
Name string `xml:"NAME"`
|
||||
Fiktiv bool `xml:"FIKTIV"`
|
||||
Anmerkungen string `xml:"Anmerkungen"`
|
||||
|
||||
@@ -8,7 +8,7 @@ type Reihentitel struct {
|
||||
}
|
||||
|
||||
type Reihe struct {
|
||||
ID string `xml:"ID"`
|
||||
ID int `xml:"ID"`
|
||||
Titel string `xml:"NAME"`
|
||||
Sortiername string `xml:"SORTIERNAME"`
|
||||
Nachweis string `xml:"NACHWEIS"`
|
||||
@@ -16,7 +16,7 @@ type Reihe struct {
|
||||
}
|
||||
|
||||
func SanitizeReihen(reihentitel Reihentitel, relationen Relationen_Bände_Reihen) Reihentitel {
|
||||
m := make(map[string]bool)
|
||||
m := make(map[int]bool)
|
||||
o := Reihentitel{
|
||||
Reihen: []Reihe{},
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ type Relationen_Bände_Reihen struct {
|
||||
}
|
||||
|
||||
type Relation_Band_Reihe struct {
|
||||
ID string `xml:"ID"`
|
||||
Band string `xml:"BAND"`
|
||||
ID int `xml:"ID"`
|
||||
Band int `xml:"BAND"`
|
||||
Relation string `xml:"BEZIEHUNG"`
|
||||
Reihe string `xml:"REIHE"`
|
||||
Reihe int `xml:"REIHE"`
|
||||
}
|
||||
|
||||
type Relationen_Inhalte_Akteure struct {
|
||||
@@ -20,10 +20,10 @@ type Relationen_Inhalte_Akteure struct {
|
||||
}
|
||||
|
||||
type Relation_Inhalt_Akteur struct {
|
||||
ID string `xml:"ID"`
|
||||
Inhalt string `xml:"INHALT"`
|
||||
ID int `xml:"ID"`
|
||||
Inhalt int `xml:"INHALT"`
|
||||
Relation string `xml:"BEZIEHUNG"`
|
||||
Akteur string `xml:"AKTEUR"`
|
||||
Akteur int `xml:"AKTEUR"`
|
||||
}
|
||||
|
||||
type Relationen_Bände_Akteure struct {
|
||||
@@ -32,8 +32,8 @@ type Relationen_Bände_Akteure struct {
|
||||
}
|
||||
|
||||
type Relation_Band_Akteur struct {
|
||||
ID string `xml:"ID"`
|
||||
Band string `xml:"BAND"`
|
||||
ID int `xml:"ID"`
|
||||
Band int `xml:"BAND"`
|
||||
Relation string `xml:"BEZIEHUNG"`
|
||||
Akteur string `xml:"AKTEUR"`
|
||||
Akteur int `xml:"AKTEUR"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user