-
Notifications
You must be signed in to change notification settings - Fork 3
/
data_model.py
81 lines (58 loc) · 2.25 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
from typing import List
class IdentifiableEntity(object) :
def __init__(self, identifier:str):
self.identifier = identifier
def getId(self) -> str:
return self.identifier
class Image(IdentifiableEntity):
def __init__(self, identifier: str):
super().__init__(identifier)
class Annotation(IdentifiableEntity):
def __init__(self, identifier: str, motivation:str, target: List, body: List):
super().__init__(identifier)
self.motivation = motivation
self.target = target
self.body = body
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, identifier: str, label: str, title : str, creators: str):
super().__init__(identifier)
self.label = label
self.title = title
self.creators = creators
def getLabel(self) -> str:
return self.label
def getTitle(self):
if len(self.title) > 0:
return self.title
else:
return None
def getCreators(self):
if len(self.creators) > 0:
return self.creators.split("; ")
else:
return list()
class Collection(EntityWithMetadata):
def __init__(self, identifier: str, label: str, items: List, title: str , creators: str):
super().__init__(identifier, label, title, creators)
self.items = list()
for item in items:
self.items.append(item)
def getItems(self):
return self.items
class Manifest(EntityWithMetadata):
def __init__(self, identifier: str, label: str, items: List, title: str, creators: str):
super().__init__(identifier, label, title, creators)
self.items = list()
for item in items:
self.items.append(item)
def getItems(self):
return self.items
class Canvas(EntityWithMetadata):
def __init__(self, identifier: str, label: str, title: str, creators: str):
super().__init__(identifier, label, title, creators)