class documentation

class SemanticManager(object):

View In Hierarchy

This class implements semantic service and helper functions.

Note

The semantic graphs are not persisted and only hold in memory at the moment. When the CSE is started the SemanticManager rebuilds the whole semantic graph from the existing <SMD> resources in the resource tree.

Method addDescriptor Perform the semantic validation of the <SMD> resource
Method configure Configure the WebSocket server.
Method executeSemanticDiscoverySPARQLQuery Recursively discover link-related <SMD> resources and run a SPARQL query against each of the results.
Method executeSPARQLQuery Run a SPARQL query against a list of <SMD> resources.
Method init Initialization of the SemanticManager plugin.
Method removeDescriptor Remove the graph for a semantic descriptor.
Method restart Restart the Semantic Manager.
Method start Start of the SemanticManager plugin. This includes re-building of the semantic graph in memory from the existing resources.
Method stop Shutdown the Semantic Manager.
Method updateDescriptor Update the graph for a semantic descriptor.
Method validateDescriptor Check that the descriptor attribute conforms to the syntax defined by the descriptorRepresentation attribute.
Method validateSPARQL Validate wether an input string is a valid SPARQL query.
Method validateValidationEnable Check and handle the setting of the validationEnable attribute.
Class Variable __slots__ Slots for SemanticManager class.
Class Variable dispatcher Injected Dispatcher instance.
Class Variable security Injected SecurityManager instance.
Instance Variable defaultFormat Default serialization format for semantic descriptions.
Instance Variable semanticHandler The semantic graph store handler to be used for the CSE.
Method _buildLinkedBasedGraphIDs Retrieve the resources in the ris attribute and follow the optional rels attribute recursively.
def addDescriptor(self, smd: SMD):

Perform the semantic validation of the <SMD> resource

Todo

Not fully implemented yet.

Parameters
smd:SMDSMD resource object to use in the validation. Attn: This procedure might update and change the provided smd object.
def configure(self, config: Configuration):

Configure the WebSocket server.

Parameters
config:ConfigurationThe configuration object to update with the semantic manager configuration.
def executeSemanticDiscoverySPARQLQuery(self, originator: str, query: str, smds: Sequence[SMD], ct: ContentSerializationType) -> list[Resource]:

Recursively discover link-related <SMD> resources and run a SPARQL query against each of the results.

This implementation support the "resource link-based" method, but not the "annotation-based" method.

When ann originator doesn't have access to a Link-related <SMD> resource then this resource is ignored.

Parameters
originator:strThe originator of the original request. It is used to determine the access to related resources.
query:strString with the SPARQL query.
smds:Sequence[SMD]A list of <SMD> resources which are to be aggregated and for the query.
ct:ContentSerializationTypeResult serialization format to determine the result format.
Returns
list[Resource]Result object. If successful, the data attribute contains the serialized result of the query.
def executeSPARQLQuery(self, query: str, smds: Sequence[SMD] | SMD, ct: ContentSerializationType) -> Result:

Run a SPARQL query against a list of <SMD> resources.

Parameters
query:strString with the SPARQL query.
smds:Sequence[SMD] | SMDA list of <SMD> resources, or a single <SMD> resource, which are to be aggregated for the query.
ct:ContentSerializationTypeResult serialization format to determine the result format.
Returns
ResultResult object. If successful, the data attribute contains the serialized result of the query.
def init(self):

Initialization of the SemanticManager plugin.

def removeDescriptor(self, smd: SMD):

Remove the graph for a semantic descriptor.

Parameters
smd:SMDSMD resource for which the graph is to be update.
def restart(self):

Restart the Semantic Manager.

def start(self):

Start of the SemanticManager plugin. This includes re-building of the semantic graph in memory from the existing resources.

def stop(self) -> bool:

Shutdown the Semantic Manager.

Returns
boolBoolean that indicates the success of the operation
def updateDescriptor(self, smd: SMD):

Update the graph for a semantic descriptor.

Parameters
smd:SMDSMD resource for which the graph is to be updated.
def validateDescriptor(self, smd: SMD):

Check that the descriptor attribute conforms to the syntax defined by the descriptorRepresentation attribute.

Todo

Not fully implemented yet.

Parameters
smd:SMDSMD object to use in the validation.
def validateSPARQL(self, query: str):

Validate wether an input string is a valid SPARQL query.

Todo

Not implemented yet.

Parameters
query:strString with the SPARQL query to validate.
def validateValidationEnable(self, smd: SMD):

Check and handle the setting of the validationEnable attribute.

Todo

Not fully implemented yet.

Parameters
smd:SMDSMD object to use in the validation. Attn: This procedure might update and change the provided smd object.
__slots__: tuple[str, ...] =

Slots for SemanticManager class.

dispatcher: Dispatcher =

Injected Dispatcher instance.

security: SecurityManager =

Injected SecurityManager instance.

defaultFormat =

Default serialization format for semantic descriptions.

semanticHandler =

The semantic graph store handler to be used for the CSE.

def _buildLinkedBasedGraphIDs(self, ris: list[str], originator: str, graphIDs: dict[str, SMD]):

Retrieve the resources in the ris attribute and follow the optional rels attribute recursively.

The result does not contain duplicates.

Parameters
ris:list[str]List of resource IDs to be included in the result and followed recursively.
originator:strThe originator of the original request. It is used to determine the access to related resources.
graphIDs:dict[str, SMD]A dictionary of resource IDs and <SMD> resources that is extended during the recursive walk.