Skip to content

Commit

Permalink
fix issue 1360 (#1362)
Browse files Browse the repository at this point in the history
* fix issue 1360

* fix issue 1360: Show persistent identifiers of manually created datasets
  • Loading branch information
nicolasfranck authored Jan 30, 2024
1 parent fd851ef commit 51ae750
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
18 changes: 18 additions & 0 deletions frontoffice/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/caltechlibrary/doitools"
"github.com/iancoleman/strcase"
"github.com/ugent-library/biblio-backoffice/identifiers"
"github.com/ugent-library/biblio-backoffice/models"
"github.com/ugent-library/biblio-backoffice/repositories"
"github.com/ugent-library/biblio-backoffice/validation"
Expand Down Expand Up @@ -171,6 +172,12 @@ type JCR struct {
PrevCategoryQuartile *int `json:"prev_category_quartile,omitempty"`
}

type Identifier struct {
Type string `json:"type"`
Value string `json:"value"`
URL string `json:"url,omitempty"`
}

type Record struct {
ID string `json:"_id"`
Abstract []string `json:"abstract,omitempty"`
Expand Down Expand Up @@ -206,6 +213,7 @@ type Record struct {
FirstAuthor []Person `json:"first_author,omitempty"`
Format []string `json:"format,omitempty"`
Handle string `json:"handle,omitempty"`
Identifier []Identifier `json:"identifier,omitempty"`
ISBN []string `json:"isbn,omitempty"`
ISSN []string `json:"issn,omitempty"`
Issue string `json:"issue,omitempty"`
Expand Down Expand Up @@ -916,6 +924,16 @@ func MapDataset(d *models.Dataset, repo *repositories.Repo) *Record {
}
}

for typ, values := range d.Identifiers {
for _, value := range values {
rec.Identifier = append(rec.Identifier, Identifier{
Type: typ,
Value: value,
URL: identifiers.Resolve(typ, value),
})
}
}

if d.Format != nil {
rec.Format = append(rec.Format, d.Format...)
}
Expand Down
15 changes: 15 additions & 0 deletions identifiers/ega.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package identifiers

type EGAType struct{}

func (i *EGAType) Validate(id string) bool {
return true
}

func (i *EGAType) Normalize(id string) (string, error) {
return id, nil
}

func (i *EGAType) Resolve(id string) string {
return "https://ega-archive.org/datasets/" + id
}
2 changes: 2 additions & 0 deletions identifiers/identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var (
DOI = &DOIType{}
ENA = &ENAType{}
ENABioProject = &ENABioProjectType{}
EGA = &EGAType{}
Ensembl = &EnsemblType{}
Handle = &HandleType{}
PubMed = &PubMedType{}
Expand All @@ -14,6 +15,7 @@ var (
var types = map[string]Type{
"BioStudies": BioStudies,
"DOI": DOI,
"EGA": EGA,
"ENA": ENA,
"ENABioProject": ENABioProject,
"Ensembl": Ensembl,
Expand Down
3 changes: 3 additions & 0 deletions locales/en/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -2348,6 +2348,9 @@ msgstr "DOI"
msgid "identifier.ENA"
msgstr "ENA"

msgid "identifier.EGA"
msgstr "EGA"

msgid "identifier.ENABioProject"
msgstr "ENA BioProject"

Expand Down
1 change: 1 addition & 0 deletions vocabularies/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ var Map = map[string][]string{
"dataset_identifier_types": {
"DOI",
"BioStudies",
"EGA",
"ENA",
"ENABioProject",
"Ensembl",
Expand Down

0 comments on commit 51ae750

Please sign in to comment.