Skip to content

Classes:

EventLoopModel

EventLoopModel(el_id, graph)

Bases: ModelBase

Model of an event loop containing models of reactions to events and flags.

Attributes:

Parameters:

  • el_id (URIRef) –

    URI of event loop

  • graph (Graph) –

    graph for loading attributes

Source code in src/rdf_utils/models/event_loop.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
def __init__(self, el_id: URIRef, graph: Graph) -> None:
    super().__init__(node_id=el_id, graph=graph)

    self.events_triggered = {}
    self.flag_values = {}
    self.event_reactions = {}
    self.flag_reactions = {}

    for evt_uri in graph.objects(subject=self.id, predicate=URI_EL_PRED_HAS_EVT):
        assert isinstance(
            evt_uri, URIRef
        ), f"Event '{evt_uri}' is not of type URIRef: {type(evt_uri)}"
        self.events_triggered[evt_uri] = False

    for flg_uri in graph.objects(subject=self.id, predicate=URI_EL_PRED_HAS_FLG):
        assert isinstance(
            flg_uri, URIRef
        ), f"Flag '{flg_uri}' is not of type URIRef: {type(flg_uri)}"
        self.flag_values[flg_uri] = False

    for evt_re_uri in graph.objects(subject=self.id, predicate=URI_EL_PRED_HAS_EVT_REACT):
        assert isinstance(
            evt_re_uri, URIRef
        ), f"EventReaction '{evt_re_uri}' is not of type URIRef: {type(evt_re_uri)}"
        evt_re_model = EventReactionModel(reaction_id=evt_re_uri, graph=graph)
        assert (
            evt_re_model.event_id in self.events_triggered
        ), f"'{evt_re_model.id}' reacts to event '{evt_re_model.event_id}', which is not in event loop '{self.id}'"
        self.event_reactions[evt_re_model.event_id] = evt_re_model

    for flg_re_uri in graph.objects(subject=self.id, predicate=URI_EL_PRED_HAS_FLG_REACT):
        assert isinstance(
            flg_re_uri, URIRef
        ), f"FlagReaction '{flg_re_uri}' is not of type URIRef: {type(flg_re_uri)}"
        flg_re_model = FlagReactionModel(reaction_id=flg_re_uri, graph=graph)
        assert (
            flg_re_model.flag_id in self.flag_values
        ), f"'{flg_re_model.id}' reacts to flag '{flg_re_model.flag_id}', which is not in event loop '{self.id}'"
        self.flag_reactions[flg_re_model.flag_id] = flg_re_model

EventReactionModel

EventReactionModel(reaction_id, graph)

Bases: ModelBase

Model for reactions to an event.

Attributes:

  • event_id (URIRef) –

    URI of the event to react to

Parameters:

  • reaction_id (URIRef) –

    URI of the reaction model

  • graph (Graph) –

    RDF graph to load relevant attributes

Source code in src/rdf_utils/models/event_loop.py
32
33
34
35
36
37
38
39
def __init__(self, reaction_id: URIRef, graph: Graph) -> None:
    super().__init__(node_id=reaction_id, graph=graph)

    evt_uri = graph.value(subject=self.id, predicate=URI_EL_PRED_REF_EVT)
    assert evt_uri is not None and isinstance(
        evt_uri, URIRef
    ), f"EventReaction '{self.id}' does not refer to a valid event URI: {evt_uri}"
    self.event_id = evt_uri

FlagReactionModel

FlagReactionModel(reaction_id, graph)

Bases: ModelBase

Model for reactions to a flag.

Attributes:

  • flag_id (URIRef) –

    URI of the flag to react to

Parameters:

  • reaction_id (URIRef) –

    URI of the reaction model

  • graph (Graph) –

    RDF graph to load relevant attributes

Source code in src/rdf_utils/models/event_loop.py
54
55
56
57
58
59
60
61
def __init__(self, reaction_id: URIRef, graph: Graph) -> None:
    super().__init__(node_id=reaction_id, graph=graph)

    flg_uri = graph.value(subject=self.id, predicate=URI_EL_PRED_REF_FLG)
    assert flg_uri is not None and isinstance(
        flg_uri, URIRef
    ), f"FlagReaction '{self.id}' does not refer to a valid flag URI: {flg_uri}"
    self.flag_id = flg_uri