irdmtools

package module
v0.0.76 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2024 License: BSD-3-Clause Imports: 27 Imported by: 0

README

Institutional Repository Data Management Tools

This is a proof of concept set tools for working with Invenio RDM and migrating content from EPrints to RDM. It consists of a small set of Go based command line programs along with Python scripts and a wrapping irdm Python module. The Go based tooling is designed to work directory with a copy of you repositories' database (e.g. Postgres for RDM or MySQL for EPrints).

The proof of concept is being developed around RDM's web services (e.g. REST API and OAI-PMH), PostgreSQL database and external metadata services (e.g. CrossRef, DataCite).

Caltech Library is using irdmtools to migrate content from our legacy EPrints 3.3 repositories (heavily customized) to RDM. Post migration the core Go tools will remain useful for curation at the collection level (e.g. rdmutil)

rdmutil

This tool is for interacting with an Invenio RDM repository via RDM's REST and OAI-PMH API. It covers most the JSON API documented at https://inveniordm.docs.cern.ch/. This includes listing, submitting and managing records and draft records.

rdmutil configuration is read either from the environment or a JSON formatted configuration file. See the man page for details.

ep3util

This tool is used for migrating data out of EPrints. It can be used on a copy of your EPrints MySQL database. It parallels rdmutil and is an evolution of our tooling developed in eprinttools. See the man page for details.

eprint2rdm

This tool is migrating content from an EPrints repository via the EPrint REST API. It will retrieve an EPrint XML representation of the EPrint record and transform it into a JSON encoded simplified record nearly compatible with Invenio RDM. See the man page for details.

doi2rdm

This tool will query the CrossRef or DataCite API and convert a works record into a JSON structure compatible with an RDM record (e.g. to be inserted via an RDM API call). See the man page for details

rdm2citeproc

This tools takes an RDM record and returns an abbreviated record inspired by citeproc. It also supports harvesting selected RDM records into a dataset collection using the -harvest and -ids options. We use this feature to facilate creating https://feeds.library.caltech.edu. See the man page for details.

eprint2citeproc

This tools take an EPrint record and returns an abbreviated record inspired by citeproc. It also supports harvesting select EPrint records into a dataset collection using the -harvest and -ids options. We use this feature to facilate creating https://feeds.library.caltech.edu. See the man page for details.

Requirements

  • An Invenio RDM deployment
  • To building the Go based software and documentation
    • git
    • Go >= 1.20.7
    • Make (e.g. GNU Make)
    • Pandoc >= 3
  • For harvesting content
  • To migrate content from EPrints 3.3 to RDM
    • Python 3 and packages listed in [requirements.txt]

Quick install

If you're running on Linux, macOS or Raspberry Pi OS you may be able to installed precompiled irdmtools Go based tools with the following curl command --

curl https://caltechlibrary.github.io/irdmtools/installer.sh | sh

Installation from source

This codebase is speculative. It is likely to change and as issues are identified. To install you need to download the source code and compile it. Here's the steps I take to install irdmtools.

git clone git@github.com:caltechlibrary/irdmtools
cd irdmtools
make
make test
make install
python -m pip install -r requirements.txt

Configuration

The Go based tools rely on a properly configured environment (i.e. environment variables set in your POSIX shell). Specific requirements are listed in the man pages for each of the Go based command line programs.

Documentation

Overview

irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.

@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>

Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/ irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.

@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>

Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.

@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>

Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.

@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>

Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.

@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>

Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.

@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>

Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.

@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>

Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.

@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>

Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.

@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>

Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.

@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>

Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

View Source
const (
	// Version number of release
	Version = "0.0.76"

	// ReleaseDate, the date version.go was generated
	ReleaseDate = "2024-03-25"

	// ReleaseHash, the Git hash when version.go was generated
	ReleaseHash = "2ef8e55f"

	LicenseText = `` /* 1430-byte string literal not displayed */

)

Variables

View Source
var (
	DefaultDoi2RdmOptionsYAML = []byte(`# This YAML file controls the mappings of 
# CrossRef records to RDM records values. It is based on the practice
# of Caltech Library in the development of CaltechAUTHORS and CaltechTHESIS
# over the last decades.
#
# Set the mail to used when connecting to CrossRef. This is usually the
# email address for our organization but could be for a person.
# It is the email address CrossRef will use if you're causing a problem
# and they need you to stop.
#
#mailto: jane.doe@example.edu
mailto: helpdesk@library.caltech.edu
# Add a period after initials is missing
dot_initials: true
# Map the CrossRef type to RDM type
contributor_types:
  author: author
  editor: editor
  reviewer: reviewer
  review-assistent: other
  stats-reviewer: other
  reader: other
  translator: translator
# Map the CrossRef resource type to the RDM type
resource_types:
  article: publication-article
  journal-article: publication-article
  book: publication-book
  book_section: publication-section
  book-chapter: publication-section
  conference_item: conference-paper
  proceedings-article: conference-paper
  dataset: dataset
  experiment: publication-deliverable
  journal_issue: publication-issue
  lab_notes: labnotebook
  monograph: publication-report
  oral_history: publication-oralhistory
  patent: publication-patent
  software: software
  teaching_resource: teachingresource
  thesis: publication-thesis
  video: video
  website: other
  other: other
  image: other
  report: publication-workingpaper
  report-component: publication-workingpaper
  posted-content: publication-preprint
# Mapping DOI prefixes to Publisher names (used to normalize publisher names)
doi_prefix_publishers:
  10.1103: American Physical Society
  10.1063: American Institute of Physics
  10.1039: Royal Society of Chemistry
  10.1242: Company of Biologists
  10.1073: PNAS
  10.1109: IEEE
  10.2514: AIAA
  10.1029: AGU (pre-Wiley hosting)
  10.1093: MNRAS
  10.1046: Geophysical Journal International
  10.1175: American Meteorological Society
  10.1083: Rockefeller University Press
  10.1084: Rockefeller University Press
  10.1085: Rockefeller University Press
  10.26508: Rockefeller University Press
  10.1371: PLOS
  10.5194: European Geosciences Union
  10.1051: EDP Sciences
  10.2140: Mathematical Sciences Publishers
  10.1074: ASBMB
  10.1091: ASCB
  10.1523: Society for Neuroscience
  10.1101: Cold Spring Harbor
  10.1128: American Society for Microbiology
  10.1115: ASME
  10.1061: ASCE
  10.1038: Nature
  10.1126: Science
  10.1021: American Chemical Society
  10.1002: Wiley
  10.1016: Elsevier
# Mapping ISSN prefixes to Publisher names (used to normalize publisher names)
issn_publishers:
  0141-8130: Elsevier
  0266-2671: Cambridge University Press
  0166-5316: Elsevier
  1610-1928: S. Hirzel Verlag
  2157-6564: AlphaMed Press
  0166-218X: Elsevier
  0288-5514: Yōdosha
  0003-2654: Royal Society of Chemistry
  0093-6405: American Society of Civil Engineers
  0181-0529: Presses de l'ecole nationale des ponts et chaussées
  1047-8477: Elsevier
  1868-2529: Springer
  1935-8237: Now Publishers
  2041-8205: American Astronomical Society
  0103-9733: Sociedade Brasileira de Física
  1063-5203: Elsevier
  1541-1672: IEEE
  2405-6014: Elsevier
  0036-0279: Turpion
  0264-410X: Elsevier
  1811-5209: Mineralogical Society of America
  2055-7434: Nature Publishing Group
  0033-5533: MIT Press
  1536-1276: IEEE
  1949-3584: Wiley
  0037-6604: Sky Publishing Corp.
  0145-2126: Elsevier
  1010-6030: Elsevier
  1751-6161: Elsevier
  0021-8723: Oxford University Press
  0026-8232: University of Chicago Press
  0018-2370: Wiley-Blackwell
  0026-2692: Elsevier
  0885-8950: IEEE
  1532-3978: Association of Moving Image Archivists
  0002-2470: Air Pollution Control Association
  1941-4889: American Institute of Mathematical Sciences
  0095-2583: John Wiley
  1389-1723: Elsevier
  0013-0117: Wiley
  0042-6636: Virginia Historical Society
  0091-6749: Elsevier
  2058-5985: Oxford University Press
  0021-3640: American Institute of Physics
  1064-8275: SIAM
  0300-9580: Royal Society of Chemistry
  1465-5411: BioMed Central
`)
)

Functions

func AddAdditionalTitles added in v0.0.3

func AddAdditionalTitles(rec *simplified.Record, title *simplified.TitleDetail) error

func AddDate added in v0.0.5

func AddDate(rec *simplified.Record, dt *simplified.DateType) error

func AddFunder

func AddFunder(rec *simplified.Record, funder *simplified.Funder) error

func AddIdentifier added in v0.0.44

func AddIdentifier(rec *simplified.Record, scheme string, identifier string) error

func AddIdentifiers added in v0.0.44

func AddIdentifiers(rec *simplified.Record, identifiers []*simplified.Identifier) error

func AddKeyword

func AddKeyword(rec *simplified.Record, keyword string) error

func AddRelatedIdentifier added in v0.0.25

func AddRelatedIdentifier(rec *simplified.Record, scheme string, relationType string, identifier string) error

func AddRelatedIdentifiers added in v0.0.3

func AddRelatedIdentifiers(rec *simplified.Record, identifiers []*simplified.Identifier) error

func AddRights added in v0.0.5

func AddRights(rec *simplified.Record, rights []*simplified.Right) error

func AddSubject

func AddSubject(rec *simplified.Record, subject string) error

func AddSubjects added in v0.0.5

func AddSubjects(rec *simplified.Record, subjects []*simplified.Subject) error

func CheckDOI added in v0.0.34

func CheckDOI(cfg *Config, doi string) ([]map[string]interface{}, error)

CheckDOI takes a DOI and does a lookup to see if there are any matching .pids.doi.indentifier values.

``` doi := "10.1126/science.82.2123.219" records, err := CheckDOI(cfg, doi)

if err != nil {
   // ... handle error ...
}
for _, rec := ranges {
   // ... process results ...
}

```

func CheckWaitInterval added in v0.0.4

func CheckWaitInterval(iTime time.Time, wait time.Duration) (time.Time, bool)

CheckWaitInterval checks to see if an interval of time has been met or exceeded. It returns the remaining time interval (possibly reset) and a boolean. The boolean is true when the time interval has been met or exceeded, false otherwise.

``` tot := len(something) // calculate the total number of items to process t0 := time.Now() iTime := time.Now() reportProgress := false

for i, key := range records {
    // ... process stuff ...
    if iTime, reportProgress = CheckWaitInterval(rptTime, (30 * time.Second)); reportProgress {
        log.Printf("%s", ProgressETA(t0, i, tot))
    }
}

```

func CrosswalkCrossRefWork

func CrosswalkCrossRefWork(cfg *Config, work *crossrefapi.Works, options *Doi2RdmOptions) (*simplified.Record, error)

CrosswalkCrossRefWork takes a Works object from the CrossRef API and maps the fields into an simplified Record struct return a new struct or error.

func CrosswalkDataCiteObject added in v0.0.72

func CrosswalkDataCiteObject(cfg *Config, object map[string]interface{}, options *Doi2RdmOptions) (*simplified.Record, error)

CrosswalkDataCiteObject takes a Object object from the DataCite API and maps the fields into an simplified Record struct return a new struct or error.

func CrosswalkEPrintToRecord

func CrosswalkEPrintToRecord(eprint *eprinttools.EPrint, rec *simplified.Record, resourceTypes map[string]string, contributorTypes map[string]string) error

CrosswalkEPrintToRecord implements a crosswalk between an EPrint 3.x EPrint XML record as struct to a Invenio RDM record as struct.

func CrosswalkRdmToEPrint added in v0.0.53

func CrosswalkRdmToEPrint(cfg *Config, rec *simplified.Record, eprint *eprinttools.EPrint) error

CrosswalkRdmToEPrint takes a public RDM record and converts it to an EPrint struct which can be rendered as JSON or XML.

``` app := new(irdmtools.Rdm2EPrint)

if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}

recordId := "woie-x0121" src, err := app.GetRecord(cfg, recordId, false)

if err != nil {
   // ... handle error ...
}

rec := new(simplified.Record) eprint := new (eprinttools.EPrint) eprints := new (eprinttools.EPrints)

if err := irdmtools.JSONUnmarshal(src, &rec); err != nil {
   // ... handle error ...
}

if err := CrosswalkRdmToEPrint(rec, eprint) {
   // ... handle error ...
}

// Add eprint to outer EPrints struct before rendering eprints.EPrint = append(eprints.EPrint, eprint) // Output as JSON for single eprint record src, _ := irdmtools.JSONMarshalIndent(eprints) fmt.Printf("%s\n", src) ```

func DeleteEndpoint added in v0.0.31

func DeleteEndpoint(cfg *Config, p string) ([]byte, error)

DeleteEndpoint takes an access token and endpoint path along with JSON source as payload and returns JSON source and error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") p := "api/records/qez01-2309a/draft" src, err := DeleteEndpoint(cfg.InvenioToken, p)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func DeleteFiles added in v0.0.29

func DeleteFiles(cfg *Config, recordId string, filenames []string, debug bool) ([]byte, error)

DeleteFiles takes a configuration object and record id, and list of files and removes from a draft.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" fNames := ["article.pdf", "data.zip" ] // add files to draft record in JSON src, _ := os.ReadFile(fName) draft, err := DeleteFiles(cfg, id, fNames)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%+v\n", draft) ```

func DiscardDraft added in v0.0.29

func DiscardDraft(cfg *Config, recordId string, debug bool) (map[string]interface{}, error)

DiscardDraft takes a configuration object and record id, contacts an RDM instance and deletes a draft of a record and an error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" debug := true _, err := DiscardDraft(cfg, id, debug)

if err != nil {
   // ... handle error ...
}

```

func DoiPrefix added in v0.0.70

func DoiPrefix(s string) (string, error)

DoiPrefix takes a DOI returns the publisher prefix

func FmtHelp added in v0.0.11

func FmtHelp(src string, appName string, version string, releaseDate string, releaseHash string) string

FmtHelp lets you process a text block with simple curly brace markup.

func GetAccess added in v0.0.29

func GetAccess(cfg *Config, recordId string, accessType string) ([]byte, error)

GetAccess takes an acces token, a record id and optionally a access type. Returns either the access object or attribute if type is specified. Also returns an error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" src, err := GetAccess(cfg.InvenioToken, id, "")

if err != nil {
   // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func GetAllEPrintIDs added in v0.0.56

func GetAllEPrintIDs(db *sql.DB) ([]int, error)

GetAllEPrintIDs return a list of all eprint ids in repository or error

func GetAllEPrintIDsWithStatus added in v0.0.56

func GetAllEPrintIDsWithStatus(db *sql.DB, status string) ([]int, error)

GetAllEPrintIDsWithStatus return a list of all eprint ids in a repository with a given status or return error

func GetAllItems added in v0.0.56

func GetAllItems(db *sql.DB, field string) ([]string, error)

GetAllItems returns a list of simple items (e.g. local_group)

func GetAllORCIDs added in v0.0.56

func GetAllORCIDs(db *sql.DB) ([]string, error)

GetAllORCIDs return a list of all ORCID in repository

func GetAllPersonNames added in v0.0.56

func GetAllPersonNames(db *sql.DB, field string) ([]string, error)

GetAllPersonNames return a list of person names in repository

func GetAllPersonOrOrgIDs added in v0.0.56

func GetAllPersonOrOrgIDs(db *sql.DB, field string) ([]string, error)

GetAllPersonOrOrgIDs return a list of creator ids or error

func GetAllUniqueID added in v0.0.56

func GetAllUniqueID(db *sql.DB, field string) ([]string, error)

GetAllUniqueID return a list of unique id values in repository

func GetAllYears added in v0.0.56

func GetAllYears(db *sql.DB) ([]int, error)

GetAllYears returns the publication years found in a repository

func GetDraft added in v0.0.28

func GetDraft(cfg *Config, id string) (map[string]interface{}, error)

GetDraft takes a configuration object and record id, contacts an RDM instance retrieves an existing draft of a record and an error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" draft, err := GetDraft(cfg, id)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%+v\n", draft) ```

func GetDraftFiles added in v0.0.31

func GetDraftFiles(cfg *Config, recordId string, debug bool) (map[string]interface{}, error)

GetDraftFiles takes a configuration object and record id, contacts an RDM instance and returns the files metadata and an error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" debug := true entries, err := GetDraftFiles(cfg, id, debug)

if err != nil {
   // ... handle error ...
}

```

func GetEPrint added in v0.0.3

func GetEPrint(cfg *Config, eprintID int, timeout time.Duration, retryCount int) (*eprinttools.EPrints, error)

GetEPrint fetches a single EPrint record via the EPrint REST API or MySQL database if configured.

func GetEPrintIDsForDateType added in v0.0.56

func GetEPrintIDsForDateType(db *sql.DB, dateType string, start string, end string) ([]int, error)

GetEPrintIDsForDateType returns list of eprints in date range or returns an error

func GetEPrintIDsForItem added in v0.0.56

func GetEPrintIDsForItem(db *sql.DB, field string, value string) ([]int, error)

GetEPrintIDsForItem

func GetEPrintIDsForORCID added in v0.0.56

func GetEPrintIDsForORCID(db *sql.DB, orcid string) ([]int, error)

GetEPrintIDsForORCID return a list of eprint ids associated with the ORCID

func GetEPrintIDsForPersonName added in v0.0.56

func GetEPrintIDsForPersonName(db *sql.DB, field string, family string, given string) ([]int, error)

GetEPrintIDsForPersonName return a list of eprint id for a person's name (family, given)

func GetEPrintIDsForPersonOrOrgID added in v0.0.56

func GetEPrintIDsForPersonOrOrgID(db *sql.DB, personOrOrgType string, personOrOrgID string) ([]int, error)

GetEPrintIDForPersonOrOrgID return a list of eprint ids associated with the person or organization id

func GetEPrintIDsForUniqueID added in v0.0.56

func GetEPrintIDsForUniqueID(db *sql.DB, field string, value string) ([]int, error)

GetEPrintIDsForUniqueID return list of eprints for DOI

func GetEPrintIDsForYear added in v0.0.56

func GetEPrintIDsForYear(db *sql.DB, year int) ([]int, error)

GetEPrintsIDsForYear returns a list of published eprint IDs for a given year.

func GetEPrintIDsInTimestampRange added in v0.0.56

func GetEPrintIDsInTimestampRange(db *sql.DB, field string, start string, end string) ([]int, error)

GetEPrintIDsInTimestampRange return a list of EPrintIDs in created timestamp range or return error. field maybe either "datestamp" (for created date), "lastmod" (for last modified date)

func GetEPrintIDsWithStatus added in v0.0.56

func GetEPrintIDsWithStatus(db *sql.DB, status string, start string, end string) ([]int, error)

GetEPrintIDsWithStatus returns a list of eprints in a timestmap range for a given status or returns an error

func GetEPrintIDsWithStatusForDateType added in v0.0.56

func GetEPrintIDsWithStatusForDateType(db *sql.DB, status string, dateType string, start string, end string) ([]int, error)

GetEPrintIDsWithStatusForDateType returns list of eprints in date range for a given status or returns an error

func GetEPrintIDsWithStatusInTimestampRange added in v0.0.56

func GetEPrintIDsWithStatusInTimestampRange(db *sql.DB, status string, field string, start string, end string) ([]int, error)

GetEPrintIDsWithStatusInTimestampRange return a list of EPrintIDs with eprint_status in field timestamp range or return error. field maybe either "datestamp" (for created date), "lastmod" (for last modified date)

func GetEndpoint added in v0.0.29

func GetEndpoint(cfg *Config, p string) ([]byte, error)

GetEndpoint takes an access token and endpoint path and returns JSON source and error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") p := "api/records/qez01-2309a/draft" src, err := GetEndpoint(cfg.InvenioToken, p)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func GetFile added in v0.0.28

func GetFile(cfg *Config, id string, fName string) (*simplified.Entry, error)

GetFile takes a configuration object, record id and filename, contacts an RDM instance and returns the specific file metadata and an error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" fName := "article.pdf" entry, err := GetFile(cfg, id, fName)

if err != nil {
   // ... handle error ...
}

```

func GetFiles added in v0.0.28

func GetFiles(cfg *Config, recordId string, debug bool) (map[string]interface{}, error)

GetFiles takes a configuration object and record id, contacts an RDM instance and returns the files metadata and an error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" debug := true entries, err := GetFiles(cfg, id, debug)

if err != nil {
   // ... handle error ...
}

```

func GetKeys added in v0.0.3

func GetKeys(cfg *Config, timeout time.Duration, retryCount int) ([]int, error)

GetKeys returns a list of eprint record ids from the EPrints REST API

func GetModifiedKeys added in v0.0.56

func GetModifiedKeys(cfg *Config, start string, end string) ([]int, error)

GetModifiedKeys returns a list of eprint record ids from the EPrints MySQL database. The REST API is just too slow to process.

func GetModifiedRecordIds

func GetModifiedRecordIds(cfg *Config, start string, end string) ([]string, error)

GetModifiedRecordIds takes a configuration object, contacts am RDM instance and returns a list of ids created, deleted or updated in the time range specififed. I problem is encountered returns an error.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

NOTE: This method relies on OAI-PMH, this is a rate limited process so results can take quiet some time.

func GetRawRecord added in v0.0.5

func GetRawRecord(cfg *Config, id string) (map[string]interface{}, error)

GetRawRecord takes a configuration object and record id, contacts an RDM instance and returns a map[string]interface{} record

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" mapRecord, err := GetRawRecord(cfg, id)

if err != nil {
    // ... handle error ...
}

```

func GetRecord

func GetRecord(cfg *Config, id string, draft bool) (*simplified.Record, error)

GetRecord takes a configuration object and record id, contacts an RDM instance and returns a simplified record and an error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" record, err := GetRecord(cfg, id, false)

if err != nil {
   // ... handle error ...
}

```

func GetRecordIds

func GetRecordIds(cfg *Config) ([]string, error)

GetRecordIds takes a configuration object, contacts am RDM instance and returns a list of ids and error. If the RDM database connection is included in the configuration the faster method of querrying Postgres is used, otherwise OAI-PMH is used to get the id list.

The configuration object must have the InvenioAPI and InvenioToken attributes set. It is highly recommended that the InvenioDbUser, InvenioDbPassword and InvenioDbHost is configured.

NOTE: This method relies on OAI-PMH, this is a rate limited process so results can take quiet some time.

func GetRecordStaleIds added in v0.0.62

func GetRecordStaleIds(cfg *Config) ([]string, error)

GetRecordStaleIds takes a configuration object, contacts am RDM instance and returns a list of ids and error. If the RDM database connection is included in the configuration the faster method of querrying Postgres is used, otherwise OAI-PMH is used to get the id list.

The configuration object must have the InvenioAPI and InvenioToken attributes set. It is highly recommended that the InvenioDbUser, InvenioDbPassword and InvenioDbHost is configured.

NOTE: This method relies on OAI-PMH, this is a rate limited process so results can take quiet some time.

func GetRecordVersions added in v0.0.64

func GetRecordVersions(cfg *Config, id string) ([]*map[string]interface{}, error)

GetRecordVersions takes a configuration object and record id, queries the Postgres database and returns the matching json blogs in the rdm_records_medata_version table as a JSON array.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" record, err := GetRecordVersions(cfg, id)

if err != nil {
   // ... handle error ...
}

```

func GetReview added in v0.0.31

func GetReview(cfg *Config, recordId string, debug bool) (map[string]interface{}, error)

GetReview takes a configuration object, record id and returns an review object (which includes a request id) and error code.

func GetTablesAndColumns added in v0.0.56

func GetTablesAndColumns(db *sql.DB) (map[string][]string, error)

func GetUserBy added in v0.0.56

func GetUserBy(db *sql.DB, queryField string, queryValue interface{}) (*eprinttools.EPrintUser, error)

GetUserBy takes a field name (e.g. userid, username) and value and returns an EPrintUser object.

func GetUserID added in v0.0.56

func GetUserID(db *sql.DB, username string) ([]int, error)

GetUserID takes a username and returns a list of userid

func GetUsernames added in v0.0.56

func GetUsernames(db *sql.DB) ([]string, error)

GetUsernames returns a list of all usernames in a repository

func GetVersionLatest added in v0.0.28

func GetVersionLatest(cfg *Config, id string) (map[string]interface{}, error)

GetVersionLatest takes a configuration object and record id, contacts an RDM instance and returns the versons metadata and an error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" versions, err := GetVersionLatest(cfg, id)

if err != nil {
   // ... handle error ...
}

```

func GetVersions added in v0.0.28

func GetVersions(cfg *Config, id string) (map[string]interface{}, error)

GetVersions takes a configuration object and record id, contacts an RDM instance and returns the versons metadata and an error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" versions, err := GetVersions(cfg, id)

if err != nil {
   // ... handle error ...
}

```

func Harvest

func Harvest(cfg *Config, fName string, debug bool) error

func HarvestEPrintRecords added in v0.0.56

func HarvestEPrintRecords(cfg *Config, recordIds []int, debug bool) error

func HarvestEPrints added in v0.0.53

func HarvestEPrints(cfg *Config, fName string, debug bool) error

func IsPublic added in v0.0.56

func IsPublic(db *sql.DB, eprintid int) (bool, error)

IsPublic takes an EPrintID and returns true if public, false otherwise

Check if an EPrint record "is public"

func JSONMarshal added in v0.0.53

func JSONMarshal(data interface{}) ([]byte, error)

JSONMarshal provides provide a custom json encoder to solve a an issue with HTML entities getting converted to UTF-8 code points by json.Marshal(), json.MarshalIndent().

func JSONMarshalIndent added in v0.0.53

func JSONMarshalIndent(data interface{}, prefix string, indent string) ([]byte, error)

JSONMarshalIndent provides provide a custom json encoder to solve a an issue with HTML entities getting converted to UTF-8 code points by json.Marshal(), json.MarshalIndent().

func JSONUnmarshal added in v0.0.53

func JSONUnmarshal(src []byte, data interface{}) error

JSONUnmarshal is a custom JSON decoder so we can treat numbers easier

func LinkToDoi added in v0.0.70

func LinkToDoi(s string) (string, error)

LinkToDoi removes a leading URL reference (DOI link) if found returning the remainder of the DOI string (prefix slash item identifier)

func LoadTypesMap added in v0.0.3

func LoadTypesMap(fName string, mapTypes map[string]string) error

```

func MigrateEPrintDatasetToCitationDataset added in v0.0.72

func MigrateEPrintDatasetToCitationDataset(ep3CName string, ids []string, repoHost string, prefix string, citeCName string) error

MigrateEPrintDatasetToCitationsDataset takes a dataset of EPrint objects and migrates the ones in the id list to a citation dataset collection.

func NewDraft added in v0.0.30

func NewDraft(cfg *Config, recordId string) (map[string]interface{}, error)

NewDraft takes a configuration object and record id, contacts an RDM instance and create a draft of an existing record and an error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id = "38rg4-36m04" draft, err := NewDraft(cfg, id)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%+v\n", draft) ```

func NewRecord added in v0.0.30

func NewRecord(cfg *Config, src []byte) (map[string]interface{}, error)

NewRecord takes a configuration object and JSON record values. It contacts an RDM instance and create a new record return the JSON for the newly created record with a record id. When records are created they are in "draft" state.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") fName := "new_record.json" // A new record in JSON src, _ := os.ReadFile(fName) record, err := NewRecord(cfg, src)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%+v\n", record) ```

func NewRecordVersion added in v0.0.30

func NewRecordVersion(cfg *Config, recordId string) (map[string]interface{}, error)

NewRecordVersion takes a configuration object and record id to create the new version draft. The returns JSON record values includes the new record id identifying the new version.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id = "38rg4-36m04" record, err := NewRecordVersion(cfg, id)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%+v\n", record) ```

func PatchEndpoint added in v0.0.30

func PatchEndpoint(cfg *Config, p string, payload []byte) ([]byte, error)

PatchEndpoint takes an access token and endpoint path along with JSON source as payload and returns JSON source and error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") p := "api/records/qez01-2309a/draft" data := os.ReadFile("draft.json") src, err := PatchEndpoint(cfg.InvenioToken, p, data)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func PostEndpoint added in v0.0.30

func PostEndpoint(cfg *Config, p string, payload []byte) ([]byte, error)

PostEndpoint takes an access token and endpoint path along with JSON source as payload and returns JSON source and error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") p := "api/records/qez01-2309a/draft" data := os.ReadFile("draft.json") src, err := PostEndpoint(cfg.InvenioToken, p, data)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func ProgressETA added in v0.0.56

func ProgressETA(t0 time.Time, i int, tot int) string

ProgressETA returns a string with the percentage processed and estimated time remaining. It requires the a counter of records processed, the total count of records and a time zero value.

``` tot := len(something) // calculate the total number of items to process t0 := time.Now() iTime := time.Now() reportProgress := false

for i, key := range records {
    // ... process stuff ...
    if iTime, reportProgress = CheckWaitInterval(rptTime, (30 * time.Second)); reportProgress {
        log.Printf("%s", ProgressETA(t0, i, tot))
    }
}

```

func ProgressIPS added in v0.0.4

func ProgressIPS(t0 time.Time, i int, timeUnit time.Duration) string

ProgressIPS returns a string with the elapsed time and increments per second. Takes a time zero, a counter and time unit. Returns a string with count, running time and increments per time unit. ``` t0 := time.Now() iTime := time.Now() reportProgress := false

for i, key := range records {
    // ... process stuff ...
    if iTime, reportProgress = CheckWaitInterval(iTime, (30 * time.Second)); reportProgress || i = 0 {
        log.Printf("%s", ProgressIPS(t0, i, time.Second))
    }
}

```

func PublishRecordVersion added in v0.0.32

func PublishRecordVersion(cfg *Config, recordId string, version string, pubDate string, debug bool) (map[string]interface{}, error)

PublishRecordVersion takes a configuration object and record id of a new version draft and publishes it. NOTE: creating a new version will clear .metadata.publication_date, version label and DOI. These can be replace when publishing in the version and pubDate parameter. If those values are empty string no change is made to the draft before publishing.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id = "38rg4-36m04" version, pubDate := "internal", "2022-08" record, err := PublicRecordVersion(cfg, id, version, pubDate)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%+v\n", record) ```

func PutEndpoint added in v0.0.30

func PutEndpoint(cfg *Config, p string, payload []byte) ([]byte, error)

PutEndpoint takes an access token and endpoint path along with JSON source as payload and returns JSON source and error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") p := "api/records/qez01-2309a/draft" data := os.ReadFile("draft.json") src, err := PutEndpoint(cfg.InvenioToken, p, data)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func Query

func Query(cfg *Config, q string, sort string) ([]map[string]interface{}, error)

Query takes a query string and returns the paged object results as a slice of `map[string]interface{}`

``` records, err := Query(cfg, "Geological History in Southern California", "newest")

if err != nil {
    // ... handle error ...
}

for _, rec := ranges {
    // ... process results ...
}

```

func QueryCrossRefWork

func QueryCrossRefWork(cfg *Config, doi string, options *Doi2RdmOptions) (*crossrefapi.Works, error)

func QueryDataCiteObject added in v0.0.72

func QueryDataCiteObject(cfg *Config, doi string, options *Doi2RdmOptions) (map[string]interface{}, error)

func RequestLogger added in v0.0.49

func RequestLogger(targetMux http.Handler) http.Handler

RequestLogger logs http request to service

func RetrieveFile added in v0.0.28

func RetrieveFile(cfg *Config, id string, fName string) ([]byte, error)

RetrieveFile takes a configuration object, record id and filename, contacts an RDM instance and returns the specific file and an error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" fName := "article.pdf" data, err := RetrieveFile(cfg, id, fName)

if err != nil {
   // ... handle error ...
}

os.WriteFile(fName, data, 0664) ```

func ReviewRequest added in v0.0.31

func ReviewRequest(cfg *Config, recordId string, decision string, comment string, debug bool) (map[string]interface{}, error)

ReviewRequest takes a configuration object and record id, a decision, and optional comment contacts an RDM instance and updates the review status for the submitted draft record.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" debug := true _, err := ReviewDraft(cfg, id, "accept", "", debug)

if err != nil {
   // ... handle error ...
}

```

func RunEPrintDSToCitationDS added in v0.0.72

func RunEPrintDSToCitationDS(in io.Reader, out io.Writer, eout io.Writer, args []string, repoHost string, prefix string, ids []string) int

RunEPrintDSToCitationDS migrates contents from an EPrint dataset collection to a citation dataset collection for a give list of ids and repostiory hostname.

func SQLCreateEPrint added in v0.0.56

func SQLCreateEPrint(db *sql.DB, eprint *eprinttools.EPrint) (int, error)

SQLCreateEPrint will read a EPrint structure and generate SQL INSERT, REPLACE and DELETE statements suitable for creating a new EPrint record in the repository.

func SQLCreateUser added in v0.0.56

func SQLCreateUser(db *sql.DB, user *eprinttools.EPrintUser) (int, error)

func SQLReadEPrint added in v0.0.56

func SQLReadEPrint(db *sql.DB, baseURL string, eprintID int) (*eprinttools.EPrint, error)

SQLReadEPrint expects a repository map and EPrint ID and will generate a series of SELECT statements populating a new EPrint struct or return an error (e.g. "not found" if eprint id is not in repository)

func SQLReadUser added in v0.0.56

func SQLReadUser(db *sql.DB, userid int) (*eprinttools.EPrintUser, error)

func SQLUpdateUser added in v0.0.56

func SQLUpdateUser(db *sql.DB, user *eprinttools.EPrintUser) error

func SampleConfig

func SampleConfig(configFName string) ([]byte, error)

SampleConfig display a minimal configuration for the rdmutil cli. The minimal values in the configuration are "invenio_api" url and "invenio_token" holding the access token.

```

src, err := SampleConfig("irdmtools.json")
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func SendToCommunity added in v0.0.30

func SendToCommunity(cfg *Config, recordId string, communityId string, debug bool) (map[string]interface{}, error)

SendToCommunity sends a draft to an RDM community. This will trigger the review step need for publication. You need the record id and a community id (looks like a UUID). Returns a map[string]interface{} and error values.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" comminityId := ... // this is a UUID like value debug := true src, err := SendToCommunity(cfg, id, communityId, debug)

if err != nil {
   // ... handle error ...
}

```

func SetAccess added in v0.0.29

func SetAccess(cfg *Config, recordId string, accessType string, accessValue string, debug bool) ([]byte, error)

SetAccess takes an access token, record id, a access type and value. Returns the updated access object and error value.

FIXME: Current this method only supports setting record and files attributes to "public" and "restricted". Future implementations may add support to set record embargos.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" debug := true src, err := SetAccess(cfg.InvenioToken, id, "", debug)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func SetArticleNumber

func SetArticleNumber(rec *simplified.Record, articleNo string) error

func SetContributors added in v0.0.3

func SetContributors(rec *simplified.Record, contributors []*simplified.Creator) error

func SetCreators added in v0.0.3

func SetCreators(rec *simplified.Record, creators []*simplified.Creator) error

func SetCustomField added in v0.0.23

func SetCustomField(rec *simplified.Record, customField string, key string, value interface{}) error

func SetDOI

func SetDOI(rec *simplified.Record, doi string) error

Wraps the simplified package with crosswalks

func SetDescription

func SetDescription(rec *simplified.Record, description string) error

func SetEdition

func SetEdition(rec *simplified.Record, edition string) error

func SetFilesEnable added in v0.0.30

func SetFilesEnable(cfg *Config, recordId string, enable bool, debug bool) (map[string]interface{}, error)

SetFilesEnable will set the metadata.files.enable value.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" enabled := true debug := true _, err := SetFilesEnable(cfg, id, enabled, debug)

if err != nil {
   // ... handle error ...
}

```

func SetFullTextStatus

func SetFullTextStatus(rec *simplified.Record, status bool) error

func SetFunding

func SetFunding(rec *simplified.Record, funding []*simplified.Funder) error

func SetImprintField added in v0.0.25

func SetImprintField(rec *simplified.Record, key string, value interface{}) error

func SetIssue added in v0.0.16

func SetIssue(rec *simplified.Record, issue string) error

func SetJournalField added in v0.0.23

func SetJournalField(rec *simplified.Record, key string, value interface{}) error

func SetLanguages added in v0.0.27

func SetLanguages(rec *simplified.Record, key string, value interface{}) error

func SetMonographType

func SetMonographType(rec *simplified.Record, monographType string) error

func SetPageRange

func SetPageRange(rec *simplified.Record, pageRange string) error

func SetPresentationType added in v0.0.3

func SetPresentationType(rec *simplified.Record, presentationType string) error

func SetProject

func SetProject(rec *simplified.Record, project string) error

func SetPubDate added in v0.0.32

func SetPubDate(cfg *Config, recordId string, pubDate string, debug bool) (map[string]interface{}, error)

SetPubDate will set the metadata.publication_date value.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" pubDate := "2016" debug := true _, err := SetPublicationDate(cfg, id, pubDate, debug)

if err != nil {
   // ... handle error ...
}

```

func SetPublication

func SetPublication(rec *simplified.Record, publication string) error

func SetPublicationDate added in v0.0.5

func SetPublicationDate(rec *simplified.Record, pubDate string) error

func SetPublicationDateByType added in v0.0.25

func SetPublicationDateByType(rec *simplified.Record, dt string, publicationType string) error

func SetPublisher

func SetPublisher(rec *simplified.Record, publisher string) error

func SetPublisherLocation

func SetPublisherLocation(rec *simplified.Record, place string) error

func SetReferred

func SetReferred(rec *simplified.Record, referred bool) error

func SetResourceType

func SetResourceType(rec *simplified.Record, resourceType string, resourceTypeMap map[string]string) error

func SetSeries

func SetSeries(rec *simplified.Record, series string) error

func SetTitle added in v0.0.3

func SetTitle(rec *simplified.Record, title string) error

func SetVersion added in v0.0.32

func SetVersion(cfg *Config, recordId string, version string, debug bool) (map[string]interface{}, error)

SetVersion will set the metadata.version value.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" versoin := 'public files' debug := true _, err := SetVersion(cfg, id, version, debug)

if err != nil {
   // ... handle error ...
}

```

func SetVolume

func SetVolume(rec *simplified.Record, volume string) error

func UpdateDraft added in v0.0.28

func UpdateDraft(cfg *Config, recordId string, payloadSrc []byte, debug bool) (map[string]interface{}, error)

UpdateDraft takes a configuration object and record id, contacts an RDM instance and create a draft of a record and an error value.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" fName := "draft.json" // An updated draft record in JSON src, _ := os.ReadFile(fName) debug := true draft, err := UpdateDraft(cfg, id, src, debug)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%+v\n", draft) ```

func UploadFiles added in v0.0.29

func UploadFiles(cfg *Config, recordId string, filenames []string, debug bool) (map[string]interface{}, error)

UploadFiles takes a configuration object and record id, and a map to filename and paths contacts an RDM instance and adds the files to a draft record.

The configuration object must have the InvenioAPI and InvenioToken attributes set.

``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" fNames := ["article.pdf", "data.zip" ] // add files to draft record in JSON src, _ := os.ReadFile(fName) draft, err := UploadFiles(cfg, id, fNames)

if err != nil {
   // ... handle error ...
}

fmt.Printf("%+v\n", draft) ```

Types

type Citation added in v0.0.72

type Citation struct {

	// ID holds a citation id. This is formed from the originating collection (e.g. repository) and that collection's id, i.e. {REPO_ID}:{RECORD_ID}.
	ID string `json:"id,required" xml:"id,required" yaml:"id,required"`

	// Collection is the dataset collection the citation came from or the Repository collection name (E.g. authors, caltechauthors)
	Collection string `json:"collection,required" xml:"collection,required" yaml:"collection,required"`

	// CollectionID is the id used in the originating collection
	CollectionID string `json:"collection_id,required" xml:"collection_id,required" yaml:"collection_id,required"`

	// CiteUsingURL holds the URL the citation will use to reach the object.
	// This is normally the URL of the item in your repository. You could map this to the DOI or other
	// resolver system.
	CiteUsingURL string `json:"cite_using_url,required" xml:"cite_using_url,required" yaml:"cite_using_url,required"`

	// PrimaryObject holds a pointers (e.g. URLs) to the primary digital object this citation record refers to.
	PrimaryObject map[string]interface{} `json:"primary_object_url,omitempty" xml:"primary_object_url,omitempty" yaml:"primary_object_url,omitempty"`

	// ResourceType is the string from the repository that identifies the type of resource the record is about
	ResourceType string `json:"resource_type,omitempty" xml:"resource_type,omitempty" yaml:"resource_type,omitempty"`

	// AlternateId a list of Item identifies, not in the CiteProc spec but useful to me and likely useful
	// in fielded searching, e.g. looking up a citation with a given ISBN ir ISSN
	AlternateId []*CitationIdentifier `json:"alternate_id,omitempty" xml:"alternate_di,omitempty" yaml:"alternate_id,omitempty"`

	// Type holds the citeproc "type" of bibliographic record. In DataCite records
	// this would be found in `.access.types.citeproc`.
	Type string `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty"`

	// Title holds the title used for the citation.
	Title string `json:"title,omitempty" xml:"title,omitempty" yaml:"title,omitempty"`

	// BookTitle holds a book title when the citation is a chapter contribution
	BookTitle string `json:"book_title,omitempty" xml:"book_title,omitempty" yaml:"book_title,omitempty"`

	// AlternateTitle holds additional titles refering to this item. Not part of the CiteProc item description but
	// useful for search purposes.
	AlternateTitle []string `json:"alternate_title,omitempty" xml:"alternate_title,omitempty" yaml:"alternate_title,omitempty"`

	// Author holds a list of author as CitationAgent objects.
	Author []*CitationAgent `json:"author,omitempty" xml:"author,omitempty" yaml:"author,omitempty"`

	// Editor holds a list of editor as CitationAgent objects
	Editor []*CitationAgent `json:"editor,omitempty" xml:"editor,omitempty" yaml:"editor,omitempty"`

	// Reviewer holds a list of reviewer as CitationAgent objects
	Reviewer []*CitationAgent `json:"reviewer,omitempty" xml:"reviewer,omitempty" yaml:"reviewer,omitempty"`

	// ThesisAdvisors holds a list of thesis advisors as CitationAgent objects
	ThesisAdvisor []*CitationAgent `json:"thesis_advisor,omitempty" xml:"thesis_advisor,omitempty" yaml:"thesis_advisor,omitempty"`

	// ThesisCommittee holds a list of thesis committee members as CitationAgent objects
	ThesisCommittee []*CitationAgent `json:"thesis_committee,omitempty" xml:"thesis_committee,omitempty" yaml:"thesis_committee,omitempty"`

	// Contributor holds a list of contributors (people who contributed but are not authors, editors, reviewers, thesis advisors, etc)
	Contributor []*CitationAgent `json:"contributor,omitempty" xml:"contributor,omitempty" yaml:"contributor,omitempty"`

	// Translator  holds a list of people who translated the work
	Translator []*CitationAgent `json:"translator,omitempty" xml:"translator,omitempty" yaml:"translator,omitempty"`

	// LocalGroup holds information about Caltech affiliated groups
	LocalGroup []*CitationAgent `json:"local_group,omitempty" xml:"local_group,omitempty" yaml:"local_group,omitempty"`

	// Date holds a map to related citeproc item dates. Currently unused.
	Date map[string]*CitationDate `json:"dates,omitempty" xml:"dates,omitempty" yaml:"dates,omitempty"`

	// Abstract holds the abstract, useful for search applications, not needed fir CiteProc
	Abstract string `json:"abstract,omitempty" xml:"abstract,omitempty" yaml:"abstract,omitempty"`

	// DOI of object
	DOI string `json:"doi,omitempty" xml:"doi,omitempty" yaml:"doi,omitempty"`

	// PMCID
	PMCID string `json:"pmcid,omitempty" xml:"pmcid,omitempty" yaml:"pmcid,omitempty"`

	// ISSN
	ISSN string `json:"issn,omitempty" xml:"issn,omitempty" yaml:"issn,omitempty"`

	// ISBN
	ISBN string `json:"isbn,omitempty" xml:"isbn,omitempty" yaml:"isbn,omitempty"`

	// Publisher holds the publisher's name
	Publisher string `json:"publisher,omitempty" xml:"publisher,omitempty" yaml:"publisher,omitempty"`

	// PlaceOfPublication holds the address or location description of the publiser (e.g. Los Angeles, CA)
	PlaceOfPublication string `json:"place_of_publication,omitempty" xml:"place_of_publication,omitempty" yaml:"place_of_publication,omitempty"`

	// Publication holds the name of the journal or publication, e.g. "Journal of Olympic Thumb Wrestling"
	Publication string `json:"publication,omitempty" xml:"publication,omitempty" yaml:"publication,omitempty"`

	// PublicationDate is a string, can be an approximate date. It's the date used to sort citations by in terms of record availabilty
	// E.g. for Thesis this would be the graduation year, for monographs and internal reports this might be the date made publically
	// available.
	PublicationDate string `json:"publication_date,omitempty" xml:"publication_date,omitempty" yaml:"publication_date,omitempty"`

	// Edition of book
	Edition string `json:"edition,omitempty" xml:"edition,omitempty" yaml:"edition,omitempty"`

	// Chapters from book
	Chapters string `json:"chapters,omitempty" xml:"chapters,omitempty" yaml:"chapters,omitempty"`

	// Series/SeriesNumber values from CaltechAUTHORS (mapped from custom fields)
	Series       string `json:"series,omitempty" xml:"series,omitempty" yaml:"series,omitempty"`
	SeriesNumber string `json:"series_number,omitempty" xml:"series_number,omitempty" yaml:"series_number,omitempty"`

	// Volume/Issue values mapped from CrossRef/DataCite data models
	Volume string `json:"volume,omitempty" xml:"volume,omitempty" yaml:"volume,omitempty"`
	Issue  string `json:"issue,omitempty" xml:"issue,omitempty" yaml:"issue,omitempty"`

	// Pages
	Pages string `json:"pages,omitempty" xml:"pages,omitempty" yaml:"pages,omitempty"`

	// ThesisDegree for thesis types
	ThesisDegree string `json:"thesis_degree,omitempty" xml:"thesis_degree,omitempty" yaml:"thesis_degree,omitempty"`

	// Thesis Type
	ThesisType string `json:"thesis_type,omitempty" xml:"thesis_type,omitempty" yaml:"thesis_type,omitempty"`

	// ThesisYear for thesis types, year degree granted
	ThesisYear string `json:"thesis_year,omitempty" xml:"thesis_year,omitempty" yaml:"thesis_year,omitempty"`

	// Patent citation data
	PatentApplication string `json:"patent_applicant,omitempty" xml:"patent_applicatant,omitempty" yaml:"patent_applicant,omitempty"`

	// Patent Assignee
	PatentAssignee string `json:"patent_assignee,omitempty" xml:"patent_assignee,omitempty" yaml:"patent_assignee,omitempty"`

	// Patent Number
	PatentNumber string `json:"patent_number,omitempty" xml:"patent_number,omitempty" yaml:"patent_number,omitempty"`
}

Citation implements the data structure for CiteProc's Item representing a single bibliographic citation.

func EPrintToCitation added in v0.0.72

func EPrintToCitation(repoName string, key string, eprint *eprinttools.EPrint, repoHost string, resourceTypes map[string]string, contributorTypes map[string]string) (*Citation, error)

EPrintToCitation takes a single EPrint records and returns a single Citation struct

func RdmToCitation added in v0.0.72

func RdmToCitation(record *simplified.Record) (*Citation, error)

Convert an RDM record to a citation in a Citation struct

func (*Citation) CrosswalkEPrint added in v0.0.73

func (cite *Citation) CrosswalkEPrint(cName string, cID string, citeUsingURL string, eprint *eprinttools.EPrint) error

CrosswalkEPrint takes an eprinttools.EPrint record and return maps the values into the Citation.

func (*Citation) CrosswalkRecord added in v0.0.72

func (cite *Citation) CrosswalkRecord(cName string, cID string, citeUsingURL string, repoURL string, rec *simplified.Record) error

CrosswalkRecord takes a simplified record and return maps the values into the Citation.

type CitationAgent added in v0.0.72

type CitationAgent struct {
	// FamilyName holds a person's family name
	FamilyName string `json:"family_name,omitempty" xml:"family_name,omitempty" yaml:"family_name,omitempty"`

	// LivedName holds a person's lived or given. It is express encoded as "given" in JSON, XML and YAML for
	// to becompatible with historical records not as a justication for that "given" implies
	// in 2024 in the United States.
	LivedName string `json:"given_name,omitempty" xml:"given_name,omitempty" yaml:"given_name,omitempty"`

	// NonDroppingParticle holds non dropping particles that should not be dropped from a name, e.g. "de las"
	NonDroppingParticle string `json:"non-dropping-particle,omitempty" xml:"non-dropping-particle,omitempty" yaml:"non-dropping-particle,omitempty"`

	// DroppingParticle holds the list of particles that can be dropped.
	DroppingParticle string `json:"dropping-particle,omitempty" xml:"dropping-particle,omitempty" yaml:"dropping-particle,omitempty"`

	// Prefix, e.g. Mr., Mrs, Prof.
	Prefix string `json:"prefix,omitempty" xml:"prefix,omitempty" yaml:"prefix,omitempty"`

	// Suffix, e.g. Jr., PhD. etc.
	Suffix string `json:"suffix,omitempty" xml:"suffix,omitempty" yaml:"suffix,omitempty"`

	// Literal would be use for a group or organization, e.g. "ACME Widgets and Gadgets, Inc."
	Literal string `json:"literal,omitempty" xml:"literal,omitempty" yaml:"literal,omitempty"`

	// ORCID identifier
	ORCID string `json:"orcid,omitempty" xml:"orcid,omitempty" yaml:"orcid,omitempty"`

	// ISNI
	ISNI string `json:"isni,omitempty" xml:"isni,omitempty" yaml:"isni,omitempty"`

	// clpid - Caltech Library Person Identifier
	CLpid string `json:"clpid,omitempty" xml:"clpid,omitempty" yaml:"clpid,omitempty"`

	// clgid - Caltech Library Group Indentifier
	CLgid string `json:"clgid,omitempty" xml:"clgid,omitempty" yaml:"clgid,omitempty"`

	// ArachivesSpaceID holds the local ArachivesSpace instance id for the person or org
	ArchivesSpaceID string `json:"archivesspace_id,omitempty" xml:"archivesspace_id,omitempty" yaml:"archivesspace_id,omitempty"`

	// Viaf holds the viaf id for a person
	Viaf string `json:"viaf,omitempty" xml:"viaf,omitempty" yaml:"viaf,omitempty"`

	// Lcnaf holds the lcnaf id for a person
	Lcnaf string `json:"lcnaf,omitempty" xml:"lcnaf,omitempty" yaml:"lcnaf,omitempty"`

	// Snac holds teh snac id for a person
	Snac string `json:"snac,omitempty" xml:"snac,omitempty" yaml:"snac,omitempty"`

	// Wikidata holds the wikidata id for a person or org
	Wikidata string `json:"wikidata,omitempty" xml:"wikidata,omitempty" yaml:"wikidata,omitempty"`

	// DirectoryID holds the local directory identifier for a person
	DirectoryID string `json:"directory_id,omitempty" xml:"directory_id,omitempty" yaml:"directory_id,omitempty"`
}

CitationAgent this describes a person or organization for the purposes of CiteProc item data. This is based on https://citeproc-js.readthedocs.io/en/latest/csl-json/markup.html, reviewed 2024-03-06.

func CrosswalkCreatorToCitationAgent added in v0.0.72

func CrosswalkCreatorToCitationAgent(creator *simplified.Creator) (*CitationAgent, string, error)

CrosswalkCreatorToCitationAgent takes a simplified.Cretor and returns a CitationAgent, role (e.g. "author", "editor", "thesis_advisor", "thesis_committee", "reviewer", "contributor"), and an error value

func CrosswalkPersonOrOrgToCitationAgent added in v0.0.72

func CrosswalkPersonOrOrgToCitationAgent(personOrOrg *simplified.PersonOrOrg) (*CitationAgent, error)

CrosswalkPersonOrOrgToCitationAgent takes a simplified.PersonOrOrg and returns a CitationAgent

func (*CitationAgent) ToString added in v0.0.72

func (ca *CitationAgent) ToString() string

ToString convert a CitationAgent to a string representation

type CitationDate added in v0.0.72

type CitationDate struct {
	// DateParts holds the data parts expressed as array of an array of integers
	DateParts [][]int `json:"date-parts,omitempty" xml:"date-parts,omitempty" yaml:"date-parts,omitempty"`
	// Raw holds the raw string from a bibiographic source, e.g. publisher
	Raw string `json:"raw,omitempty" xml:"raw,omitempty" yaml:"raw,omitempty"`
}

CitationDate holds date information, this includes support for partial dates (e.g. year, year-month).

type CitationIdentifier added in v0.0.72

type CitationIdentifier struct {
	// Type holds the identifier type, e.g. ISSN, ISBN, ROR, ORCID
	Type string `json:"type,omitempty" yaml:"type,omitempty"`
	// Value holds an identifier value.
	Value string `json:"id,omitempty" yaml:"id,omitempty"`
}

CitationIdentifier is a minimal object to identify a type of identifier, e.g. ISBN, ISSN, ROR, ORCID, etc.

type Config

type Config struct {
	// Debug is set true then methods with access to the Config obect
	// can use this flag to implement addition logging to standard err
	Debug bool `json:"-"`
	// Repository Name, e.g. CaltechAUTHORS, CaltechTHESIS, CaltechDATA
	RepoName string `json:"repo_name,omitempty"`
	// Repository ID, e.g. caltechauthors, caltechthesis, caltechdata (usually the db name for repository)
	RepoID string `json:"repo_id,omitempty"`
	// InvenioAPI holds the URL to the InvenioAPI
	InvenioAPI string `json:"rdm_url,omitempty"`
	// InvenioToken is holds the token string to access the API
	InvenioToken string `json:"rdmtok,omitempty"`
	// Invenio DSN holds the data source name for the Postgres database storing the invenio records
	InvenioDSN string `json:"rdm_dsn,omitempty"`
	// InvenioStorage holds the URI to the default storage of Invenio RDM objects, e.g. local file system or S3 bucket
	InvenioStorage string `json:"rdm_storage,omitempty"`
	// InvenioCommunityID holds the community id for use with the API.
	InvenioCommunityID string `json:"rdm_community_id,omitempty"`
	// InvenioDbHost holds the name of the machine for the Postgres server
	InvenioDbHost string `json:"rdm_db_host,omitempty"`
	// InvenioDbUser holds the database username of the machine for the Postgres server
	InvenioDbUser string `json:"rdm_db_user,omitempty"`
	// InvenioDbPassword holds the database password of the machine for the Postgres server
	InvenioDbPassword string `json:"rdm_db_password,omitempty"`

	// CName holds the dataset collection name used when harvesting content
	CName string `json:"c_name,omitempty"`
	// MailTo holds an email address to use when an email (e.g. CrossRef API access) is needed
	MailTo string `json:"mailto,omitempty"`

	// EPrint configuration needed for migration related tools
	EPrintHost         string `json:"eprint_host,omitempty"`
	EPrintUser         string `json:"eprint_user,omitempty"`
	EPrintPassword     string `json:"eprint_password,omitempty"`
	EPrintArchivesPath string `json:"eprint_archives_path,omitempty"`
	EPrintDbHost       string `json:"eprint_db_host,omitempty"`
	EPrintDbUser       string `json:"eprint_db_user,omitempty"`
	EPrintDbPassword   string `json:"eprint_db_password,omitempty"`
	// contains filtered or unexported fields
}

Config holds the common configuration used by all irdmtools

func NewConfig added in v0.0.5

func NewConfig() *Config

NewConfig generates an empty configuration struct.

func (*Config) LoadConfig

func (cfg *Config) LoadConfig(configFName string) error

LoadConfig reads the configuration file and initializes the attributes in the Config struct. It returns an error if problem were encounter. NOTE: It does NOT merge the settings in the environment.

```

cfg := NewConfig()
if err := cfg.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
fmt.Printf("Invenio RDM API UTL: %q\n", cfg.IvenioAPI)
fmt.Printf("Invenio RDM token: %q\n", cfg.InvenioToken)
fmt.Printf("Dataset Collection: %q\n", cfg.CName)
fmt.Printf("MailTo: %q\n", cfg.MailTo)

```

func (*Config) LoadEnv

func (cfg *Config) LoadEnv(prefix string) error

LoadEnv checks the environment for configuration values if not previusly sets them. It will apply a prefix to the expected environment variable names if one is provided.

```

cfg := new(Config)
if err := cfg.LoadEnv("TEST_"); err != nil {
      // ... error handle ...
}

```

type Doi2Rdm

type Doi2Rdm struct {
	Cfg *Config
}

Doi2Rdm holds the configuration for doi2rdm cli.

func (*Doi2Rdm) Configure

func (app *Doi2Rdm) Configure(configFName string, envPrefix string, debug bool) error

Configure reads the configuration file and environtment initialing the Cfg attribute of a Doi2Rdm object. It returns an error if problem were encounter.

```

app := new(irdmtools.Doi2Rdm)
if err := app.Configure("irdmtools.yaml", "TEST_"); err != nil {
   // ... handle error ...
}
fmt.Printf("Invenio RDM API UTL: %q\n", app.Cfg.IvenioAPI)
fmt.Printf("Invenio RDM token: %q\n", app.Cfg.InvenioToken)

```

func (*Doi2Rdm) RunCrossRefToRdm added in v0.0.72

func (app *Doi2Rdm) RunCrossRefToRdm(in io.Reader, out io.Writer, eout io.Writer, optionFName, doi string, diffFName string) error

RunCrossRefToRdm implements the doi2rdm cli behaviors using the CrossRef service. With the exception of the "setup" action you should call `app.LoadConfig()` before execute Run.

```

	app := new(irdmtools.Doi2Rdm)
 // Load irdmtools settings
	if err := app.LoadConfig("irdmtools.json"); err != nil {
	   // ... handle error ...
	}
 // If options are provided then we need to set the filename
 optionsFName := "doi2rdm.yaml"
	doi := "10.48550/arXiv.2104.02480"
	src, err := app.Run(os.Stdin, os.Stdout, os.Stderr, optionFName, doi, "", false)
	if err != nil {
	    // ... handle error ...
	}
	fmt.Printf("%s\n", src)

```

func (*Doi2Rdm) RunDataCiteToRdm added in v0.0.72

func (app *Doi2Rdm) RunDataCiteToRdm(in io.Reader, out io.Writer, eout io.Writer, optionFName, doi string, diffFName string) error

RunDataCiteToRdm implements the doi2rdm cli behaviors using the DataCite service. With the exception of the "setup" action you should call `app.LoadConfig()` before execute Run.

```

	app := new(irdmtools.Doi2Rdm)
 // Load irdmtools settings
	if err := app.LoadConfig("irdmtools.json"); err != nil {
	   // ... handle error ...
	}
 // If options are provided then we need to set the filename
 optionsFName := "doi2rdm.yaml"
	doi := "10.48550/arXiv.2104.02480"
	src, err := app.RunDataCiteToRdm(os.Stdin, os.Stdout, os.Stderr, optionFName, doi, "", false)
	if err != nil {
	    // ... handle error ...
	}
	fmt.Printf("%s\n", src)

```

type Doi2RdmOptions added in v0.0.70

type Doi2RdmOptions struct {
	MailTo              string            `json:"mailto,omitempty" yaml:"mailto"`
	Download            bool              `json:"download,omitempty" yaml:"download"`
	DotInitials         bool              `json:"dot_initials,omitempty" yaml:"dot_initials"`
	ContributorTypes    map[string]string `json:"contributor_types,omitemptpy" yaml:"contributor_types"`
	ResourceTypes       map[string]string `json:"resource_types,omitempty" yaml:"resource_types"`
	DoiPrefixPublishers map[string]string `json:"doi_prefix_publishers,omitempty" yaml:"doi_prefix_publishers"`
	ISSNPublishers      map[string]string `json:"issn_publishers,omitempty" yaml:"issn_publishers"`
	Debug               bool              `json:"debug,omitempty" yaml:"debug"`
}

type EPrint2Rdm

type EPrint2Rdm struct {
	Cfg *Config
}

EPrint2Rdm holds the configuration for rdmutil cli.

func (*EPrint2Rdm) Configure added in v0.0.54

func (app *EPrint2Rdm) Configure(configFName string, envPrefix string, debug bool) error

Configure reads the configuration file and environment initialing the Cfg attribute of a Eprint2Rdm object. It returns an error if problem were encounter.

```

app := new(irdmtools.EPrint2Rdm)
if err := app.Configure("irdmtools.json", "TEST_"); err != nil {
   // ... handle error ...
}
fmt.Printf("Invenio RDM API UTL: %q\n", app.Cfg.IvenioAPI)
fmt.Printf("Invenio RDM token: %q\n", app.Cfg.InvenioToken)

```

func (*EPrint2Rdm) Run

func (app *EPrint2Rdm) Run(in io.Reader, out io.Writer, eout io.Writer, username string, password string, host string, eprintId string, resourceTypesFName string, contributorTypesFName string, allIds bool, idList string, cName string, debug bool) error

Run implements the eprint2rdm cli behaviors.

```

	app := new(irdmtools.EPrint2Rdm)
	eprintUsername := os.Getenv("EPRINT_USERNAME")
	eprintPassword := os.Getenv("EPRINT_PASSWORD")
	eprintHost := "eprints.example.edu"
	eprintId := "11822"
	resourceTypes := map[string]string{}
 if err := LoadTypesMap("resource-types.csv", resourceTypes);
		err != nil {
		// ... handle error ...
	}
 contributorTypes := map[string]string{}
 if err := LoadTypesMap("contributor-types.csv", contributorTypes);
		err != nil {
		// ... handle error ...
	}
	src, err := app.Run(os.Stdin, os.Stdout, os.Stderr,
						eprintUser, eprintPassword,
						eprintHost, eprintId,
                     resourceTypes, contributorsTypes,
						debug)
	if err != nil {
		// ... handle error ...
	}
	fmt.Printf("%s\n", src)

```

type EPrintKeysPage added in v0.0.2

type EPrintKeysPage struct {
	XMLName xml.Name `xml:"html"`
	Anchors []string `xml:"body>ul>li>a"`
}

EPrintKeysPage holds the structure of the HTML page with the EPrint IDs embedded from the EPrint REST API.

type EPrintRest added in v0.0.49

type EPrintRest struct {
	RepoID             string `json:"repo_id,required"`
	EPrintArchivesPath string `json:"eprint_archives_path,required"`
	Port               string `json:"rest_port,omitempty"`
	DbHost             string `json:"db_host,omitempty`
	DbUser             string `json:"db_user,omitempty`
	DbPassword         string `json:"db_password,omitempty`
	// contains filtered or unexported fields
}

EPrintRest the "app" structure for the service.

func (*EPrintRest) EPrintXMLPath added in v0.0.49

func (app *EPrintRest) EPrintXMLPath(db *sql.DB, id string) (string, error)

EPrintXMLPath takes the app setup and generates the path do the EPrintXML document from an id.

func (*EPrintRest) ListenAndServe added in v0.0.49

func (app *EPrintRest) ListenAndServe() error

Serve runs the web service minimally replicating the EPrints 3.x REST API.

func (*EPrintRest) LoadEnv added in v0.0.49

func (app *EPrintRest) LoadEnv()

LoadEnv settings from the enviroment to run a local host clone of the EPrints REST API using the archives content and MySQL database.

func (*EPrintRest) MkDatasetPage added in v0.0.49

func (app *EPrintRest) MkDatasetPage(db *sql.DB, tmpl string, dataset string, label string) (string, error)

MkDatasetPage takes the simple page template and maps the dataset and label rendering the HTML page as a string

func (*EPrintRest) Run added in v0.0.49

func (app *EPrintRest) Run(in io.Reader, out io.Writer, eout io.Writer) error

Run loads a configuration from the environment and does a sanity check of the service setup maps standard in, out and error to the service then invokes app.ListenAndServe().

type Ep3Util added in v0.0.53

type Ep3Util struct {
	Cfg   *Config
	Debug bool
}

Ep3Util holds the configuration for ep3util cli.

func (*Ep3Util) Configure added in v0.0.53

func (app *Ep3Util) Configure(configFName string, envPrefix string, debug bool) error

Configure reads the configuration file and environtment initialing the Cfg attribute of a Ep3Util object. It returns an error if problem were encounter.

```

app := new(irdmtools.Ep3Util)
if err := app.Configure("irdmtools.json", "TEST_"); err != nil {
   // ... handle error ...
}
fmt.Printf("Invenio RDM API UTL: %q\n", app.Cfg.IvenioAPI)
fmt.Printf("Invenio RDM token: %q\n", app.Cfg.InvenioToken)

```

func (*Ep3Util) GetModifiedRecordIds added in v0.0.56

func (app *Ep3Util) GetModifiedRecordIds(start string, end string) ([]byte, error)

GetModifiedRecordIds returns a byte slice for a JSON encode list of record ids or an error based on the records listed in EPrints.

```

app := new(irdmtools.Ep3Util)
if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
src, err := app.GetModifiedRecordIds("2023-09-01", "2023-09-30")
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func (*Ep3Util) GetRecord added in v0.0.53

func (app *Ep3Util) GetRecord(id string) ([]byte, error)

GetRecord returns a byte slice for a JSON encoded record or an error.

```

app := new(irdmtools.Ep3Util)
if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
recordId := "23808"
src, err := app.GetRecord(recordId)
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func (*Ep3Util) GetRecordIds added in v0.0.53

func (app *Ep3Util) GetRecordIds() ([]byte, error)

GetRecordIds returns a byte slice for a JSON encode list of record ids or an error based on the records listed in the EPrints.

```

app := new(irdmtools.Ep3Util)
if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
src, err := app.GetRecordIds()
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func (*Ep3Util) Run added in v0.0.53

func (app *Ep3Util) Run(in io.Reader, out io.Writer, eout io.Writer, action string, params []string) error

Run implements the irdmapp cli behaviors. With the exception of the Run.

```

app := new(irdmtools.Ep3Util)
if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
recordId := "23808"
src, err := app.Run(os.Stdin, os.Stdout, os.Stderr,
                     "get_record", []string{recordId})
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func (*Ep3Util) RunHarvest added in v0.0.56

func (app *Ep3Util) RunHarvest(in io.Reader, out io.Writer, eout io.Writer, all bool, modified bool, params []string) error

Harvest takes a JSON file contianing a list of record ids and harvests them into a dataset v2 collection. The dataset collection must exist and be configured in either the environment or configuration file.

type Hits

type Hits struct {
	Hits  []map[string]interface{} `json:"hits,omitempty"`
	Total int                      `json:"total,omitempty"`
}
type Links struct {
	Self string `json:"self,omitempty"`
	Next string `json:"next,omitempty"`
	Prev string `json:"prev,omitempty"`
}

type OAIHeader

type OAIHeader struct {
	Status     string   `xml:"status,attr,omitempty" json:"status,omitempty"`
	Identifier string   `xml:"identifier,omitempty" json:"identifier,omitempty"`
	DateStamp  string   `xml:"datestamp,omitempty" json:"datestamp,omitempty"`
	SetSpec    []string `xml:"setSpec,omitempty" json:"set_spec,omitempty"`
}

OAIHeader holds the response items for

type OAIListIdentifiers

type OAIListIdentifiers struct {
	Headers         []OAIHeader `xml:"header,omitempty" json:"header,omitempty"`
	ResumptionToken string      `xml:"resumptionToken,omitempty" json:"resumption_token,omitempty"`
}

type OAIListIdentifiersResponse

type OAIListIdentifiersResponse struct {
	XMLName         xml.Name            `xml:"OAI-PMH" json:"-"`
	XMLNS           string              `xml:"xmlns,attr,omitempty" json:"xmlns,omitempty"`
	ResponseDate    string              `xml:"responseDate,omitempty" json:"response_date,omitempty"`
	Request         string              `xml:"request,omitempty" json:"request,omitempty"`
	RequestAttr     map[string]string   `xml:"request,attr,omitempty" json:"request_attr,omitempty"`
	ListIdentifiers *OAIListIdentifiers `xml:"ListIdentifiers,omitempty" json:"list_identifiers,omitempty"`
}

OAIListIdendifiersResponse

type QueryResponse

type QueryResponse struct {
	//
	Hits   *Hits  `json:"hits,omitepmty"`
	Links  *Links `json:"links,omitempty"`
	SortBy string `json:"sortBy,omitempty"`
}

QueryResponse holds the response to /api/records?q=...

type RateLimit

type RateLimit struct {
	// Limit maps to X-RateLimit-Limit
	Limit int `json:"limit,omitempty"`
	// OldLimit holds the last value of rate limit before change.
	OldLimit int `json:"-"`
	// Remaining maps to X-RateLimit-Remaining
	Remaining int `json:"remaining,omitempty"`
	// Reset maps to X-RateLimit-Reset
	Reset int `json:"reset,omitempty"`
}

RateLimit holds the values used to play nice with OAI-PMH or REST API. It normally is extracted from the response header.

func (*RateLimit) Fprintf

func (rl *RateLimit) Fprintf(out io.Writer)

func (*RateLimit) FromHeader

func (rl *RateLimit) FromHeader(header http.Header)

FromHeader takes an http.Header (e.g. http.Response.Header) and updates a rate limit struct.

``` rl := new(RateLimit) rl.FromHeader(header) ```

func (*RateLimit) FromResponse

func (rl *RateLimit) FromResponse(resp *http.Response)

FromResponse takes an http.Response struct and extracts the header values realated to rate limits (e.g. X-RateLite-Limit)

``` rl := new(RateLimit) rl.FromResponse(response) ```

func (*RateLimit) ResetString

func (rl *RateLimit) ResetString() string

func (*RateLimit) String

func (rl *RateLimit) String() string

func (*RateLimit) Throttle

func (rl *RateLimit) Throttle(i int, tot int)

Throttle looks at the rate limit structure and implements an appropriate sleep time based on rate limits.

```

 i, tot := 0, 1000 // This ith' iteration and total number of records
	rl := new(RateLimit)
	// Set our rate limit from
	rl.FromResponse(response)
 rl.Throttle(i, tot)

```

func (*RateLimit) TimeToReset

func (rl *RateLimit) TimeToReset() (time.Duration, time.Time)

func (*RateLimit) TimeToWait

func (rl *RateLimit) TimeToWait(unit time.Duration) time.Duration

SecondsToWait returns the number of seconds (as a time.Duratin) to wait to avoid a http status code 429 and a ratio (float64) of remaining per request limit.

``` rl := new(RateLimit) rl.FromHeader(response.Header) timeToWait := rl.TimeToWait() time.Sleep(timeToWait) ```

type Rdm2EPrint added in v0.0.53

type Rdm2EPrint struct {
	Cfg *Config
}

Rdm2EPrint holds the configuration for rdmutil cli.

func (*Rdm2EPrint) Configure added in v0.0.53

func (app *Rdm2EPrint) Configure(configFName string, envPrefix string, debug bool) error

Configure reads the configuration file and environtment initialing the Cfg attribute of a RdmUtil object. It returns an error if problem were encounter.

```

app := new(irdmtools.RdmUtil)
if err := app.Configure("irdmtools.json", "TEST_"); err != nil {
   // ... handle error ...
}
fmt.Printf("Invenio RDM API UTL: %q\n", app.Cfg.IvenioAPI)
fmt.Printf("Invenio RDM token: %q\n", app.Cfg.InvenioToken)

```

func (*Rdm2EPrint) Run added in v0.0.53

func (app *Rdm2EPrint) Run(in io.Reader, out io.Writer, eout io.Writer, rdmids []string, asXML bool) error

func (*Rdm2EPrint) RunHarvest added in v0.0.53

func (app *Rdm2EPrint) RunHarvest(in io.Reader, out io.Writer, eout io.Writer, cName string, rdmids []string) error

func (*Rdm2EPrint) RunPipeline added in v0.0.54

func (app *Rdm2EPrint) RunPipeline(in io.Reader, out io.Writer, eout io.Writer, asXML bool) error

Run in pipline mode, e.g. `eprint2rdm XXXXX-XXXXX | rdm2eprint` should round trip the EPrint record to RDM then back again. It reads from standard input and writes to standard out.

type RdmUtil

type RdmUtil struct {
	Cfg   *Config
	Debug bool
}

RdmUtil holds the configuration for rdmutil cli.

func (*RdmUtil) CheckDOI added in v0.0.34

func (app *RdmUtil) CheckDOI(doi string) ([]byte, error)

CheckDOI checks the .pids.doi.identifier and returns a record from the match DOI.

```

	app := new(irdmtools.RdmUtil)
	if err := app.LoadConfig("irdmtools.json"); err != nil {
	   // ... handle error ...
	}
 doi := '10.1126/science.82.2123.219'
	src, err := app.CheckDOI(doi)
	if err != nil {
	    // ... handle error ...
	}
	fmt.Printf("%s\n", src)

```

func (*RdmUtil) Configure

func (app *RdmUtil) Configure(configFName string, envPrefix string, debug bool) error

Configure reads the configuration file and environtment initialing the Cfg attribute of a RdmUtil object. It returns an error if problem were encounter.

```

app := new(irdmtools.RdmUtil)
if err := app.Configure("irdmtools.json", "TEST_"); err != nil {
   // ... handle error ...
}
fmt.Printf("Invenio RDM API UTL: %q\n", app.Cfg.IvenioAPI)
fmt.Printf("Invenio RDM token: %q\n", app.Cfg.InvenioToken)

```

func (*RdmUtil) DeleteEndpoint added in v0.0.31

func (app *RdmUtil) DeleteEndpoint(p string) ([]byte, error)

DeleteEndpoint performs a DELETE on the endpoint indicated by PATH provided.

func (*RdmUtil) DeleteFiles added in v0.0.29

func (app *RdmUtil) DeleteFiles(recordId string, filenames []string) ([]byte, error)

DeleteFiles takes a RDM record id an list of files and removes them from a draft.

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

id := "woie-x0121" filenames := []string{ "article.pdf", "charts.zip", "data.zip" } src, err := app.DeleteFiles(id, filenames)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src)

```

func (*RdmUtil) DiscardDraft added in v0.0.29

func (app *RdmUtil) DiscardDraft(recordId string) ([]byte, error)

DiscardDraft takes a record id and delete the draft.

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

id := "woie-x0121" src, err := app.DiscardDraft(id)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src)

```

func (*RdmUtil) GetAccess added in v0.0.29

func (app *RdmUtil) GetAccess(id string, accessType string) ([]byte, error)

GetAccess returns the JSON for the access attribute in a record if accessType parameter is an empty string or the specific access requested if not (e.g. "files", "record"). An error value is also returned.

``` app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

recordId := "woie-x0121" accessType := "" // accessType = "record" // accessType := "files" src, err := app.GetAccess(recordId, accessType)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func (*RdmUtil) GetDraft added in v0.0.28

func (app *RdmUtil) GetDraft(id string) ([]byte, error)

GetDraft returns an existing draft of a record.

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

recordId := "woie-x0121" src, err := app.GetDraft(recordId)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src)

```

func (*RdmUtil) GetDraftFiles added in v0.0.31

func (app *RdmUtil) GetDraftFiles(recordId string) ([]byte, error)

GetDraftFiles returns the metadata for a draft's files

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

recordId := "woie-x0121" src, err := app.GetFiles(recordId)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src)

```

func (*RdmUtil) GetEndpoint added in v0.0.29

func (app *RdmUtil) GetEndpoint(p string) ([]byte, error)

GetEndpoint performs a GET on the endpoint indicated by PATH provided.

func (*RdmUtil) GetFile added in v0.0.28

func (app *RdmUtil) GetFile(id string, fName string) ([]byte, error)

GetFile returns the metadata for a file

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

recordId := "woie-x0121" fName := "article.pdf" src, err := app.GetFile(recordId, fName)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src)

```

func (*RdmUtil) GetFiles added in v0.0.28

func (app *RdmUtil) GetFiles(recordId string) ([]byte, error)

GetFiles returns the metadata for working with files

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

recordId := "woie-x0121" src, err := app.GetFiles(recordId)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src)

```

func (*RdmUtil) GetModifiedIds

func (app *RdmUtil) GetModifiedIds(start string, end string) ([]byte, error)

GetModified returns a byte slice for a JSON encode list of record ids modified (created, updated, deleted) in the given time range. If a problem occurs an error is returned.

```

app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
src, err := app.GetModifiedIds("2020-01-01", "2020-12-31")
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func (*RdmUtil) GetRawRecord added in v0.0.5

func (app *RdmUtil) GetRawRecord(id string) ([]byte, error)

GetRawRecord returns a byte slice for a JSON encoded record as a `map[string]interface{}` retrieved from the RDM API.

```

app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
recordId := "woie-x0121"
src, err := app.GetRawRecord(recordId)
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func (*RdmUtil) GetRecord

func (app *RdmUtil) GetRecord(id string) ([]byte, error)

GetRecord returns a byte slice for a JSON encoded record or an error.

```

app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
recordId := "woie-x0121"
src, err := app.GetRecord(recordId)
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func (*RdmUtil) GetRecordIds

func (app *RdmUtil) GetRecordIds() ([]byte, error)

GetRecordIds returns a byte slice for a JSON encode list of record ids or an error. The record ids are for the latest pbulished verison of the records.

```

app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
src, err := app.GetRecordIds()
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func (*RdmUtil) GetRecordStaleIds added in v0.0.62

func (app *RdmUtil) GetRecordStaleIds() ([]byte, error)

GetRecordStaleIds returns a byte slice for a JSON encode list of record ids or an error. The record ids are for the stale versions of published records.

```

app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
src, err := app.GetRecordStaleIds()
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func (*RdmUtil) GetRecordVersions added in v0.0.64

func (app *RdmUtil) GetRecordVersions(id string) ([]byte, error)

GetRecordVersions returns a byte slice fron JSON encoded list of record versions for a given RDM record id.

```

app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
recordId := "5wh3x-cj477"
src, err := app.GetRecordVersions(recordId)
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func (*RdmUtil) GetReview added in v0.0.31

func (app *RdmUtil) GetReview(recordId string) ([]byte, error)

GetReview takes a record id and returns information about review requests.

``` app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

id := "woie-x0121" src, err := app.GetReview(id, "accept", "")

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func (*RdmUtil) GetVersionLatest added in v0.0.28

func (app *RdmUtil) GetVersionLatest(id string) ([]byte, error)

GetVersionLatest returns the latest version metadata for a record.

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

recordId := "woie-x0121" src, err := app.GetVersionLatest(recordId)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src)

```

func (*RdmUtil) GetVersions added in v0.0.28

func (app *RdmUtil) GetVersions(id string) ([]byte, error)

GetVersions returns the versioning metadata for a record.

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

recordId := "woie-x0121" src, err := app.GetVersions(recordId)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src)

```

func (*RdmUtil) Harvest

func (app *RdmUtil) Harvest(fName string) error

Harvest takes a JSON file contianing a list of record ids and harvests them into a dataset v2 collection. The dataset collection must exist and be configured in either the environment or configuration file.

func (*RdmUtil) NewDraft added in v0.0.30

func (app *RdmUtil) NewDraft(recordId string) ([]byte, error)

NewDraft returns the a new draft of an existing record.

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

recordId = "woie-x0121" src, err := app.NewDraft(recordId)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src)

```

func (*RdmUtil) NewRecord added in v0.0.30

func (app *RdmUtil) NewRecord(src []byte) ([]byte, error)

NewRecord create a new record from JSON source. It returns a created record including a record id.

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

jsonSrc, _ := os.ReadFile("new_record.json") src, err := app.NewRecord(jsonSrc)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src)

```

func (*RdmUtil) NewRecordVersion added in v0.0.30

func (app *RdmUtil) NewRecordVersion(recordId string) ([]byte, error)

NewRecordVersion create a new record version using record id. It returns a created record including a record id.

``` app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

recordId = "woie-x0121" src, err := app.NewRecordVersion(recordId)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func (*RdmUtil) PatchEndpoint added in v0.0.30

func (app *RdmUtil) PatchEndpoint(p string, data []byte) ([]byte, error)

PatchEndpoint performs a PATCH on the endpoint indicated by PATH provided.

func (*RdmUtil) PostEndpoint added in v0.0.30

func (app *RdmUtil) PostEndpoint(p string, data []byte) ([]byte, error)

PostEndpoint performs a POST on the endpoint indicated by PATH provided.

func (*RdmUtil) PublishRecordVersion added in v0.0.32

func (app *RdmUtil) PublishRecordVersion(recordId string, version string, pubDate string) ([]byte, error)

PublishRecordVersion publish a new version draft using the version's record id.

``` app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

recordId = "woie-x0121" version, pubDate := "internal", "2022-08" src, err := app.PublishRecordVersion(recordId)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func (*RdmUtil) PutEndpoint added in v0.0.30

func (app *RdmUtil) PutEndpoint(p string, data []byte) ([]byte, error)

PutEndpoint performs a PUT on the endpoint indicated by PATH provided.

func (*RdmUtil) Query

func (app *RdmUtil) Query(q string, sort string) ([]byte, error)

Query returns a byte slice for a JSON encode list of record summaries or an error.

```

app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
src, err := app.Query("My favorite book", -1, "newest")
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func (*RdmUtil) RetrieveFile added in v0.0.28

func (app *RdmUtil) RetrieveFile(id string, fName string) ([]byte, error)

RetrieveFile retrieves the file from an RDM instance.

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

recordId := "woie-x0121" fName := "article.pdf" data, err := app.RetrieveFile(recordId, fName)

if err != nil {
  // ... handle error ...
}

os.WriteFile("article.pdf", data, 0664)

```

func (*RdmUtil) ReviewComment added in v0.0.40

func (app *RdmUtil) ReviewComment(recordId string, comment string) ([]byte, error)

ReviewComment takes a record id and a comment and submits the comment to the review process.

``` app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

id := "woie-x0121" src, err := app.ReviewComment(id, "Not sure about this one, but it is exciting")

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func (*RdmUtil) ReviewRequest added in v0.0.31

func (app *RdmUtil) ReviewRequest(recordId string, decision string, comment string) ([]byte, error)

ReviewRequest takes a record id, a decision and a comment and submits it to the review process.

``` app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

id := "woie-x0121" src, err := app.ReviewRequest(id, "accept", "")

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src) ```

func (*RdmUtil) Run

func (app *RdmUtil) Run(in io.Reader, out io.Writer, eout io.Writer, action string, params []string) error

Run implements the irdmapp cli behaviors. With the exception of the Run.

```

app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil {
   // ... handle error ...
}
recordId := "wx0w-2231"
src, err := app.Run(os.Stdin, os.Stdout, os.Stderr,
                     "get_record", []string{recordId})
if err != nil {
    // ... handle error ...
}
fmt.Printf("%s\n", src)

```

func (*RdmUtil) SendToCommunity added in v0.0.30

func (app *RdmUtil) SendToCommunity(recordId string, communityId string) ([]byte, error)

SendToCommunity takes a RDM record id and community UUID. It populates the the parent element approriately for draft to be submitted to a specific community.

func (*RdmUtil) SetAccess added in v0.0.29

func (app *RdmUtil) SetAccess(id string, accessType string, accessValue string) ([]byte, error)

SetAccess sets the access attribute for a record. The access type can be either record or files. The value can be either "public" or "restricted". An error value is also returned with the function.

```

	app := new(irdmtools.RdmUtil)
	if err := app.LoadConfig("irdmtools.json"); err != nil {
	   // ... handle error ...
	}
	recordId := "woie-x0121"
 accessType := "record"
	src, err := app.SetAccess(recordId, accessType, "public")
	if err != nil {
	    // ... handle error ...
	}
	fmt.Printf("%s\n", src)
 accessType = "files"
	src, err := app.SetAccess(recordId, accessType, "restricted")
	if err != nil {
	    // ... handle error ...
	}
	fmt.Printf("%s\n", src)

```

func (*RdmUtil) SetFilesEnable added in v0.0.30

func (app *RdmUtil) SetFilesEnable(recordId string, enable bool) ([]byte, error)

SetFilesEnable takes a RDM record id and either boolean setting the files.enabled value in a draft record. Returns the draft record and an error value.

func (*RdmUtil) SetPubDate added in v0.0.32

func (app *RdmUtil) SetPubDate(recordId string, pubDate string) ([]byte, error)

SetPubDate takes a RDM record id and publication date string setting the .metadata.publication_date in a draft record.

func (*RdmUtil) SetVersion added in v0.0.32

func (app *RdmUtil) SetVersion(recordId string, version string) ([]byte, error)

SetVersion takes a RDM record id and version string setting the .metadata.version in a draft record.

func (*RdmUtil) UpdateDraft added in v0.0.28

func (app *RdmUtil) UpdateDraft(recordId string, src []byte) ([]byte, error)

UpdateDraft returns takes a record id and returns a draft record.

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

id := "woie-x0121" jsonSrc, _ := os.ReadFile("draft.json") src, err := app.UpdateDraft(id, jsonSrc)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src)

```

func (*RdmUtil) UploadFiles added in v0.0.29

func (app *RdmUtil) UploadFiles(recordId string, filenames []string) ([]byte, error)

UploadFiles takes a RDM record id an list of files and uploads them to a draft.

```

app := new(irdmtools.RdmUtil)

if err := app.LoadConfig("irdmtools.json"); err != nil {
  // ... handle error ...
}

id := "woie-x0121" filenames := []string{ "article.pdf", "charts.zip", "data.zip" } src, err := app.UploadFiles(id, filenames)

if err != nil {
  // ... handle error ...
}

fmt.Printf("%s\n", src)

```

type RorOrgAPIResponse added in v0.0.50

type RorOrgAPIResponse struct {
	NumberOfResults int                      `json:"number_of_results,omitempty"`
	TimeTaken       time.Duration            `json:"time_taken,omitempty"`
	Items           []map[string]interface{} `json:"items,omitempty"`
}

Directories

Path Synopsis
cmd
doi2rdm
doi2rdm is a command line program for harvesting DOI metadata from CrossRef and DataCite returning a JSON documentument sutiable for import into Invenio RDM.
doi2rdm is a command line program for harvesting DOI metadata from CrossRef and DataCite returning a JSON documentument sutiable for import into Invenio RDM.
ep3ds2citations
ep3ds2citations is a command line program that will convert a dataset collection of EPrint 3.3 records into a citations dataset collection
ep3ds2citations is a command line program that will convert a dataset collection of EPrint 3.3 records into a citations dataset collection
ep3util
ep3util is a command line program for working with a read only EPrint API.
ep3util is a command line program for working with a read only EPrint API.
eprint2rdm
eprint2rdm is a command line program for harvesting an EPrint metadata record and return a Invenio RDM style record.
eprint2rdm is a command line program for harvesting an EPrint metadata record and return a Invenio RDM style record.
eprintrest
eprintrest is a command line program that re-creates a EPrints 3.x REST API running on localhost.
eprintrest is a command line program that re-creates a EPrints 3.x REST API running on localhost.
rdm2eprint
rdm2eprint is a command line program for harvesting an RDM record and rendering it as a EPrint 3.3 record.
rdm2eprint is a command line program for harvesting an RDM record and rendering it as a EPrint 3.3 record.
rdmutil
rdmutil is a command line program for working with Invenio RDM.
rdmutil is a command line program for working with Invenio RDM.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL