-
Notifications
You must be signed in to change notification settings - Fork 5
/
shared_classes.py
388 lines (348 loc) · 11.5 KB
/
shared_classes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# -*- coding: utf-8 -*-
"""
.. module:: shared_classes.py
:synopsis: Set of CIM v2 ontology type definitions
which are used to describe attributes of many of
the other classes.
"""
def text_blob():
"""Provides a text class which supports plaintext, html, and friends
(or will do)."""
return {
"type": "class",
"base": None,
"is_abstract": False,
"pstr": ("{}", ("content",)),
"properties": [
("content", "str", "1.1", "Raw content (including markup)."),
(
"encoding",
"shared.text_blob_encoding",
"1.1",
"Content encoding.",
),
],
}
def citation():
"""An academic reference to published work."""
return {
"type": "class",
"base": None,
"is_abstract": False,
"is_document": True,
"pstr": ("{}", ("title",)),
"properties": [
(
"abstract",
"str",
"0.1",
"Abstract providing high level reference overview.",
),
("authors", "str", "0.N", "The Authors of the work."),
("bibtex", "str", "0.1", "A BibTeX reference for the work."),
(
"citation_detail",
"str",
"0.1",
"A complete citation string as would appear in a "
"bibliography.",
),
(
"collective_title",
"str",
"0.1",
"Citation collective title, i.e. with all authors declared.",
),
(
"context",
"str",
"0.1",
"Brief text description of why this resource is being cited.",
),
("doi", "str", "0.1", "Digital Object Identifier, if it exists."),
("title", "str", "0.1", "The title of the work."),
("type", "str", "0.1", "Citation type."),
("year", "int", "0.1", "Year of publication."),
(
"url",
"shared.online_resource",
"0.1",
"Location of electronic version.",
),
],
}
def extra_attribute():
"""An extra attribute with key and value needed to encode further
information not in the CIM domain model or specialisation.
Typical use case: in parsing data and encoding attributes found in
data.
"""
return {
"type": "class",
"base": None,
"is_abstract": False,
"pstr": ("{}:{}", ("key", "value")),
"properties": [
("doc", "str", "0.1", "Documentation associated with this key."),
("key", "str", "1.1", "Name of attribute."),
("type", "str", "0.1", "If a non-string type, provide type."),
("value", "str", "1.1", "Value associated with key."),
],
}
def nil_reason():
"""Provides an enumeration of possible reasons why a property has
not been defined Based on GML nilReason as discussed here:
https://www.seegrid.csiro.au/wiki/AppSchemas/NilValues."""
return {
"type": "enum",
"is_open": False,
"members": [
("nil:inapplicable", "There is no value"),
(
"nil:missing",
"The correct value is not available. Furthermore, a correct "
"value may not exist",
),
("nil:template", "The value will be available later"),
(
"nil:unknown",
"The correct value is not known at this time. However, a "
"correct value probably exists",
),
("nil:withheld", "The value is not divulged"),
],
}
def online_resource():
"""A minimal approximation of ISO19115 CI_ONLINERESOURCE, provides a
link and details of how to use that link."""
return {
"type": "class",
"base": None,
"is_abstract": False,
"pstr": ("{}", ("linkage",)),
"properties": [
(
"description",
"str",
"0.1",
"Detail of how to access the resource.",
),
("linkage", "str", "1.1", "A URL."),
("name", "str", "1.1", "Name of online resource."),
("protocol", "str", "0.1", "Protocol to use at the linkage."),
],
}
def party():
"""Implements minimal material for an ISO19115-1 (2014) compliant
party.
For our purposes this is a much better animal than the previous
responsibleParty which munged roles together with people. Note we
have collapsed CI_Contact, CI_Individual and CI_Organisation as well
as the abstract CI_Party.
"""
return {
"type": "class",
"base": None,
"is_abstract": False,
"pstr": ("{}", ("name",)),
"is_document": True,
"properties": [
("address", "str", "0.1", "Institutional address."),
("email", "str", "0.1", "Email address."),
("name", "str", "0.1", "Name of person or organisation."),
("orcid_id", "str", "0.1", "Orcid ID if available."),
(
"is_organisation",
"bool",
"0.1",
"True if an organisation not a person.",
),
(
"url",
"shared.online_resource",
"0.1",
"URL of person or institution.",
),
],
}
def quality_review():
"""Assertions as to the completeness and quality of a document.
Not to be confused with assertions as to the quality of the resource
described by the document (as covered by the iso.quality_report). A
future version of this ontology may rename this class.
"""
return {
"type": "class",
"base": None,
"is_abstract": False,
"is_document": True,
"pstr": (
"{}: {}",
(
"target_document",
"quality_status",
),
),
"properties": [
("date", "str", "1.1", "Date upon which review was made."),
(
"metadata_reviewer",
"linked_to(shared.party)",
"1.1",
"Party who made the metadata quality assessment.",
),
(
"quality_description",
"str",
"1.1",
"Assessment of quality of target document.",
),
(
"quality_status",
"shared.quality_status",
"0.1",
"Status from a controlled vocabulary.",
),
(
"target_document",
"shared.doc_reference",
"1.1",
"This is the document about which quality is asserted.",
),
],
}
def quality_status():
"""Assertion as to the review status of document."""
return {
"type": "enum",
"is_open": False,
"members": [
("incomplete", "Currently being worked on"),
("finalised", "Author has completed document, prior to review"),
("under_review", "Document is being reviewed"),
(
"reviewed",
"Document has been formally reviewed and assessed as "
"complete and accurate",
),
],
}
def responsibility():
"""Implements the ISO19115-1 (2014) CI_Responsibility (which
replaces responsibleParty).
Combines a person and their role in doing something.
"""
return {
"type": "class",
"base": None,
"is_abstract": False,
"pstr": ("{}:{}", ("role", "parties")),
"properties": [
(
"parties",
"linked_to(shared.party)",
"1.N",
"Parties delivering responsibility.",
),
(
"role",
"shared.role_code",
"1.1",
"Role that the party plays or played.",
),
(
"when",
"time.time_period",
"0.1",
"Period when role was active, if no longer.",
),
],
}
def role_code():
"""Responsibility role codes: roles that a party may play in
delivering a responsibility.
This is an extension and modification of CI_RoleCode from ISO19115.
"""
return {
"type": "enum",
"is_open": False,
"members": [
(
"Principal Investigator",
"Key party responsible for the existence of the resource",
),
(
"originator",
"Original source for the resource if obtained from elsewhere",
),
("author", "Party who created (or co-created) resource"),
("collaborator", "Contributor to the production of the resource"),
("publisher", "Party who published the resource"),
("owner", "Party with legal ownership of the resource"),
(
"processor",
"Party who has taken part in the workflow that resulted in "
"this resource",
),
("distributor", "Party who distributes the resource"),
(
"sponsor",
"Party who has invested in the production of the resource",
),
("user", "Party who uses the resource"),
(
"point of contact",
"Party who can be contacted for acquiring knowledge about or "
"acquisition of the resource",
),
("resource provider", "Party that supplies the resource"),
(
"custodian",
"Party that accepts accountability and responsibility for the "
"source resource",
),
(
"metadata_reviewer",
"Party who carried out an independent review of (this) "
"documentation",
),
("metadata_author", "Party who created (this) documentation"),
],
}
def text_blob_encoding():
"""Types of text understood by the CIM notebook.
Currently only plaintext, but we expect safe HTML to be supported as
soon as practicable.
"""
return {
"type": "enum",
"is_open": False,
"members": [("ascii", "Normal plain text")],
}
def numeric():
"""A number which comes with a unit, potentially from a controlled
vocabulary of units.
#FIXME: Need to work on the relationship between unit_source and base_unit.
"""
return {
"type": "class",
"base": None,
"is_abstract": False,
"is_document": False,
"pstr": ("{}{}", ("value", "units")),
"properties": [
("value", "float", "1.1", "Numerical value of number"),
("units", "str", "1.1", "Associated Units"),
("unit_enumeration", "str", "0.1", "Internal CIM vocabulary"),
(
"unit_source",
"shared.online_resource",
"0.1",
"External vocabulary source",
),
("base_unit", "str", "0.1", "type of unit in external vocabulary"),
],
"constraints": [
("mutually_exclusive", ("unit_enumeration", "unit_source"), "0.1"),
],
}