|
0
|
1 |
# -*- coding: utf-8 -*- |
|
|
2 |
|
|
|
3 |
from django.db import models |
|
|
4 |
from p4l.models.common import P4lModel, P4lModelLang |
|
|
5 |
|
|
|
6 |
|
|
|
7 |
class Imprint(P4lModelLang): |
|
|
8 |
record = models.ForeignKey('p4l.Record', related_name="imprints") |
|
|
9 |
imprintCity = models.CharField(max_length=512, blank=True, null=True, db_index=True) |
|
|
10 |
publisher = models.CharField(max_length=512, blank=True, null=True, db_index=True) |
|
|
11 |
imprintDate = models.CharField(max_length=512, blank=True, null=True, db_index=True) |
|
|
12 |
|
|
|
13 |
|
|
|
14 |
class Serie(P4lModel): |
|
|
15 |
title = models.CharField(max_length=2048, blank=False, null=False, db_index=True) |
|
|
16 |
volume = models.CharField(max_length=2048, blank=True, null=True, db_index=True) |
|
|
17 |
class Meta(P4lModel.Meta): |
|
|
18 |
unique_together = ['title', 'volume'] |
|
|
19 |
|
|
|
20 |
class RecordSerie(P4lModelLang): |
|
|
21 |
record = models.ForeignKey('p4l.Record', related_name="series+") |
|
|
22 |
serie = models.ForeignKey('p4l.Serie', related_name="records") |
|
|
23 |
class Meta(P4lModelLang.Meta): |
|
|
24 |
unique_together = ['record','serie'] |
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
class ProjectName(P4lModel): |
|
|
29 |
label = models.CharField(max_length=2048, blank=False, null=False, db_index=True) |
|
|
30 |
acronym = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:acronym |
|
|
31 |
class Meta(P4lModel.Meta): |
|
|
32 |
unique_together = ['label', 'acronym'] |
|
|
33 |
|
|
|
34 |
|
|
|
35 |
class CorporateAuthor(P4lModel): |
|
|
36 |
label = models.CharField(max_length=2048, blank=False, null=False, db_index=True) |
|
|
37 |
acronym = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:acronym |
|
|
38 |
class Meta(P4lModel.Meta): |
|
|
39 |
unique_together = ['label', 'acronym'] |
|
|
40 |
|
|
|
41 |
|
|
|
42 |
class Url(P4lModel): |
|
|
43 |
record = models.ForeignKey('p4l.Record', related_name="urls") |
|
|
44 |
address = models.CharField(max_length=2048, blank=False, null=False, db_index=True) #iiep:address |
|
|
45 |
display = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:display |
|
|
46 |
accessLevel = models.CharField(max_length=512, blank=True, null=True, db_index=True) #iiep:accessLevel |
|
|
47 |
|
|
|
48 |
|
|
|
49 |
class Subject(P4lModel): |
|
|
50 |
subject = models.URLField(max_length=2048, unique=True, db_index=True) |
|
9
|
51 |
label = models.CharField(max_length=2048, blank=True, null=True, db_index=True) # filled from sparql request after import |
|
0
|
52 |
|
|
|
53 |
class Theme(P4lModel): |
|
|
54 |
theme = models.URLField(max_length=2048, unique=True, db_index=True) |
|
9
|
55 |
label = models.CharField(max_length=2048, blank=True, null=True, db_index=True) # filled from sparql request after import |
|
0
|
56 |
|
|
|
57 |
|
|
|
58 |
class Country(P4lModel): |
|
|
59 |
country = models.URLField(max_length=2048, unique=True, db_index=True) |
|
|
60 |
|
|
|
61 |
|
|
|
62 |
class Isbn(P4lModelLang): |
|
|
63 |
record = models.ForeignKey('p4l.Record', related_name="isbns") |
|
|
64 |
isbn = models.CharField(max_length=128) #iiep:isbn |
|
|
65 |
|
|
|
66 |
|
|
|
67 |
class Issn(P4lModelLang): |
|
|
68 |
record = models.ForeignKey('p4l.Record', related_name="issns") |
|
|
69 |
issn = models.CharField(max_length=128) #iiep:issn |
|
|
70 |
|
|
|
71 |
class DocumentCode(P4lModelLang): |
|
|
72 |
record = models.ForeignKey('p4l.Record', related_name="documentCodes") |
|
|
73 |
documentCode = models.CharField(max_length=128) #iiep:issn |
|
|
74 |
|
|
|
75 |
class Language(P4lModel): |
|
|
76 |
language = models.URLField(max_length=2048, unique=True, db_index=True) |
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
class BaseTitle(P4lModelLang): |
|
|
81 |
title = models.CharField(max_length=2048, blank=False, null=False, db_index=True) |
|
|
82 |
class Meta(P4lModelLang.Meta): |
|
|
83 |
abstract = True |
|
|
84 |
|
|
|
85 |
class Title(BaseTitle): |
|
|
86 |
record = models.ForeignKey('p4l.Record', related_name="titles") |
|
|
87 |
|
|
|
88 |
class AddedTitle(BaseTitle): |
|
|
89 |
record = models.ForeignKey('p4l.Record', related_name="addedTitles") |
|
|
90 |
|
|
|
91 |
class TitleMainDocument(BaseTitle): |
|
|
92 |
record = models.ForeignKey('p4l.Record', related_name="titlesMainDocument") |
|
|
93 |
|
|
|
94 |
|
|
|
95 |
class Abstract(P4lModelLang): |
|
|
96 |
record = models.ForeignKey('p4l.Record', related_name="abstracts") |
|
|
97 |
abstract = models.TextField(blank=True, null=True) |
|
|
98 |
|
|
|
99 |
|
|
|
100 |
class Collation(P4lModelLang): |
|
|
101 |
record = models.ForeignKey('p4l.Record', related_name="collations") |
|
|
102 |
collation = models.CharField(max_length=1024, blank=False, null=False, db_index=True) |
|
|
103 |
|
|
|
104 |
|
|
|
105 |
class VolumeIssue(P4lModelLang): |
|
|
106 |
record = models.ForeignKey('p4l.Record', related_name="volumeIssues") |
|
|
107 |
volume = models.CharField(max_length=1024, blank=True, null=True, db_index=True) #iiep:volume |
|
|
108 |
number = models.CharField(max_length=1024, blank=True, null=True, db_index=True) #iiep:number |
|
|
109 |
|
|
|
110 |
|
|
|
111 |
class P4lPerson(P4lModel): |
|
|
112 |
name = models.CharField(max_length=2048, blank=False, null=False, db_index=True, unique=True) |
|
|
113 |
class Meta(P4lModel.Meta): |
|
|
114 |
abstract = True |
|
|
115 |
|
|
|
116 |
|
|
|
117 |
class Author(P4lPerson): |
|
|
118 |
pass |
|
|
119 |
|
|
|
120 |
class SubjectPerson(P4lPerson): |
|
|
121 |
pass |
|
|
122 |
|
|
|
123 |
|
|
|
124 |
class Periodical(P4lModel): |
|
|
125 |
label = models.CharField(max_length=2048, blank=False, null=False, db_index=True, unique=True) #iiep:periodical |
|
|
126 |
|
|
|
127 |
class RecordPeriodical(P4lModelLang): |
|
|
128 |
record = models.ForeignKey('p4l.Record', related_name="periodicals+") |
|
|
129 |
periodical = models.ForeignKey('p4l.Periodical', related_name="records") |
|
|
130 |
class Meta(P4lModelLang.Meta): |
|
|
131 |
unique_together = ['record','periodical'] |
|
|
132 |
|
|
|
133 |
|
|
|
134 |
class BaseMeeting(P4lModel): |
|
|
135 |
label = models.CharField(max_length=2048, blank=False, null=False, db_index=True) #rdfs:label |
|
|
136 |
meetingNumber = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:meetingNumber |
|
|
137 |
meetingPlace = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:meetingPlace |
|
|
138 |
meetingDate = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:meetingDate |
|
|
139 |
meetingYear = models.PositiveSmallIntegerField(blank=True, null=True, db_index=True) #iiep:meetingYear |
|
|
140 |
class Meta(P4lModel.Meta): |
|
|
141 |
abstract = True |
|
|
142 |
unique_together = ['label', 'meetingNumber', 'meetingPlace', 'meetingDate', 'meetingYear'] |
|
|
143 |
|
|
|
144 |
|
|
|
145 |
class Meeting(BaseMeeting): |
|
|
146 |
pass |
|
|
147 |
|
|
|
148 |
class RecordMeeting(P4lModelLang): |
|
|
149 |
record = models.ForeignKey('p4l.Record', related_name="meetings+") |
|
|
150 |
meeting = models.ForeignKey('p4l.Meeting', related_name="records") |
|
|
151 |
class Meta(P4lModelLang.Meta): |
|
|
152 |
unique_together = ['record','meeting'] |
|
|
153 |
|
|
|
154 |
|
|
|
155 |
class SubjectMeeting(BaseMeeting): |
|
|
156 |
pass |
|
|
157 |
|
|
|
158 |
|
|
|
159 |
class CorporateBody(P4lModel): |
|
|
160 |
label = models.CharField(max_length=2048, blank=False, null=False, db_index=True) #rdfs:label |
|
|
161 |
acronym = models.CharField(max_length=2048, blank=True, null=True, db_index=True) #iiep:acronym |
|
|
162 |
class Meta(P4lModel.Meta): |
|
|
163 |
unique_together = ['label','acronym'] |
|
|
164 |
|
|
|
165 |
class Record(P4lModel): |
|
|
166 |
uri = models.URLField(max_length=2048, unique=True, db_index=True) #subject |
|
4
|
167 |
subjects = models.ManyToManyField('p4l.Subject') #dct:subject # Thesaurus with no country |
|
|
168 |
themes = models.ManyToManyField('p4l.Theme') #iiep:theme # Theme |
|
|
169 |
countries = models.ManyToManyField('p4l.Country') #iiep:country # Thesaurus filtered with country only |
|
0
|
170 |
identifier = models.CharField(max_length=128, unique=True, db_index=True) #dct:identifier |
|
|
171 |
notes = models.TextField(blank=True, null=True) #iiep:notes |
|
|
172 |
#issns foreign key from Isbn #iiep:issn |
|
|
173 |
#isbns foreign key from Isbn #iiep:isbn |
|
|
174 |
#documentCodes foreign key from Isbn #iiep:documentCode |
|
4
|
175 |
language = models.ForeignKey('p4l.Language', blank=True, null=True) #dct:language # Language |
|
|
176 |
otherLanguages = models.ManyToManyField('p4l.Language', related_name='otherLanguage_record') #iiep:otherLanguage # Language |
|
0
|
177 |
#titles foreign Key from Title #dct:title |
|
|
178 |
#addedTitles foreign Key from AddedTitle #iiep:addedTitle |
|
|
179 |
#titlesMainDocument foreign Key from TitleMainDocument #iiep:titleMainDocument |
|
|
180 |
editionStatement = models.CharField(max_length=1024, blank=True, null=True) #iiep:editionStatement |
|
|
181 |
#imprints foreign Key from Imprint #iiep:imprint |
|
|
182 |
#collations = foreign Key from Collation #iiep:collation |
|
|
183 |
#volumeIssues = foreign Key from VolumeIssue #iiep:volumeIssue |
|
|
184 |
projectNames = models.ManyToManyField('p4l.ProjectName') #iiep:projectName |
|
|
185 |
periodicals = models.ManyToManyField('p4l.Periodical', through='p4l.RecordPeriodical') #iiep:periodical |
|
|
186 |
meetings = models.ManyToManyField('p4l.Meeting', through='p4l.RecordMeeting') #iiep:meeting |
|
|
187 |
series = models.ManyToManyField('p4l.Serie', through='p4l.RecordSerie') #iiep:serie |
|
|
188 |
authors = models.ManyToManyField('p4l.Author') #iiep:author |
|
|
189 |
subjectPersons = models.ManyToManyField('p4l.SubjectPerson') #iiep:subjectPerson |
|
4
|
190 |
subjectCorporateBodies = models.ManyToManyField('p4l.CorporateBody') #iiep:subjectCorporateBody # Organisation ? |
|
0
|
191 |
subjectMeetings = models.ManyToManyField('p4l.SubjectMeeting') #iiep:subjectMeeting |
|
4
|
192 |
corporateAuthors = models.ManyToManyField('p4l.CorporateAuthor') #iiep:corporateAuthor # Organisation ? |
|
0
|
193 |
#urls foreign Key from Url #iiep:url |
|
|
194 |
recordType = models.URLField(max_length=2048) #dct:type |
|
|
195 |
isDocumentPart = models.BooleanField() #iiep:isDocumentPart |
|
|
196 |
|
|
|
197 |
def __unicode__(self): |
|
|
198 |
return "Record id %s { identifier: %s, uri: %s, editionStatement: %s, recordType: %s, isDocumentPart: %s, notes: %s, language : %s}" \ |
|
|
199 |
% ( |
|
|
200 |
self.id, |
|
|
201 |
self.identifier, |
|
|
202 |
self.uri, |
|
|
203 |
self.editionStatement, |
|
|
204 |
self.recordType, |
|
|
205 |
self.isDocumentPart, |
|
|
206 |
self.notes[:100] if self.notes else None, |
|
|
207 |
self.language.id if self.language else None |
|
|
208 |
) |
|
|
209 |
|
|
|
210 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}issn', 3) |
|
|
211 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}documentCode', 3) |
|
|
212 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}country', 44) |
|
|
213 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}imprint', 5) |
|
|
214 |
#('{http://purl.org/dc/terms/}title', 4) |
|
|
215 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}isDocumentPart', 1) |
|
|
216 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}notes', 1) |
|
|
217 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}isbn', 8) |
|
|
218 |
#('{http://purl.org/dc/terms/}identifier', 1) |
|
|
219 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}meeting', 4) |
|
|
220 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}projectName', 10) |
|
|
221 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}addedTitle', 18) |
|
|
222 |
#('{http://purl.org/dc/terms/}subject', 29) |
|
|
223 |
#('{http://purl.org/dc/terms/}language', 1) |
|
|
224 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}serie', 4) |
|
|
225 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}volumeIssue', 3) |
|
|
226 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}url', 20) |
|
|
227 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}titleMainDocument', 3) |
|
|
228 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}otherLanguage', 13) |
|
|
229 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}periodical', 3) |
|
|
230 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}editionStatement', 1) |
|
|
231 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}collation', 4) |
|
|
232 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}subjectMeeting', 6) |
|
|
233 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}corporateAuthor', 7) |
|
|
234 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}author', 26) |
|
|
235 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}subjectPerson', 2) |
|
|
236 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}subjectCorporateBody', 8) |
|
|
237 |
#('{http://www.iiep.unesco.org/plan4learning/model.owl#}theme', 6) |
|
|
238 |
#('{http://purl.org/dc/terms/}abstract', 3) |
|
|
239 |
#('{http://purl.org/dc/terms/}type', 1) |