models

package
v1.62.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	CreatedState          = "created"
	SubmittedState        = "submitted"
	CompletedState        = "completed"
	EditionConfirmedState = "edition-confirmed"
	AssociatedState       = "associated"
	PublishedState        = "published"
	DetachedState         = "detached"
	FailedState           = "failed"
)

A list of reusable states across application

Variables

View Source
var (
	ErrAssociatedVersionCollectionIDInvalid = errors.New("missing collection_id for association between version and a collection")
	ErrPublishedVersionCollectionIDInvalid  = errors.New("unexpected collection_id in published version")
	ErrVersionStateInvalid                  = errors.New("incorrect state, can be one of the following: edition-confirmed, associated or published")
	ErrEditionLinksInvalid                  = errors.New("editions links do not exist")
)

List of error variables

Functions

func CheckState

func CheckState(docType, state string) error

CheckState checks state against a whitelist of valid states

func CleanDataset added in v1.27.0

func CleanDataset(dataset *Dataset)

CleanDataset trims URI and any hrefs contained in the database

func ParseAndValidateVersionNumber added in v1.42.0

func ParseAndValidateVersionNumber(ctx context.Context, version string) (int, error)

ParseAndValidateVersionNumber checks the version is a positive integer above 0

func ValidateDataset added in v1.23.0

func ValidateDataset(dataset *Dataset) error

ValidateDataset checks the dataset has invalid fields

func ValidateImportTask

func ValidateImportTask(task GenericTaskDetails) error

ValidateImportTask checks the task contains mandatory fields

func ValidateInstanceState

func ValidateInstanceState(state string) error

ValidateInstanceState checks the list of instance states from a whitelist

func ValidateNomisURL added in v1.25.0

func ValidateNomisURL(ctx context.Context, datasetType, nomisURL string) (string, error)

ValidateNomisURL checks for the nomis type when the dataset has nomis URL

func ValidateStateFilter

func ValidateStateFilter(filterList []string) error

ValidateStateFilter checks the list of filter states from a whitelist

func ValidateVersion

func ValidateVersion(version *Version) error

ValidateVersion checks the content of the version structure TODO: Refactor this to reduce the complexity

Types

type Alert

type Alert struct {
	Date        string `bson:"date,omitempty"        json:"date,omitempty"`
	Description string `bson:"description,omitempty" json:"description,omitempty"`
	Type        string `bson:"type,omitempty"        json:"type,omitempty"`
}

Alert represents an object containing information on an alert

type BuildHierarchyTask

type BuildHierarchyTask struct {
	DimensionID        string `bson:"code_list_id,omitempty"   json:"code_list_id,omitempty"`
	GenericTaskDetails `bson:",inline"`
}

BuildHierarchyTask represents a task of importing a single hierarchy.

type BuildSearchIndexTask

type BuildSearchIndexTask struct {
	GenericTaskDetails `bson:",inline"`
}

BuildSearchIndexTask represents a task of importing a single search index into search.

type CachedDimensionOption

type CachedDimensionOption struct {
	Code       string `bson:"code,omitempty"           json:"code"`
	CodeList   string `bson:"code_list,omitempty"      json:"code_list,omitempty"`
	InstanceID string `bson:"instance_id,omitempty"    json:"instance_id,omitempty"`
	Label      string `bson:"label,omitempty"          json:"label"`
	Name       string `bson:"name,omitempty"           json:"dimension"`
	NodeID     string `bson:"node_id,omitempty"        json:"node_id"`
	Option     string `bson:"option,omitempty"         json:"option"`
	Order      *int   `bson:"order,omitempty"          json:"order"`
}

CachedDimensionOption contains information used to create a dimension option

type Contact

type Contact struct {
	Email       string    `bson:"email,omitempty"          json:"email,omitempty"`
	ID          string    `bson:"_id,omitempty"            json:"id,omitempty"`
	LastUpdated time.Time `bson:"last_updated,omitempty"   json:"-"`
	Name        string    `bson:"name,omitempty"           json:"name,omitempty"`
	Telephone   string    `bson:"telephone,omitempty"      json:"telephone,omitempty"`
}

Contact represents information of individual contact details

func CreateContact

func CreateContact(reader io.Reader) (*Contact, error)

CreateContact manages the creation of a contact from a reader

type ContactDetails

type ContactDetails struct {
	Email     string `bson:"email,omitempty"      json:"email,omitempty"`
	Name      string `bson:"name,omitempty"       json:"name,omitempty"`
	Telephone string `bson:"telephone,omitempty"  json:"telephone,omitempty"`
}

ContactDetails represents an object containing information of the contact

type Dataset

type Dataset struct {
	CollectionID      string           `bson:"collection_id,omitempty"          json:"collection_id,omitempty"`
	Contacts          []ContactDetails `bson:"contacts,omitempty"               json:"contacts,omitempty"`
	Description       string           `bson:"description,omitempty"            json:"description,omitempty"`
	Keywords          []string         `bson:"keywords,omitempty"               json:"keywords,omitempty"`
	ID                string           `bson:"_id,omitempty"                    json:"id,omitempty"`
	LastUpdated       time.Time        `bson:"last_updated,omitempty"           json:"-"`
	License           string           `bson:"license,omitempty"                json:"license,omitempty"`
	Links             *DatasetLinks    `bson:"links,omitempty"                  json:"links,omitempty"`
	Methodologies     []GeneralDetails `bson:"methodologies,omitempty"          json:"methodologies,omitempty"`
	NationalStatistic *bool            `bson:"national_statistic,omitempty"     json:"national_statistic,omitempty"`
	NextRelease       string           `bson:"next_release,omitempty"           json:"next_release,omitempty"`
	Publications      []GeneralDetails `bson:"publications,omitempty"           json:"publications,omitempty"`
	Publisher         *Publisher       `bson:"publisher,omitempty"              json:"publisher,omitempty"`
	QMI               *GeneralDetails  `bson:"qmi,omitempty"                    json:"qmi,omitempty"`
	RelatedDatasets   []GeneralDetails `bson:"related_datasets,omitempty"       json:"related_datasets,omitempty"`
	ReleaseFrequency  string           `bson:"release_frequency,omitempty"      json:"release_frequency,omitempty"`
	State             string           `bson:"state,omitempty"                  json:"state,omitempty"`
	Theme             string           `bson:"theme,omitempty"                  json:"theme,omitempty"`
	Title             string           `bson:"title,omitempty"                  json:"title,omitempty"`
	UnitOfMeasure     string           `bson:"unit_of_measure,omitempty"        json:"unit_of_measure,omitempty"`
	URI               string           `bson:"uri,omitempty"                    json:"uri,omitempty"`
	Type              string           `bson:"type,omitempty"                   json:"type,omitempty"`
	NomisReferenceURL string           `bson:"nomis_reference_url,omitempty"    json:"nomis_reference_url,omitempty"`
	IsBasedOn         *IsBasedOn       `bson:"is_based_on,omitempty"            json:"is_based_on,omitempty"`
	CanonicalTopic    string           `bson:"canonical_topic,omitempty"        json:"canonical_topic,omitempty"`
	Subtopics         []string         `bson:"subtopics,omitempty"              json:"subtopics,omitempty"`
	Survey            string           `bson:"survey,omitempty"                 json:"survey,omitempty"`
	RelatedContent    []GeneralDetails `bson:"related_content,omitempty"        json:"related_content,omitempty"`
}

Dataset represents information related to a single dataset

func CreateDataset

func CreateDataset(reader io.Reader) (*Dataset, error)

CreateDataset manages the creation of a dataset from a reader

func (*Dataset) UpdateMetadata added in v1.56.0

func (d *Dataset) UpdateMetadata(metadata EditableMetadata)

UpdateMetadata updates the metadata fields for a dataset

type DatasetLinks struct {
	AccessRights  *LinkObject `bson:"access_rights,omitempty"   json:"access_rights,omitempty"`
	Editions      *LinkObject `bson:"editions,omitempty"        json:"editions,omitempty"`
	LatestVersion *LinkObject `bson:"latest_version,omitempty"  json:"latest_version,omitempty"`
	Self          *LinkObject `bson:"self,omitempty"            json:"self,omitempty"`
	Taxonomy      *LinkObject `bson:"taxonomy,omitempty"        json:"taxonomy,omitempty"`
}

DatasetLinks represents a list of specific links related to the dataset resource

type DatasetType added in v1.25.0

type DatasetType int

DatasetType defines possible dataset types

const (
	Filterable DatasetType = iota
	Nomis
	CantabularTable
	CantabularBlob
	CantabularFlexibleTable
	CantabularMultivariateTable
	Invalid
)

possible dataset types

func GetDatasetType added in v1.25.0

func GetDatasetType(datasetType string) (DatasetType, error)

GetDatasetType returns a dataset type for a given dataset

func ValidateDatasetType added in v1.25.0

func ValidateDatasetType(ctx context.Context, datasetType string) (*DatasetType, error)

ValidateDatasetType checks the dataset.type field has valid type

func (DatasetType) String added in v1.25.0

func (dt DatasetType) String() string

type DatasetUpdate

type DatasetUpdate struct {
	ID      string   `bson:"_id,omitempty"         json:"id,omitempty"`
	Current *Dataset `bson:"current,omitempty"     json:"current,omitempty"`
	Next    *Dataset `bson:"next,omitempty"        json:"next,omitempty"`
}

DatasetUpdate represents an evolving dataset with the current dataset and the updated dataset Note: Stored as Dataset (in `dataset` Collection) in MongoDB

type Dimension

type Dimension struct {
	Description          string        `bson:"description,omitempty"            json:"description,omitempty"`
	Label                string        `bson:"label,omitempty"                  json:"label,omitempty"`
	LastUpdated          time.Time     `bson:"last_updated,omitempty"           json:"-"`
	Links                DimensionLink `bson:"links,omitempty"                  json:"links,omitempty"`
	HRef                 string        `json:"href,omitempty"`
	ID                   string        `json:"id,omitempty"`
	Name                 string        `bson:"name,omitempty"                   json:"name,omitempty"`
	Variable             string        `bson:"variable,omitempty"               json:"variable,omitempty"`
	NumberOfOptions      *int          `bson:"number_of_options,omitempty"      json:"number_of_options,omitempty"`
	IsAreaType           *bool         `bson:"is_area_type,omitempty"           json:"is_area_type,omitempty"`
	QualityStatementText string        `bson:"quality_statement_text,omitempty" json:"quality_statement_text,omitempty"`
	QualityStatementURL  string        `bson:"quality_statement_url,omitempty"  json:"quality_statement_url,omitempty"`
}

Dimension represents an overview for a single dimension. This includes a link to the code list API which provides metadata about the dimension and all possible values.

type DimensionLink struct {
	CodeList LinkObject `bson:"code_list,omitempty"     json:"code_list,omitempty"`
	Options  LinkObject `bson:"options,omitempty"       json:"options,omitempty"`
	Version  LinkObject `bson:"version,omitempty"       json:"version,omitempty"`
}

DimensionLink contains all links needed for a dimension

type DimensionNodeResults

type DimensionNodeResults struct {
	Items []DimensionOption `json:"items"`
}

DimensionNodeResults wraps dimension node objects for pagination

type DimensionObject

type DimensionObject struct {
	HRef  string `json:"href"`
	ID    string `json:"id"`
	Label string `json:"label"`
}

DimensionObject represents the unique dimension option data relevant to the observation

type DimensionOption

type DimensionOption struct {
	InstanceID  string               `bson:"instance_id,omitempty"    json:"instance_id,omitempty"`
	Label       string               `bson:"label,omitempty"          json:"label"`
	LastUpdated time.Time            `bson:"last_updated,omitempty"   json:"-"`
	Links       DimensionOptionLinks `bson:"links,omitempty"          json:"links"`
	Name        string               `bson:"name,omitempty"           json:"dimension"`
	NodeID      string               `bson:"node_id,omitempty"        json:"node_id"`
	Option      string               `bson:"option,omitempty"         json:"option"`
	Order       *int                 `bson:"order,omitempty"          json:"order"`
}

DimensionOption contains unique information and metadata used when processing the data

type DimensionOptionLinks struct {
	Code     LinkObject `bson:"code,omitempty"              json:"code"`
	CodeList LinkObject `bson:"code_list,omitempty"         json:"code_list"`
	Version  LinkObject `bson:"version,omitempty"           json:"version"`
}

DimensionOptionLinks represents a list of link objects related to dimension options

type DimensionValues

type DimensionValues struct {
	Name    string   `json:"dimension"`
	Options []string `json:"options"`
}

DimensionValues holds all unique values for a dimension

type DownloadList

type DownloadList struct {
	XLS  *DownloadObject `bson:"xls,omitempty" json:"xls,omitempty"`
	XLSX *DownloadObject `bson:"xlsx,omitempty" json:"xlsx,omitempty"`
	CSV  *DownloadObject `bson:"csv,omitempty" json:"csv,omitempty"`
	TXT  *DownloadObject `bson:"txt,omitempty" json:"txt,omitempty"`
	CSVW *DownloadObject `bson:"csvw,omitempty" json:"csvw,omitempty"`
}

DownloadList represents a list of objects of containing information on the downloadable files. Items are in a specific order and should not be changed (xls, xlsx, csv, txt, csvw)

func CreateDownloadList

func CreateDownloadList(reader io.Reader) (*DownloadList, error)

CreateDownloadList manages the creation of a list downloadable items from a reader

type DownloadObject

type DownloadObject struct {
	HRef    string `bson:"href,omitempty"  json:"href,omitempty"`
	Private string `bson:"private,omitempty" json:"private,omitempty"`
	Public  string `bson:"public,omitempty" json:"public,omitempty"`
	// TODO size is in bytes and probably should be an int64 instead of a string this
	// will have to change for several services (filter API, exporter services and web)
	Size string `bson:"size,omitempty" json:"size,omitempty"`
}

DownloadObject represents information on the downloadable file

type EditableMetadata added in v1.56.0

type EditableMetadata struct {
	Alerts            *[]Alert         `json:"alerts,omitempty"`
	CanonicalTopic    string           `json:"canonical_topic,omitempty"`
	Contacts          []ContactDetails `json:"contacts,omitempty"`
	Description       string           `json:"description,omitempty"`
	Dimensions        []Dimension      `json:"dimensions,omitempty"`
	Keywords          []string         `json:"keywords,omitempty"`
	LatestChanges     *[]LatestChange  `json:"latest_changes,omitempty"`
	License           string           `json:"license,omitempty"`
	Methodologies     []GeneralDetails `json:"methodologies,omitempty"`
	NationalStatistic *bool            `json:"national_statistic,omitempty"`
	NextRelease       string           `json:"next_release,omitempty"`
	Publications      []GeneralDetails `json:"publications,omitempty"`
	QMI               *GeneralDetails  `json:"qmi,omitempty"`
	RelatedDatasets   []GeneralDetails `json:"related_datasets,omitempty"`
	ReleaseDate       string           `json:"release_date,omitempty"`
	ReleaseFrequency  string           `json:"release_frequency,omitempty"`
	Title             string           `json:"title,omitempty"`
	Survey            string           `json:"survey,omitempty"`
	Subtopics         []string         `json:"subtopics,omitempty"`
	UnitOfMeasure     string           `json:"unit_of_measure,omitempty"`
	UsageNotes        *[]UsageNote     `json:"usage_notes,omitempty"`
	RelatedContent    []GeneralDetails `json:"related_content,omitempty"`
}

EditableMetadata represents the metadata fields that can be edited

type Edition

type Edition struct {
	Edition     string              `bson:"edition,omitempty"      json:"edition,omitempty"`
	ID          string              `bson:"id,omitempty"           json:"id,omitempty"`
	LastUpdated time.Time           `bson:"last_updated,omitempty" json:"-"`
	Links       *EditionUpdateLinks `bson:"links,omitempty"        json:"links,omitempty"`
	State       string              `bson:"state,omitempty"        json:"state,omitempty"`
	IsBasedOn   *IsBasedOn          `bson:"is_based_on,omitempty"  json:"is_based_on,omitempty"`
	Type        string              `bson:"type,omitempty"         json:"type,omitempty"`
}

Edition represents information related to a single edition for a dataset

type EditionUpdate

type EditionUpdate struct {
	ID      string   `bson:"id,omitempty"         json:"id,omitempty"`
	Current *Edition `bson:"current,omitempty"     json:"current,omitempty"`
	Next    *Edition `bson:"next,omitempty"        json:"next,omitempty"`
}

EditionUpdate represents an evolving edition containing both the next and current edition

func CreateEdition

func CreateEdition(host, datasetID, edition string) (*EditionUpdate, error)

CreateEdition manages the creation of an edition object

func (ed *EditionUpdate) PublishLinks(ctx context.Context, versionLink *LinkObject) error

PublishLinks applies the provided versionLink object to the edition being published only if that version is greater than the latest published version

func (ed *EditionUpdate) UpdateLinks(ctx context.Context, host string) error

UpdateLinks in the editions.next document, ensuring links can't regress once published to current

type EditionUpdateLinks struct {
	Dataset       *LinkObject `bson:"dataset,omitempty"        json:"dataset,omitempty"`
	LatestVersion *LinkObject `bson:"latest_version,omitempty" json:"latest_version,omitempty"`
	Self          *LinkObject `bson:"self,omitempty"           json:"self,omitempty"`
	Versions      *LinkObject `bson:"versions,omitempty"       json:"versions,omitempty"`
}

EditionUpdateLinks represents those links common the both the current and next edition

type Event

type Event struct {
	Message       string     `bson:"message,omitempty"        json:"message"`
	MessageOffset string     `bson:"message_offset,omitempty" json:"message_offset"`
	Time          *time.Time `bson:"time,omitempty"           json:"time"`
	Type          string     `bson:"type,omitempty"           json:"type"`
}

Event which has happened to an instance

func (*Event) Validate

func (e *Event) Validate() error

Validate the event structure

type GeneralDetails

type GeneralDetails struct {
	Description string `bson:"description,omitempty"    json:"description,omitempty"`
	HRef        string `bson:"href,omitempty"           json:"href,omitempty"`
	Title       string `bson:"title,omitempty"          json:"title,omitempty"`
}

GeneralDetails represents generic fields stored against an object (reused)

type GenericTaskDetails

type GenericTaskDetails struct {
	DimensionName string `bson:"dimension_name,omitempty" json:"dimension_name,omitempty"`
	State         string `bson:"state,omitempty"          json:"state,omitempty"`
}

type ImportObservationsTask

type ImportObservationsTask struct {
	InsertedObservations int64  `bson:"total_inserted_observations" json:"total_inserted_observations"`
	State                string `bson:"state,omitempty"             json:"state,omitempty"`
}

ImportObservationsTask represents the task of importing instance observation data into the database.

type Instance

type Instance struct {
	Alerts            *[]Alert             `bson:"alerts,omitempty"                      json:"alerts,omitempty"`
	CollectionID      string               `bson:"collection_id,omitempty"               json:"collection_id,omitempty"`
	Dimensions        []Dimension          `bson:"dimensions,omitempty"                  json:"dimensions,omitempty"`
	Downloads         *DownloadList        `bson:"downloads,omitempty"                   json:"downloads,omitempty"`
	Edition           string               `bson:"edition,omitempty"                     json:"edition,omitempty"`
	Events            *[]Event             `bson:"events,omitempty"                      json:"events,omitempty"`
	Headers           *[]string            `bson:"headers,omitempty"                     json:"headers,omitempty"`
	ImportTasks       *InstanceImportTasks `bson:"import_tasks,omitempty"                json:"import_tasks"`
	InstanceID        string               `bson:"id,omitempty"                          json:"id,omitempty"`
	LastUpdated       time.Time            `bson:"last_updated,omitempty"                json:"last_updated,omitempty"`
	ETag              string               `bson:"e_tag"                                 json:"-"`
	LatestChanges     *[]LatestChange      `bson:"latest_changes,omitempty"              json:"latest_changes,omitempty"`
	Links             *InstanceLinks       `bson:"links,omitempty"                       json:"links,omitempty"`
	ReleaseDate       string               `bson:"release_date,omitempty"                json:"release_date,omitempty"`
	State             string               `bson:"state,omitempty"                       json:"state,omitempty"`
	Temporal          *[]TemporalFrequency `bson:"temporal,omitempty"                    json:"temporal,omitempty"`
	TotalObservations *int                 `bson:"total_observations,omitempty"          json:"total_observations,omitempty"`
	UniqueTimestamp   bsonprim.Timestamp   `bson:"unique_timestamp"                      json:"-"`
	Version           int                  `bson:"version,omitempty"                     json:"version,omitempty"`
	Type              string               `bson:"type,omitempty"                        json:"type,omitempty"`
	IsBasedOn         *IsBasedOn           `bson:"is_based_on,omitempty"                 json:"is_based_on,omitempty"`
	LowestGeography   string               `bson:"lowest_geography,omitempty"            json:"lowest_geography,omitempty"`
}

Instance which presents a single dataset being imported

func (*Instance) Hash added in v1.34.0

func (i *Instance) Hash(extraBytes []byte) (string, error)

Hash generates a SHA-1 hash of the instance struct. SHA-1 is not cryptographically safe, but it has been selected for performance as we are only interested in uniqueness. ETag field value is ignored when generating a hash. An optional byte array can be provided to append to the hash. This can be used, for example, to calculate a hash of this instance and an update applied to it.

type InstanceImportTasks

type InstanceImportTasks struct {
	BuildHierarchyTasks   []*BuildHierarchyTask   `bson:"build_hierarchies,omitempty"    json:"build_hierarchies"`
	BuildSearchIndexTasks []*BuildSearchIndexTask `bson:"build_search_indexes,omitempty" json:"build_search_indexes"`
	ImportObservations    *ImportObservationsTask `bson:"import_observations,omitempty"  json:"import_observations"`
}

InstanceImportTasks represents all of the tasks required to complete an import job.

type InstanceLinks struct {
	Dataset    *LinkObject `bson:"dataset,omitempty"    json:"dataset,omitempty"`
	Dimensions *LinkObject `bson:"dimensions,omitempty" json:"dimensions,omitempty"`
	Edition    *LinkObject `bson:"edition,omitempty"    json:"edition,omitempty"`
	Job        *LinkObject `bson:"job,omitempty"        json:"job"`
	Self       *LinkObject `bson:"self,omitempty"       json:"self,omitempty"`
	Spatial    *LinkObject `bson:"spatial,omitempty"    json:"spatial,omitempty"`
	Version    *LinkObject `bson:"version,omitempty"    json:"version,omitempty"`
}

InstanceLinks holds all links for an instance

type IsBasedOn added in v1.34.0

type IsBasedOn struct {
	Type string `bson:"type" json:"@type"`
	ID   string `bson:"id"   json:"@id"`
}

IsBasedOn refers to the Cantabular blob source

type LatestChange

type LatestChange struct {
	Description string `bson:"description,omitempty" json:"description,omitempty"`
	Name        string `bson:"name,omitempty"        json:"name,omitempty"`
	Type        string `bson:"type,omitempty"        json:"type,omitempty"`
}

LatestChange represents an object contining information on a single change between versions

type LinkObject

type LinkObject struct {
	HRef string `bson:"href,omitempty"  json:"href,omitempty"`
	ID   string `bson:"id,omitempty"    json:"id,omitempty"`
}

LinkObject represents a generic structure for all links

type Metadata

type Metadata struct {
	EditableMetadata
	Distribution    []string             `json:"distribution,omitempty"`
	Downloads       *DownloadList        `json:"downloads,omitempty"`
	Links           *MetadataLinks       `json:"links,omitempty"`
	TableID         string               `json:"table_id,omitempty"`
	CSVHeader       []string             `json:"headers,omitempty"`
	Version         int                  `json:"version,omitempty"`
	DatasetLinks    *DatasetLinks        `json:"dataset_links,omitempty"`
	Publisher       *Publisher           `json:"publisher,omitempty"`
	Temporal        *[]TemporalFrequency `json:"temporal,omitempty"`
	Theme           string               `json:"theme,omitempty"`
	URI             string               `json:"uri,omitempty"`
	Coverage        string               `json:"coverage,omitempty"`
	TablePopulation string               `json:"table_population,omitempty"`
	AreaType        string               `json:"area_type,omitempty"`
	Classifications string               `json:"classifications,omitempty"`
	Source          string               `json:"source,omitempty"`
	IsBasedOn       *IsBasedOn           `json:"is_based_on,omitempty"`
}

Metadata represents information (metadata) relevant to a version

func CreateCantabularMetaDataDoc added in v1.37.0

func CreateCantabularMetaDataDoc(d *Dataset, v *Version) *Metadata

CreateCantabularMetaDataDoc manages the creation of metadata across dataset and version docs for cantabular datasets note: logic to retrieve the newly-added Cantabular-specific fields to the Metadata model will be created at a later date

func CreateMetaDataDoc

func CreateMetaDataDoc(datasetDoc *Dataset, versionDoc *Version, urlBuilder *url.Builder) *Metadata

CreateMetaDataDoc manages the creation of metadata across dataset and version docs

type MetadataLinks struct {
	AccessRights   *LinkObject `json:"access_rights,omitempty"`
	Self           *LinkObject `json:"self,omitempty"`
	Spatial        *LinkObject `json:"spatial,omitempty"`
	Version        *LinkObject `json:"version,omitempty"`
	WebsiteVersion *LinkObject `json:"website_version,omitempty"`
}

MetadataLinks represents a link object to list of metadata relevant to a version

type Observation

type Observation struct {
	Dimensions  map[string]*DimensionObject `json:"dimensions,omitempty"`
	Metadata    map[string]string           `json:"metadata,omitempty"`
	Observation string                      `json:"observation"`
}

Observation represents an object containing a single observation and its equivalent metadata

type ObservationLinks struct {
	DatasetMetadata *LinkObject `json:"dataset_metadata,omitempty"`
	Self            *LinkObject `json:"self,omitempty"`
	Version         *LinkObject `json:"version,omitempty"`
}

ObservationLinks represents a link object to list of links relevant to the observation

type ObservationsDoc

type ObservationsDoc struct {
	Dimensions        map[string]Option `json:"dimensions"`
	Limit             int               `json:"limit"`
	Links             *ObservationLinks `json:"links"`
	Observations      []Observation     `json:"observations"`
	Offset            int               `json:"offset"`
	TotalObservations int               `json:"total_observations"`
	UnitOfMeasure     string            `json:"unit_of_measure,omitempty"`
	UsageNotes        *[]UsageNote      `json:"usage_notes,omitempty"`
}

ObservationsDoc represents information (observations) relevant to a version

func CreateObservationsDoc

func CreateObservationsDoc(rawQuery string, versionDoc *Version, datasetDoc *Dataset, observations []Observation, queryParameters map[string]string, offset, limit int) *ObservationsDoc

CreateObservationsDoc manages the creation of metadata across dataset and version docs

type Option

type Option struct {
	LinkObject *LinkObject `json:"option,omitempty"`
}

Option represents an object containing a list of link objects that refer to the code url for that dimension option

type PublicDimensionOption

type PublicDimensionOption struct {
	Label  string               `bson:"label,omitempty"          json:"label"`
	Links  DimensionOptionLinks `bson:"links,omitempty"          json:"links"`
	Name   string               `bson:"name,omitempty"           json:"dimension"`
	Option string               `bson:"option,omitempty"         json:"option"`
}

PublicDimensionOption hides values which are only used by interval services

type Publisher

type Publisher struct {
	HRef string `bson:"href,omitempty" json:"href,omitempty"`
	Name string `bson:"name,omitempty" json:"name,omitempty"`
	Type string `bson:"type,omitempty" json:"type,omitempty"`
}

Publisher represents an object containing information of the publisher

type TemporalFrequency

type TemporalFrequency struct {
	EndDate   string `bson:"end_date,omitempty"    json:"end_date,omitempty"`
	Frequency string `bson:"frequency,omitempty"   json:"frequency,omitempty"`
	StartDate string `bson:"start_date,omitempty"  json:"start_date,omitempty"`
}

TemporalFrequency represents a frequency for a particular period of time

type UsageNote

type UsageNote struct {
	Note  string `bson:"note,omitempty"     json:"note,omitempty"`
	Title string `bson:"title,omitempty"    json:"title,omitempty"`
}

UsageNote represents a note containing extra information associated to the resource

type Version

type Version struct {
	Alerts          *[]Alert             `bson:"alerts,omitempty"           json:"alerts,omitempty"`
	CollectionID    string               `bson:"collection_id,omitempty"    json:"collection_id,omitempty"`
	DatasetID       string               `bson:"-"                          json:"dataset_id,omitempty"`
	Dimensions      []Dimension          `bson:"dimensions,omitempty"       json:"dimensions,omitempty"`
	Downloads       *DownloadList        `bson:"downloads,omitempty"        json:"downloads,omitempty"`
	Edition         string               `bson:"edition,omitempty"          json:"edition,omitempty"`
	Headers         []string             `bson:"headers,omitempty"          json:"-"`
	ID              string               `bson:"id,omitempty"               json:"id,omitempty"`
	LastUpdated     time.Time            `bson:"last_updated,omitempty"     json:"-"`
	LatestChanges   *[]LatestChange      `bson:"latest_changes,omitempty"   json:"latest_changes,omitempty"`
	Links           *VersionLinks        `bson:"links,omitempty"            json:"links,omitempty"`
	ReleaseDate     string               `bson:"release_date,omitempty"     json:"release_date,omitempty"`
	State           string               `bson:"state,omitempty"            json:"state,omitempty"`
	Temporal        *[]TemporalFrequency `bson:"temporal,omitempty"         json:"temporal,omitempty"`
	UsageNotes      *[]UsageNote         `bson:"usage_notes,omitempty"      json:"usage_notes,omitempty"`
	IsBasedOn       *IsBasedOn           `bson:"is_based_on,omitempty"      json:"is_based_on,omitempty"`
	Version         int                  `bson:"version,omitempty"          json:"version,omitempty"`
	Type            string               `bson:"type,omitempty"             json:"type,omitempty"`
	ETag            string               `bson:"e_tag"                      json:"-"`
	LowestGeography string               `bson:"lowest_geography,omitempty" json:"lowest_geography,omitempty"`
}

Version represents information related to a single version for an edition of a dataset

func CreateVersion

func CreateVersion(reader io.Reader, datasetID string) (*Version, error)

CreateVersion manages the creation of a version from a reader

func (*Version) Hash added in v1.41.0

func (v *Version) Hash(extraBytes []byte) (string, error)

Hash generates a SHA-1 hash of the version struct. SHA-1 is not cryptographically safe, but it has been selected for performance as we are only interested in uniqueness. ETag field value is ignored when generating a hash. An optional byte array can be provided to append to the hash. This can be used, for example, to calculate a hash of this version and an update applied to it.

func (*Version) UpdateMetadata added in v1.56.0

func (v *Version) UpdateMetadata(metadata EditableMetadata)

UpdateMetadata updates the metadata fields for a version

type VersionLinks struct {
	Dataset    *LinkObject `bson:"dataset,omitempty"     json:"dataset,omitempty"`
	Dimensions *LinkObject `bson:"dimensions,omitempty"  json:"dimensions,omitempty"`
	Edition    *LinkObject `bson:"edition,omitempty"     json:"edition,omitempty"`
	Self       *LinkObject `bson:"self,omitempty"        json:"self,omitempty"`
	Spatial    *LinkObject `bson:"spatial,omitempty"     json:"spatial,omitempty"`
	Version    *LinkObject `bson:"version,omitempty"     json:"-"`
}

VersionLinks represents a list of specific links related to the version resource for an edition of a dataset

func (*VersionLinks) DeepCopy added in v1.41.0

func (vl *VersionLinks) DeepCopy() *VersionLinks

Jump to

Keyboard shortcuts

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