sparql

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Harvest added in v0.3.0

func Harvest(ctx context.Context, repo *Repo, query string) (responses []*responseWithContext, err error)

TODO(kiivihal): finish implementation

Types

type BulkMetrics added in v0.3.0

type BulkMetrics struct {
	Graphs  int
	Triples int
}

type BulkRequest added in v0.3.0

type BulkRequest struct {
	// contains filtered or unexported fields
}

BulkRequest can send multiple namedgraphs to an repo with a single request. Do(ctx) sends the actual request.

func NewBulkRequest added in v0.3.0

func NewBulkRequest(repo *Repo, datasetID string, revision int) *BulkRequest

NewBulkRequest retutrns a new BulkRequest

func (*BulkRequest) Add added in v0.3.0

func (br *BulkRequest) Add(namedGraphUri string, g *rdf.Graph) error

Add adds all the triples from the rdf.Graph

func (*BulkRequest) AddString added in v0.3.0

func (br *BulkRequest) AddString(namedGraphUri, triples string) error

AddString adds triples to a namedgraph. A namedgraph cannot be added multiple times. All triples will be merged in the last entry.

func (*BulkRequest) Do added in v0.3.0

func (br *BulkRequest) Do(ctx context.Context) error

Do executes the SPARQL update for all the added namedgraphs.

func (*BulkRequest) UpdateQuery added in v0.3.0

func (br *BulkRequest) UpdateQuery() string

UpdateQuery returns the SPARQL update query that is send with the Do function

type DataSetStore added in v0.3.0

type DataSetStore struct {
	// contains filtered or unexported fields
}

DataSetStore manage domain.DataSet specific options for saved rdf.Record instances.

func NewDataSetStore added in v0.3.0

func NewDataSetStore(repo *Repo, datasetID string) (*DataSetStore, error)

func (*DataSetStore) CountGraphsBySpec added in v0.3.0

func (ds *DataSetStore) CountGraphsBySpec() (int, error)

CountGraphsBySpec counts all the named graphs for a spec

func (*DataSetStore) CountRevisionsBySpec added in v0.3.0

func (ds *DataSetStore) CountRevisionsBySpec() ([]domain.DataSetRevisions, error)

CountRevisionsBySpec counts each revision available in the spec

func (*DataSetStore) DeleteAllGraphsBySpec added in v0.3.0

func (ds *DataSetStore) DeleteAllGraphsBySpec(ctx context.Context) (bool, error)

DeleteAllGraphsBySpec issues an SPARQL Update query to delete all graphs for a DataSet from the triple store

func (*DataSetStore) DeleteGraphsOrphansBySpec added in v0.3.0

func (ds *DataSetStore) DeleteGraphsOrphansBySpec(ctx context.Context, revision int) (bool, error)

DeleteGraphsOrphansBySpec issues an SPARQL Update query to delete all orphaned graphs for a DataSet from the triple store.

type Entry added in v0.3.0

type Entry struct {
	Type     TermType `json:"type"` // "uri", "literal", "typed-literal" or "bnode"
	XMLLang  string   `json:"xml:lang"`
	Value    string   `json:"value"`
	DataType string   `json:"datatype"`
}
type Head struct {
	Vars []string `json:"vars"`
}
type Header struct {
	Link []string
	Vars []string
}

type Option

type Option func(*Service) error

func SetCustomQueries

func SetCustomQueries(queries string) Option

SetCustomQueries allows custom Sparql Queries to be added to the sparql.Bank

Each query must be preceded by a comment otherwise the query is silently ignored.

type Repo added in v0.3.0

type Repo struct {
	// contains filtered or unexported fields
}

Repo represent a RDF repository, assumed to be queryable via the SPARQL protocol over HTTP.

func NewRepo added in v0.3.0

func NewRepo(cfg RepoConfig) (*Repo, error)

NewRepo creates a new representation of a RDF repository that can be queried through SPARQL.

func (*Repo) Construct added in v0.3.0

func (r *Repo) Construct(q string) (*rdf.Graph, error)

Construct performs a SPARQL HTTP request to the Repo, and returns the result as a rdf.Graph.

func (*Repo) Query added in v0.3.0

func (r *Repo) Query(q string) (*Results, error)

Query performs a SPARQL Get HTTP request to the Repo, and returns the parsed application/sparql-results+json response.

func (*Repo) QueryPost added in v0.3.0

func (r *Repo) QueryPost(q string) (*Results, error)

Query performs a SPARQL POST HTTP request to the Repo, and returns the parsed application/sparql-results+json response.

func (*Repo) Resolve added in v0.3.0

func (r *Repo) Resolve(ctx context.Context, subj rdf.Subject) (*rdf.Graph, error)

func (*Repo) Update added in v0.3.0

func (r *Repo) Update(q string) error

Update performs a SPARQL HTTP update request

type RepoConfig added in v0.3.0

type RepoConfig struct {
	Host           string `json:"host"`       // the base-url to the SPARQL endpoint including the scheme and the port
	QueryPath      string `json:"queryPath"`  // the relative path of the endpoint. This can should contain the database name that is injected when the sparql endpoint is build
	UpdatePath     string `json:"updatePath"` // the relative path of the update endpoint. This can should contain the database name that is injected when the sparql endpoint is build
	GraphStorePath string `json:"dataPath"`   // the relative GraphStore path of the endpoint. This can should contain the database name that is injected when the sparql endpoint is build
	Transport      struct {
		Retry    int
		Timeout  int
		UserName string `json:"userName"`
		Password string `json:"password"`
	}
	Bank *sparql.Bank
}

type Results added in v0.3.0

type Results struct {
	Head    Header
	Results results
}

Results holds the parsed results of a application/sparql-results+json response.

func (*Results) Bindings added in v0.3.0

func (r *Results) Bindings() map[string][]rdf.Term

Bindings returns a map of the bound variables in the SPARQL response, where each variable points to one or more RDF terms.

func (*Results) Solutions added in v0.3.0

func (r *Results) Solutions() []map[string]rdf.Term

Solutions returns a slice of the query solutions, each containing a map of all bindings to RDF terms.

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(options ...Option) (*Service, error)

func (*Service) GetRepo added in v0.3.0

func (s *Service) GetRepo(orgID domain.OrganizationID) (*Repo, error)

func (*Service) Resolve added in v0.3.0

func (s *Service) Resolve(ctx context.Context, orgID domain.OrganizationID, subj rdf.Subject) (g *rdf.Graph, err error)

func (*Service) Routes added in v0.3.0

func (s *Service) Routes(pattern string, r chi.Router)

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

implement sparql proxy implementation

func (*Service) SetServiceBuilder added in v0.3.0

func (s *Service) SetServiceBuilder(b *domain.ServiceBuilder)

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

should connections be shutdown

type TermType added in v0.3.0

type TermType string
const (
	TypeURI          TermType = "uri"
	TypeBnode        TermType = "bnode"
	TypeLiteral      TermType = "literal"
	TypeTypedLiteral TermType = "typed-literal"
)

Jump to

Keyboard shortcuts

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