mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-29 17:15:31 +00:00
Search Index Build
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package xmlmodels
|
||||
|
||||
import "encoding/xml"
|
||||
import (
|
||||
"encoding/xml"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type AgentRef struct {
|
||||
XMLName xml.Name `xml:"akteur"`
|
||||
@@ -12,6 +15,19 @@ func (ar AgentRef) Name() string {
|
||||
return x.Name()
|
||||
}
|
||||
|
||||
func (ar AgentRef) Readable(lib *Library) map[string]interface{} {
|
||||
data := make(map[string]interface{})
|
||||
agent := lib.Agents.Item(ar.Ref)
|
||||
if agent != nil {
|
||||
data["AgentNames"] = agent.Names
|
||||
}
|
||||
|
||||
for k, v := range ar.Reference.Readable(lib) {
|
||||
data[k] = v
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
type IssueRef struct {
|
||||
XMLName xml.Name `xml:"stueck"`
|
||||
Nr int `xml:"nr,attr"`
|
||||
@@ -22,6 +38,25 @@ type IssueRef struct {
|
||||
Reference // Nicht im Schema
|
||||
}
|
||||
|
||||
func (ir IssueRef) Readable(lib *Library) map[string]interface{} {
|
||||
data := make(map[string]interface{})
|
||||
if ir.When.Year != 0 {
|
||||
data["IssueYear"] = ir.When.Year
|
||||
} else {
|
||||
return data
|
||||
}
|
||||
|
||||
issuekey := strconv.Itoa(ir.When.Year) + "-" + strconv.Itoa(ir.Nr)
|
||||
issue := lib.Issues.Item(issuekey)
|
||||
if issue != nil {
|
||||
data["IssueDate"] = issue.Datum.When.String()
|
||||
}
|
||||
|
||||
data["IssueNumber"] = ir.Nr
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func (ir IssueRef) Name() string {
|
||||
var x Issue
|
||||
return x.Name()
|
||||
@@ -32,6 +67,19 @@ type PlaceRef struct {
|
||||
Reference
|
||||
}
|
||||
|
||||
func (pr *PlaceRef) Readable(lib *Library) map[string]interface{} {
|
||||
data := make(map[string]interface{})
|
||||
place := lib.Places.Item(pr.Ref)
|
||||
if place != nil {
|
||||
data["PlaceNames"] = place.Names
|
||||
}
|
||||
|
||||
for k, v := range pr.Reference.Readable(lib) {
|
||||
data[k] = v
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (pr PlaceRef) Name() string {
|
||||
var x Place
|
||||
return x.Name()
|
||||
@@ -47,12 +95,45 @@ func (cr CategoryRef) Name() string {
|
||||
return x.Name()
|
||||
}
|
||||
|
||||
func (cr CategoryRef) Readable(lib *Library) map[string]interface{} {
|
||||
data := make(map[string]interface{})
|
||||
cat := lib.Categories.Item(cr.Ref)
|
||||
if cat != nil {
|
||||
data["CategoryNames"] = cat.Names
|
||||
}
|
||||
|
||||
for k, v := range cr.Reference.Readable(lib) {
|
||||
data[k] = v
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
type WorkRef struct {
|
||||
XMLName xml.Name `xml:"werk"`
|
||||
Page string `xml:"s,attr"`
|
||||
Reference
|
||||
}
|
||||
|
||||
func (wr WorkRef) Readable(lib *Library) map[string]interface{} {
|
||||
data := make(map[string]interface{})
|
||||
work := lib.Works.Item(wr.Ref)
|
||||
if work != nil {
|
||||
data["WorkTitle"] = work.Citation.Title
|
||||
data["WorkYear"] = work.Citation.Year
|
||||
data["WorkPreferredTitle"] = work.PreferredTitle
|
||||
prefs := make([]map[string]interface{}, len(work.AgentRefs))
|
||||
for k, v := range work.AgentRefs {
|
||||
prefs[k] = v.Readable(lib)
|
||||
}
|
||||
data["WorkAgents"] = prefs
|
||||
}
|
||||
|
||||
for k, v := range wr.Reference.Readable(lib) {
|
||||
data[k] = v
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (wr WorkRef) Name() string {
|
||||
var x Work
|
||||
return x.Name()
|
||||
|
||||
Reference in New Issue
Block a user