Skip to content

Commit

Permalink
Fixup agents and field_related_item
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Sep 3, 2024
1 parent 3f7196f commit 9b88190
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ func readCSVWithJSONTags(filePath string) (map[string]bool, []map[string][]strin
var rows []map[string][]string
newHeaders := map[string]bool{}
linkedAgents = append(linkedAgents, []string{
"name",
"vid",
"term_name",
"field_contributor_status",
"field_relationships",
"field_email",
Expand Down Expand Up @@ -97,14 +96,21 @@ func readCSVWithJSONTags(filePath string) (map[string]bool, []map[string][]strin
if len(name) < 4 {
return nil, nil, fmt.Errorf("poorly formatted contributor: %s %v", str, err)
}
linkedAgents = append(linkedAgents, []string{
agent := []string{
strings.Join(name[3:], ":"),
"person",
c.Status,
fmt.Sprintf("schema:worksFor:corporate_body:%s", c.Institution),
c.Email,
fmt.Sprintf(`{"attr0": "orcid", "value": "%s"}`, c.Orcid),
})
}
if c.Institution == "" {
agent[2] = ""
}
if c.Orcid == "" {
agent[4] = ""
}

linkedAgents = append(linkedAgents, agent)
}

case "field_add_coverpage", "published":
Expand Down Expand Up @@ -206,7 +212,9 @@ func readCSVWithJSONTags(filePath string) (map[string]bool, []map[string][]strin
components := strings.Split(column, ".vid=")
column = components[0]
str = fmt.Sprintf("%s:%s", components[1], str)
// TODO case "field_related_item.title":
case "field_related_item.title":
column = "field_related_item"
str = fmt.Sprintf(`{"title": "%s"}`, str)
// TODO case "field_related_item.identifier_type=issn":
case "file":
str = strings.ReplaceAll(str, `\`, `/`)
Expand Down

0 comments on commit 9b88190

Please sign in to comment.