Documentation
¶
Overview ¶
Package querytranslate compiles OSLC Query 3.0 text and the SysML v2 API Query into document-query plans, so every query surface runs the native semantics of internal/doc/queryexec over one loaded model.
Index ¶
- Constants
- Variables
- func DefaultProjection() []string
- func IgnoredParameterNames() []string
- func OutcomeOf(err error) *queryexec.Outcome
- func ParameterNames() []string
- func PrefixedPropertyNames(prefixes map[string]string, table *Table) (names []string, unbound map[string][]string)
- type Comparison
- type Conjunction
- type Constraint
- type Context
- type Disjunction
- type Error
- type ErrorKind
- type Instances
- type Operator
- type OrderTerm
- type Plan
- type Query
- type Scoped
- type Selection
- type Table
- type TypeTest
Constants ¶
const SelectAll = "*"
SelectAll is the wildcard oslc.select spells every property with.
const SourceParameter = "source"
SourceParameter is the entry query's parameter a frontend binds the elements the query considers to: the model's, or the scope's and everything nested.
Variables ¶
var DefaultPrefixes = rdf.DefaultPrefixes
DefaultPrefixes are the prefixes available without an oslc.prefix binding: the ones the RDF conversion writes on every graph.
Functions ¶
func DefaultProjection ¶
func DefaultProjection() []string
DefaultProjection is what a query over elements selecting nothing reports: every queryable property but elementId, read from a conversion of the whole model and so reported only when named.
func IgnoredParameterNames ¶
func IgnoredParameterNames() []string
IgnoredParameterNames returns the parameters this implementation accepts without reading, in stable order.
func OutcomeOf ¶
OutcomeOf is the QVTS record of a translator refusal that has one: an unknown property is a path error whose frontier lists the properties the query could have named, with the nearest.
func ParameterNames ¶
func ParameterNames() []string
ParameterNames returns the query parameters this implementation reads, in stable order. It is what an unknown-parameter error lists.
func PrefixedPropertyNames ¶
func PrefixedPropertyNames(prefixes map[string]string, table *Table) (names []string, unbound map[string][]string)
PrefixedPropertyNames returns the property names OSLC query text spells under prefixes, in stable order, along with the local names of every namespace those bindings leave unnamed, keyed by namespace. An oslc.prefix binding decides what the parser accepts, so a diagnostic reads the same map.
Types ¶
type Comparison ¶
Comparison keeps the rows a property of which compares to one of the values.
type Conjunction ¶
type Conjunction struct {
Terms []Constraint
}
Conjunction keeps the rows satisfying every term.
type Constraint ¶
type Constraint interface {
// contains filtered or unexported methods
}
Constraint is one node of a query's filter. Its unexported marker method closes the set to the forms this package declares.
type Context ¶
type Context struct {
Index *symbols.Index
Model *semantics.Model
// Table is the property table; built from Index and Model when nil.
Table *Table
}
Context is what a translation reads of the model: its index and semantics, for the property table and the metaclasses a type test may name.
type Disjunction ¶
type Disjunction struct {
Terms []Constraint
}
Disjunction keeps the rows satisfying any term.
type Error ¶
type Error struct {
Kind ErrorKind
Message string
// Property is the unknown property as the query wrote it, for
// ErrUnknownProperty.
Property string
// Candidates are the names the query could have written in place of the
// unknown one, sorted.
Candidates []string
}
Error is a typed query refusal. A refusal must not be represented as an empty result, which is indistinguishable from a valid no-match.
type ErrorKind ¶
type ErrorKind int
ErrorKind identifies a query the translator refuses.
const ( // ErrUnknownProperty identifies a property the metamodel does not define. ErrUnknownProperty ErrorKind = iota + 1 // ErrMalformed identifies malformed query syntax or structure. ErrMalformed // ErrUnorderedProperty identifies an ordered comparison on a property whose // values are not ordered, or instanceOf on a property other than the type. ErrUnorderedProperty // ErrUnparsableValue identifies a value an operator cannot compare. ErrUnparsableValue // ErrUnknownScope identifies a scope absent from the model. ErrUnknownScope // ErrNoModel identifies a query without a loaded model. ErrNoModel // ErrUnsupportedDisjunction identifies `or` in OSLC text, which the // language does not define. ErrUnsupportedDisjunction // ErrUnsupportedLiteral identifies an unsupported literal form. ErrUnsupportedLiteral // ErrUnsupportedInstanceTerm identifies an instance selection written where // it cannot be the root of the query: negated, scoped or under a disjunction. ErrUnsupportedInstanceTerm // ErrUnsupportedWildcard identifies the `*` value on a property other than // the multiplicity bounds, whose infinity it is. ErrUnsupportedWildcard )
type Instances ¶
type Instances struct {
Elements []string
}
Instances selects the objects the session holds whose definition or usage is one of the named elements, by qualified name.
func ElementInstances ¶
ElementInstances reads a list of @type values as element IRIs of the RDF conversion (<urn:sysmlv2:element:id> or elmt:id), the objects of which an instance term selects; it reports false when no value is one, and an error when only some are.
type Plan ¶
type Plan struct {
Program *queryplan.Program
// Columns are the properties projected as written, a wildcard among them
// as `*`; the result's columns name what it expanded to.
Columns []string
// Objects reports a query over the session's held objects, whose root is
// Objects rather than the bound source.
Objects bool
}
Plan is a translated query: the program to execute, bound at SourceParameter, and the columns its rows report, in order.
type Query ¶
type Query struct {
// Scope names the elements considered, with everything nested inside them;
// empty considers the whole model.
Scope []string
Select []Selection
Where Constraint
OrderBy []OrderTerm
SearchTerms []string
// Spelling names, per reported column, the name the request asked for it by,
// where that differs from the column name.
Spelling map[string]string
// Features are the properties the request named as features of the model
// itself (OSLC's sysx: namespace), which the evaluator judges on its rows.
Features map[string]bool
}
Query is the common representation OSLC text and the API Query parse into.
func ParseOSLC ¶
ParseOSLC parses a where expression against the model's property table. It also accepts a query-parameter string, allowing callers to pass an HTTP-style OSLC query directly.
func ParseParameters ¶
ParseParameters parses oslc.where, oslc.select, oslc.orderBy, oslc.searchTerms and oslc.prefix parameters. Parameter text follows URL query decoding rules.
func (Query) Columns ¶
Columns are the names the query's selected properties are reported under: a property, or a dotted path for a nested selection.
func (Query) SpellingOf ¶
SpellingOf returns the name the request asked for column by, so a frontend reports a result in terms its caller can ask the next query in.
type Scoped ¶
type Scoped struct {
Property string
Inner Constraint
}
Scoped keeps the rows one of whose Property values satisfies Inner.
type Selection ¶
Selection is one property to report, with the properties of the elements it holds when nested.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is the reflective property table of a loaded model: every feature the metamodel library declares on a metaclass, and the evaluator's own properties.
func NewTable ¶
NewTable reads the metaclass declarations of the model's library. A model loaded without the library knows the evaluator's queryable properties alone.
func (*Table) DerivedNames ¶
DerivedNames lists the evaluator's own properties, sorted.
func (*Table) Known ¶
Known reports whether name is a property the evaluator can read: of the metamodel, of the evaluator, or a dotted path whose every segment is one.
func (*Table) MetamodelNames ¶
MetamodelNames lists the metamodel's properties, sorted.