-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.py
95 lines (64 loc) · 2.08 KB
/
model.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
from typing import List
class IdentifiableEntity:
id: str
def __init__(self, id):
self.id = id
def getId(self):
return self.id
class Image(IdentifiableEntity):
pass
class Annotation(IdentifiableEntity):
motivation: str
body: Image
target: str
def __init__(self, id, motivation, body, target):
self.motivation = motivation
self.target = target
self.body = body
super().__init__(id)
def getBody(self):
return self.body
def getMotivation(self):
return self.motivation
def getTarget(self):
return self.target
class EntityWithMetadata(IdentifiableEntity):
label: str
title: str = None
creators: list = []
def __init__(self, id, label, title=None, creators=None):
self.label = label
self.title = title
if isinstance(creators, str) and creators != "":
self.creators = creators.split("; ")
elif isinstance(creators, list):
self.creators = creators
else:
self.creators = []
super().__init__(id)
def getLabel(self):
return self.label
def getTitle(self):
return self.title
def getCreators(self):
return self.creators
class Canvas(EntityWithMetadata):
pass
class Manifest(EntityWithMetadata):
list_of_canvas: List[Canvas] = []
def __init__(self, id, label, title=None, creators=None, list_of_canvas=None):
if isinstance(list_of_canvas, list):
self.list_of_canvas = list_of_canvas
else:
self.list_of_canvas = []
super().__init__(id, label, title, creators)
def getItems(self):
return self.list_of_canvas
class Collection(EntityWithMetadata):
list_of_manifests: List[Manifest] = []
def __init__(self, id, label, title=None, creators=None, list_of_manifests=None):
if isinstance(list_of_manifests, list):
self.list_of_manifests = list_of_manifests
super().__init__(id, label, title, creators)
def getItems(self):
return self.list_of_manifests