Statement Template rules. Contains functions to parse rules, apply them to Statements, and validate Statements against rules.
Note that this namespace is used during both Profile compilation and Statement generation.
Statement Template rules. Contains functions to parse rules, apply them to Statements, and validate Statements against rules. Note that this namespace is used during both Profile compilation and Statement generation.
(add-rule-valuegen extension-spec-map
valuesets
{:keys [presence path valueset none spec] :as parsed-rule})
If parsed-rule
does not already have a valueset
, then either
derive one from the profile cosmos (i.e. the valuesets
arg), or
add a :spec
and :generator
to generate random values. This will
ensure that during rule application, the rule will always be able to
come up with a value.
Also revises any extension specs to those specified in extension-map
.
If `parsed-rule` does not already have a `valueset`, then either derive one from the profile cosmos (i.e. the `valuesets` arg), or add a `:spec` and `:generator` to generate random values. This will ensure that during rule application, the rule will always be able to come up with a value. Also revises any extension specs to those specified in `extension-map`.
(add-rules-valuegen {:keys [activity-map verb-map extension-spec-map]}
parsed-rules)
Use information from iri-map
and activities
maps, to complete the
parsed-rules
by adding additional valuesets or spec generators.
Use information from `iri-map` and `activities` maps, to complete the `parsed-rules` by adding additional valuesets or spec generators.
(apply-exclusion-rules statement parsed-rules)
Given a partial statement
and parsed-rules
, apply all rules that do
do have excluded
presence to make the statement satisfy
those rules. Excises values at the specified rule location.
Given a partial `statement` and `parsed-rules`, apply all rules that do do have `excluded` presence to make the statement satisfy those rules. Excises values at the specified rule location.
(apply-inclusion-rules statement parsed-rules rng)
Given a partial statement
and parsed-rules
, apply all rules that do
not have excluded
presence to make the statement satisfy
those rules. Must provide an rng
in order to randomly choose or
generate values; these values are then assoc'd into the proper position
in statement
as determined by the respective rule location.
Given a partial `statement` and `parsed-rules`, apply all rules that do not have `excluded` presence to make the statement satisfy those rules. Must provide an `rng` in order to randomly choose or generate values; these values are then assoc'd into the proper position in `statement` as determined by the respective rule location.
(apply-rules statement parsed-rules rng)
Apply all parsed-rules
to a partial statement
. An rng
must be
provided in order to randomly choose or generate values.
Apply all `parsed-rules` to a partial `statement`. An `rng` must be provided in order to randomly choose or generate values.
(follows-rule? statement
{:keys [location any all none presence] :as _parsed-rule})
Simple predicate check to see if parsed-rule
satisfies statement
.
Note that in this function, recommended
presence acts exactly like
included
presence. This is more strict than what the xAPI Profile spec
specifies (in which recommended
rules do not require values to be
present at the location), but this is so recommended
rules
can still be applied to the statement
.
Simple predicate check to see if `parsed-rule` satisfies `statement`. Note that in this function, `recommended` presence acts exactly like `included` presence. This is more strict than what the xAPI Profile spec specifies (in which `recommended` rules do not require values to be present at the location), but this is so `recommended` rules can still be applied to the `statement`.
(parse-rules rules)
(parse-rules object-property rules)
Parse a collection of rules
and return a coll of parsed and
separated rules with specs and generators applied. object-property
may be provided if the containing Template contains an Object-related
Determining property.
Parse a collection of `rules` and return a coll of parsed and separated rules with specs and generators applied. `object-property` may be provided if the containing Template contains an Object-related Determining property.
(property-rule? property {:keys [location]})
Does the first key at the rule's location
equal property
?
Does the first key at the rule's `location` equal `property`?
(rules->object-types parsed-rules)
Derive object types from parsed-rules
and return a map from paths
to the set of possible object types at that location (e.g. one
possible key-value pair is ["actor"] #{"agent" "group"}
).
Derive object types from `parsed-rules` and return a map from paths to the set of possible object types at that location (e.g. one possible key-value pair is `["actor"] #{"agent" "group"}`).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close