xml2triples

package
v0.0.0-...-96d10c3 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const HTTPTHREADS = 100

max number of simultaneous http posts allowed

Variables

This section is empty.

Functions

func DbTriples2XML

func DbTriples2XML(refid string, context string, stripempty bool) ([]byte, error)

Retrieve the XML object corresponding to the tuples stored under the given RefId. Synchronous. If stripempty, strip empty tags from the XML object.

func DeleteTriplesForRefId

func DeleteTriplesForRefId(refid string, context string) error

Delete all triples with given refis as subject; synchronous

func DeleteTriplesForRefIdAsync

func DeleteTriplesForRefIdAsync(deleteReq []byte, context string, outch chan<- *Triple, errch chan<- SifResponse, ch chan<- struct{})

processes deleteRequest object Delete all triples with their subject being one of the refids given in the SIF deleteRequest object deleteReq; asynchronous. Outputs SIF responses for each refid to errch Outputs a list of tuples to be sent to Hexastore to outch

func GetAllXMLByObject

func GetAllXMLByObject(object string, context string) ([]string, error)

TODO: no flow control yet: may retrieve a massive number of RefIds Retrieve all RefIDs from Hexastore for the given object class. Synchronous

func Kla2staff

func Kla2staff(kla string, yrlvl string) []string

NSW Digital Classroom hard coded query: retrieve staff teaching KLA (key learning area) in given year level

func Kla2student

func Kla2student(kla string, yrlvl string) []string

NSW Digital Classroom hard coded query: retrieve students studying KLA (key learning area) in given year level

func Kla2teachinggroup

func Kla2teachinggroup(kla string, yrlvl string) []string

NSW Digital Classroom hard coded query: retrieve teaching groups about KLA (key learning area) in given year level

func Kla2timetablesubject

func Kla2timetablesubject(kla string, yrlvl string) []string

NSW Digital Classroom hard coded query: retrieve timetable subjects about KLA (key learning area) in given year level

func Map2SIFXML

func Map2SIFXML(m mxj.Map, stripempty bool) ([]byte, error)

Convert an MXJ map, as retrieved from tuples, into a byte encoding of a SIF XML object. If stripempty, make an effort to remove empty tags in the XML.

func Root2SIF

func Root2SIF(r string, j []byte) ([]byte, error)

func SendTriplesAsync

func SendTriplesAsync(triples []*Triple, context string, done chan<- struct{})

Send a slice of triples asynchronously to Nias3Engine

func StoreJSONasDBtriplesAsync

func StoreJSONasDBtriplesAsync(s []byte, context string, outch chan<- *Triple, errch chan<- SifResponse, ch chan<- struct{})

Store a JSON object on the Hexastore. Asynchronous. Outputs SIF responses for each refid to errch Outputs a list of tuples to be sent to Hexastore to outch JSON object is assumed to have an "id" top-level value, which is the subject for the tuples of that object. If not present, one will be created. If it is present, and it has already been used as an object in that context, the request will be denied.

func StoreXMLasDBtriplesAsync

func StoreXMLasDBtriplesAsync(s []byte, mustUseAdvisory bool, context string, outch chan<- *Triple, errch chan<- SifResponse, ch chan<- struct{})

Store an XML object on the Hexastore. If mustUseAdvisory is on, use the supplied RefId if available, else raise error; if off, generate new RefId. Asynchronous. Outputs SIF responses for each refid to errch Outputs a list of tuples to be sent to Hexastore to outch

func Tuples2JSON

func Tuples2JSON(triples []*Triple) (string, error)

get tuples, and organise them into JSON objects by subject

func UpdateFullXMLasDBtriples

func UpdateFullXMLasDBtriples(object []byte, requested_refid string, context string) error

Update an object, with Full Replacement on the Hexastore; synchronous Deletes all tuples for the refid from Hexastore, then creates tuples for the replacement object, and sends them to Hexastore as an ordered set of tuples

func UpdateFullXMLasDBtriplesAsync

func UpdateFullXMLasDBtriplesAsync(object []byte, context string, outch chan<- *Triple, errch chan<- SifResponse, ch chan<- struct{})

Update an object, with Full Replacement on the Hexastore; asynchronous Deletes all tuples for the refid from Hexastore, then creates tuples for the replacement object, and sends them to Hexastore as an ordered set of tuples Outputs SIF responses for each refid to errch Outputs a list of tuples to be sent to Hexastore to outch

func UpdatePartialXMLasDBtriples

func UpdatePartialXMLasDBtriples(object []byte, requested_refid string, context string) error

Update an object, with Partial Replacement on the Hexastore; synchronous. Is a brute force patch; deletes then writes to all the subject-predicate instances it finds in the object. Does not otherwise delete anything, including extra list entries: e.g. if a list with two items is patched with a list of one item, it will overwrite the first item in the list, and will leave alone the second.

func UpdatePartialXMLasDBtriplesAsync

func UpdatePartialXMLasDBtriplesAsync(object []byte, context string, outch chan<- *Triple, errch chan<- SifResponse, ch chan<- struct{})

Update an object, with Partial Replacement on the Hexastore; asynchronous. Is a brute force patch; deletes then writes to all the subject-predicate instances it finds in the object. Does not otherwise delete anything, including extra list entries: e.g. if a list with two items is patched with a list of one item, it will overwrite the first item in the list, and will leave alone the second. Outputs SIF responses for each refid to errch Outputs a list of tuples to be sent to Hexastore to outch

func XMLtoJSON

func XMLtoJSON(x []byte) ([]byte, error)

Convert an XML object to JSON using Goessner notation. Ignores namespaces, and gets rid of xs:nil

Types

type DeleteRequest

type DeleteRequest struct {
	XMLName            xml.Name           `xml:"deleteRequest"`
	DeletesRequestElem DeletesRequestElem `xml:"deletes"`
}

type DeleteRequestElem

type DeleteRequestElem struct {
	Id string `xml:"id,attr"`
}

type DeletesRequestElem

type DeletesRequestElem struct {
	Delete []DeleteRequestElem `xml:"delete"`
}

type SifResponse

type SifResponse struct {
	AdvisoryId string // The RefId in the request
	RefId      string // The RefId of the response object, which may be different
	Error      error
}

Response to CRUD action, to be posted back as SIF response for a payload with multiple records.

type Triple

type Triple struct {
	Subject   string
	Object    string
	Predicate string
	Context   string
}

func Sif2Xapi

func Sif2Xapi(refid string) []*Triple

Retrieve xAPI tuples aligned to SIF refid. Synchronous.

func StoreXMLasDBtriples

func StoreXMLasDBtriples(object []byte, mustUseAdvisory bool, context string) (string, []*Triple, error)

Store the object on the Hexastore. If mustUseAdvisory is on, use the supplied RefId if available, else raise error; if off, generate new RefId. Synchronous. Return the RefId used, the triples to be posted, and the error.

Jump to

Keyboard shortcuts

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