Vocabulary Integration
Contents
Vocabulary Integration#
Module: spp_cel_vocabulary
Overview#
Vocabulary-aware CEL functions for robust eligibility rules
Purpose#
This module is designed to:
Enable vocabulary-aware CEL expressions: Provide CEL functions that compare and group vocabulary codes by URI, supporting local code mappings and concept groups.
Offer semantic helper shortcuts: Supply human-readable CEL functions like
is_female()andis_head()that map to concept group membership checks.Cache vocabulary lookups for performance: Use session-scoped and ORM-level caching to avoid N+1 queries during CEL evaluation.
Module Dependencies#
Dependency |
Purpose |
|---|---|
|
Write simple CEL-like expressions to filter records (Open... |
|
OpenSPP: Vocabulary |
Key Features#
Vocabulary Functions#
The module registers the following functions for use in CEL expressions:
Function |
Description |
Example |
|---|---|---|
|
Resolve a vocabulary code by URI or alias |
|
|
Compare a code field handling local code mappings |
|
|
Check if a code belongs to a concept group |
|
Semantic Helpers#
Shortcut functions that delegate to in_group() with predefined concept group names:
Function |
Concept Group |
Example |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
N/A (checks membership type) |
|
The head() function checks whether a member holds the "head" membership type in their group, rather than checking a vocabulary code field.
Domain Translation#
The CEL translator is extended to convert vocabulary functions into Odoo domains:
in_group()and semantic helpers produceORdomains checking bothuriandreference_urifields against the group's code URIs.code_eq()andcode()comparisons resolve identifiers via alias lookup and build URI-based equality domains.Only
==and!=operators are supported for code comparisons.
Vocabulary Cache#
A two-layer caching system optimizes vocabulary lookups:
Layer 1 (ORM cache): Registry-scoped cache in
VocabularyConceptGroupfor group URI sets.Layer 2 (Session cache): Per-evaluation
VocabularyCacheinstance that provides O(1) frozenset membership checks and avoids redundant lookups within a single CEL evaluation session.
Integration#
spp_cel_domain: Extends the CEL translator to handle vocabulary function calls and the CEL function registry for runtime function resolution. Auto-installs when both dependencies are present.
spp_vocabulary: Reads from
spp.vocabulary.codefor code resolution andspp.vocabulary.concept.groupfor group membership checks. Ships predefined concept groups via XML data.
openspp.org