-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModelClasses.py
269 lines (197 loc) · 7.96 KB
/
ModelClasses.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
# Implementation of the UML data model via Python classes
'''
class <class name>(<superclass 1>,<superclass 2>, ...):
def __init__(self, <param 1>, <param 2>, ...) -> constructor of an object of that class
! All the methods of a class, including its constructor __init__, MUST specify "self" as the first parameter !
! In Python relations can be represented as the other attributes (e.g. by assigning some specific values to self-declared variables) !
'''
class IdentifiableEntity(object):
# -- Constructor
def __init__(self, identifiers):
self.id = set() # Constraint is [1..*], hence the set
for identifier in identifiers:
self.id.add(identifier)
# -- Methods
def getIds(self):
result = list()
for ids in self.id:
result.append(ids)
return result
""" id1 = IdentifiableEntity(["10546"])
print(id1)
print(type(id1))
print(id1.getIds())
print("\n------------------------\n")
id2 = IdentifiableEntity(["10546","46351"])
print("This is id2 \n",id2)
print(type(id2))
print(id2.getIds())
"""
class Person(IdentifiableEntity):
# -- Constructor
def __init__(self, givenName, familyName, identifiers):
self.givenName = givenName # Must be exactly 1 string
self.familyName = familyName # Must be exactly 1 string
# --- Upperclass parameters
super().__init__(identifiers)
# -- Methods
def getGivenName(self):
return self.givenName
def getFamilyName(self):
return self.familyName
# person1 = Person("Ahsan","Syed",["Ahsa98"])
""" print("This is person1",person1)
print(type(person1))
print("This is the familyName of person1\n",person1.getFamilyName())
print("This is the givenName of person1\n",person1.getGivenName())
print(person1.getIds())
"""
# person2 = Person("Francesca","Budel",["FraB99","Fra99"])
class Organization(IdentifiableEntity):
# -- Constructor
def __init__(self, name, identifiers):
self.name = name
# --- Upperclass parameters
super().__init__(identifiers)
# -- Methods
def getName(self):
return self.name
# org1 = Organization("The Belmeloro organization",["belm2023"])
"""
print(org1)
print(type(org1))
print("This is the name of org1\n",org1.getName())
print(org1.getIds()) """
class Venue(IdentifiableEntity):
# -- Constructor
def __init__(self, title, identifiers, publisher):
self.title = title
# --- Relations
self.publisher = publisher
# --- Upperclass parameters
super().__init__(identifiers)
# -- Methods
def getTitle(self):
return self.title
def getPublisher(self): # Returns an Organization object
return self.publisher
# ven1 = Venue("Belmeloro Venue", ["belm0000", "belm1111"], org1)
"""
print(ven1)
print(type(ven1))
print("This is the title of the venue\n",ven1.getTitle())
print("This is the publisher of the venue",ven1.getPublisher())
print("This is the ID of the venue", ven1.getIds())
print("------------------------------------ \n ------------------------------")
print("ID OF THE PUBLISHER\n",ven1.getPublisher().getIds())
print("NAME OF THE PUBLISHER\n",ven1.getPublisher().getName()) """
class Publication(IdentifiableEntity):
# -- Constructor
def __init__(self, publicationYear, title, identifiers, publicationVenue, author, cites):
self.publicationYear = publicationYear
self.title = title
# --- Relations
self.publicationVenue = publicationVenue
self.author = author # This can be an input list/set as the relation has constraints 1..*
self.cites = cites # Input list/set, as constraint is 0..*
# --- Upperclass parameters
super().__init__(identifiers)
# -- Methods
def getPublicationYear(self):
return self.publicationYear
def getTitle(self):
return self.title
def getCitedPublications(self):
return self.cites
def getPublicationVenue(self):
return self.publicationVenue
def getAuthors(self):
result = set()
for person in self.author:
result.add(person)
return result
# pub1 = Publication(1963, "The Name of the Rose", ["abc1001","cba1001"], ven1,[person1,person2],[])
""" print(pub1)
print(type(pub1))
print("This is the publication year of the publication\n",pub1.getPublicationYear())
print("This is the title of the publication",pub1.getTitle())
print("This is the cited publications of the publication", pub1.getCitedPublications())
print("This is the publication venue of the publication",pub1.getPublicationVenue())
print("This is the authors of the publication",pub1.getAuthors())
"""
class JournalArticle(Publication):
# -- Constructor
def __init__(self, issue, volume, publicationYear, title, identifiers, publicationVenue, author, cites):
self.issue = issue
self.volume = volume
# --- Upperclass parameters
super().__init__(publicationYear, title, identifiers, publicationVenue, author, cites)
# -- Methods
def getIssue(self):
return self.issue
def getVolume(self):
return self.volume
# journal_article1 = JournalArticle("issue1","volume1",1944,"Journal Article on WW2",["id1","id2"],ven1,[person2],[pub1])
""" print(journal_article1)
print(type(journal_article1))
print(journal_article1.getIssue())
print(journal_article1.getVolume())
print(journal_article1.getAuthors())
print(journal_article1.getCitedPublications())
print(journal_article1.getIds())
print(journal_article1.getPublicationYear())
print(journal_article1.getTitle())
print(journal_article1.getPublicationVenue())
"""
class BookChapter(Publication):
# -- Constructor
def __init__(self, chapterNumber, publicationYear, title, identifiers, publicationVenue, author, cites):
self.chapterNumber = chapterNumber
# --- Upperclass parameters
super().__init__(publicationYear, title, identifiers, publicationVenue, author, cites)
# -- Methods
def getChapterNumber(self):
return self.chapterNumber
""" book_chapter1 = BookChapter(1,1944,"Book on WW2",["id11","id12"],ven1,[person1],[pub1])
print(book_chapter1)
print(type(book_chapter1))
print(book_chapter1.getChapterNumber())
print(book_chapter1.getAuthors())
print(book_chapter1.getCitedPublications())
print(book_chapter1.getIds())
print(book_chapter1.getPublicationYear())
print(book_chapter1.getTitle())
print(book_chapter1.getPublicationVenue())
print("--------------------- \n ------------------- \n -----------------") """
class ProceedingsPaper(Publication):
pass
""" proceedings_paper1 = ProceedingsPaper(1963, "The Name of the Rose", ["abc1001","cba1001"], ven1,[person1,person2],[])
print(proceedings_paper1)
print(type(proceedings_paper1))
print("--------------------- \n ------------------- \n -----------------") """
class Journal(Venue):
pass
""" journal1 = Journal("Belmeloro Venue", ["belm0000", "belm1111"], org1)
print(journal1)
print(type(journal1))
print("--------------------- \n ------------------- \n -----------------") """
class Book(Venue):
pass
""" book1 = Book("Belmeloro Venue", ["belm0000", "belm1111"], org1)
print(book1)
print(type(book1))
print("--------------------- \n ------------------- \n -----------------") """
class Proceedings(Venue):
# -- Constructor
def __init__(self, event, title, identifiers, publisher):
self.event = event
# --- Upperclass parameters
super().__init__(title, identifiers, publisher)
def getEvent(self):
return self.event
""" proceedings1 = Proceedings("Event Belmeloro","Belmeloro Venue", ["belm0000", "belm1111"], org1)
print(proceedings1)
print(type(proceedings1))
print(proceedings1.getEvent()) """
class QueryProcessor(object):
pass