mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-28 16:55:32 +00:00
Places, Agents, Serials, Entries
This commit is contained in:
100
xmlmodels/accessdb.go
Normal file
100
xmlmodels/accessdb.go
Normal file
@@ -0,0 +1,100 @@
|
||||
package xmlmodels
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/musenalm/helpers/datatypes"
|
||||
)
|
||||
|
||||
type AccessDB struct {
|
||||
Orte *Orte
|
||||
Akteure *Akteure
|
||||
Reihen *Reihentitel
|
||||
Bände *Bände
|
||||
Inhalte *Inhalte
|
||||
Relationen_Bände_Akteure *Relationen_Bände_Akteure
|
||||
Relationen_Inhalte_Akteure *Relationen_Inhalte_Akteure
|
||||
Relationen_Bände_Reihen *Relationen_Bände_Reihen
|
||||
BIBLIO *map[int]BIBLIOEintrag
|
||||
}
|
||||
|
||||
func ReadAccessDB(path string) (*AccessDB, error) {
|
||||
var Akteure Akteure
|
||||
var Reihentitel Reihentitel
|
||||
var Bände Bände
|
||||
var Inhalte Inhalte
|
||||
var Orte Orte
|
||||
var Relationen_Bände_Akteure Relationen_Bände_Akteure
|
||||
var Relationen_Bände_Reihen Relationen_Bände_Reihen
|
||||
var Relationen_Inhalte_Akteure Relationen_Inhalte_Akteure
|
||||
var BIBLIO BIBLIOEinträge
|
||||
|
||||
if err := unmarshalFile(path+"Akteure.xml", &Akteure); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := unmarshalFile(path+"Orte.xml", &Orte); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := unmarshalFile(path+"Reihen.xml", &Reihentitel); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := unmarshalFile(path+"Baende.xml", &Bände); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := unmarshalFile(path+"Inhalte.xml", &Inhalte); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := unmarshalFile(path+"_RELATION_BaendeAkteure.xml", &Relationen_Bände_Akteure); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := unmarshalFile(path+"_RELATION_BaendeReihen.xml", &Relationen_Bände_Reihen); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := unmarshalFile(path+"_RELATION_InhalteAkteure.xml", &Relationen_Inhalte_Akteure); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := unmarshalFile(path+"GM-BIBLIO.xml", &BIBLIO); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var BIBLIOM = datatypes.MakeMap(BIBLIO.Einträge, func(e BIBLIOEintrag) int { return e.Nummer })
|
||||
|
||||
lib := AccessDB{
|
||||
Orte: &Orte,
|
||||
Akteure: &Akteure,
|
||||
Reihen: &Reihentitel,
|
||||
Bände: &Bände,
|
||||
Inhalte: &Inhalte,
|
||||
Relationen_Bände_Akteure: &Relationen_Bände_Akteure,
|
||||
Relationen_Bände_Reihen: &Relationen_Bände_Reihen,
|
||||
Relationen_Inhalte_Akteure: &Relationen_Inhalte_Akteure,
|
||||
BIBLIO: &BIBLIOM,
|
||||
}
|
||||
|
||||
return &lib, nil
|
||||
}
|
||||
|
||||
func unmarshalFile[T any](filename string, data *T) error {
|
||||
xmlFile, err := os.Open(filename)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return err
|
||||
}
|
||||
fmt.Println("Successfully opened " + filename)
|
||||
defer xmlFile.Close()
|
||||
byteValue, _ := io.ReadAll(xmlFile)
|
||||
xml.Unmarshal(byteValue, data)
|
||||
|
||||
return nil
|
||||
}
|
||||
20
xmlmodels/akteure.go
Normal file
20
xmlmodels/akteure.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package xmlmodels
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
type Akteure struct {
|
||||
XMLName xml.Name `xml:"dataroot"`
|
||||
Akteure []Akteur `xml:"Akteure"`
|
||||
}
|
||||
|
||||
type Akteur struct {
|
||||
ID string `xml:"ID"`
|
||||
Name string `xml:"NAME"`
|
||||
Körperschaft bool `xml:"ORGANISATION"`
|
||||
Beruf string `xml:"BERUF"`
|
||||
Nachweis string `xml:"NACHWEIS"`
|
||||
Pseudonyme string `xml:"PSEUDONYM"`
|
||||
Lebensdaten string `xml:"LEBENSDATEN"`
|
||||
Anmerkungen string `xml:"ANMERKUNGEN"`
|
||||
GND string `xml:"GND"`
|
||||
}
|
||||
34
xmlmodels/baende.go
Normal file
34
xmlmodels/baende.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package xmlmodels
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
type Bände struct {
|
||||
XMLName xml.Name `xml:"dataroot"`
|
||||
Bände []Band `xml:"Baende"`
|
||||
}
|
||||
|
||||
type Band struct {
|
||||
ID string `xml:"ID"`
|
||||
BiblioID int `xml:"BIBLIO-ID"`
|
||||
Titelangabe string `xml:"TITEL"`
|
||||
Ortsangabe string `xml:"ORT-ALT"`
|
||||
Orte []Ortverweis `xml:"ORTE"`
|
||||
Verantwortlichkeitsangabe string `xml:"HERAUSGEBER"`
|
||||
Jahr int `xml:"JAHR"`
|
||||
Gesichtet bool `xml:"AUTOPSIE"`
|
||||
Erfasst bool `xml:"ERFASST"`
|
||||
Nachweis string `xml:"NACHWEIS"`
|
||||
Struktur string `xml:"STRUKTUR"`
|
||||
Norm string `xml:"NORM"`
|
||||
Status Status `xml:"STATUS"`
|
||||
Anmerkungen string `xml:"ANMERKUNGEN"`
|
||||
ReihentitelALT string `xml:"REIHENTITEL-ALT"`
|
||||
}
|
||||
|
||||
type Ortverweis struct {
|
||||
Value string `xml:"Value"`
|
||||
}
|
||||
|
||||
type Status struct {
|
||||
Value []string `xml:"Value"`
|
||||
}
|
||||
32
xmlmodels/biblio.go
Normal file
32
xmlmodels/biblio.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package xmlmodels
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
type BIBLIOEinträge struct {
|
||||
XMLName xml.Name `xml:"dataroot"`
|
||||
Einträge []BIBLIOEintrag `xml:"GM-BIBLIO"`
|
||||
}
|
||||
|
||||
type BIBLIOEintrag struct {
|
||||
Nummer int `xml:"NUMMER"`
|
||||
Eingetragen bool `xml:"EINGETRAGEN_x003F_"`
|
||||
Gesucht bool `xml:"GESUCHT_x003F_"`
|
||||
Autor string `xml:"AUTOR"`
|
||||
Herausgeber string `xml:"HERAUSGEBER"`
|
||||
Titel string `xml:"TITEL"`
|
||||
Untertitel string `xml:"UNTERTITEL"`
|
||||
ErschienenIn string `xml:"ERSCHIENEN_x0020_IN"`
|
||||
Ort string `xml:"ORT"`
|
||||
Jahr int `xml:"JAHR"`
|
||||
Nachweis string `xml:"NACHWEIS"`
|
||||
Kurztitel string `xml:"KURZTITEL"`
|
||||
Zugehörig string `xml:"ZUGEHöRIG"`
|
||||
VorhandenAls string `xml:"VORHANDEN_x0020_ALS"`
|
||||
Inhalt string `xml:"INHALT"`
|
||||
Zustand string `xml:"ZUSTAND"`
|
||||
NotizÄusseres string `xml:"NOTIZ_x0020_ÄUSSERES"`
|
||||
NotizInhalt string `xml:"NOTIZ_x0020_INHALT"`
|
||||
Anmerkungen string `xml:"ALLGEMEINE_x0020_BEMERKUNG"`
|
||||
Standort string `xml:"STANDORT"`
|
||||
Unklar bool `xml:"UNKLAR"`
|
||||
}
|
||||
25
xmlmodels/inhalte.go
Normal file
25
xmlmodels/inhalte.go
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 string `xml:"ID"`
|
||||
Titelangabe string `xml:"TITEL"`
|
||||
Urheberangabe string `xml:"AUTOR"`
|
||||
Band string `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"`
|
||||
}
|
||||
15
xmlmodels/orte.go
Normal file
15
xmlmodels/orte.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package xmlmodels
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
type Orte struct {
|
||||
XMLName xml.Name `xml:"dataroot"`
|
||||
Orte []Ort `xml:"Orte"`
|
||||
}
|
||||
|
||||
type Ort struct {
|
||||
ID string `xml:"ID"`
|
||||
Name string `xml:"NAME"`
|
||||
Fiktiv bool `xml:"FIKTIV"`
|
||||
Anmerkungen string `xml:"Anmerkungen"`
|
||||
}
|
||||
35
xmlmodels/reihen.go
Normal file
35
xmlmodels/reihen.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package xmlmodels
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
type Reihentitel struct {
|
||||
XMLName xml.Name `xml:"dataroot"`
|
||||
Reihen []Reihe `xml:"Reihen"`
|
||||
}
|
||||
|
||||
type Reihe struct {
|
||||
ID string `xml:"ID"`
|
||||
Titel string `xml:"NAME"`
|
||||
Sortiername string `xml:"SORTIERNAME"`
|
||||
Nachweis string `xml:"NACHWEIS"`
|
||||
Anmerkungen string `xml:"Anmerkungen"`
|
||||
}
|
||||
|
||||
func SanitizeReihen(reihentitel Reihentitel, relationen Relationen_Bände_Reihen) Reihentitel {
|
||||
m := make(map[string]bool)
|
||||
o := Reihentitel{
|
||||
Reihen: []Reihe{},
|
||||
}
|
||||
|
||||
for _, r := range relationen.Relationen {
|
||||
m[r.Reihe] = true
|
||||
}
|
||||
|
||||
for i := 0; i < len(reihentitel.Reihen); i++ {
|
||||
if _, ok := m[reihentitel.Reihen[i].ID]; ok {
|
||||
o.Reihen = append(o.Reihen, reihentitel.Reihen[i])
|
||||
}
|
||||
}
|
||||
|
||||
return o
|
||||
}
|
||||
39
xmlmodels/relationen.go
Normal file
39
xmlmodels/relationen.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package xmlmodels
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
type Relationen_Bände_Reihen struct {
|
||||
XMLName xml.Name `xml:"dataroot"`
|
||||
Relationen []Relation_Band_Reihe `xml:"_x002A_RELATION_BaendeReihen"`
|
||||
}
|
||||
|
||||
type Relation_Band_Reihe struct {
|
||||
ID string `xml:"ID"`
|
||||
Band string `xml:"BAND"`
|
||||
Relation string `xml:"BEZIEHUNG"`
|
||||
Reihe string `xml:"REIHE"`
|
||||
}
|
||||
|
||||
type Relationen_Inhalte_Akteure struct {
|
||||
XMLName xml.Name `xml:"dataroot"`
|
||||
Relationen []Relation_Inhalt_akteur `xml:"_x002A_RELATION_InhalteAkteure"`
|
||||
}
|
||||
|
||||
type Relation_Inhalt_akteur struct {
|
||||
ID string `xml:"ID"`
|
||||
Band string `xml:"INHALT"`
|
||||
Relation string `xml:"BEZIEHUNG"`
|
||||
Akteur string `xml:"AKTEUR"`
|
||||
}
|
||||
|
||||
type Relationen_Bände_Akteure struct {
|
||||
XMLName xml.Name `xml:"dataroot"`
|
||||
Relationen []Relation_Band_Akteur `xml:"_x002A_RELATION_BaendeAkteure"`
|
||||
}
|
||||
|
||||
type Relation_Band_Akteur struct {
|
||||
ID string `xml:"ID"`
|
||||
Band string `xml:"BAND"`
|
||||
Relation string `xml:"BEZIEHUNG"`
|
||||
Akteur string `xml:"AKTEUR"`
|
||||
}
|
||||
3
xmlmodels/xmldata.go
Normal file
3
xmlmodels/xmldata.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package xmlmodels
|
||||
|
||||
const DATA_PATH = "data/"
|
||||
Reference in New Issue
Block a user