pid_record
PIDRecord ¶
" This class represents a PID record with a PID and entries. For more information on the PID record format, see the documentation of the Typed PID Maker (https://kit-data-manager.github.io/webpage/typed-pid-maker/openapi.html)
Attributes:
Name | Type | Description |
---|---|---|
_pid |
str
|
The PID of the PID record |
_entries |
dict[str, list[PIDRecordEntry]]
|
The entries of the PID record. The entries are stored in a dictionary with the key as the key of the entry and the value as a list of values for the entry. Each value is a dictionary with the key "value" and the value of the entry as the value. The value can also be accessed with the key "@value" |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
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 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
|
__init__ ¶
__init__(pid: str, entries: list[PIDRecordEntry] = None)
Creates a PID record
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pid |
str
|
The PID of the PID record |
required |
entries |
list[PIDRecordEntry]
|
The entries of the PID record (optional) Entries is a dictionary with the key as the key of the entry and the value as a list of values for the entry. Each value is a dictionary with the key "value" and the value of the entry as the value. The value can also be accessed with the key "@value" |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If the PID is None |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
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 |
|
addPIDRecordEntry ¶
addPIDRecordEntry(entry: PIDRecordEntry)
Adds a PID record entry to the PID record
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry |
PIDRecordEntry
|
The PID record entry to add |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the key of the entry is None or the value of the entry is None |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
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 |
|
addEntry ¶
addEntry(key: str, value: str | dict, name: str = None)
Adds an entry to the PID record If the entry already exists, it is not added again (no duplicates)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key of the entry |
required |
value |
str | dict
|
The value of the entry |
required |
name |
str
|
The name of the entry (optional) |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If the key is None or the values are None |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
addListOfEntries ¶
addListOfEntries(entries: list[PIDRecordEntry])
Adds multiple PID record entries to the PID record
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entries |
list[PIDRecordEntry]
|
The PID record entries to add |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the entries are None |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
addEntries ¶
addEntries(key: str, values: list[str], name: str = None)
Adds multiple entries to the PID record
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key of the entries |
required |
values |
list[str]
|
The values of the entries. All values are added to the PID record with the same key. |
required |
name |
str
|
The name of the entries (optional) |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If the key is None or the values are None |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
updateEntry ¶
updateEntry(key: str, value: str | dict, name: str = None)
Updates an entry in the PID record If the entry does not exist, it is added
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key of the entry |
required |
value |
str | dict
|
The value of the entry. If the value is a dictionary, it is converted to a string internally. |
required |
name |
str
|
The name of the entry (optional) |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If the key is None |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
getEntries ¶
getEntries() -> dict
Returns the entries of the PID record
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The entries of the PID record |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
191 192 193 194 195 196 197 198 |
|
getPID ¶
getPID() -> str
Returns the PID of the PID record
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The PID of the PID record |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
200 201 202 203 204 205 206 207 |
|
getEntry ¶
getEntry(
key: str,
) -> list[PIDRecordEntry] | PIDRecordEntry | None
Returns all entries with the given key
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key of the entries |
required |
Returns:
Name | Type | Description |
---|---|---|
list[PIDRecordEntry] | PIDRecordEntry | None
|
list[PIDRecordEntry]: The entries with the given key |
|
PIDRecordEntry |
list[PIDRecordEntry] | PIDRecordEntry | None
|
The entry with the given key if only one entry is found |
None |
list[PIDRecordEntry] | PIDRecordEntry | None
|
If no entry is found |
Raises:
Type | Description |
---|---|
ValueError
|
If the key is None |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
deleteEntry ¶
deleteEntry(key: str, value: str | dict = None)
Deletes an entry from the PID record
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key of the entry |
required |
value |
str | dict
|
The value of the entry (optional) If the value is None, all entries with the given key are deleted. If the value is not None, only the entry with the given key and value is deleted. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If the key is None |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
deleteAllEntries ¶
deleteAllEntries()
Deletes all entries from the PID record
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
254 255 256 257 258 |
|
entryExists ¶
entryExists(key: str, value: str | dict = None) -> bool
Checks if an entry exists
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key of the entry |
required |
value |
str | dict
|
The value of the entry (optional) If the value is None, the method checks if an entry with the given key exists. If the value is not None, the method checks if an entry with the given key and value exists. |
None
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the entry exists, False otherwise |
Raises:
Type | Description |
---|---|
ValueError
|
If the key is None |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
toJSON ¶
toJSON() -> dict
Exports the PID record as JSON object
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The PID record as JSON object |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
exportSimpleFormatJSON ¶
exportSimpleFormatJSON() -> dict
Exports the PID record as a simple JSON object
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The PID record as a simple JSON object |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
fromJSON
staticmethod
¶
fromJSON(input_json: dict) -> PIDRecord
Creates a PID record from a JSON object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_json |
dict
|
The JSON object to create the PID record from |
required |
Returns:
Name | Type | Description |
---|---|---|
PIDRecord |
PIDRecord
|
The PID record created from the JSON object |
Raises:
Type | Description |
---|---|
ValueError
|
If the JSON object is None or invalid |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
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 |
|
merge ¶
merge(other: PIDRecord) -> PIDRecord
Merges the PID record with another PID record
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
PIDRecord
|
The PID record to merge with |
required |
Returns:
Name | Type | Description |
---|---|---|
PIDRecord |
PIDRecord
|
The merged PID record |
Raises:
Type | Description |
---|---|
ValueError
|
If the other PID record is None |
Source code in src/nmr_FAIR_DOs/domain/pid_record.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|