@@ -6,125 +6,143 @@ For a more general overview, go to [getting started](./getting_started.md#genera
66
77``` eval_rst
88.. uml::
9- :caption: Standard design
10- :align: center
11-
12- allow_mixing
13- actor User
14-
15- rectangle SemanticLayer {
16-
17- class Cuds {
18- Session session
19- UUID uuid
20- CUBA cuba_key
21- --
22- add() : Cuds
23- get() : Cuds
24- remove() : void
25- update() : void
26- iter() : Iterator<Cuds>
27- }
28- }
29-
30- rectangle InteroperabilityLayer {
31-
32- class Registry <dict> {
33- }
34-
35- abstract class Session {
36- Registry : registry
37- --
38- store() : void
39- load() : Cuds
40- sync() : void
41- }
42-
43- class SomeWrapperSession implements Session {
44- List added
45- List updated
46- List removed
47- SyntacticLayer syntactic
48- --
49- }
50- }
9+ :caption: Standard design
10+ :align: center
11+
12+ allow_mixing
13+ actor User
14+
15+ circle pico
16+
17+ rectangle SemanticLayer {
18+ class Cuds {
19+ Session session
20+ UUID uuid
21+ OntologyEntity oclass
22+ --
23+ add() : Cuds
24+ get() : Cuds
25+ remove() : void
26+ update() : void
27+ iter() : Iterator<Cuds>
28+ }
29+
30+ abstract class OntologyEntity {
31+ String name
32+ URIRef iri
33+ String tblname
34+ OntologyNamespace namespace
35+ Set direct_superclasses
36+ Set direct_subclasses
37+ Set superclasses
38+ Set subclasses
39+ String description
40+ --
41+ get_triples() : triple
42+ is_superclass_of() : bool
43+ is_subclass_of() : bool
44+ }
45+ class OntologyClass implements OntologyEntity {
46+ Dict attributes
47+ Dict own_attributes
48+ }
49+
50+ class OntologyRelationship implements OntologyEntity {
51+ OntologyRelationship inverse
52+ }
53+
54+ class OntologyAttribute implements OntologyEntity {
55+ URIRef datatype
56+ --
57+ convert_to_datatype() : Any
58+ convert_to_basic_type() : Any
59+ }
60+
61+ class OntologyNamespace {
62+ --
63+ get_iri() : URIRef
64+ get_default_rel() : OntologyRelationship
65+ get() : OntologyEntity
66+
67+ }
68+
69+ class NamespaceRegistry {
70+ --
71+ get() : OntologyNamespace
72+ update_namespaces() : void
73+ from_iri() : OntologyEntity
74+ clear() : Graph
75+ store() : void
76+ load() : void
77+ }
78+ }
5179
52- rectangle SyntacticLayer {
53- class SyntacticLayer {
80+ rectangle InteroperabilityLayer {
81+ class Registry <dict> {
82+ }
83+
84+ abstract class Session {
85+ Registry : registry
86+ --
87+ store() : void
88+ load() : Cuds
89+ sync() : void
90+ }
91+
92+ class SomeWrapperSession implements Session {
93+ List added
94+ List updated
95+ List removed
96+ SyntacticLayer syntactic
97+ --
98+ }
5499 }
55- }
56100
57- database backend
101+ rectangle SyntacticLayer {
102+ class SyntacticLayer {
103+ }
104+ }
58105
106+ database backend
59107
60- ' -----------------------
61- ' ------ RELATIONS ------
62- ' -----------------------
63- User -> Cuds : interacts_with
108+ ' -----------------------
109+ ' ------ RELATIONS ------
110+ ' -----------------------
111+ User -up-> OntologyClass : interacts_with
112+ Cuds -left> OntologyClass : instance_of
113+ OntologyEntity -> OntologyNamespace : part_of
114+ OntologyNamespace -> NamespaceRegistry : contained_in
115+ OntologyClass -left> OntologyAttribute : has
64116
65- Cuds -> Session : has_a
66- Session -> Registry : manages
117+ pico -> NamespaceRegistry : manages
67118
68- SomeWrapperSession -> SyntacticLayer : manages
119+ Cuds -> Session : has_a
120+ Session -> Registry : manages
69121
70- SyntacticLayer -> backend : acts_on
122+ SomeWrapperSession -> SyntacticLayer : manages
71123
72- ' -----------------------
73- ' -------- NOTES --------
74- ' -----------------------
75- note top of Cuds
76- This will be shallow structure with
77- the uuids of the contained elements:
78- {
79- Relation1: {uid1: cuba_key, uid2: cuba_key},
80- Relation2: {uid4: cuba_key},
81- Relation3: {uid3: cuba_key, uid5: cuba_key},
82- }
83- end note
84-
85- note top of Session
86- Provides the info requested to Cuds
87- end note
88-
89- note top of SomeWrapperSession
90- Updates the registry with information
91- from the backend and vice versa.
92- end note
93-
94- note top of Registry
95- Flat structure that contains all the
96- objects accessible through their uid:
97- {
98- uid1: object1,
99- uid2: object2,
100- uid3: object3,
101- }
102- end note
124+ SyntacticLayer -> backend : acts_on
103125
104- note top of SyntacticLayer
105- Connects to the engine and
106- knows its specific API
107- end note
126+ OntologyRelationship -[hidden]> OntologyAttribute
108127```
109128
110-
111129## Semantic layer
112130The semantic layer is the representation of the classes of the ontology in a programming language.
113131
114132When the user installs an ontology through ` pico ` ,
115- all ontology classes are saved in a pickle file in the site-packages of the python environment .
133+ all ontology concepts are saved in a graph in ` ~/.osp_ontologies ` .
116134
117135The procedure is as follows:
118136- The ` OntologyInstallationManager ` receives a list of yml files with ontologies to install.
119137- It instantiates a ` Parser ` .
120138- The parser goes through the ontologies and creates an ` OntologyClass ` per entity.
121139- All the oclasses of the same namespace are grouped in an ` OntologyNamespace ` .
122- - All the registries are collected in the ` NamespaceRegistry ` . This object will be pickled.
140+ - All the registries are collected in the ` NamespaceRegistry ` .
123141
124- Installing new ontologies loads the pickle and adds new namespaces or modifies the existing ones.
142+ Installing new ontologies loads the graph and adds new namespaces or modifies the existing ones.
125143
126144When a class is instantiated, an individual is created.
127- The pickled file is read, and an instance of the [ Cuds] ( #cuds ) class with the ontology information is created.
145+ The graph is read, and an instance of the [ Cuds] ( #cuds ) class with the ontology information is created.
128146
129147Through the Cuds they realise the [ Cuds API] ( #cuds-api ) which enables the user to work with them in a generic, simple way.
130148
@@ -133,15 +151,15 @@ _Location:_ `osp.core.cuds`
133151
134152It is the base class for all instances.
135153Besides whatever might have been defined in the ontology, they all have 3 basic attributes:
136- - uid: instance of ` uuid.UUID ` , it serves to uniquely identify an instance
154+ - uid: instance of ` uuid.UUID ` , it serves to uniquely identify an instance.
137155 - session: this is the link to the interoperability layer.
138156 By default all objects are in the ` CoreSession ` , unless they are in a wrapper.
139157 - oclass: indicates the ontology class they originate from.
140158
141159#### Cuds structure
142160Each cuds object contains the uids and oclass of the directly related entities,
143161as well as the relationship that connects them.
144- The actual related objects are kept in the [ registry] ( #registry )
162+ The actual related objects are kept in the [ registry] ( #registry ) .
145163```
146164 a_cuds_object := {
147165 Relation1: {uid1: oclass, uid2: oclass},
0 commit comments