-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdata_model.py
108 lines (75 loc) · 2.53 KB
/
data_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
96
97
98
99
100
101
102
103
104
105
106
107
108
class IdentifiableEntity:
def __init__(self, id):
self.id = id
def getId(self) -> str:
return self.id
class Image(IdentifiableEntity):
pass
class Annotation(IdentifiableEntity):
def __init__(self, id, motivation: str, target, body):
self.motivation = motivation
self.target = target
self.body = body
super().__init__(id)
def getBody(self) -> Image:
return self.body
def getMotivation(self) -> str:
return self.motivation
def getTarget(self) -> IdentifiableEntity:
return self.target
class EntityWithMetadata(IdentifiableEntity):
def __init__(self, id, label: str, title: str, creators: str):
self.label = label
self.title = title
self.creators = creators
# self.creators = list()
# for creator in creators:
# self.creators.append(creator)
super().__init__(id)
def getLabel(self) -> str:
return self.label
def getTitle(self) -> str:
return self.title
def getCreators(self) -> list[str]:
return self.creators
class Canvas(EntityWithMetadata):
def __init__(self, id, label: str, title: str, creators: list[str]):
self.label = label
self.title = title
self.creators = list()
for creator in creators:
self.creators.append(creator)
super().__init__(id, label, title, creators)
class Manifest(EntityWithMetadata):
def __init__(
self, id, label: str, title: str, creators: list[str], items: list[Canvas]
):
self.label = label
self.title = title
self.creators = list()
self.items = list()
for creator in creators:
self.creators.append(creator)
for item in items:
self.items.append(item)
super().__init__(id, label, title, creators)
def getItems(self) -> list[Canvas]:
result = list()
for item in self.items:
result.append(item)
return result
class Collection(EntityWithMetadata):
def __init__(
self, id, label: str, title: str, creators: list[str], items: list[Manifest]
):
self.label = label
self.title = title
self.creators = list()
self.items = list()
for creator in creators:
self.creators.append(creator.lstrip(" "))
for item in items:
self.items.append(item)
super().__init__(id, label, title, creators)
def getItems(self) -> list[Manifest]:
return self.items