domain

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package domain contains all Ikuzo domain models.

To ensure decoupling and optimal reuse we have gathered the models in domain, the service package contains the services for each model. The storage package contains various implementations of the service store interfaces.

TODO: document the main flow of the application and the use of the models.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrNameSpaceNotFound       = errors.New("namespace not found")
	ErrNameSpaceDuplicateEntry = errors.New("prefix and base stored in different entries")
	ErrNameSpaceNotValid       = errors.New("prefix or base not valid")
)
View Source
var (
	ErrIDTooLong          = errors.New("identifier is too long")
	ErrIDNotLowercase     = errors.New("uppercase not allowed in identifier")
	ErrIDInvalidCharacter = errors.New("only letters are allowed in organization")
	ErrIDCannotBeEmpty    = errors.New("empty string is not a valid identifier")
	ErrIDExists           = errors.New("identifier already exists")
	ErrOrgNotFound        = errors.New("organization not found")
)

errors

View Source
var (
	// MaxLengthID the maximum length of an identifier
	MaxLengthID = 10
)

Functions

func SplitURI

func SplitURI(uri string) (base, name string)

SplitURI takes a given URI and splits it into a base-URI and a localname. When the URI can't be split, the full URI is returned as the label with an empty base.

Example
package main

import (
	"fmt"

	"github.com/delving/hub3/ikuzo/domain"
)

func main() {
	fmt.Println(domain.SplitURI("http://purl.org/dc/elements/1.1/title"))
}
Output:

http://purl.org/dc/elements/1.1/ title

Types

type NameSpace

type NameSpace struct {

	// UUID is the unique identifier of a namespace
	UUID string `json:"uuid"`

	// Base is the default base-URI for a namespace
	Base string `json:"base"`

	// Prefix is the default short version that identifies the base-URI
	Prefix string `json:"prefix"`

	// BaseAlt are alternative base-URI for the same prefix.
	// Sometimes historically the base-URIs for a namespace changes and we still
	// have to correctly resolve both.
	BaseAlt []string `json:"baseAlt,omitempty"`

	// PrefixAlt are altenative prefixes for the default base URI.
	// Different content-providers and organizations have at time selected alternative
	// prefixes for the same base URI. We need to support both entry-points.
	PrefixAlt []string `json:"prefixAlt,omitempty"`

	// Schema is an URL to the RDFS or OWL definition of namespace
	Schema string `json:"schema,omitempty"`

	// Temporary defines if the NameSpace has been given a temporary prefix because
	// only the base-URI was known when the NameSpace was created.
	// Namespaces with prefix collissions will also be given a temporary prefix
	Temporary bool `json:"temporary,omitempty"`
}

NameSpace is a container for URI conversions for RDF- and XML-namespaces.

func (*NameSpace) AddBase

func (ns *NameSpace) AddBase(base string) error

AddBase adds a base-URI to the list of base alternatives.

When the base-URI is already present in BaseAlt no error is thrown.

func (*NameSpace) AddPrefix

func (ns *NameSpace) AddPrefix(prefix string) error

AddPrefix adds a prefix to the list of prefix alternatives.

When the prefix is already present in PrefixAlt no error is thrown.

func (*NameSpace) BaseURIs

func (ns *NameSpace) BaseURIs() []string

BaseURIs returns all namespace base-URIs linked to this NameSpace. This includes the default Base and all alternative base-URIs.

func (*NameSpace) GetID

func (ns *NameSpace) GetID() string

GetID returns a string representation of a UUID. When no UUID is set, this function will generate it and update the NameSpace.

func (*NameSpace) Merge

func (ns *NameSpace) Merge(other *NameSpace) error

Merge merges the values of two NameSpace objects. The prefixes and alternative base URIs of the other NameSpace are merged into ns.

func (*NameSpace) Prefixes

func (ns *NameSpace) Prefixes() []string

Prefixes returns all namespace prefix linked to this NameSpace. This includes the default Prefix and all alternative prefixes.

type Organization

type Organization struct {
	ID          OrganizationID `json:"orgID"`
	Description string         `json:"description,omitempty"`
}

Organization is a basic building block for storing information. Everything that is stored by ikuzo must have an organization.ID as part of its metadata.

type OrganizationFilter added in v0.1.8

type OrganizationFilter struct {
	// OffSet is the start of the results returned
	OffSet int
	// Limit is the number of items returned from the filter
	Limit int
	// Org can be used to filter the results based on the filled in value.
	// This is mostly usefull if you want to filter by attributes..
	Org Organization
}

type OrganizationID

type OrganizationID string

OrganizationID represents a short identifier for an Organization.

The maximum length is MaxLengthID.

In JSON the OrganizationID is represented as 'orgID'.

func NewOrganizationID

func NewOrganizationID(input string) (OrganizationID, error)

NewOrganizationID returns an OrganizationID and an error if the supplied input is invalid.

func (OrganizationID) Valid

func (id OrganizationID) Valid() error

Valid validates the identifier.

- ErrIDTooLong is returned when ID is too long

- ErrIDNotLowercase is returned when ID contains uppercase characters

- ErrIDInvalidCharacter is returned when ID contains non-letters

type URI

type URI string

URI represents a NameSpace URI.

func (URI) String

func (uri URI) String() string

String returns a string representation of URI

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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