Revision 7
Added by Matt Wheeler almost 14 years ago
models.py | ||
---|---|---|
1 |
|
|
1 | 2 |
#There are 223 defined entities. |
2 | 3 |
import string |
3 | 4 |
import xml.dom.minidom |
4 | 5 |
from random import choice |
5 |
from django.db import models |
|
6 |
from django.contrib.gis.geos import * |
|
7 |
from django.contrib.gis.db import models |
|
6 | 8 |
|
7 | 9 |
def getRandom(length=8, chars=string.letters + string.digits): |
8 | 10 |
return ''.join([choice(chars) for i in range(length)]) |
... | ... | |
29 | 31 |
def getRandomTime(): |
30 | 32 |
return '08:30:00' |
31 | 33 |
|
34 |
class EntryInfo(models.Model): |
|
35 |
creationDate = models.DateTimeField(auto_now_add=True) |
|
36 |
lastUpdatedDate = models.DateTimeField(auto_now=True) |
|
37 |
dataSource = models.CharField(max_length=255, db_index=True) |
|
38 |
|
|
39 |
class taxonNames(models.Model): |
|
40 |
entryInfo = models.ForeignKey('EntryInfo') |
|
41 |
|
|
42 |
def exportVegX(self,myNode,doc): |
|
43 |
for childRef in self.ScientificName_taxonNames_id.all(): |
|
44 |
newEl = doc.createElement('taxonName') |
|
45 |
myNode.appendChild(childRef.exportVegX(newEl,doc)) |
|
46 |
|
|
47 |
return myNode |
|
48 |
|
|
49 |
def importVegX(self,node,info): |
|
50 |
self.entryInfo = info |
|
51 |
self.save() |
|
52 |
#members & relationships |
|
53 |
for child in node.childNodes: |
|
54 |
cName = child.nodeName |
|
55 |
#These are the elements that refer to this one |
|
56 |
if cName == 'taxonName': |
|
57 |
newEl = ScientificName().retrieveOrNew(child) |
|
58 |
newEl.taxonNames_id = self |
|
59 |
newEl.importVegX(child,info) |
|
60 |
|
|
61 |
self.save() |
|
62 |
|
|
63 |
def exportDummyVegX(self,myNode,doc,usedObjectsStack): |
|
64 |
if 'ScientificName' not in usedObjectsStack: |
|
65 |
usedObjectsStack.append('ScientificName') |
|
66 |
|
|
67 |
newEl = doc.createElement('taxonName') |
|
68 |
childRef = ScientificName() |
|
69 |
myNode.appendChild(childRef.exportDummyVegX(newEl,doc,usedObjectsStack)) |
|
70 |
usedObjectsStack.pop() |
|
71 |
|
|
72 |
return myNode |
|
73 |
|
|
74 |
def retrieveOrNew(self,node): |
|
75 |
return taxonNames() |
|
76 |
|
|
77 |
|
|
78 |
class Meta: |
|
79 |
db_table = u'v_taxonnames_lc' |
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
class taxonConcepts(models.Model): |
|
84 |
entryInfo = models.ForeignKey('EntryInfo') |
|
85 |
|
|
86 |
def exportVegX(self,myNode,doc): |
|
87 |
for childRef in self.TaxonConceptType_taxonConcepts_id.all(): |
|
88 |
newEl = doc.createElement('taxonConcept') |
|
89 |
myNode.appendChild(childRef.exportVegX(newEl,doc)) |
|
90 |
|
|
91 |
return myNode |
|
92 |
|
|
93 |
def importVegX(self,node,info): |
|
94 |
self.entryInfo = info |
|
95 |
self.save() |
|
96 |
#members & relationships |
|
97 |
for child in node.childNodes: |
|
98 |
cName = child.nodeName |
|
99 |
#These are the elements that refer to this one |
|
100 |
if cName == 'taxonConcept': |
|
101 |
newEl = TaxonConceptType().retrieveOrNew(child) |
|
102 |
newEl.taxonConcepts_id = self |
|
103 |
newEl.importVegX(child,info) |
|
104 |
|
|
105 |
self.save() |
|
106 |
|
|
107 |
def exportDummyVegX(self,myNode,doc,usedObjectsStack): |
|
108 |
if 'TaxonConceptType' not in usedObjectsStack: |
|
109 |
usedObjectsStack.append('TaxonConceptType') |
|
110 |
|
|
111 |
newEl = doc.createElement('taxonConcept') |
|
112 |
childRef = TaxonConceptType() |
|
113 |
myNode.appendChild(childRef.exportDummyVegX(newEl,doc,usedObjectsStack)) |
|
114 |
usedObjectsStack.pop() |
|
115 |
|
|
116 |
return myNode |
|
117 |
|
|
118 |
def retrieveOrNew(self,node): |
|
119 |
return taxonConcepts() |
|
120 |
|
|
121 |
|
|
122 |
class Meta: |
|
123 |
db_table = u'v_taxonconcepts_lc' |
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
class TaxonNames(models.Model): |
|
128 |
entryInfo = models.ForeignKey('EntryInfo') |
|
129 |
|
|
130 |
def exportVegX(self,myNode,doc): |
|
131 |
for childRef in self.ScientificName_TaxonNames_id.all(): |
|
132 |
newEl = doc.createElement('TaxonName') |
|
133 |
myNode.appendChild(childRef.exportVegX(newEl,doc)) |
|
134 |
|
|
135 |
return myNode |
|
136 |
|
|
137 |
def importVegX(self,node,info): |
|
138 |
self.entryInfo = info |
|
139 |
self.save() |
|
140 |
#members & relationships |
|
141 |
for child in node.childNodes: |
|
142 |
cName = child.nodeName |
|
143 |
#These are the elements that refer to this one |
|
144 |
if cName == 'TaxonName': |
|
145 |
newEl = ScientificName().retrieveOrNew(child) |
|
146 |
newEl.TaxonNames_id = self |
|
147 |
newEl.importVegX(child,info) |
|
148 |
|
|
149 |
self.save() |
|
150 |
|
|
151 |
def exportDummyVegX(self,myNode,doc,usedObjectsStack): |
|
152 |
if 'ScientificName' not in usedObjectsStack: |
|
153 |
usedObjectsStack.append('ScientificName') |
|
154 |
|
|
155 |
newEl = doc.createElement('TaxonName') |
|
156 |
childRef = ScientificName() |
|
157 |
myNode.appendChild(childRef.exportDummyVegX(newEl,doc,usedObjectsStack)) |
|
158 |
usedObjectsStack.pop() |
|
159 |
|
|
160 |
return myNode |
|
161 |
|
|
162 |
def retrieveOrNew(self,node): |
|
163 |
return TaxonNames() |
|
164 |
|
|
165 |
|
|
166 |
class Meta: |
|
167 |
db_table = u'v_taxonnames_uc' |
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
class TaxonConcepts(models.Model): |
|
172 |
entryInfo = models.ForeignKey('EntryInfo') |
|
173 |
|
|
174 |
def exportVegX(self,myNode,doc): |
|
175 |
for childRef in self.TaxonConceptType_TaxonConcepts_id.all(): |
|
176 |
newEl = doc.createElement('TaxonConcept') |
|
177 |
myNode.appendChild(childRef.exportVegX(newEl,doc)) |
|
178 |
|
|
179 |
return myNode |
|
180 |
|
|
181 |
def importVegX(self,node,info): |
|
182 |
self.entryInfo = info |
|
183 |
self.save() |
|
184 |
#members & relationships |
|
185 |
for child in node.childNodes: |
|
186 |
cName = child.nodeName |
|
187 |
#These are the elements that refer to this one |
|
188 |
if cName == 'TaxonConcept': |
|
189 |
newEl = TaxonConceptType().retrieveOrNew(child) |
|
190 |
newEl.TaxonConcepts_id = self |
|
191 |
newEl.importVegX(child,info) |
|
192 |
|
|
193 |
self.save() |
|
194 |
|
|
195 |
def exportDummyVegX(self,myNode,doc,usedObjectsStack): |
|
196 |
if 'TaxonConceptType' not in usedObjectsStack: |
|
197 |
usedObjectsStack.append('TaxonConceptType') |
|
198 |
|
|
199 |
newEl = doc.createElement('TaxonConcept') |
|
200 |
childRef = TaxonConceptType() |
|
201 |
myNode.appendChild(childRef.exportDummyVegX(newEl,doc,usedObjectsStack)) |
|
202 |
usedObjectsStack.pop() |
|
203 |
|
|
204 |
return myNode |
|
205 |
|
|
206 |
def retrieveOrNew(self,node): |
|
207 |
return TaxonConcepts() |
|
208 |
|
|
209 |
|
|
210 |
class Meta: |
|
211 |
db_table = u'v_taxonconcepts_uc' |
|
212 |
|
|
213 |
|
|
214 |
|
|
32 | 215 |
class eml_access(models.Model): |
33 |
access = models.ForeignKey('AccessType', unique=True,related_name='eml_access_access', null=True, blank=True) |
|
216 |
entryInfo = models.ForeignKey('EntryInfo') |
|
217 |
access = models.ForeignKey('AccessType', related_name='eml_access_access', null=True, blank=True) #Complex one2Many |
|
34 | 218 |
|
35 | 219 |
def exportVegX(self,myNode,doc): |
36 | 220 |
if self.access != None: |
... | ... | |
39 | 223 |
|
40 | 224 |
return myNode |
41 | 225 |
|
42 |
def importVegX(self,node): |
|
226 |
def importVegX(self,node,info): |
|
227 |
self.entryInfo = info |
|
43 | 228 |
self.save() |
44 | 229 |
#members & relationships |
45 | 230 |
for child in node.childNodes: |
46 | 231 |
cName = child.nodeName |
47 | 232 |
if cName == 'access': |
48 |
newEl = AccessType() |
|
49 |
newEl.importVegX(child) |
|
233 |
newEl = AccessType().retrieveOrNew(child)
|
|
234 |
newEl.importVegX(child,info)
|
|
50 | 235 |
self.access = newEl |
51 | 236 |
|
52 | 237 |
self.save() |
... | ... | |
61 | 246 |
|
62 | 247 |
return myNode |
63 | 248 |
|
249 |
def retrieveOrNew(self,node): |
|
250 |
return eml_access() |
|
64 | 251 |
|
252 |
|
|
65 | 253 |
class AccessType(models.Model): |
66 |
ReferencesGroup = models.ForeignKey('ReferencesGroup', unique=True,related_name='AccessType_ReferencesGroup', null=True, blank=True) |
|
254 |
entryInfo = models.ForeignKey('EntryInfo') |
|
255 |
ReferencesGroup = models.ForeignKey('ReferencesGroup', related_name='AccessType_ReferencesGroup', null=True, blank=True) #Complex one2Many |
|
67 | 256 |
allow = models.ManyToManyField('AccessRule',related_name='AccessType_allow') |
68 | 257 |
deny = models.ManyToManyField('AccessRule',related_name='AccessType_deny') |
69 |
attr_id = models.CharField(max_length=255, null=True, blank=True) |
|
258 |
attr_id = models.CharField(max_length=255, null=True, blank=True, db_index=True)
|
|
70 | 259 |
attr_system = models.CharField(max_length=255, null=True, blank=True) |
71 | 260 |
attr_scope = models.CharField(max_length=255, null=True, blank=True, default = 'document') |
72 | 261 |
attr_order = models.CharField(max_length=255, null=True, blank=True, default = 'allowFirst') |
... | ... | |
112 | 301 |
|
113 | 302 |
return myNode |
114 | 303 |
|
115 |
def importVegX(self,node): |
|
304 |
def importVegX(self,node,info): |
|
305 |
self.entryInfo = info |
|
116 | 306 |
self.save() |
117 | 307 |
#attributes |
118 | 308 |
for attr in node.attributes.keys(): |
... | ... | |
132 | 322 |
for child in node.childNodes: |
133 | 323 |
cName = child.nodeName |
134 | 324 |
if cName == 'ReferencesGroup': |
135 |
newEl = ReferencesGroup() |
|
136 |
newEl.importVegX(child) |
|
325 |
newEl = ReferencesGroup().retrieveOrNew(child)
|
|
326 |
newEl.importVegX(child,info)
|
|
137 | 327 |
self.ReferencesGroup = newEl |
138 | 328 |
elif cName == 'allow': |
139 |
newEl = AccessRule() |
|
140 |
newEl.importVegX(child) |
|
329 |
newEl = AccessRule().retrieveOrNew(child)
|
|
330 |
newEl.importVegX(child,info)
|
|
141 | 331 |
self.allow.add(newEl) |
142 | 332 |
elif cName == 'deny': |
143 |
newEl = AccessRule() |
|
144 |
newEl.importVegX(child) |
|
333 |
newEl = AccessRule().retrieveOrNew(child)
|
|
334 |
newEl.importVegX(child,info)
|
|
145 | 335 |
self.deny.add(newEl) |
146 | 336 |
|
147 | 337 |
self.save() |
... | ... | |
190 | 380 |
|
191 | 381 |
return myNode |
192 | 382 |
|
383 |
def retrieveOrNew(self,node): |
|
384 |
a_id = None |
|
385 |
a_system = None |
|
386 |
a_scope = None |
|
387 |
for attr in node.attributes.keys(): |
|
388 |
aVal = node.attributes[attr].nodeValue |
|
389 |
if attr == 'id': |
|
390 |
a_id = aVal |
|
391 |
elif attr == 'system': |
|
392 |
a_system = aVal |
|
393 |
elif attr == 'scope': |
|
394 |
a_scope = aVal |
|
395 |
if a_id != None: |
|
396 |
q = AccessType.objects.filter(attr_id__exact = a_id) |
|
397 |
if a_system != None: |
|
398 |
q = q.filter(attr_system__exact = a_system) |
|
399 |
if a_scope != None: |
|
400 |
q = q.filter(attr_scope__exact = a_scope) |
|
401 |
if len(q) > 0: |
|
402 |
return q[0] |
|
403 |
else: |
|
404 |
return AccessType() |
|
405 |
else: |
|
406 |
return AccessType() |
|
193 | 407 |
|
408 |
|
|
194 | 409 |
class ReferencesGroup(models.Model): |
410 |
entryInfo = models.ForeignKey('EntryInfo') |
|
195 | 411 |
references = models.CharField(max_length=255, null=True, blank=True) |
196 | 412 |
|
197 | 413 |
def exportVegX(self,myNode,doc): |
... | ... | |
203 | 419 |
|
204 | 420 |
return myNode |
205 | 421 |
|
206 |
def importVegX(self,node): |
|
422 |
def importVegX(self,node,info): |
|
423 |
self.entryInfo = info |
|
207 | 424 |
self.save() |
208 | 425 |
#members & relationships |
209 | 426 |
for child in node.childNodes: |
210 | 427 |
cName = child.nodeName |
211 | 428 |
if cName == 'references': |
212 |
cVal = child.childNodes[0].nodeValue |
|
213 |
self.references = cVal |
|
429 |
if(len(child.childNodes) > 0): |
|
430 |
cVal = child.childNodes[0].nodeValue |
|
431 |
self.references = cVal |
|
214 | 432 |
|
215 | 433 |
self.save() |
216 | 434 |
|
... | ... | |
222 | 440 |
|
223 | 441 |
return myNode |
224 | 442 |
|
443 |
def retrieveOrNew(self,node): |
|
444 |
return ReferencesGroup() |
|
225 | 445 |
|
446 |
|
|
226 | 447 |
class AccessRule(models.Model): |
227 |
id = models.AutoField(primary_key=True) |
|
448 |
entryInfo = models.ForeignKey('EntryInfo') |
|
449 |
|
|
228 | 450 |
def exportVegX(self,myNode,doc): |
229 | 451 |
for childRef in self.AccessRule_principal_AccessRule_id.all(): |
230 | 452 |
newEl = doc.createElement('principal') |
... | ... | |
236 | 458 |
|
237 | 459 |
return myNode |
238 | 460 |
|
239 |
def importVegX(self,node): |
|
461 |
def importVegX(self,node,info): |
|
462 |
self.entryInfo = info |
|
240 | 463 |
self.save() |
241 | 464 |
#members & relationships |
242 | 465 |
for child in node.childNodes: |
243 | 466 |
cName = child.nodeName |
244 | 467 |
#These are the elements that refer to this one |
245 | 468 |
if cName == 'principal': |
246 |
newEl = AccessRule_principal() |
|
469 |
newEl = AccessRule_principal().retrieveOrNew(child)
|
|
247 | 470 |
newEl.AccessRule_id = self |
248 |
newEl.importVegX(child) |
|
471 |
newEl.importVegX(child,info)
|
|
249 | 472 |
elif cName == 'permission': |
250 |
newEl = AccessRule_permission() |
|
473 |
newEl = AccessRule_permission().retrieveOrNew(child)
|
|
251 | 474 |
newEl.AccessRule_id = self |
252 |
newEl.importVegX(child) |
|
475 |
newEl.importVegX(child,info)
|
|
253 | 476 |
|
254 | 477 |
self.save() |
255 | 478 |
|
... | ... | |
272 | 495 |
|
273 | 496 |
return myNode |
274 | 497 |
|
498 |
def retrieveOrNew(self,node): |
|
499 |
return AccessRule() |
|
275 | 500 |
|
501 |
|
|
276 | 502 |
class AccessRule_principal(models.Model): |
277 |
AccessRule_id = models.ForeignKey('AccessRule',related_name='AccessRule_principal_AccessRule_id') |
|
503 |
entryInfo = models.ForeignKey('EntryInfo') |
|
504 |
AccessRule_id = models.ForeignKey('AccessRule', related_name='AccessRule_principal_AccessRule_id') |
|
278 | 505 |
primitive_type_value = models.CharField(max_length=255, null=True, blank=True) |
279 | 506 |
|
280 | 507 |
def exportVegX(self,myNode,doc): |
... | ... | |
284 | 511 |
|
285 | 512 |
return myNode |
286 | 513 |
|
287 |
def importVegX(self,node): |
|
514 |
def importVegX(self,node,info): |
|
515 |
self.entryInfo = info |
|
288 | 516 |
self.save() |
289 | 517 |
#members & relationships |
290 | 518 |
for child in node.childNodes: |
291 | 519 |
cName = child.nodeName |
292 |
cVal = node.childNodes[0].nodeValue |
|
293 |
self.primitive_type_value = cVal |
|
520 |
if(len(node.childNodes) > 0): |
|
521 |
cVal = node.childNodes[0].nodeValue |
|
522 |
self.primitive_type_value = cVal |
|
294 | 523 |
|
295 | 524 |
self.save() |
296 | 525 |
|
... | ... | |
300 | 529 |
|
301 | 530 |
return myNode |
302 | 531 |
|
532 |
def retrieveOrNew(self,node): |
|
533 |
return AccessRule_principal() |
|
303 | 534 |
|
535 |
|
|
304 | 536 |
class AccessRule_permission(models.Model): |
305 |
AccessRule_id = models.ForeignKey('AccessRule',related_name='AccessRule_permission_AccessRule_id') |
|
537 |
entryInfo = models.ForeignKey('EntryInfo') |
|
538 |
AccessRule_id = models.ForeignKey('AccessRule', related_name='AccessRule_permission_AccessRule_id') |
|
306 | 539 |
primitive_type_value = models.CharField(max_length=255, null=True, blank=True) |
307 | 540 |
|
308 | 541 |
def exportVegX(self,myNode,doc): |
... | ... | |
312 | 545 |
|
313 | 546 |
return myNode |
314 | 547 |
|
315 |
def importVegX(self,node): |
|
548 |
def importVegX(self,node,info): |
|
549 |
self.entryInfo = info |
|
316 | 550 |
self.save() |
317 | 551 |
#members & relationships |
318 | 552 |
for child in node.childNodes: |
319 | 553 |
cName = child.nodeName |
320 |
cVal = node.childNodes[0].nodeValue |
|
321 |
self.primitive_type_value = cVal |
|
554 |
if(len(node.childNodes) > 0): |
|
555 |
cVal = node.childNodes[0].nodeValue |
|
556 |
self.primitive_type_value = cVal |
|
322 | 557 |
|
323 | 558 |
self.save() |
324 | 559 |
|
... | ... | |
328 | 563 |
|
329 | 564 |
return myNode |
330 | 565 |
|
566 |
def retrieveOrNew(self,node): |
|
567 |
return AccessRule_permission() |
|
331 | 568 |
|
569 |
|
|
332 | 570 |
class GeographicCoverage(models.Model): |
333 |
ReferencesGroup = models.ForeignKey('ReferencesGroup', unique=True,related_name='GeographicCoverage_ReferencesGroup', null=True, blank=True) |
|
334 |
boundingCoordinates = models.ForeignKey('boundingCoordinates', unique=True,related_name='GeographicCoverage_boundingCoordinates', null=True, blank=True) |
|
335 |
datasetGPolygon = models.ManyToManyField('datasetGPolygon',related_name='GeographicCoverage_datasetGPolygon') |
|
336 |
attr_id = models.CharField(max_length=255, null=True, blank=True) |
|
571 |
entryInfo = models.ForeignKey('EntryInfo') |
|
572 |
Coverage_id = models.ForeignKey('Coverage', related_name='GeographicCoverage_Coverage_id', null=True, blank=True) #Complex one2Many |
|
573 |
ReferencesGroup = models.ForeignKey('ReferencesGroup', related_name='GeographicCoverage_ReferencesGroup', null=True, blank=True) #Complex one2Many |
|
574 |
boundingCoordinates = models.ForeignKey('boundingCoordinates', related_name='GeographicCoverage_boundingCoordinates', null=True, blank=True) #Complex one2Many |
|
575 |
Map_id = models.ForeignKey('Map', related_name='GeographicCoverage_Map_id', null=True, blank=True) #Complex one2Many |
|
576 |
attr_id = models.CharField(max_length=255, null=True, blank=True, db_index=True) |
|
337 | 577 |
attr_system = models.CharField(max_length=255, null=True, blank=True) |
338 | 578 |
attr_scope = models.CharField(max_length=255, null=True, blank=True, default = 'document') |
339 | 579 |
geographicDescription = models.CharField(max_length=255, null=True, blank=True) |
... | ... | |
368 | 608 |
newEl = doc.createElement('boundingCoordinates') |
369 | 609 |
myNode.appendChild(self.boundingCoordinates.exportVegX(newEl,doc)) |
370 | 610 |
|
371 |
for childRef in self.datasetGPolygon.all(): |
|
611 |
for childRef in self.datasetGPolygon_GeographicCoverage_id.all():
|
|
372 | 612 |
newEl = doc.createElement('datasetGPolygon') |
373 | 613 |
myNode.appendChild(childRef.exportVegX(newEl,doc)) |
374 | 614 |
|
375 | 615 |
return myNode |
376 | 616 |
|
377 |
def importVegX(self,node): |
|
617 |
def importVegX(self,node,info): |
|
618 |
self.entryInfo = info |
|
378 | 619 |
self.save() |
379 | 620 |
#attributes |
380 | 621 |
for attr in node.attributes.keys(): |
... | ... | |
390 | 631 |
for child in node.childNodes: |
391 | 632 |
cName = child.nodeName |
392 | 633 |
if cName == 'geographicDescription': |
393 |
cVal = child.childNodes[0].nodeValue |
|
394 |
self.geographicDescription = cVal |
|
634 |
if(len(child.childNodes) > 0): |
|
635 |
cVal = child.childNodes[0].nodeValue |
|
636 |
self.geographicDescription = cVal |
|
395 | 637 |
elif cName == 'ReferencesGroup': |
396 |
newEl = ReferencesGroup() |
|
397 |
newEl.importVegX(child) |
|
638 |
newEl = ReferencesGroup().retrieveOrNew(child)
|
|
639 |
newEl.importVegX(child,info)
|
|
398 | 640 |
self.ReferencesGroup = newEl |
399 | 641 |
elif cName == 'boundingCoordinates': |
400 |
newEl = boundingCoordinates() |
|
401 |
newEl.importVegX(child) |
|
642 |
newEl = boundingCoordinates().retrieveOrNew(child)
|
|
643 |
newEl.importVegX(child,info)
|
|
402 | 644 |
self.boundingCoordinates = newEl |
645 |
#These are the elements that refer to this one |
|
403 | 646 |
elif cName == 'datasetGPolygon': |
404 |
newEl = datasetGPolygon() |
|
405 |
newEl.importVegX(child)
|
|
406 |
self.datasetGPolygon.add(newEl)
|
|
647 |
newEl = datasetGPolygon().retrieveOrNew(child)
|
|
648 |
newEl.GeographicCoverage_id = self
|
|
649 |
newEl.importVegX(child,info)
|
|
407 | 650 |
|
408 | 651 |
self.save() |
409 | 652 |
|
... | ... | |
441 | 684 |
|
442 | 685 |
if 'datasetGPolygon' not in usedObjectsStack: |
443 | 686 |
usedObjectsStack.append('datasetGPolygon') |
687 |
|
|
444 | 688 |
newEl = doc.createElement('datasetGPolygon') |
445 |
newElObj = datasetGPolygon()
|
|
446 |
myNode.appendChild(newElObj.exportDummyVegX(newEl,doc,usedObjectsStack))
|
|
689 |
childRef = datasetGPolygon()
|
|
690 |
myNode.appendChild(childRef.exportDummyVegX(newEl,doc,usedObjectsStack))
|
|
447 | 691 |
usedObjectsStack.pop() |
448 | 692 |
|
449 | 693 |
return myNode |
450 | 694 |
|
695 |
def retrieveOrNew(self,node): |
|
696 |
a_id = None |
|
697 |
a_system = None |
|
698 |
a_scope = None |
|
699 |
for attr in node.attributes.keys(): |
|
700 |
aVal = node.attributes[attr].nodeValue |
|
701 |
if attr == 'id': |
|
702 |
a_id = aVal |
|
703 |
elif attr == 'system': |
|
704 |
a_system = aVal |
|
705 |
elif attr == 'scope': |
|
706 |
a_scope = aVal |
|
707 |
if a_id != None: |
|
708 |
q = GeographicCoverage.objects.filter(attr_id__exact = a_id) |
|
709 |
if a_system != None: |
|
710 |
q = q.filter(attr_system__exact = a_system) |
|
711 |
if a_scope != None: |
|
712 |
q = q.filter(attr_scope__exact = a_scope) |
|
713 |
if len(q) > 0: |
|
714 |
return q[0] |
|
715 |
else: |
|
716 |
return GeographicCoverage() |
|
717 |
else: |
|
718 |
return GeographicCoverage() |
|
451 | 719 |
|
720 |
|
|
452 | 721 |
class TemporalCoverage(models.Model): |
453 |
ReferencesGroup = models.ForeignKey('ReferencesGroup', unique=True,related_name='TemporalCoverage_ReferencesGroup', null=True, blank=True)
|
|
454 |
singleDateTime = models.ManyToManyField('SingleDateTimeType',related_name='TemporalCoverage_singleDateTime')
|
|
455 |
rangeOfDates = models.ForeignKey('rangeOfDates', unique=True,related_name='TemporalCoverage_rangeOfDates', null=True, blank=True)
|
|
456 |
attr_id = models.CharField(max_length=255, null=True, blank=True) |
|
722 |
entryInfo = models.ForeignKey('EntryInfo')
|
|
723 |
ReferencesGroup = models.ForeignKey('ReferencesGroup', related_name='TemporalCoverage_ReferencesGroup', null=True, blank=True) #Complex one2Many
|
|
724 |
rangeOfDates = models.ForeignKey('rangeOfDates', related_name='TemporalCoverage_rangeOfDates', null=True, blank=True) #Complex one2Many
|
|
725 |
attr_id = models.CharField(max_length=255, null=True, blank=True, db_index=True)
|
|
457 | 726 |
|
458 | 727 |
def exportVegX(self,myNode,doc): |
459 | 728 |
if self.attr_id != None: |
... | ... | |
465 | 734 |
newEl = doc.createElement('ReferencesGroup') |
466 | 735 |
myNode.appendChild(self.ReferencesGroup.exportVegX(newEl,doc)) |
467 | 736 |
|
468 |
for childRef in self.singleDateTime.all(): |
|
469 |
newEl = doc.createElement('singleDateTime') |
|
470 |
myNode.appendChild(childRef.exportVegX(newEl,doc)) |
|
471 |
|
|
472 | 737 |
if self.rangeOfDates != None: |
473 | 738 |
newEl = doc.createElement('rangeOfDates') |
474 | 739 |
myNode.appendChild(self.rangeOfDates.exportVegX(newEl,doc)) |
475 | 740 |
|
741 |
for childRef in self.SingleDateTimeType_TemporalCoverage_id.all(): |
|
742 |
newEl = doc.createElement('singleDateTime') |
|
743 |
myNode.appendChild(childRef.exportVegX(newEl,doc)) |
|
744 |
|
|
476 | 745 |
return myNode |
477 | 746 |
|
478 |
def importVegX(self,node): |
|
747 |
def importVegX(self,node,info): |
|
748 |
self.entryInfo = info |
|
479 | 749 |
self.save() |
480 | 750 |
#attributes |
481 | 751 |
for attr in node.attributes.keys(): |
... | ... | |
487 | 757 |
for child in node.childNodes: |
488 | 758 |
cName = child.nodeName |
489 | 759 |
if cName == 'ReferencesGroup': |
490 |
newEl = ReferencesGroup() |
|
491 |
newEl.importVegX(child) |
|
760 |
newEl = ReferencesGroup().retrieveOrNew(child)
|
|
761 |
newEl.importVegX(child,info)
|
|
492 | 762 |
self.ReferencesGroup = newEl |
493 |
elif cName == 'singleDateTime': |
|
494 |
newEl = SingleDateTimeType() |
|
495 |
newEl.importVegX(child) |
|
496 |
self.singleDateTime.add(newEl) |
|
497 | 763 |
elif cName == 'rangeOfDates': |
498 |
newEl = rangeOfDates() |
|
499 |
newEl.importVegX(child) |
|
764 |
newEl = rangeOfDates().retrieveOrNew(child)
|
|
765 |
newEl.importVegX(child,info)
|
|
500 | 766 |
self.rangeOfDates = newEl |
767 |
#These are the elements that refer to this one |
|
768 |
elif cName == 'singleDateTime': |
|
769 |
newEl = SingleDateTimeType().retrieveOrNew(child) |
|
770 |
newEl.TemporalCoverage_id = self |
|
771 |
newEl.importVegX(child,info) |
|
501 | 772 |
|
502 | 773 |
self.save() |
503 | 774 |
|
... | ... | |
513 | 784 |
myNode.appendChild(newElObj.exportDummyVegX(newEl,doc,usedObjectsStack)) |
514 | 785 |
usedObjectsStack.pop() |
515 | 786 |
|
516 |
if 'SingleDateTimeType' not in usedObjectsStack: |
|
517 |
usedObjectsStack.append('SingleDateTimeType') |
|
518 |
newEl = doc.createElement('singleDateTime') |
|
519 |
newElObj = SingleDateTimeType() |
|
520 |
myNode.appendChild(newElObj.exportDummyVegX(newEl,doc,usedObjectsStack)) |
|
521 |
usedObjectsStack.pop() |
|
522 |
|
|
523 | 787 |
if 'rangeOfDates' not in usedObjectsStack: |
524 | 788 |
usedObjectsStack.append('rangeOfDates') |
525 | 789 |
newEl = doc.createElement('rangeOfDates') |
... | ... | |
527 | 791 |
myNode.appendChild(newElObj.exportDummyVegX(newEl,doc,usedObjectsStack)) |
528 | 792 |
usedObjectsStack.pop() |
529 | 793 |
|
794 |
if 'SingleDateTimeType' not in usedObjectsStack: |
|
795 |
usedObjectsStack.append('SingleDateTimeType') |
|
796 |
|
|
797 |
newEl = doc.createElement('singleDateTime') |
|
798 |
childRef = SingleDateTimeType() |
|
799 |
myNode.appendChild(childRef.exportDummyVegX(newEl,doc,usedObjectsStack)) |
|
800 |
usedObjectsStack.pop() |
|
801 |
|
|
530 | 802 |
return myNode |
531 | 803 |
|
804 |
def retrieveOrNew(self,node): |
|
805 |
id_val = None #ad hoc attr |
|
806 |
for attr in node.attributes.keys(): |
|
807 |
aVal = node.attributes[attr].nodeValue |
|
808 |
if attr == 'id': |
|
809 |
id_val = aVal |
|
532 | 810 |
|
533 |
class temporalCoverage(models.Model): |
|
534 |
TemporalCoverage_extend = models.ForeignKey('TemporalCoverage', unique=True,related_name='temporalCoverage_TemporalCoverage_extend') |
|
811 |
if id_val != None: |
|
812 |
q = TemporalCoverage.objects.filter(attr_id__exact = id_val) |
|
813 |
if len(q) > 0: |
|
814 |
return q[0] |
|
815 |
else: |
|
816 |
return TemporalCoverage() |
|
817 |
else: |
|
818 |
return TemporalCoverage() |
|
819 |
|
|
820 |
|
|
821 |
class Meta: |
|
822 |
db_table = u'v_temporalcoverage_uc' |
|
823 |
|
|
824 |
|
|
825 |
|
|
826 |
class temporalCoverageLC(models.Model): |
|
827 |
entryInfo = models.ForeignKey('EntryInfo') |
|
828 |
TemporalCoverage_extend = models.ForeignKey('TemporalCoverage', related_name='temporalCoverageLC_TemporalCoverage_extend') #Complex one2Many |
|
829 |
Coverage_id = models.ForeignKey('Coverage', related_name='temporalCoverageLC_Coverage_id', null=True, blank=True) #Complex one2Many |
|
535 | 830 |
attr_system = models.CharField(max_length=255, null=True, blank=True) |
536 | 831 |
attr_scope = models.CharField(max_length=255, null=True, blank=True, default = 'document') |
537 | 832 |
|
... | ... | |
551 | 846 |
|
552 | 847 |
return myNode |
553 | 848 |
|
554 |
def importVegX(self,node): |
|
555 |
extendedEl = TemporalCoverage() |
|
556 |
extendedEl.importVegX(node) |
|
849 |
def importVegX(self,node,info): |
|
850 |
self.entryInfo = info |
|
851 |
extendedEl = TemporalCoverage().retrieveOrNew(node) |
|
852 |
extendedEl.importVegX(node,info) |
|
557 | 853 |
self.TemporalCoverage_extend = extendedEl |
558 | 854 |
|
559 | 855 |
self.save() |
... | ... | |
588 | 884 |
|
589 | 885 |
return myNode |
590 | 886 |
|
887 |
def retrieveOrNew(self,node): |
|
888 |
system_val = None |
|
889 |
scope_val = None |
|
890 |
id_val = None #ad hoc attr |
|
891 |
for attr in node.attributes.keys(): |
|
892 |
aVal = node.attributes[attr].nodeValue |
|
893 |
if attr == 'id': |
|
894 |
id_val = aVal |
|
895 |
if attr == 'system': |
|
896 |
system_val = aVal |
|
897 |
if attr == 'scope': |
|
898 |
scope_val = aVal |
|
591 | 899 |
|
900 |
if id_val != None: |
|
901 |
q = temporalCoverageLC.objects.filter(TemporalCoverage_extend__attr_id__exact = id_val) |
|
902 |
if system_val != None: |
|
903 |
q = q.filter(attr_system__exact = system_val) |
|
904 |
if scope_val != None: |
|
905 |
q = q.filter(attr_scope__exact = scope_val) |
|
906 |
if len(q) > 0: |
|
907 |
return q[0] |
|
908 |
else: |
|
909 |
return temporalCoverageLC() |
|
910 |
else: |
|
911 |
return temporalCoverageLC() |
|
912 |
|
|
913 |
|
|
592 | 914 |
class TaxonomicCoverage(models.Model): |
593 |
ReferencesGroup = models.ForeignKey('ReferencesGroup', unique=True,related_name='TaxonomicCoverage_ReferencesGroup', null=True, blank=True)
|
|
594 |
taxonomicSystem = models.ForeignKey('taxonomicSystem', unique=True,related_name='TaxonomicCoverage_taxonomicSystem', null=True, blank=True)
|
|
595 |
taxonomicClassification = models.ManyToManyField('TaxonomicClassificationType',related_name='TaxonomicCoverage_taxonomicClassification',db_table = 'v_TaxonomicCoverage_TaxonomicClassificationType_taxonomi')
|
|
596 |
attr_id = models.CharField(max_length=255, null=True, blank=True) |
|
915 |
entryInfo = models.ForeignKey('EntryInfo')
|
|
916 |
ReferencesGroup = models.ForeignKey('ReferencesGroup', related_name='TaxonomicCoverage_ReferencesGroup', null=True, blank=True) #Complex one2Many
|
|
917 |
taxonomicSystem = models.ForeignKey('taxonomicSystem', related_name='TaxonomicCoverage_taxonomicSystem', null=True, blank=True) #Complex one2Many
|
|
918 |
attr_id = models.CharField(max_length=255, null=True, blank=True, db_index=True)
|
|
597 | 919 |
generalTaxonomicCoverage = models.CharField(max_length=255, null=True, blank=True) |
598 | 920 |
|
599 | 921 |
def exportVegX(self,myNode,doc): |
... | ... | |
616 | 938 |
newEl = doc.createElement('taxonomicSystem') |
617 | 939 |
myNode.appendChild(self.taxonomicSystem.exportVegX(newEl,doc)) |
618 | 940 |
|
619 |
for childRef in self.taxonomicClassification.all():
|
|
941 |
for childRef in self.TaxonomicClassificationType_TaxonomicCoverage_id.all():
|
|
620 | 942 |
newEl = doc.createElement('taxonomicClassification') |
621 | 943 |
myNode.appendChild(childRef.exportVegX(newEl,doc)) |
622 | 944 |
|
623 | 945 |
return myNode |
624 | 946 |
|
625 |
def importVegX(self,node): |
|
947 |
def importVegX(self,node,info): |
|
948 |
self.entryInfo = info |
|
626 | 949 |
self.save() |
627 | 950 |
#attributes |
628 | 951 |
for attr in node.attributes.keys(): |
... | ... | |
634 | 957 |
for child in node.childNodes: |
635 | 958 |
cName = child.nodeName |
636 | 959 |
if cName == 'generalTaxonomicCoverage': |
637 |
cVal = child.childNodes[0].nodeValue |
|
638 |
self.generalTaxonomicCoverage = cVal |
|
960 |
if(len(child.childNodes) > 0): |
|
961 |
cVal = child.childNodes[0].nodeValue |
|
962 |
self.generalTaxonomicCoverage = cVal |
|
639 | 963 |
elif cName == 'ReferencesGroup': |
640 |
newEl = ReferencesGroup() |
|
641 |
newEl.importVegX(child) |
|
964 |
newEl = ReferencesGroup().retrieveOrNew(child)
|
|
965 |
newEl.importVegX(child,info)
|
|
642 | 966 |
self.ReferencesGroup = newEl |
643 | 967 |
elif cName == 'taxonomicSystem': |
644 |
newEl = taxonomicSystem() |
|
645 |
newEl.importVegX(child) |
|
968 |
newEl = taxonomicSystem().retrieveOrNew(child)
|
|
969 |
newEl.importVegX(child,info)
|
|
646 | 970 |
self.taxonomicSystem = newEl |
971 |
#These are the elements that refer to this one |
|
647 | 972 |
elif cName == 'taxonomicClassification': |
648 |
newEl = TaxonomicClassificationType() |
|
649 |
newEl.importVegX(child)
|
|
650 |
self.taxonomicClassification.add(newEl)
|
|
973 |
newEl = TaxonomicClassificationType().retrieveOrNew(child)
|
|
974 |
newEl.TaxonomicCoverage_id = self
|
|
975 |
newEl.importVegX(child,info)
|
|
651 | 976 |
|
652 | 977 |
self.save() |
653 | 978 |
|
... | ... | |
677 | 1002 |
|
678 | 1003 |
if 'TaxonomicClassificationType' not in usedObjectsStack: |
679 | 1004 |
usedObjectsStack.append('TaxonomicClassificationType') |
1005 |
|
|
680 | 1006 |
newEl = doc.createElement('taxonomicClassification') |
681 |
newElObj = TaxonomicClassificationType()
|
|
682 |
myNode.appendChild(newElObj.exportDummyVegX(newEl,doc,usedObjectsStack))
|
|
1007 |
childRef = TaxonomicClassificationType()
|
|
1008 |
myNode.appendChild(childRef.exportDummyVegX(newEl,doc,usedObjectsStack))
|
|
683 | 1009 |
usedObjectsStack.pop() |
684 | 1010 |
|
685 | 1011 |
return myNode |
686 | 1012 |
|
1013 |
def retrieveOrNew(self,node): |
|
1014 |
id_val = None #ad hoc attr |
|
1015 |
for attr in node.attributes.keys(): |
|
1016 |
aVal = node.attributes[attr].nodeValue |
|
1017 |
if attr == 'id': |
|
1018 |
id_val = aVal |
|
687 | 1019 |
|
688 |
class taxonomicCoverage(models.Model): |
|
689 |
TaxonomicCoverage_extend = models.ForeignKey('TaxonomicCoverage', unique=True,related_name='taxonomicCoverage_TaxonomicCoverage_extend') |
|
1020 |
if id_val != None: |
|
1021 |
q = TaxonomicCoverage.objects.filter(attr_id__exact = id_val) |
|
1022 |
if len(q) > 0: |
|
1023 |
return q[0] |
|
1024 |
else: |
|
1025 |
return TaxonomicCoverage() |
|
1026 |
else: |
|
1027 |
return TaxonomicCoverage() |
|
1028 |
|
|
1029 |
|
|
1030 |
class taxonomicCoverageLC(models.Model): |
|
1031 |
entryInfo = models.ForeignKey('EntryInfo') |
|
1032 |
TaxonomicCoverage_extend = models.ForeignKey('TaxonomicCoverage', related_name='taxonomicCoverageLC_TaxonomicCoverage_extend') #Complex one2Many |
|
1033 |
Coverage_id = models.ForeignKey('Coverage', related_name='taxonomicCoverageLC_Coverage_id', null=True, blank=True) #Complex one2Many |
|
690 | 1034 |
attr_system = models.CharField(max_length=255, null=True, blank=True) |
691 | 1035 |
attr_scope = models.CharField(max_length=255, null=True, blank=True, default = 'document') |
692 | 1036 |
|
... | ... | |
706 | 1050 |
|
707 | 1051 |
return myNode |
708 | 1052 |
|
709 |
def importVegX(self,node): |
|
710 |
extendedEl = TaxonomicCoverage() |
|
711 |
extendedEl.importVegX(node) |
|
1053 |
def importVegX(self,node,info): |
|
1054 |
self.entryInfo = info |
|
1055 |
extendedEl = TaxonomicCoverage().retrieveOrNew(node) |
|
1056 |
extendedEl.importVegX(node,info) |
|
712 | 1057 |
self.TaxonomicCoverage_extend = extendedEl |
713 | 1058 |
|
714 | 1059 |
self.save() |
... | ... | |
743 | 1088 |
|
744 | 1089 |
return myNode |
745 | 1090 |
|
1091 |
def retrieveOrNew(self,node): |
|
1092 |
system_val = None |
|
1093 |
scope_val = None |
|
1094 |
id_val = None #ad hoc attr |
|
1095 |
for attr in node.attributes.keys(): |
|
1096 |
aVal = node.attributes[attr].nodeValue |
|
1097 |
if attr == 'id': |
|
1098 |
id_val = aVal |
|
1099 |
if attr == 'system': |
|
1100 |
system_val = aVal |
|
1101 |
if attr == 'scope': |
|
1102 |
scope_val = aVal |
|
746 | 1103 |
|
1104 |
if id_val != None: |
|
1105 |
q = taxonomicCoverageLC.objects.filter(TaxonomicCoverage_extend__attr_id__exact = id_val) |
|
1106 |
if system_val != None: |
|
1107 |
q = q.filter(attr_system__exact = system_val) |
|
1108 |
if scope_val != None: |
|
1109 |
q = q.filter(attr_scope__exact = scope_val) |
|
1110 |
if len(q) > 0: |
|
1111 |
return q[0] |
|
1112 |
else: |
|
1113 |
return taxonomicCoverageLC() |
|
1114 |
else: |
|
1115 |
return taxonomicCoverageLC() |
|
1116 |
|
|
1117 |
|
|
747 | 1118 |
class Coverage(models.Model): |
748 |
ReferencesGroup = models.ForeignKey('ReferencesGroup', unique=True,related_name='Coverage_ReferencesGroup', null=True, blank=True) |
|
749 |
geographicCoverage = models.ManyToManyField('GeographicCoverage',related_name='Coverage_geographicCoverage') |
|
750 |
temporalCoverage = models.ManyToManyField('temporalCoverage',related_name='Coverage_temporalCoverage') |
|
751 |
taxonomicCoverage = models.ManyToManyField('taxonomicCoverage',related_name='Coverage_taxonomicCoverage') |
|
752 |
attr_id = models.CharField(max_length=255, null=True, blank=True) |
|
1119 |
entryInfo = models.ForeignKey('EntryInfo') |
|
1120 |
ReferencesGroup = models.ForeignKey('ReferencesGroup', related_name='Coverage_ReferencesGroup', null=True, blank=True) #Complex one2Many |
|
1121 |
studyAreaDescription_id = models.ForeignKey('studyAreaDescription', related_name='Coverage_studyAreaDescription_id', null=True, blank=True) #Complex one2Many |
|
1122 |
attr_id = models.CharField(max_length=255, null=True, blank=True, db_index=True) |
|
753 | 1123 |
attr_system = models.CharField(max_length=255, null=True, blank=True) |
754 | 1124 |
attr_scope = models.CharField(max_length=255, null=True, blank=True, default = 'document') |
755 | 1125 |
|
... | ... | |
773 | 1143 |
newEl = doc.createElement('ReferencesGroup') |
774 | 1144 |
myNode.appendChild(self.ReferencesGroup.exportVegX(newEl,doc)) |
775 | 1145 |
|
776 |
for childRef in self.geographicCoverage.all():
|
|
1146 |
for childRef in self.GeographicCoverage_Coverage_id.all():
|
|
777 | 1147 |
newEl = doc.createElement('geographicCoverage') |
778 | 1148 |
myNode.appendChild(childRef.exportVegX(newEl,doc)) |
779 | 1149 |
|
780 |
for childRef in self.temporalCoverage.all(): |
|
1150 |
for childRef in self.temporalCoverageLC_Coverage_id.all():
|
|
781 | 1151 |
newEl = doc.createElement('temporalCoverage') |
782 | 1152 |
myNode.appendChild(childRef.exportVegX(newEl,doc)) |
783 | 1153 |
|
784 |
for childRef in self.taxonomicCoverage.all(): |
|
1154 |
for childRef in self.taxonomicCoverageLC_Coverage_id.all():
|
|
785 | 1155 |
newEl = doc.createElement('taxonomicCoverage') |
786 | 1156 |
myNode.appendChild(childRef.exportVegX(newEl,doc)) |
787 | 1157 |
|
788 | 1158 |
return myNode |
789 | 1159 |
|
790 |
def importVegX(self,node): |
|
1160 |
def importVegX(self,node,info): |
|
1161 |
self.entryInfo = info |
|
791 | 1162 |
self.save() |
792 | 1163 |
#attributes |
793 | 1164 |
for attr in node.attributes.keys(): |
... | ... | |
803 | 1174 |
for child in node.childNodes: |
804 | 1175 |
cName = child.nodeName |
805 | 1176 |
if cName == 'ReferencesGroup': |
806 |
newEl = ReferencesGroup() |
|
807 |
newEl.importVegX(child) |
|
1177 |
newEl = ReferencesGroup().retrieveOrNew(child)
|
|
1178 |
newEl.importVegX(child,info)
|
|
808 | 1179 |
self.ReferencesGroup = newEl |
1180 |
#These are the elements that refer to this one |
|
809 | 1181 |
elif cName == 'geographicCoverage': |
810 |
newEl = GeographicCoverage() |
|
811 |
newEl.importVegX(child)
|
|
812 |
self.geographicCoverage.add(newEl)
|
|
1182 |
newEl = GeographicCoverage().retrieveOrNew(child)
|
|
1183 |
newEl.Coverage_id = self
|
|
1184 |
newEl.importVegX(child,info)
|
|
813 | 1185 |
elif cName == 'temporalCoverage': |
814 |
newEl = temporalCoverage()
|
|
815 |
newEl.importVegX(child)
|
|
816 |
self.temporalCoverage.add(newEl)
|
|
1186 |
newEl = temporalCoverageLC().retrieveOrNew(child)
|
|
1187 |
newEl.Coverage_id = self
|
|
1188 |
newEl.importVegX(child,info)
|
|
817 | 1189 |
elif cName == 'taxonomicCoverage': |
818 |
newEl = taxonomicCoverage()
|
|
819 |
newEl.importVegX(child)
|
|
820 |
self.taxonomicCoverage.add(newEl)
|
|
1190 |
newEl = taxonomicCoverageLC().retrieveOrNew(child)
|
|
1191 |
newEl.Coverage_id = self
|
|
1192 |
newEl.importVegX(child,info)
|
|
821 | 1193 |
|
822 | 1194 |
self.save() |
823 | 1195 |
|
... | ... | |
843 | 1215 |
|
844 | 1216 |
if 'GeographicCoverage' not in usedObjectsStack: |
845 | 1217 |
usedObjectsStack.append('GeographicCoverage') |
1218 |
|
|
846 | 1219 |
newEl = doc.createElement('geographicCoverage') |
847 |
newElObj = GeographicCoverage()
|
|
848 |
myNode.appendChild(newElObj.exportDummyVegX(newEl,doc,usedObjectsStack))
|
|
1220 |
childRef = GeographicCoverage()
|
|
1221 |
myNode.appendChild(childRef.exportDummyVegX(newEl,doc,usedObjectsStack))
|
|
849 | 1222 |
usedObjectsStack.pop() |
850 | 1223 |
|
851 |
if 'temporalCoverage' not in usedObjectsStack: |
|
852 |
usedObjectsStack.append('temporalCoverage') |
|
1224 |
if 'temporalCoverageLC' not in usedObjectsStack: |
|
1225 |
usedObjectsStack.append('temporalCoverageLC') |
|
1226 |
|
|
853 | 1227 |
newEl = doc.createElement('temporalCoverage') |
854 |
newElObj = temporalCoverage()
|
|
855 |
myNode.appendChild(newElObj.exportDummyVegX(newEl,doc,usedObjectsStack))
|
|
1228 |
childRef = temporalCoverageLC()
|
|
1229 |
myNode.appendChild(childRef.exportDummyVegX(newEl,doc,usedObjectsStack))
|
|
856 | 1230 |
usedObjectsStack.pop() |
857 | 1231 |
|
858 |
if 'taxonomicCoverage' not in usedObjectsStack: |
|
859 |
usedObjectsStack.append('taxonomicCoverage') |
|
1232 |
if 'taxonomicCoverageLC' not in usedObjectsStack: |
|
1233 |
usedObjectsStack.append('taxonomicCoverageLC') |
|
1234 |
|
|
860 | 1235 |
newEl = doc.createElement('taxonomicCoverage') |
861 |
newElObj = taxonomicCoverage()
|
|
862 |
myNode.appendChild(newElObj.exportDummyVegX(newEl,doc,usedObjectsStack))
|
|
1236 |
childRef = taxonomicCoverageLC()
|
|
1237 |
myNode.appendChild(childRef.exportDummyVegX(newEl,doc,usedObjectsStack))
|
|
863 | 1238 |
usedObjectsStack.pop() |
864 | 1239 |
|
865 | 1240 |
return myNode |
866 | 1241 |
|
1242 |
def retrieveOrNew(self,node): |
|
1243 |
a_id = None |
|
1244 |
a_system = None |
|
1245 |
a_scope = None |
|
1246 |
for attr in node.attributes.keys(): |
|
1247 |
aVal = node.attributes[attr].nodeValue |
|
1248 |
if attr == 'id': |
|
1249 |
a_id = aVal |
|
1250 |
elif attr == 'system': |
|
1251 |
a_system = aVal |
|
1252 |
elif attr == 'scope': |
|
1253 |
a_scope = aVal |
|
1254 |
if a_id != None: |
|
1255 |
q = Coverage.objects.filter(attr_id__exact = a_id) |
|
1256 |
if a_system != None: |
|
1257 |
q = q.filter(attr_system__exact = a_system) |
|
1258 |
if a_scope != None: |
|
1259 |
q = q.filter(attr_scope__exact = a_scope) |
|
1260 |
if len(q) > 0: |
|
1261 |
return q[0] |
|
1262 |
else: |
|
1263 |
return Coverage() |
|
1264 |
else: |
|
1265 |
return Coverage() |
|
867 | 1266 |
|
1267 |
|
|
868 | 1268 |
class SingleDateTimeType(models.Model): |
869 |
alternativeTimeScale = models.ForeignKey('alternativeTimeScale', unique=True,related_name='SingleDateTimeType_alternativeTimeScale', null=True, blank=True) |
|
1269 |
entryInfo = models.ForeignKey('EntryInfo') |
|
1270 |
TemporalCoverage_id = models.ForeignKey('TemporalCoverage', related_name='SingleDateTimeType_TemporalCoverage_id', null=True, blank=True) #Complex one2Many |
|
1271 |
alternativeTimeScale = models.ForeignKey('alternativeTimeScale', related_name='SingleDateTimeType_alternativeTimeScale', null=True, blank=True) #Complex one2Many |
|
870 | 1272 |
calendarDate = models.DateField(null=True, blank=True) |
871 | 1273 |
time = models.TimeField(null=True, blank=True) |
872 | 1274 |
|
... | ... | |
889 | 1291 |
|
890 | 1292 |
return myNode |
891 | 1293 |
|
892 |
def importVegX(self,node): |
|
1294 |
def importVegX(self,node,info): |
|
1295 |
self.entryInfo = info |
|
893 | 1296 |
self.save() |
894 | 1297 |
#members & relationships |
895 | 1298 |
for child in node.childNodes: |
896 | 1299 |
cName = child.nodeName |
897 | 1300 |
if cName == 'calendarDate': |
898 |
cVal = child.childNodes[0].nodeValue |
|
899 |
self.calendarDate = cVal |
|
1301 |
if(len(child.childNodes) > 0): |
|
1302 |
cVal = child.childNodes[0].nodeValue |
|
1303 |
self.calendarDate = cVal |
|
900 | 1304 |
elif cName == 'time': |
901 |
cVal = child.childNodes[0].nodeValue |
|
902 |
self.time = cVal |
|
1305 |
if(len(child.childNodes) > 0): |
|
1306 |
cVal = child.childNodes[0].nodeValue |
|
1307 |
self.time = cVal |
|
903 | 1308 |
elif cName == 'alternativeTimeScale': |
904 |
newEl = alternativeTimeScale() |
|
905 |
newEl.importVegX(child) |
|
1309 |
newEl = alternativeTimeScale().retrieveOrNew(child)
|
|
1310 |
newEl.importVegX(child,info)
|
|
906 | 1311 |
self.alternativeTimeScale = newEl |
907 | 1312 |
|
908 | 1313 |
self.save() |
... | ... | |
927 | 1332 |
|
928 | 1333 |
return myNode |
929 | 1334 |
|
1335 |
def retrieveOrNew(self,node): |
|
1336 |
return SingleDateTimeType() |
|
930 | 1337 |
|
1338 |
|
|
931 | 1339 |
class rangeOfDates(models.Model): |
932 |
beginDate = models.ForeignKey('SingleDateTimeType', unique=True,related_name='rangeOfDates_beginDate', null=True, blank=True) |
|
933 |
endDate = models.ForeignKey('SingleDateTimeType', unique=True,related_name='rangeOfDates_endDate', null=True, blank=True) |
|
1340 |
entryInfo = models.ForeignKey('EntryInfo') |
|
1341 |
beginDate = models.ForeignKey('SingleDateTimeType', related_name='rangeOfDates_beginDate', null=True, blank=True) #Complex one2Many |
|
1342 |
endDate = models.ForeignKey('SingleDateTimeType', related_name='rangeOfDates_endDate', null=True, blank=True) #Complex one2Many |
|
934 | 1343 |
|
935 | 1344 |
def exportVegX(self,myNode,doc): |
936 | 1345 |
if self.beginDate != None: |
... | ... | |
943 | 1352 |
|
944 | 1353 |
return myNode |
945 | 1354 |
|
946 |
def importVegX(self,node): |
|
1355 |
def importVegX(self,node,info): |
|
1356 |
self.entryInfo = info |
|
947 | 1357 |
self.save() |
948 | 1358 |
#members & relationships |
949 | 1359 |
for child in node.childNodes: |
950 | 1360 |
cName = child.nodeName |
951 | 1361 |
if cName == 'beginDate': |
952 |
newEl = SingleDateTimeType() |
|
953 |
newEl.importVegX(child) |
|
1362 |
newEl = SingleDateTimeType().retrieveOrNew(child)
|
|
1363 |
newEl.importVegX(child,info)
|
|
954 | 1364 |
self.beginDate = newEl |
955 | 1365 |
elif cName == 'endDate': |
956 |
newEl = SingleDateTimeType() |
|
957 |
newEl.importVegX(child) |
|
1366 |
newEl = SingleDateTimeType().retrieveOrNew(child)
|
|
1367 |
newEl.importVegX(child,info)
|
|
958 | 1368 |
self.endDate = newEl |
959 | 1369 |
|
960 | 1370 |
self.save() |
... | ... | |
976 | 1386 |
|
977 | 1387 |
return myNode |
978 | 1388 |
|
1389 |
def retrieveOrNew(self,node): |
|
1390 |
return rangeOfDates() |
|
979 | 1391 |
|
1392 |
|
|
980 | 1393 |
class CitationType(models.Model): |
981 |
ReferencesGroup = models.ForeignKey('ReferencesGroup', unique=True,related_name='CitationType_ReferencesGroup', null=True, blank=True) |
|
982 |
ResourceGroup = models.ForeignKey('ResourceGroup', unique=True,related_name='CitationType_ResourceGroup', null=True, blank=True) |
|
983 |
access = models.ForeignKey('AccessType', unique=True,related_name='CitationType_access', null=True, blank=True) |
|
984 |
article = models.ForeignKey('Article', unique=True,related_name='CitationType_article', null=True, blank=True) |
|
985 |
book = models.ForeignKey('Book', unique=True,related_name='CitationType_book', null=True, blank=True) |
|
986 |
chapter = models.ForeignKey('Chapter', unique=True,related_name='CitationType_chapter', null=True, blank=True) |
|
987 |
editedBook = models.ForeignKey('Book', unique=True,related_name='CitationType_editedBook', null=True, blank=True) |
|
988 |
manuscript = models.ForeignKey('Manuscript', unique=True,related_name='CitationType_manuscript', null=True, blank=True) |
|
989 |
report = models.ForeignKey('Report', unique=True,related_name='CitationType_report', null=True, blank=True) |
|
990 |
thesis = models.ForeignKey('Thesis', unique=True,related_name='CitationType_thesis', null=True, blank=True) |
|
991 |
conferenceProceedings = models.ForeignKey('ConferenceProceedings', unique=True,related_name='CitationType_conferenceProceedings', null=True, blank=True) |
|
992 |
personalCommunication = models.ForeignKey('PersonalCommunication', unique=True,related_name='CitationType_personalCommunication', null=True, blank=True) |
|
993 |
map = models.ForeignKey('Map', unique=True,related_name='CitationType_map', null=True, blank=True) |
|
994 |
generic = models.ForeignKey('Generic', unique=True,related_name='CitationType_generic', null=True, blank=True) |
|
995 |
audioVisual = models.ForeignKey('AudioVisual', unique=True,related_name='CitationType_audioVisual', null=True, blank=True) |
|
996 |
presentation = models.ForeignKey('Presentation', unique=True,related_name='CitationType_presentation', null=True, blank=True) |
|
997 |
attr_id = models.CharField(max_length=255, null=True, blank=True) |
|
1394 |
entryInfo = models.ForeignKey('EntryInfo') |
|
1395 |
alternativeTimeScale_id = models.ForeignKey('alternativeTimeScale', related_name='CitationType_alternativeTimeScale_id', null=True, blank=True) #Complex one2Many |
|
1396 |
taxonomicSystem_id = models.ForeignKey('taxonomicSystem', related_name='CitationType_taxonomicSystem_id', null=True, blank=True) #Complex one2Many |
|
1397 |
ReferencesGroup = models.ForeignKey('ReferencesGroup', related_name='CitationType_ReferencesGroup', null=True, blank=True) #Complex one2Many |
|
1398 |
ResourceGroup = models.ForeignKey('ResourceGroup', related_name='CitationType_ResourceGroup', null=True, blank=True) #Complex one2Many |
|
1399 |
access = models.ForeignKey('AccessType', related_name='CitationType_access', null=True, blank=True) #Complex one2Many |
|
1400 |
article = models.ForeignKey('Article', related_name='CitationType_article', null=True, blank=True) #Complex one2Many |
|
1401 |
book = models.ForeignKey('Book', related_name='CitationType_book', null=True, blank=True) #Complex one2Many |
|
1402 |
chapter = models.ForeignKey('Chapter', related_name='CitationType_chapter', null=True, blank=True) #Complex one2Many |
|
1403 |
editedBook = models.ForeignKey('Book', related_name='CitationType_editedBook', null=True, blank=True) #Complex one2Many |
|
1404 |
manuscript = models.ForeignKey('Manuscript', related_name='CitationType_manuscript', null=True, blank=True) #Complex one2Many |
|
1405 |
report = models.ForeignKey('Report', related_name='CitationType_report', null=True, blank=True) #Complex one2Many |
|
1406 |
thesis = models.ForeignKey('Thesis', related_name='CitationType_thesis', null=True, blank=True) #Complex one2Many |
|
1407 |
conferenceProceedings = models.ForeignKey('ConferenceProceedings', related_name='CitationType_conferenceProceedings', null=True, blank=True) #Complex one2Many |
|
1408 |
personalCommunication = models.ForeignKey('PersonalCommunication', related_name='CitationType_personalCommunication', null=True, blank=True) #Complex one2Many |
|
1409 |
map = models.ForeignKey('Map', related_name='CitationType_map', null=True, blank=True) #Complex one2Many |
|
1410 |
generic = models.ForeignKey('Generic', related_name='CitationType_generic', null=True, blank=True) #Complex one2Many |
|
1411 |
audioVisual = models.ForeignKey('AudioVisual', related_name='CitationType_audioVisual', null=True, blank=True) #Complex one2Many |
|
1412 |
presentation = models.ForeignKey('Presentation', related_name='CitationType_presentation', null=True, blank=True) #Complex one2Many |
|
1413 |
descriptor_id = models.ForeignKey('descriptor', related_name='CitationType_descriptor_id', null=True, blank=True) #Complex one2Many |
|
1414 |
studyAreaDescription_id = models.ForeignKey('studyAreaDescription', related_name='CitationType_studyAreaDescription_id', null=True, blank=True) #Complex one2Many |
|
1415 |
designDescription_id = models.ForeignKey('designDescription', related_name='CitationType_designDescription_id', null=True, blank=True) #Complex one2Many |
|
1416 |
literature_id = models.ForeignKey('literature', related_name='CitationType_literature_id', null=True, blank=True) #Complex one2Many |
|
1417 |
attr_id = models.CharField(max_length=255, null=True, blank=True, db_index=True) |
|
998 | 1418 |
attr_system = models.CharField(max_length=255, null=True, blank=True) |
999 | 1419 |
attr_scope = models.CharField(max_length=255, null=True, blank=True, default = 'document') |
1000 | 1420 |
|
... | ... | |
1080 | 1500 |
|
1081 | 1501 |
return myNode |
1082 | 1502 |
|
1083 |
def importVegX(self,node): |
|
1503 |
def importVegX(self,node,info): |
|
1504 |
self.entryInfo = info |
|
1084 | 1505 |
self.save() |
1085 | 1506 |
#attributes |
1086 | 1507 |
for attr in node.attributes.keys(): |
... | ... | |
1096 | 1517 |
for child in node.childNodes: |
1097 | 1518 |
cName = child.nodeName |
1098 | 1519 |
if cName == 'ReferencesGroup': |
1099 |
newEl = ReferencesGroup() |
|
1100 |
newEl.importVegX(child) |
|
1520 |
newEl = ReferencesGroup().retrieveOrNew(child)
|
|
1521 |
newEl.importVegX(child,info)
|
|
1101 | 1522 |
self.ReferencesGroup = newEl |
1102 | 1523 |
elif cName == 'ResourceGroup': |
1103 |
newEl = ResourceGroup() |
|
1104 |
newEl.importVegX(child) |
|
1524 |
newEl = ResourceGroup().retrieveOrNew(child)
|
|
1525 |
newEl.importVegX(child,info)
|
|
1105 | 1526 |
self.ResourceGroup = newEl |
1106 | 1527 |
elif cName == 'access': |
1107 |
newEl = AccessType() |
|
1108 |
newEl.importVegX(child) |
|
1528 |
newEl = AccessType().retrieveOrNew(child)
|
|
1529 |
newEl.importVegX(child,info)
|
|
1109 | 1530 |
self.access = newEl |
1110 | 1531 |
elif cName == 'article': |
1111 |
newEl = Article() |
|
1112 |
newEl.importVegX(child) |
|
1532 |
newEl = Article().retrieveOrNew(child)
|
|
1533 |
newEl.importVegX(child,info)
|
|
1113 | 1534 |
self.article = newEl |
1114 | 1535 |
elif cName == 'book': |
1115 |
newEl = Book() |
|
1116 |
newEl.importVegX(child) |
|
1536 |
newEl = Book().retrieveOrNew(child)
|
|
1537 |
newEl.importVegX(child,info)
|
|
1117 | 1538 |
self.book = newEl |
1118 | 1539 |
elif cName == 'chapter': |
1119 |
newEl = Chapter() |
|
1120 |
newEl.importVegX(child) |
|
1540 |
newEl = Chapter().retrieveOrNew(child)
|
|
1541 |
newEl.importVegX(child,info)
|
|
1121 | 1542 |
self.chapter = newEl |
1122 | 1543 |
elif cName == 'editedBook': |
1123 |
newEl = Book() |
|
1124 |
newEl.importVegX(child) |
|
1544 |
newEl = Book().retrieveOrNew(child)
|
|
1545 |
newEl.importVegX(child,info)
|
|
1125 | 1546 |
self.editedBook = newEl |
1126 | 1547 |
elif cName == 'manuscript': |
1127 |
newEl = Manuscript() |
|
1128 |
newEl.importVegX(child) |
|
1548 |
newEl = Manuscript().retrieveOrNew(child)
|
|
1549 |
newEl.importVegX(child,info)
|
|
1129 | 1550 |
self.manuscript = newEl |
1130 | 1551 |
elif cName == 'report': |
1131 |
newEl = Report() |
|
1132 |
newEl.importVegX(child) |
|
1552 |
newEl = Report().retrieveOrNew(child)
|
|
1553 |
newEl.importVegX(child,info)
|
|
1133 | 1554 |
self.report = newEl |
1134 | 1555 |
elif cName == 'thesis': |
1135 |
newEl = Thesis() |
|
1136 |
newEl.importVegX(child) |
|
1556 |
newEl = Thesis().retrieveOrNew(child)
|
|
1557 |
newEl.importVegX(child,info)
|
|
1137 | 1558 |
self.thesis = newEl |
1138 | 1559 |
elif cName == 'conferenceProceedings': |
1139 |
newEl = ConferenceProceedings() |
|
1140 |
newEl.importVegX(child) |
|
1560 |
newEl = ConferenceProceedings().retrieveOrNew(child)
|
|
1561 |
newEl.importVegX(child,info)
|
|
1141 | 1562 |
self.conferenceProceedings = newEl |
1142 | 1563 |
elif cName == 'personalCommunication': |
1143 |
newEl = PersonalCommunication() |
|
1144 |
newEl.importVegX(child) |
|
1564 |
newEl = PersonalCommunication().retrieveOrNew(child)
|
|
1565 |
newEl.importVegX(child,info)
|
|
1145 | 1566 |
self.personalCommunication = newEl |
1146 | 1567 |
elif cName == 'map': |
1147 |
newEl = Map() |
|
1148 |
newEl.importVegX(child) |
|
1568 |
newEl = Map().retrieveOrNew(child)
|
|
1569 |
newEl.importVegX(child,info)
|
|
1149 | 1570 |
self.map = newEl |
1150 | 1571 |
elif cName == 'generic': |
1151 |
newEl = Generic() |
|
1152 |
newEl.importVegX(child) |
|
1572 |
newEl = Generic().retrieveOrNew(child)
|
|
1573 |
newEl.importVegX(child,info)
|
|
1153 | 1574 |
self.generic = newEl |
1154 | 1575 |
elif cName == 'audioVisual': |
1155 |
newEl = AudioVisual() |
|
1156 |
newEl.importVegX(child) |
|
1576 |
newEl = AudioVisual().retrieveOrNew(child)
|
|
1577 |
newEl.importVegX(child,info)
|
|
1157 | 1578 |
self.audioVisual = newEl |
1158 | 1579 |
elif cName == 'presentation': |
1159 |
newEl = Presentation() |
|
1160 |
newEl.importVegX(child) |
|
1580 |
newEl = Presentation().retrieveOrNew(child)
|
|
1581 |
newEl.importVegX(child,info)
|
|
1161 | 1582 |
self.presentation = newEl |
1162 | 1583 |
|
1163 | 1584 |
self.save() |
... | ... | |
1289 | 1710 |
|
1290 | 1711 |
return myNode |
1291 | 1712 |
|
1713 |
def retrieveOrNew(self,node): |
|
1714 |
a_id = None |
|
1715 |
a_system = None |
|
1716 |
a_scope = None |
|
1717 |
for attr in node.attributes.keys(): |
|
1718 |
aVal = node.attributes[attr].nodeValue |
|
1719 |
if attr == 'id': |
|
1720 |
a_id = aVal |
|
1721 |
elif attr == 'system': |
|
1722 |
a_system = aVal |
|
1723 |
elif attr == 'scope': |
|
1724 |
a_scope = aVal |
|
1725 |
if a_id != None: |
|
1726 |
q = CitationType.objects.filter(attr_id__exact = a_id) |
|
1727 |
if a_system != None: |
|
1728 |
q = q.filter(attr_system__exact = a_system) |
|
1729 |
if a_scope != None: |
|
1730 |
q = q.filter(attr_scope__exact = a_scope) |
|
1731 |
if len(q) > 0: |
|
1732 |
return q[0] |
|
1733 |
else: |
|
1734 |
return CitationType() |
|
1735 |
else: |
|
1736 |
return CitationType() |
|
1292 | 1737 |
|
1738 |
|
|
1293 | 1739 |
class alternativeTimeScale(models.Model): |
1294 |
timeScaleCitation = models.ManyToManyField('CitationType',related_name='alternativeTimeScale_timeScaleCitation')
|
|
1740 |
entryInfo = models.ForeignKey('EntryInfo')
|
|
1295 | 1741 |
timeScaleName = models.CharField(max_length=255, null=True, blank=True) |
1296 | 1742 |
timeScaleAgeEstimate = models.CharField(max_length=255, null=True, blank=True) |
1297 | 1743 |
timeScaleAgeUncertainty = models.CharField(max_length=255, null=True, blank=True) |
... | ... | |
1322 | 1768 |
newEl.appendChild(newElText) |
1323 | 1769 |
myNode.appendChild(newEl) |
1324 | 1770 |
|
1325 |
for childRef in self.timeScaleCitation.all():
|
|
1771 |
for childRef in self.CitationType_alternativeTimeScale_id.all():
|
|
1326 | 1772 |
newEl = doc.createElement('timeScaleCitation') |
1327 | 1773 |
myNode.appendChild(childRef.exportVegX(newEl,doc)) |
1328 | 1774 |
|
1329 | 1775 |
return myNode |
1330 | 1776 |
|
1331 |
def importVegX(self,node): |
|
1777 |
def importVegX(self,node,info): |
|
1778 |
self.entryInfo = info |
|
1332 | 1779 |
self.save() |
1333 | 1780 |
#members & relationships |
1334 | 1781 |
for child in node.childNodes: |
1335 | 1782 |
cName = child.nodeName |
1336 | 1783 |
if cName == 'timeScaleName': |
1337 |
cVal = child.childNodes[0].nodeValue |
|
1338 |
self.timeScaleName = cVal |
|
1784 |
if(len(child.childNodes) > 0): |
|
1785 |
cVal = child.childNodes[0].nodeValue |
|
1786 |
self.timeScaleName = cVal |
|
1339 | 1787 |
elif cName == 'timeScaleAgeEstimate': |
1340 |
cVal = child.childNodes[0].nodeValue |
|
1341 |
self.timeScaleAgeEstimate = cVal |
|
1788 |
if(len(child.childNodes) > 0): |
|
1789 |
cVal = child.childNodes[0].nodeValue |
|
1790 |
self.timeScaleAgeEstimate = cVal |
|
1342 | 1791 |
elif cName == 'timeScaleAgeUncertainty': |
1343 |
cVal = child.childNodes[0].nodeValue |
|
1344 |
self.timeScaleAgeUncertainty = cVal |
|
1792 |
if(len(child.childNodes) > 0): |
|
1793 |
cVal = child.childNodes[0].nodeValue |
|
1794 |
self.timeScaleAgeUncertainty = cVal |
|
1345 | 1795 |
elif cName == 'timeScaleAgeExplanation': |
1346 |
cVal = child.childNodes[0].nodeValue |
|
1347 |
self.timeScaleAgeExplanation = cVal |
|
1796 |
if(len(child.childNodes) > 0): |
|
1797 |
cVal = child.childNodes[0].nodeValue |
|
1798 |
self.timeScaleAgeExplanation = cVal |
|
1799 |
#These are the elements that refer to this one |
|
1348 | 1800 |
elif cName == 'timeScaleCitation': |
1349 |
newEl = CitationType() |
|
1350 |
newEl.importVegX(child)
|
|
1351 |
self.timeScaleCitation.add(newEl)
|
|
1801 |
newEl = CitationType().retrieveOrNew(child)
|
|
1802 |
newEl.alternativeTimeScale_id = self
|
|
1803 |
newEl.importVegX(child,info)
|
|
1352 | 1804 |
|
1353 | 1805 |
self.save() |
1354 | 1806 |
|
... | ... | |
1375 | 1827 |
|
1376 | 1828 |
if 'CitationType' not in usedObjectsStack: |
1377 | 1829 |
usedObjectsStack.append('CitationType') |
1830 |
|
|
1378 | 1831 |
newEl = doc.createElement('timeScaleCitation') |
1379 |
newElObj = CitationType()
|
|
1380 |
myNode.appendChild(newElObj.exportDummyVegX(newEl,doc,usedObjectsStack))
|
|
1832 |
childRef = CitationType()
|
|
1833 |
myNode.appendChild(childRef.exportDummyVegX(newEl,doc,usedObjectsStack))
|
|
1381 | 1834 |
usedObjectsStack.pop() |
1382 | 1835 |
|
1383 | 1836 |
return myNode |
1384 | 1837 |
|
1838 |
def retrieveOrNew(self,node): |
|
1839 |
return alternativeTimeScale() |
|
1385 | 1840 |
|
1841 |
|
|
1386 | 1842 |
class boundingAltitudes(models.Model): |
1843 |
entryInfo = models.ForeignKey('EntryInfo') |
|
1387 | 1844 |
altitudeMinimum = models.CharField(max_length=255, null=True, blank=True) |
1388 | 1845 |
altitudeMaximum = models.CharField(max_length=255, null=True, blank=True) |
1389 | 1846 |
altitudeUnits = models.CharField(max_length=255, null=True, blank=True) |
... | ... | |
1409 | 1866 |
|
1410 | 1867 |
return myNode |
1411 | 1868 |
|
1412 |
def importVegX(self,node): |
|
1869 |
def importVegX(self,node,info): |
|
1870 |
self.entryInfo = info |
|
1413 | 1871 |
self.save() |
1414 | 1872 |
#members & relationships |
1415 | 1873 |
for child in node.childNodes: |
1416 | 1874 |
cName = child.nodeName |
1417 | 1875 |
if cName == 'altitudeMinimum': |
1418 |
cVal = child.childNodes[0].nodeValue |
|
1419 |
self.altitudeMinimum = cVal |
|
1876 |
if(len(child.childNodes) > 0): |
|
1877 |
cVal = child.childNodes[0].nodeValue |
|
1878 |
self.altitudeMinimum = cVal |
|
1420 | 1879 |
elif cName == 'altitudeMaximum': |
1421 |
cVal = child.childNodes[0].nodeValue |
|
1422 |
self.altitudeMaximum = cVal |
|
1880 |
if(len(child.childNodes) > 0): |
|
1881 |
cVal = child.childNodes[0].nodeValue |
|
1882 |
self.altitudeMaximum = cVal |
|
1423 | 1883 |
elif cName == 'altitudeUnits': |
1424 |
cVal = child.childNodes[0].nodeValue |
|
1425 |
self.altitudeUnits = cVal |
|
1884 |
if(len(child.childNodes) > 0): |
|
1885 |
cVal = child.childNodes[0].nodeValue |
|
1886 |
self.altitudeUnits = cVal |
|
1426 | 1887 |
|
1427 | 1888 |
self.save() |
1428 | 1889 |
|
... | ... | |
1444 | 1905 |
|
1445 | 1906 |
return myNode |
1446 | 1907 |
|
1908 |
def retrieveOrNew(self,node): |
|
1909 |
return boundingAltitudes() |
|
1447 | 1910 |
|
1911 |
|
|
1448 | 1912 |
class boundingCoordinates(models.Model): |
1449 |
boundingAltitudes = models.ForeignKey('boundingAltitudes', unique=True,related_name='boundingCoordinates_boundingAltitudes', null=True, blank=True) |
|
1913 |
entryInfo = models.ForeignKey('EntryInfo') |
|
1914 |
boundingAltitudes = models.ForeignKey('boundingAltitudes', related_name='boundingCoordinates_boundingAltitudes', null=True, blank=True) #Complex one2Many |
|
1450 | 1915 |
westBoundingCoordinate = models.CharField(max_length=255, null=True, blank=True) |
1451 | 1916 |
eastBoundingCoordinate = models.CharField(max_length=255, null=True, blank=True) |
1452 | 1917 |
northBoundingCoordinate = models.CharField(max_length=255, null=True, blank=True) |
... | ... | |
1483 | 1948 |
|
1484 | 1949 |
return myNode |
1485 | 1950 |
|
1486 |
def importVegX(self,node): |
|
1951 |
def importVegX(self,node,info): |
|
1952 |
self.entryInfo = info |
|
1487 | 1953 |
self.save() |
1488 | 1954 |
#members & relationships |
1489 | 1955 |
for child in node.childNodes: |
1490 | 1956 |
cName = child.nodeName |
1491 | 1957 |
if cName == 'westBoundingCoordinate': |
1492 |
cVal = child.childNodes[0].nodeValue |
|
1493 |
self.westBoundingCoordinate = cVal |
|
1958 |
if(len(child.childNodes) > 0): |
|
1959 |
cVal = child.childNodes[0].nodeValue |
|
1960 |
self.westBoundingCoordinate = cVal |
|
1494 | 1961 |
elif cName == 'eastBoundingCoordinate': |
1495 |
cVal = child.childNodes[0].nodeValue |
|
1496 |
self.eastBoundingCoordinate = cVal |
|
1962 |
if(len(child.childNodes) > 0): |
|
1963 |
cVal = child.childNodes[0].nodeValue |
|
1964 |
self.eastBoundingCoordinate = cVal |
|
1497 | 1965 |
elif cName == 'northBoundingCoordinate': |
1498 |
cVal = child.childNodes[0].nodeValue |
|
1499 |
self.northBoundingCoordinate = cVal |
|
1966 |
if(len(child.childNodes) > 0): |
|
1967 |
cVal = child.childNodes[0].nodeValue |
|
1968 |
self.northBoundingCoordinate = cVal |
|
1500 | 1969 |
elif cName == 'southBoundingCoordinate': |
1501 |
cVal = child.childNodes[0].nodeValue |
|
1502 |
self.southBoundingCoordinate = cVal |
|
1970 |
if(len(child.childNodes) > 0): |
|
1971 |
cVal = child.childNodes[0].nodeValue |
|
1972 |
self.southBoundingCoordinate = cVal |
|
1503 | 1973 |
elif cName == 'boundingAltitudes': |
1504 |
newEl = boundingAltitudes() |
|
1505 |
newEl.importVegX(child) |
|
1974 |
newEl = boundingAltitudes().retrieveOrNew(child)
|
|
1975 |
newEl.importVegX(child,info)
|
|
1506 | 1976 |
self.boundingAltitudes = newEl |
1507 | 1977 |
|
1508 | 1978 |
self.save() |
... | ... | |
1537 | 2007 |
|
1538 | 2008 |
return myNode |
1539 | 2009 |
|
2010 |
def retrieveOrNew(self,node): |
|
2011 |
return boundingCoordinates() |
|
1540 | 2012 |
|
2013 |
|
|
1541 | 2014 |
class GRingPointType(models.Model): |
1542 |
gRingLatitude = models.CharField(max_length=255, null=True, blank=True) |
|
1543 |
gRingLongitude = models.CharField(max_length=255, null=True, blank=True) |
|
2015 |
entryInfo = models.ForeignKey('EntryInfo') |
|
2016 |
datasetGPolygonOuterGRing_id = models.ForeignKey('datasetGPolygonOuterGRing', related_name='GRingPointType_datasetGPolygonOuterGRing_id', null=True, blank=True) #Complex one2Many |
|
2017 |
datasetGPolygonExclusionGRing_id = models.ForeignKey('datasetGPolygonExclusionGRing', related_name='GRingPointType_datasetGPolygonExclusionGRing_id', null=True, blank=True) #Complex one2Many |
|
2018 |
gRingLatitude = models.FloatField(null=True, blank=True) |
|
2019 |
gRingLongitude = models.FloatField(null=True, blank=True) |
|
2020 |
|
|
2021 |
# GeoDjango-specific: a geometry field, and |
|
2022 |
# overriding the default manager with a GeoManager instance. |
|
2023 |
gRingPoint = models.PointField(null=True,blank=True) |
|
2024 |
objects = models.GeoManager() |
|
1544 | 2025 |
|
1545 | 2026 |
def exportVegX(self,myNode,doc): |
1546 | 2027 |
if self.gRingLatitude != None: |
... | ... | |
1557 | 2038 |
|
1558 | 2039 |
return myNode |
1559 | 2040 |
|
1560 |
def importVegX(self,node): |
|
2041 |
def importVegX(self,node,info): |
|
2042 |
self.entryInfo = info |
|
1561 | 2043 |
self.save() |
1562 | 2044 |
#members & relationships |
1563 | 2045 |
for child in node.childNodes: |
1564 | 2046 |
cName = child.nodeName |
1565 | 2047 |
if cName == 'gRingLatitude': |
1566 |
cVal = child.childNodes[0].nodeValue |
|
1567 |
self.gRingLatitude = cVal |
|
2048 |
if(len(child.childNodes) > 0): |
|
2049 |
cVal = child.childNodes[0].nodeValue |
|
2050 |
self.gRingLatitude = cVal |
|
1568 | 2051 |
elif cName == 'gRingLongitude': |
1569 |
cVal = child.childNodes[0].nodeValue |
|
1570 |
self.gRingLongitude = cVal |
|
2052 |
if(len(child.childNodes) > 0): |
|
2053 |
cVal = child.childNodes[0].nodeValue |
|
2054 |
self.gRingLongitude = cVal |
Also available in: Unified diff
Committing first working copy of models.py. Other py/pyc files are added/modified just to get in repos.