package gold
import "bitbucket.org/ww/gold"


This program depends on an external library, libraptor, used for RDF
serialisation and parsing which is available from
http://librdf.org/raptor At least version 2.0.0 is required, and
version 2.0.3 or greater is recommended. Also required is libxml2
and libxslt, I use versions 2.7.8 and 1.1.26 respectively

    hg clone https://go.googlecode.com/hg go
    cd go/src && hg up -r release && ./all.bash

Next, goinstall doesn't know how to build commands and we build two of
them. Until this is fixed, the install process will be a little bit

    goinstall bitbucket.org/ww/goautoneg
    goinstall bitbucket.org/ww/libxml
    goinstall bitbucket.org/ww/goraptor
    goinstall bitbucket.org/ww/gold

    (cd pkg/bitbucket.org/ww/gold && gomake build)


The HTTP server and harvester programs both use the same configuration
file. An example can be found in the distribution directory. In
particular, the global setting for the root directory where the
processes will run should be changed as well as the [http]/root which
is where the HTTP server will look for its static content, templates
and such. This last is typically set to


but could equally well be elsewhere, particularly for a customised web
site layout. Another setting that will likely need to be changed is the
location of the log files.

The HTTP server can now be started with the command,

    ${GOBIN}/deref -d gold.cfg

The harvest daemon takes some more configuration. It needs to be told
about harvest sources, and there are some examples in the example
configuration file.

RDF helper routines.


const Version = "1.0"
Version of GoLD. Once 1.0 is reached versions will approximate
the golden mean by the continued  fraction method.


func Alternatives(resource, description goraptor.Uri) (ch chan *goraptor.Statement)

func Blank() goraptor.Term
Generate a new blank node

func GoldenRatio(n int) float64
Calculate the golden ration using the continued fraction method
for n iterations.

func ParseSparqlJson(json_data []byte) (results []map[string]goraptor.Term, err os.Error)
Parse a JSON serialised result set from a SPARQL query

func RegisterRepository(name string, factory RepositoryFactory)
Register a repository constructor. Intended to be called from the init
function of a package. Panics if name is already registered

func Serializer(format string) (serializer *goraptor.Serializer)
Return a serializer, basically a wrapper around the
goraptor.NewSerializer that also takes care of setting the
namespaces that we know about.


type Catalog struct {
    // contains unexported fields
Catalog is a structure that implements some required
common functionality amongst Repository implementations.
It is intended to be embedded into the implementation type.

func NewCatalog(cfg *config.Config) (cat *Catalog, err os.Error)
It is required that this method be called on initialisation of
a type that embeds Catalog.

func (cat *Catalog) Copy(source Repository, store SparqlStore) (err os.Error)

func (cat *Catalog) PutDataset(dset Dataset, store SparqlStore) (err os.Error)
Copy a Dataset into a SparqlStore

func (cat *Catalog) Record(dataset Dataset) (rec *Record)
Produce an RDF representation of the given package as a
dcat:CatalogRecord using the given url as package identifier

type Dataset interface {
    // Return a string identifier for the dataset, usually a UUID
    Id() string
    // Return an RDF Term for the dataset
    Term() goraptor.Term
    // An RDF Term describing the source of the dataset
    Source() goraptor.Term
    // Returns an OPM(V) Process
    Process() *Process
    // Return a channel of RDF statements describing this dataset
    ToRdf() chan *goraptor.Statement
Interface that must be satisfied by any concrete dataset type

type MemRepo struct {
    // contains unexported fields

func (mr *MemRepo) Count() int

func (mr *MemRepo) Datasets() (ch chan Dataset, err os.Error)

func (mr *MemRepo) GetDataset(id string) (dset Dataset, err os.Error)

func (mr *MemRepo) PutDataset(dset Dataset) (err os.Error)

func (mr *MemRepo) String() string

func (mr *MemRepo) Term() goraptor.Term

func (mr *MemRepo) ToRdf() (ch chan *goraptor.Statement, err os.Error)

type Namespace string
An RDF namespace

var DC Namespace
Dublin Core

var DCAT Namespace
Data Catalog

var FOAF Namespace
Friend of a Friend

var GIS Namespace

var INSP Namespace

var LIC Namespace

var MOAT Namespace
Meaning of a Tag

var OPMV Namespace
Open Provenance Model Vocabulary

var RDF Namespace

var RDFS Namespace
RDF Schema

var REV Namespace

var TIME Namespace
OWL Time

var VOID Namespace
XML Schema Datatypes

var XSD Namespace
VOID descriptions of RDF datasets

func (ns Namespace) U(value string) goraptor.Term
Return a goraptor.Term (actually &goraptor.Uri) that
is the concatenation of the namespace and the provided

type Process struct {
    Node   goraptor.Term
    Used   []goraptor.Term
    OpName goraptor.Term
    Time   *time.Time
Implementation of some aspects of the Open Provenance Model
This structure can be used either persistently or on the fly

func NewProcess() (proc *Process)

func (proc *Process) SetOp(opname string)
Indicate that the process was controlled by the entity
with the given name

func (proc *Process) ToRdf() (ch chan *goraptor.Statement)
Generate an RDF description of the process

func (proc *Process) Use(url string)
Indicate that the process used a particular resource

type Record struct {
    // contains unexported fields

func (rec *Record) Term() goraptor.Term

func (rec *Record) ToRdf() (ch chan *goraptor.Statement)

type Repository interface {
    // the URI to identify of this repository
    Term() goraptor.Term
    // number of packages present
    Count() int
    // a channel over which all packages are sent
    Datasets() (chan Dataset, os.Error)
    // retrieve a particular package
    GetDataset(id string) (Dataset, os.Error)
    // add or replace a particular package
    PutDataset(dset Dataset) os.Error
    // return a description of the repository
    ToRdf() (chan *goraptor.Statement, os.Error)
Interface to the Repository

func MakeRepository(cfg *config.Config, section string, store SparqlStore) (repo Repository, err os.Error)

func NewMemRepo(cfg *config.Config, section string, store SparqlStore) (repo Repository, err os.Error)

type RepositoryFactory func(cfg *config.Config, section string, store SparqlStore) (repo Repository, err os.Error)

type SparqlStore interface {
    // Execute a sparql query and give back a series (slice) of result rows
    Query(query string) (results []map[string]goraptor.Term, err os.Error)
    // Execute a sparql update or delete query
    Execute(query string) (err os.Error)
    // Replace the given graph, expressed as statements sent over a channel
    PutGraph(graph string, ch chan *goraptor.Statement) (err os.Error)
    // Replace the given graph, expressed as serialised text with associated mime type
    PutGraphText(graph, text, mime_type string) (err os.Error)
    // Append to the given graph, expressed as statements sent over a channel
    AppendGraph(graph string, ch chan *goraptor.Statement) (err os.Error)
    // Append to the given graph, expressed as serialised text and mime type
    AppendGraphText(graph string, text, mime_type string) (err os.Error)
    // Delete the given graph
    DeleteGraph(graph string) (err os.Error)
Interface that must be satisfied by a SPARQL store