Documentation ¶
Overview ¶
Package meta:
- defines NSW State Archives approach to the construction of SIPS in the [OAIS model](https://www.oclc.org/research/publications/library/2000/lavoie-oais.html). - defines schemas for the metadata.json, manifest.json and json log files within these SIPS - is a software library that can be used by scripts in order to generate these SIPS.
Index ¶
- Constants
- Variables
- func IndexPath(m *Meta, index string) string
- func MustInt(s string) int
- func NewDateTime(t string) *time.Time
- func ParseDateTime(t string) (time.Time, error)
- func ReadAll(path string, lq ...bool) ([][]string, error)
- func ReferenceLog(i int) string
- func ReferenceMigration(i int) string
- func ReferenceN(refs ...Ref) string
- func ReferenceObject(i int) string
- func ReferenceVersion(v int) string
- func ToConsignment(i int) string
- func ToID(i int, pat string) string
- func ToPUID(puid string) string
- func ToRef(i int, ref string) string
- func ToSeries(i int) string
- func ToSz(s string) int64
- type AccessRule
- type Action
- type Agency
- type Agent
- type Basis
- type Business
- type Container
- type Context
- type Disposal
- type DisposalRule
- type Field
- type File
- type FileTarget
- type GlobalAccess
- type Hash
- type Loader
- type Log
- type Manifest
- type Meta
- type Metadata
- type Obj
- type Ref
- type Series
- type Siegfried
- type Thing
- type TitleFn
- type VarStr
- type Version
- type W3CDate
Constants ¶
const ( FBDTF = "2006-01-02T15:04:05+0000" SlashDMY = "2/01/2006" SlashYMD = "2006/01/02" DashDMY = "02-01-06" RelDTF = SlashDMY + " 15:04" //relativity RelNoSlash = "20060102" )
Add new date formats here, using the special Golang date value
const ( ModificationEvent = "http://id.loc.gov/vocabulary/preservation/eventType/mod" MigrationEvent = "http://id.loc.gov/vocabulary/preservation/eventType/mig" )
Variables ¶
var Cap int = 1000
Cap defines the capacity of the index slice. Edit for large jobs to an approximate number of objects
Functions ¶
func IndexPath ¶
IndexPath is an example function that could be supplied to ManifestCopy IndexPath assumes that the index holds the full path to a file, so takes the dir of that path.
func NewDateTime ¶
NewDate returns a reference to a time.Time from a W3C style datetime string. If the string provided is an invalid datetime, a nil reference is returned.
func ParseDateTime ¶
ParseDateTime makes a time.Time from a W3C style datetime string
func ReadAll ¶
ReadAll is a helper function that opens a file at path and reads as a CSV. Provide an optional lazy quote bool if you'd like lazy quotes. Returns a slice of string slices and an error.
func ReferenceLog ¶
ReferenceLog makes a temporary reference to a log event. This reference is swapped for a UUID by the migrate tool.
func ReferenceMigration ¶
ReferenceMigration makes a temporary reference to another migration (that doesn't yet have a UUID). This reference is swapped for a UUID by the migrate tool.
func ReferenceN ¶
ReferenceN constructs an internal reference string from the supplied Ref(s)
func ReferenceObject ¶
ReferenceObject makes a temporary reference to another object in the consignment. This reference is swapped for a UUID by the migrate tool.
func ReferenceVersion ¶
func ToConsignment ¶
ToConsignment turns a consignment number into an IRI @id
func ToID ¶
ToID is a helper function that turns an integer identififier into a string @id It is useful for places where we use integer IDs e.g. series numbers but want an IRI for the @id
func ToPUID ¶
ToPUID is a helper function that turns a short PUID (e.g. fmt/1) into a fully qualified PUID (e.g. http://www.nationalarchives.gov.uk/pronom/fmt/1)
Types ¶
type AccessRule ¶
type AccessRule struct { ID string `json:"@id"` ExecuteDate W3CDate `json:"executeDate"` Scope string `json:"scope"` Publish bool `json:"publish"` Basis *Basis `json:"basis,omitempty"` Patch *int `json:"metadataPatch,omitempty"` FullManifest *bool `json:"fullManifest,omitempty"` Display VarStr `json:"displayTarget,omitempty"` Preview VarStr `json:"previewTarget,omitempty"` Text VarStr `json:"textTarget,omitempty"` }
AccessRule represents accessRules
func AppendAR ¶
func AppendAR(rules []AccessRule, executeDate, scope string, publish bool, accessDirection int, accessDescription string, display, preview, text []FileTarget, ) ([]AccessRule, string, error)
AppendAR adds a new access rule to a set of rules (or create a new set of rules by appending to nil) Provide access rule fields in the supplied arguments. Because of their rarity, Patch and FullManifest fields aren't supplied as arguments but should be manipulated directly. Returns the list of access rules, the new access rule's @id, and an error.
func CopyARs ¶
func CopyARs(ar []AccessRule) []AccessRule
CopyARs copies a slice of AccessRules. This allows you to create a template access rule and copy it e.g. to change file references.
type Action ¶
Action is a function (such as file copy) that is called when generating output
func Decompress ¶
Decompress takes a path to a siegfried signature file and a pathfunc. The pathfunc returns the directory that will be joined to the filename out of the manifest. It returns an action that: - checks if a PUID (assuming a single version 0/ file 0) is a compressed type and recursively decompresses, - adding new files to manifest and copying them to output.
func ManifestCopy ¶
ManifestCopy copies files and versions as listed in the manifest Supply a pathfunc takes the Meta and index as parameters. The output of the pathfunc will be joined with the filename as listed in manifest.
func SimpleManifest ¶
SimpleManifest observes the files in the "versions" folder and builds a simple manifest based on that information. It takes a fmtmap argument and path to a siegfried file. The fmtmap links file extensions e.g. "pdf" to PUID + mimetype. It can be nil if you want siegfried identification only. The siegfried path can be an empty string if you don't want siegfried scanning.
type Agent ¶
type Agent interface{}
Agent can be a string e.g. "Richard Lehane" or an object with @id/@type, or a slice of Agents
func AppendAgent ¶
AppendAgent is a helper func to add agents to a slice of agents
func MakeAgency ¶
MakePerson creates an Agent that is of @type terms/Agency. Sets the @id to the supplied value.
func MakeAgent ¶
MakeAgent returns an Agent with the given name, @id and @type. If @id and @type aren't given, the Agent is a simple string e.g. "Richard Lehane"
func MakeOrganization ¶
MakePerson creates an Agent that is of @type schema.org/Organization.
func MakePerson ¶
MakePerson creates an Agent that is of @type terms/Person. Sets the @id to the supplied value.
func MakeSDOPerson ¶
MakeSDOPerson creates an Agent that is of @type schema.org/Person. Does not set an @id.
func MakeSoftware ¶
MakeSoftware creates an Agent that is of @type https://schema.org/SoftwareApplication. Sets the version to the supplied value.
type Basis ¶
type Basis struct { AccessDirection string `json:"accessDirection"` AccessDescription string `json:"accessDescription,omitempty"` }
Basis is a json basis
type Business ¶
type Business struct { Typ string `json:"@type,omitempty"` LegalName string `json:"legalName,omitempty"` CommencedTrading *W3CDate `json:"commencedTrading,omitempty"` CeasedTrading *W3CDate `json:"ceasedTrading,omitempty"` RenewalDueDate *W3CDate `json:"renewalDueDate,omitempty"` RegistrationNumber string `json:"registrationNumber,omitempty"` ABN string `json:"abn,omitempty"` Proprietor Agent `json:"proprietor,omitempty"` }
Business is a type of Thing. It is used for the BRS project
type Container ¶
type Container interface{}
Type container can be anything a metadata isPartOf
func FileContainer ¶
func MakeContainer ¶
type Disposal ¶
type Disposal interface{}
Disposal can be a single DisposalRule{} or a slice of []DisposalRule{}
type DisposalRule ¶
func (DisposalRule) Load ¶
func (d DisposalRule) Load(m *Meta) error
DisposalRule loader. Applies a single disposal rule to all digital objects
type File ¶
type File struct { ID string `json:"@id"` Name string `json:"name"` OriginalName string `json:"originalName,omitempty"` Size int64 `json:"size"` Created *time.Time `json:"fileCreated,omitempty"` Modified *time.Time `json:"modified,omitempty"` MIME string `json:"mime,omitempty"` PUID string `json:"puid,omitempty"` Hash *Hash `json:"hash,omitempty"` HasAccessRules []string `json:"hasAccessRules,omitempty"` }
File represents files
type FileTarget ¶
type FileTarget [2]int
FileTarget is an internal reference for a file target
func (FileTarget) String ¶
func (ft FileTarget) String() string
String is a string representation of a FileTarget
type GlobalAccess ¶
GlobalAccess loader. Applies a simple, global access rule to all digital objects
func (GlobalAccess) Load ¶
func (g GlobalAccess) Load(m *Meta) error
type Hash ¶
type Hash struct { Algorithm string `json:"hashAlgorithm,omitempty"` Value string `json:"hashValue,omitempty"` }
Hash is a json hash
type Log ¶
type Log struct { ID string `json:"@id"` Typ string `json:"@type"` // from http://id.loc.gov/vocabulary/preservation/eventType.html e.g. http://id.loc.gov/vocabulary/preservation/eventType/mig Start *time.Time `json:"startTime,omitempty"` End *time.Time `json:"endTime"` Detail string `json:"detail"` Agent Agent `json:"agent"` Context Context `json:"@context"` }
Log represents a preservation event e.g. format migration. The PROV and PREMIS ontologies are primarily used for this metadata.
type Manifest ¶
type Manifest struct { Type string `json:"@type"` AccessRules []AccessRule `json:"accessRules,omitempty"` Versions []Version `json:"versions,omitempty"` Context Context `json:"@context"` }
Manifest represents a manifest.json file
func NewManifest ¶
func NewManifest() *Manifest
NewManifest returns a reference to a manifest. It also sets the @type field.
func (*Manifest) AddAR ¶
func (m *Manifest) AddAR( executeDate, scope string, publish bool, accessDirection int, accessDescription string, display, preview, text []FileTarget, ) (arid string, err error)
AddAR adds a new access rule to a Manifest Provide access rule fields in the supplied arguments. Because of their rarity, Patch and FullManifest fields aren't supplied as arguments but should be manipulated directly. Returns the new access rule's @id and an error.
func (*Manifest) AddVersion ¶
AddVersion adds a new version to a Manifest. It takes a slice of access rules, and a slice of files. It returns the version @id.
type Meta ¶
type Meta struct { SampleOff int SampleSz int // sample size (-1 if doing a full run) Index []string Metadata map[string]*Metadata Manifest map[string]*Manifest Logs map[string][]*Log Store map[string]interface{} }
Meta is a set of metadata (metadata.json and manifest.json) The Index field provides ordering. The Store field can be used to store arbitrary data needed for particular projects.
type Metadata ¶
type Metadata struct { ID string `json:"@id"` Migration string `json:"migration"` Typ VarStr `json:"@type"` Title string `json:"title"` Description string `json:"description,omitempty"` Creator Agent `json:"creator,omitempty"` Created *W3CDate `json:"created,omitempty"` Modified *W3CDate `json:"modified,omitempty"` AgencyID string `json:"agencyIdentifier,omitempty"` // original @id used within agency e.g. TRANS.01.01 Provenance string `json:"provenance,omitempty"` Source VarStr `json:"source,omitempty"` IsPartOf Container `json:"isPartOf,omitempty"` DeliveryMethod string `json:"deliveryMethod,omitempty"` DocumentType string `json:"documentType,omitempty"` // document genre e.g. Research, Correspondence Series string `json:"series,omitempty"` Consignment string `json:"consignment,omitempty"` DisposalRule Disposal `json:"disposalRule,omitempty"` Duration string `json:"duration,omitempty"` Language VarStr `json:"language,omitempty"` Subtitles VarStr `json:"subtitles,omitempty"` Director VarStr `json:"director,omitempty"` Actor VarStr `json:"actor,omitempty"` ProductionCompany VarStr `json:"productionCompany,omitempty"` About Thing `json:"about,omitempty"` Context Context `json:"@context"` }
Metadata represents a metadata.json file
func NewMetadata ¶
NewMetadata returns a Metadata with the supplied title. It also sets the @type.
type Obj ¶
type Obj struct { ID string `json:"@id,omitempty"` Typ string `json:"@type,omitempty"` Container string `json:"@container,omitempty"` Name string `json:"name,omitempty"` Title string `json:"title,omitempty"` SoftwareVersion string `json:"softwareVersion,omitempty"` }
Obj is a json object. Used with @id/@type in @context. Can also be used to generate generic objects e.g. Agents and containers in metadata are Objs
type Siegfried ¶
Siegfried loader. Reads a siegfried file (or droid or fido) to generate generic digital objects
func NewSiegfried ¶
NewSiegfried takes an io Reader for a siegfried/droid/fido results file and an optional blacklist. The blacklist is IDs you'd like to exclude e.g. to prune thumbs db files
type Thing ¶
type Thing interface{}
Thing can be anything that a metadata is "about"
func MakeBusiness ¶
func MakeBusiness(legalName, registrationNumber, abn string, commencedTrading, ceasedTrading, renewalDueDate time.Time, proprietors ...string) Thing
MakeBusiness returns a Thing of @type schema.org/Organization and sets the supplied fields. A variable number of proprietors can be supplied and these will be set as a slice of Organizations.
type TitleFn ¶
Title func loader. Allows you to customise a title based on other metadata (e.g. manipulate the file name to make a title)
type VarStr ¶
type VarStr interface{}
VarStr represents a single string or a slice of strings
func ReferenceFiles ¶
func ReferenceFiles(ts []FileTarget) VarStr
type Version ¶
type Version struct { ID string `json:"@id"` Base string `json:"base,omitempty"` DerivedFrom string `json:"derivedFrom,omitempty"` GeneratedBy string `json:"generatedBy,omitempty"` HasAccessRules []string `json:"hasAccessRules,omitempty"` Files []File `json:"files"` }
Version represents versions
type W3CDate ¶
W3CDate contains a time.Time but marshals to json in form yyyy-mm-dd
func NewDate ¶
NewDate returns a reference to W3CDate from a W3C style date string. If the string provided is an invalid date, a nil reference is returned.
func NewDateLayout ¶
NewDate returns a reference to W3CDate from a time layout string and a date in that layout string. If the string provided is an invalid date, a nil reference is returned.
func ParseDateLayout ¶
ParseDateLayout returns a reference to W3CDate from a time layout string and a date in that layout string. If the string provided is an invalid date, an error is returned
func WrapDate ¶
WrapDate allows you to create a *W3CDate (with YMD precision) when you already have a *time.Time
func (W3CDate) MarshalJSON ¶
MarshalJSON makes W3CDate a json Marshaller with yyyy-mm-dd output