Project

General

Profile

« Previous | Next » 

Revision 6

Added by Matt Wheeler about 14 years ago

Adding vegx definition. Current models.py building script.

View differences:

makeVegxModel/trunk/eml-documentation.xsd
1
<?xml version="1.0" encoding="UTF-8"?>
2
<xs:schema 
3
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
4
    xmlns="eml://ecoinformatics.org/documentation-2.0.1" 
5
    xmlns:txt="eml://ecoinformatics.org/text-2.0.1" 
6
    targetNamespace="eml://ecoinformatics.org/documentation-2.0.1">
7
  <xs:import namespace="eml://ecoinformatics.org/text-2.0.1" 
8
  schemaLocation="eml-text.xsd"/>
9
  <xs:annotation>
10
    <xs:documentation>
11
       '$RCSfile: eml-documentation.xsd,v $'
12
       Copyright: 1997-2002 Regents of the University of California,
13
                            University of New Mexico, and
14
                            Arizona State University
15
        Sponsors: National Center for Ecological Analysis and Synthesis and
16
                  Partnership for Interdisciplinary Studies of Coastal Oceans,
17
                     University of California Santa Barbara
18
                  Long-Term Ecological Research Network Office,
19
                     University of New Mexico
20
                  Center for Environmental Studies, Arizona State University
21
   Other funding: National Science Foundation (see README for details)
22
                  The David and Lucile Packard Foundation
23
     For Details: http://knb.ecoinformatics.org/
24

  
25
        '$Author: jones $'
26
          '$Date: 2003/11/06 20:15:20 $'
27
      '$Revision: 1.22 $'
28

  
29
    This program is free software; you can redistribute it and/or modify
30
    it under the terms of the GNU General Public License as published by
31
    the Free Software Foundation; either version 2 of the License, or
32
    (at your option) any later version.
33

  
34
    This program is distributed in the hope that it will be useful,
35
    but WITHOUT ANY WARRANTY; without even the implied warranty of
36
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
    GNU General Public License for more details.
38

  
39
    You should have received a copy of the GNU General Public License
40
    along with this program; if not, write to the Free Software
41
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
42
    </xs:documentation>
43
  </xs:annotation>
44
  <xs:element name="moduleDocs">
45
    <xs:complexType>
46
      <xs:sequence>
47
        <xs:element name="moduleName" type="xs:string"/>
48
        <xs:element name="moduleDescription" type="txt:TextType"/>
49
        <xs:element name="recommendedUsage" type="xs:string"/>
50
        <xs:element name="standAlone" type="xs:string"/>
51
      </xs:sequence>
52
    </xs:complexType>
53
  </xs:element>
54
  <xs:element name="tooltip" type="xs:string"/>
55
  <xs:element name="summary" type="xs:string"/>
56
  <xs:element name="description" type="txt:TextType"/>
57
  <xs:element name="example" type="txt:TextType"/>
58
  <xs:element name="lineage" type="xs:string"/>
59
  <xs:element name="module" type="xs:string"/>
60
</xs:schema>
makeVegxModel/trunk/tdwg_basetypes.xsd
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!-- ==================================================================== -->
3
<!-- Introduction                                                         -->
4
<!-- ==================================================================== -->
5
<!-- Schema for a type library for darwin and extension data types.       -->
6
<!-- History:                                                             -->
7
<!--   version 0.5 2007-02-14 John Wieczorek                              --> 
8
<!--   version 0.6 2007-08-22 R. De Giovanni: added new probabilityType.  --> 
9
<!-- Status:                                                              -->
10
<!--   Ready for testing.                                                 -->
11
<!--   Should be placed in a tdwg shared data types library.              -->
12
<!--   See http://wiki.tdwg.org for current status of this standard       -->
13

  
14
<!-- ==================================================================== -->
15
<!-- Schema                                                               -->
16
<!-- ==================================================================== -->
17
<xs:schema 
18
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
19
	elementFormDefault="unqualified" version="0.6">
20

  
21
	<!-- ============================================================== -->
22
	<!-- Types                                                          -->
23
	<!-- ============================================================== -->
24
	<xs:simpleType name="positiveDouble">
25
	  <xs:restriction base="xs:double">
26
	    <xs:minExclusive value="0"/>
27
	  </xs:restriction>
28
	</xs:simpleType>
29

  
30
	<xs:simpleType name="dayOfYearDataType">
31
	  <xs:restriction base="xs:integer">
32
	    <xs:minInclusive value="1"/>
33
	    <xs:maxInclusive value="366"/>
34
	  </xs:restriction>
35
	</xs:simpleType>
36

  
37
	<xs:simpleType name="decimalLatitudeDataType">
38
	  <xs:restriction base="xs:double">
39
	    <xs:minInclusive value="-90"/>
40
	    <xs:maxInclusive value="90"/>
41
	  </xs:restriction>
42
	</xs:simpleType>
43

  
44
	<xs:simpleType name="decimalLongitudeDataType">
45
	  <xs:restriction base="xs:double">
46
	    <xs:minInclusive value="-180"/>
47
	    <xs:maxInclusive value="180"/>
48
	  </xs:restriction>
49
	</xs:simpleType>
50

  
51
	<xs:simpleType name="spatialFitDataType">
52
	  <xs:union>
53
	    <xs:simpleType>
54
	      <xs:restriction base="xs:double">
55
		<xs:minInclusive value="0"/>
56
		<xs:maxInclusive value="0"/>
57
	      </xs:restriction>
58
	    </xs:simpleType>
59
	    <xs:simpleType>
60
	      <xs:restriction base="xs:double">
61
		<xs:minInclusive value="1"/>
62
	      </xs:restriction>
63
	    </xs:simpleType>
64
	    <xs:simpleType>
65
	      <xs:restriction base="xs:NMTOKEN">
66
		<xs:enumeration value="undefined"/>
67
	      </xs:restriction>
68
	    </xs:simpleType>
69
	  </xs:union>
70
	</xs:simpleType>
71

  
72
        <xs:simpleType name="DateTimeISO">
73
          <xs:annotation>
74
            <xs:documentation xml:lang="en">
75
              The date and time expressed in a way conforming to a subset of ISO 8601. Meant to be exactly the same as DateTimeISO defined in ABCD.
76
            </xs:documentation>
77
          </xs:annotation>
78
          <xs:restriction base="xs:string">
79
            <xs:pattern value="\d\d\d\d(\-(0[1-9]|1[012])(\-((0[1-9])|1\d|2\d|3[01])(T(0\d|1\d|2[0-3])(:[0-5]\d){0,2})?)?)?|\-\-(0[1-9]|1[012])(\-(0[1-9]|1\d|2\d|3[01]))?|\-\-\-(0[1-9]|1\d|2\d|3[01])">
80
            </xs:pattern>
81
          </xs:restriction>
82
        </xs:simpleType>
83

  
84
	<xs:simpleType name="probabilityType">
85
	  <xs:restriction base="xs:double">
86
	    <xs:minInclusive value="0"/>
87
	    <xs:maxInclusive value="1"/>
88
	  </xs:restriction>
89
	</xs:simpleType>
90

  
91
</xs:schema>
makeVegxModel/trunk/makeModel.php
64 64
print "import string\n";
65 65
print "import xml.dom.minidom\n";
66 66
print "from random import choice\n";
67
print "from django.db import models\n\n";
67
print "from django.contrib.gis.geos import *\n";
68
print "from django.contrib.gis.db import models\n\n";
68 69
print "def getRandom(length=8, chars=string.letters + string.digits):\n".
69 70
      "  return ''.join([choice(chars) for i in range(length)])\n\n".
70 71
      "def getRandomString():\n".
......
81 82
      "def getRandomDate():\n".
82 83
      "  return '2007-07-16'\n\n".
83 84
      "def getRandomTime():\n".
84
      "  return '08:30:00'\n\n";
85
      "  return '08:30:00'\n\n".
86
      "class EntryInfo(models.Model):\n".
87
      "  creationDate = models.DateTimeField(auto_now_add=True)\n".
88
      "  lastUpdatedDate = models.DateTimeField(auto_now=True)\n".
89
      "  dataSource = models.CharField(max_length=255, db_index=True)\n\n";
85 90

  
86 91
$eList->printAll();
87 92

  
makeVegxModel/trunk/eml-literature.xsd
1
<?xml version="1.0" encoding="UTF-8"?>
2
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:doc="eml://ecoinformatics.org/documentation-2.0.1" xmlns:rp="eml://ecoinformatics.org/party-2.0.1" xmlns:cov="eml://ecoinformatics.org/coverage-2.0.1" xmlns:res="eml://ecoinformatics.org/resource-2.0.1" xmlns:acc="eml://ecoinformatics.org/access-2.0.1" xmlns:proj="eml://ecoinformatics.org/project-2.0.1" xmlns="eml://ecoinformatics.org/literature-2.0.1" targetNamespace="eml://ecoinformatics.org/literature-2.0.1">
3
	<xs:import namespace="eml://ecoinformatics.org/documentation-2.0.1" schemaLocation="eml-documentation.xsd"/>
4
	<xs:import namespace="eml://ecoinformatics.org/resource-2.0.1" schemaLocation="eml-resource.xsd"/>
5
	<xs:import namespace="eml://ecoinformatics.org/coverage-2.0.1" schemaLocation="eml-coverage.xsd"/>
6
	<xs:import namespace="eml://ecoinformatics.org/party-2.0.1" schemaLocation="eml-party.xsd"/>
7
	<xs:import namespace="eml://ecoinformatics.org/access-2.0.1" schemaLocation="eml-access.xsd"/>
8
	<xs:import namespace="eml://ecoinformatics.org/project-2.0.1" schemaLocation="eml-project.xsd"/>
9
	<xs:annotation>
10
		<xs:documentation>
11
      '$RCSfile: eml-literature.xsd,v $'
12
       Copyright: 1997-2002 Regents of the University of California,
13
                            University of New Mexico, and
14
                            Arizona State University
15
        Sponsors: National Center for Ecological Analysis and Synthesis and
16
                  Partnership for Interdisciplinary Studies of Coastal Oceans,
17
                     University of California Santa Barbara
18
                  Long-Term Ecological Research Network Office,
19
                     University of New Mexico
20
                  Center for Environmental Studies, Arizona State University
21
   Other funding: National Science Foundation (see README for details)
22
                  The David and Lucile Packard Foundation
23
     For Details: http://knb.ecoinformatics.org/
24

  
25
        '$Author: jones $'
26
          '$Date: 2003/11/06 20:15:20 $'
27
      '$Revision: 1.51 $'
28

  
29
    This program is free software; you can redistribute it and/or modify
30
    it under the terms of the GNU General Public License as published by
31
    the Free Software Foundation; either version 2 of the License, or
32
    (at your option) any later version.
33

  
34
    This program is distributed in the hope that it will be useful,
35
    but WITHOUT ANY WARRANTY; without even the implied warranty of
36
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
    GNU General Public License for more details.
38

  
39
    You should have received a copy of the GNU General Public License
40
    along with this program; if not, write to the Free Software
41
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
42
    </xs:documentation>
43
		<xs:appinfo>
44
		</xs:appinfo>
45
	</xs:annotation>
46
	<xs:element name="citation" type="CitationType">
47
		<xs:annotation>
48
			<xs:appinfo>
49
				<doc:tooltip>Literature Citation</doc:tooltip>
50
				<doc:summary>Information describing a literature
51
        resource.</doc:summary>
52
			</xs:appinfo>
53
		</xs:annotation>
54
	</xs:element>
55
	<xs:complexType name="CitationType">
56
		<xs:choice>
57
			<xs:sequence>
58
				<xs:group ref="res:ResourceGroup"/>
59
				<xs:choice>
60
					<xs:element name="article" type="Article">
61
						<xs:annotation>
62
							<xs:appinfo>
63
								<doc:tooltip>article</doc:tooltip>
64
								<doc:summary>Information for full citation of a journal article
65
                or other periodical article.</doc:summary>
66
							</xs:appinfo>
67
						</xs:annotation>
68
					</xs:element>
69
					<xs:element name="book" type="Book">
70
						<xs:annotation>
71
							<xs:appinfo>
72
								<doc:tooltip>Book</doc:tooltip>
73
								<doc:summary>Information for full citation of a
74
                book</doc:summary>
75
							</xs:appinfo>
76
						</xs:annotation>
77
					</xs:element>
78
					<xs:element name="chapter" type="Chapter">
79
						<xs:annotation>
80
							<xs:appinfo>
81
								<doc:tooltip>Book Chapter</doc:tooltip>
82
								<doc:summary>Information for citation of a chapter in a
83
                book</doc:summary>
84
							</xs:appinfo>
85
						</xs:annotation>
86
					</xs:element>
87
					<xs:element name="editedBook" type="Book">
88
						<xs:annotation>
89
							<xs:appinfo>
90
								<doc:tooltip>Book</doc:tooltip>
91
								<doc:summary>Information for full citation of an edited
92
                book</doc:summary>
93
							</xs:appinfo>
94
						</xs:annotation>
95
					</xs:element>
96
					<xs:element name="manuscript" type="Manuscript">
97
						<xs:annotation>
98
							<xs:appinfo>
99
								<doc:tooltip>unpublished manuscipt</doc:tooltip>
100
								<doc:summary>Information about an unpublished
101
                manuscript</doc:summary>
102
							</xs:appinfo>
103
						</xs:annotation>
104
					</xs:element>
105
					<xs:element name="report" type="Report">
106
						<xs:annotation>
107
							<xs:appinfo>
108
								<doc:tooltip>Report</doc:tooltip>
109
								<doc:summary>Information about a report published by an
110
                institution.</doc:summary>
111
							</xs:appinfo>
112
						</xs:annotation>
113
					</xs:element>
114
					<xs:element name="thesis" type="Thesis">
115
						<xs:annotation>
116
							<xs:appinfo>
117
								<doc:tooltip>Thesis as part of a degree</doc:tooltip>
118
								<doc:summary>Information about a thesis that has been written
119
                as part of a degree requirement and is frequently published in
120
                small numbers by the degree awarding institution.</doc:summary>
121
							</xs:appinfo>
122
						</xs:annotation>
123
					</xs:element>
124
					<xs:element name="conferenceProceedings" type="ConferenceProceedings">
125
						<xs:annotation>
126
							<xs:appinfo>
127
								<doc:tooltip>conference proceedings</doc:tooltip>
128
								<doc:summary>The published notes, papers, presentations etc...
129
                of a conference.</doc:summary>
130
							</xs:appinfo>
131
						</xs:annotation>
132
					</xs:element>
133
					<xs:element name="personalCommunication" type="PersonalCommunication">
134
						<xs:annotation>
135
							<xs:appinfo>
136
								<doc:tooltip>Personal communication</doc:tooltip>
137
								<doc:summary>A personal communication that has been saved
138
                online or as hard-copy.</doc:summary>
139
							</xs:appinfo>
140
						</xs:annotation>
141
					</xs:element>
142
					<xs:element name="map" type="Map">
143
						<xs:annotation>
144
							<xs:appinfo>
145
								<doc:tooltip>map</doc:tooltip>
146
								<doc:summary>This element desribes the map that is being cited
147
                or cataloged.</doc:summary>
148
							</xs:appinfo>
149
						</xs:annotation>
150
					</xs:element>
151
					<xs:element name="generic" type="Generic">
152
						<xs:annotation>
153
							<xs:appinfo>
154
								<doc:tooltip>Generic Citation</doc:tooltip>
155
								<doc:summary>This reference type was created for references
156
                that do not fit in to the other existing reference
157
                types</doc:summary>
158
							</xs:appinfo>
159
						</xs:annotation>
160
					</xs:element>
161
					<xs:element name="audioVisual" type="AudioVisual">
162
						<xs:annotation>
163
							<xs:appinfo>
164
								<doc:tooltip>audio visual</doc:tooltip>
165
								<doc:summary>This reference type is meant to cover all forms of
166
                audio and visual media.</doc:summary>
167
							</xs:appinfo>
168
						</xs:annotation>
169
					</xs:element>
170
					<xs:element name="presentation" type="Presentation">
171
						<xs:annotation>
172
							<xs:appinfo>
173
								<doc:tooltip>Unpublished Presentation</doc:tooltip>
174
								<doc:summary>An unpublished presentation from a conference,
175
                workshop, workgroup, symposium etc.</doc:summary>
176
							</xs:appinfo>
177
						</xs:annotation>
178
					</xs:element>
179
				</xs:choice>
180
				<xs:element name="access" type="acc:AccessType" minOccurs="0">
181
					<xs:annotation>
182
						<xs:appinfo>
183
							<doc:tooltip>access control rules</doc:tooltip>
184
							<doc:summary>The access element describes the access control
185
              rules for this literature resource.</doc:summary>
186
						</xs:appinfo>
187
					</xs:annotation>
188
				</xs:element>
189
			</xs:sequence>
190
			<xs:group ref="res:ReferencesGroup"/>
191
		</xs:choice>
192
		<xs:attribute name="id" type="res:IDType" use="optional"/>
193
		<xs:attribute name="system" type="res:SystemType" use="optional"/>
194
		<xs:attribute name="scope" type="res:ScopeType" use="optional" default="document"/>
195
	</xs:complexType>
196
	<xs:complexType name="Article">
197
		<xs:annotation>
198
			<xs:appinfo>
199
				<doc:tooltip>article</doc:tooltip>
200
				<doc:summary>Information for full citation of a journal article or
201
        other periodical article.</doc:summary>
202
			</xs:appinfo>
203
		</xs:annotation>
204
		<xs:sequence>
205
			<xs:element name="journal" type="xs:string">
206
				<xs:annotation>
207
					<xs:appinfo>
208
						<doc:tooltip>Journal Name</doc:tooltip>
209
						<doc:summary>The name of the journal, magazine, newspaper, zine,
210
            etc... in which the article was published.</doc:summary>
211
					</xs:appinfo>
212
				</xs:annotation>
213
			</xs:element>
214
			<xs:element name="volume" type="xs:string">
215
				<xs:annotation>
216
					<xs:appinfo>
217
						<doc:tooltip>Journal Volume</doc:tooltip>
218
						<doc:summary>The volume of the journal in which the article
219
            appears</doc:summary>
220
					</xs:appinfo>
221
				</xs:annotation>
222
			</xs:element>
223
			<xs:element name="issue" type="xs:string" minOccurs="0">
224
				<xs:annotation>
225
					<xs:appinfo>
226
						<doc:tooltip>Journal issue</doc:tooltip>
227
						<doc:summary>The issue of the journal in which the article
228
            appears</doc:summary>
229
					</xs:appinfo>
230
				</xs:annotation>
231
			</xs:element>
232
			<xs:element name="pageRange" type="xs:string">
233
				<xs:annotation>
234
					<xs:appinfo>
235
						<doc:tooltip>Journal Pages</doc:tooltip>
236
						<doc:summary>The beginning and end page numbers of the journal
237
            article</doc:summary>
238
					</xs:appinfo>
239
				</xs:annotation>
240
			</xs:element>
241
			<xs:element name="publisher" type="rp:ResponsibleParty" minOccurs="0">
242
				<xs:annotation>
243
					<xs:appinfo>
244
						<doc:tooltip>Publisher</doc:tooltip>
245
						<doc:summary>Organization that actually publishes the
246
            article</doc:summary>
247
					</xs:appinfo>
248
				</xs:annotation>
249
			</xs:element>
250
			<xs:element name="publicationPlace" type="xs:string" minOccurs="0">
251
				<xs:annotation>
252
					<xs:appinfo>
253
						<doc:tooltip>Publication Place</doc:tooltip>
254
						<doc:summary>The location at which the work was
255
            published.</doc:summary>
256
					</xs:appinfo>
257
				</xs:annotation>
258
			</xs:element>
259
			<xs:element name="ISSN" type="xs:string" minOccurs="0">
260
				<xs:annotation>
261
					<xs:appinfo>
262
						<doc:tooltip>International Standard Serial Number</doc:tooltip>
263
						<doc:summary>The unique Internation Standard Serial
264
            Number</doc:summary>
265
					</xs:appinfo>
266
				</xs:annotation>
267
			</xs:element>
268
		</xs:sequence>
269
	</xs:complexType>
270
	<xs:complexType name="Book">
271
		<xs:annotation>
272
			<xs:appinfo>
273
				<doc:tooltip>Book</doc:tooltip>
274
				<doc:summary>Information for full citation of a book</doc:summary>
275
			</xs:appinfo>
276
		</xs:annotation>
277
		<xs:sequence>
278
			<xs:element name="publisher" type="rp:ResponsibleParty">
279
				<xs:annotation>
280
					<xs:appinfo>
281
						<doc:tooltip>Publisher</doc:tooltip>
282
						<doc:summary>Organization that actually publishes the
283
            book</doc:summary>
284
					</xs:appinfo>
285
				</xs:annotation>
286
			</xs:element>
287
			<xs:element name="publicationPlace" type="xs:string" minOccurs="0">
288
				<xs:annotation>
289
					<xs:appinfo>
290
						<doc:tooltip>Publication Place</doc:tooltip>
291
						<doc:summary>The location at which the work was
292
            published.</doc:summary>
293
					</xs:appinfo>
294
				</xs:annotation>
295
			</xs:element>
296
			<xs:element name="edition" type="xs:string" minOccurs="0">
297
				<xs:annotation>
298
					<xs:appinfo>
299
						<doc:tooltip>Book edition</doc:tooltip>
300
						<doc:summary>The edition of the book being described.</doc:summary>
301
					</xs:appinfo>
302
				</xs:annotation>
303
			</xs:element>
304
			<xs:element name="volume" type="xs:string" minOccurs="0">
305
				<xs:annotation>
306
					<xs:appinfo>
307
						<doc:tooltip>Book volume</doc:tooltip>
308
						<doc:summary>The volume of the book that is part of a
309
            series.</doc:summary>
310
					</xs:appinfo>
311
				</xs:annotation>
312
			</xs:element>
313
			<xs:element name="numberOfVolumes" type="xs:string" minOccurs="0">
314
				<xs:annotation>
315
					<xs:appinfo>
316
						<doc:tooltip>Number of Volumes</doc:tooltip>
317
						<doc:summary>Number of volumes in a collection</doc:summary>
318
					</xs:appinfo>
319
				</xs:annotation>
320
			</xs:element>
321
			<xs:element name="totalPages" type="xs:string" minOccurs="0">
322
				<xs:annotation>
323
					<xs:appinfo>
324
						<doc:tooltip>Total book pages</doc:tooltip>
325
						<doc:summary>The total number of pages in the book.</doc:summary>
326
					</xs:appinfo>
327
				</xs:annotation>
328
			</xs:element>
329
			<xs:element name="totalFigures" type="xs:string" minOccurs="0">
330
				<xs:annotation>
331
					<xs:appinfo>
332
						<doc:tooltip>Number of figures in book</doc:tooltip>
333
						<doc:summary>The total number of figures in the book.</doc:summary>
334
					</xs:appinfo>
335
				</xs:annotation>
336
			</xs:element>
337
			<xs:element name="totalTables" type="xs:string" minOccurs="0">
338
				<xs:annotation>
339
					<xs:appinfo>
340
						<doc:tooltip>Number of tables in book</doc:tooltip>
341
						<doc:summary>The total number of tables in a book.</doc:summary>
342
					</xs:appinfo>
343
				</xs:annotation>
344
			</xs:element>
345
			<xs:element name="ISBN" type="xs:string" minOccurs="0">
346
				<xs:annotation>
347
					<xs:appinfo>
348
						<doc:tooltip>International Standard Book Number</doc:tooltip>
349
						<doc:summary>The unique Internation Standard Book
350
            Number</doc:summary>
351
					</xs:appinfo>
352
				</xs:annotation>
353
			</xs:element>
354
		</xs:sequence>
355
	</xs:complexType>
356
	<xs:complexType name="Chapter">
357
		<xs:annotation>
358
			<xs:appinfo>
359
				<doc:tooltip>Book Chapter</doc:tooltip>
360
				<doc:summary>Information for citation of a chapter in a
361
        book</doc:summary>
362
			</xs:appinfo>
363
		</xs:annotation>
364
		<xs:complexContent>
365
			<xs:extension base="Book">
366
				<xs:sequence>
367
					<xs:element name="chapterNumber" type="xs:string" minOccurs="0">
368
						<xs:annotation>
369
							<xs:appinfo>
370
								<doc:tooltip>Chapter number</doc:tooltip>
371
								<doc:summary>The chapter number of interest within a
372
                book</doc:summary>
373
							</xs:appinfo>
374
						</xs:annotation>
375
					</xs:element>
376
					<xs:element name="editor" type="rp:ResponsibleParty" maxOccurs="unbounded">
377
						<xs:annotation>
378
							<xs:appinfo>
379
								<doc:tooltip>Book editor</doc:tooltip>
380
								<doc:summary>The name of the editor of the book.</doc:summary>
381
							</xs:appinfo>
382
						</xs:annotation>
383
					</xs:element>
384
					<xs:element name="bookTitle" type="xs:string">
385
						<xs:annotation>
386
							<xs:appinfo>
387
								<doc:tooltip>Book title</doc:tooltip>
388
								<doc:summary>The title of the book.</doc:summary>
389
							</xs:appinfo>
390
						</xs:annotation>
391
					</xs:element>
392
					<xs:element name="pageRange" type="xs:string" minOccurs="0">
393
						<xs:annotation>
394
							<xs:appinfo>
395
								<doc:tooltip>Chapter page range</doc:tooltip>
396
								<doc:summary>The beginning and ending page numbers of a
397
                chapter.</doc:summary>
398
							</xs:appinfo>
399
						</xs:annotation>
400
					</xs:element>
401
				</xs:sequence>
402
			</xs:extension>
403
		</xs:complexContent>
404
	</xs:complexType>
405
	<xs:complexType name="ConferenceProceedings">
406
		<xs:annotation>
407
			<xs:appinfo>
408
				<doc:tooltip>conference proceedings</doc:tooltip>
409
				<doc:summary>The published notes, papers, presentations etc... of a
410
        conference.</doc:summary>
411
			</xs:appinfo>
412
		</xs:annotation>
413
		<xs:complexContent>
414
			<xs:extension base="Chapter">
415
				<xs:sequence>
416
					<xs:element name="conferenceName" type="xs:string" minOccurs="0">
417
						<xs:annotation>
418
							<xs:appinfo>
419
								<doc:tooltip>Conference Name</doc:tooltip>
420
								<doc:summary>The name of the conference whose proceedings have
421
                been published.</doc:summary>
422
							</xs:appinfo>
423
						</xs:annotation>
424
					</xs:element>
425
					<xs:element name="conferenceDate" type="xs:string" minOccurs="0">
426
						<xs:annotation>
427
							<xs:appinfo>
428
								<doc:tooltip>Conference Date</doc:tooltip>
429
								<doc:summary>The date the conference was held.</doc:summary>
430
							</xs:appinfo>
431
						</xs:annotation>
432
					</xs:element>
433
					<xs:element name="conferenceLocation" type="rp:Address" minOccurs="0">
434
						<xs:annotation>
435
							<xs:appinfo>
436
								<doc:tooltip>Conference Location</doc:tooltip>
437
								<doc:summary>The location where the conference was
438
                held.</doc:summary>
439
							</xs:appinfo>
440
						</xs:annotation>
441
					</xs:element>
442
				</xs:sequence>
443
			</xs:extension>
444
		</xs:complexContent>
445
	</xs:complexType>
446
	<xs:complexType name="Manuscript">
447
		<xs:annotation>
448
			<xs:appinfo>
449
				<doc:tooltip>unpublished manuscipt</doc:tooltip>
450
				<doc:summary>Information about an unpublished manuscript</doc:summary>
451
			</xs:appinfo>
452
		</xs:annotation>
453
		<xs:sequence>
454
			<xs:element name="institution" type="rp:ResponsibleParty" maxOccurs="unbounded">
455
				<xs:annotation>
456
					<xs:appinfo>
457
						<doc:tooltip>Manuscript publication information</doc:tooltip>
458
						<doc:summary>The address and contact information needed to request
459
            a manuscript.</doc:summary>
460
					</xs:appinfo>
461
				</xs:annotation>
462
			</xs:element>
463
			<xs:element name="totalPages" type="xs:string" minOccurs="0">
464
				<xs:annotation>
465
					<xs:appinfo>
466
						<doc:tooltip>Total manuscript pages</doc:tooltip>
467
						<doc:summary>The total number of pages in the
468
            manuscript.</doc:summary>
469
					</xs:appinfo>
470
				</xs:annotation>
471
			</xs:element>
472
		</xs:sequence>
473
	</xs:complexType>
474
	<xs:complexType name="Report">
475
		<xs:annotation>
476
			<xs:appinfo>
477
				<doc:tooltip>Report</doc:tooltip>
478
				<doc:summary>Information about a report published by an
479
        institution.</doc:summary>
480
			</xs:appinfo>
481
		</xs:annotation>
482
		<xs:sequence>
483
			<xs:element name="reportNumber" type="xs:string" minOccurs="0">
484
				<xs:annotation>
485
					<xs:appinfo>
486
						<doc:tooltip>Report Number</doc:tooltip>
487
						<doc:summary>The unique identification number assigned to the
488
            report.</doc:summary>
489
					</xs:appinfo>
490
				</xs:annotation>
491
			</xs:element>
492
			<xs:element name="publisher" type="rp:ResponsibleParty" minOccurs="0">
493
				<xs:annotation>
494
					<xs:appinfo>
495
						<doc:tooltip>Publisher</doc:tooltip>
496
						<doc:summary>Organization that actually publishes the
497
            report</doc:summary>
498
					</xs:appinfo>
499
				</xs:annotation>
500
			</xs:element>
501
			<xs:element name="publicationPlace" type="xs:string" minOccurs="0">
502
				<xs:annotation>
503
					<xs:appinfo>
504
						<doc:tooltip>Publication Place</doc:tooltip>
505
						<doc:summary>The location at which the work was
506
            published.</doc:summary>
507
					</xs:appinfo>
508
				</xs:annotation>
509
			</xs:element>
510
			<xs:element name="totalPages" type="xs:string" minOccurs="0">
511
				<xs:annotation>
512
					<xs:appinfo>
513
						<doc:tooltip>Total report pages</doc:tooltip>
514
						<doc:summary>The total number of pages in the report.</doc:summary>
515
					</xs:appinfo>
516
				</xs:annotation>
517
			</xs:element>
518
		</xs:sequence>
519
	</xs:complexType>
520
	<xs:complexType name="PersonalCommunication">
521
		<xs:annotation>
522
			<xs:appinfo>
523
				<doc:tooltip>Personal communication</doc:tooltip>
524
				<doc:summary>A personal communication that has been saved online or as
525
        hard-copy.</doc:summary>
526
			</xs:appinfo>
527
		</xs:annotation>
528
		<xs:sequence>
529
			<xs:element name="publisher" type="rp:ResponsibleParty" minOccurs="0">
530
				<xs:annotation>
531
					<xs:appinfo>
532
						<doc:tooltip>Publisher</doc:tooltip>
533
						<doc:summary>Organization that actually publishes the
534
            communication</doc:summary>
535
					</xs:appinfo>
536
				</xs:annotation>
537
			</xs:element>
538
			<xs:element name="publicationPlace" type="xs:string" minOccurs="0">
539
				<xs:annotation>
540
					<xs:appinfo>
541
						<doc:tooltip>Publication Place</doc:tooltip>
542
						<doc:summary>The location at which the work was
543
            published.</doc:summary>
544
					</xs:appinfo>
545
				</xs:annotation>
546
			</xs:element>
547
			<xs:element name="communicationType" type="xs:string" minOccurs="0">
548
				<xs:annotation>
549
					<xs:appinfo>
550
						<doc:tooltip>Type of communication</doc:tooltip>
551
						<doc:summary>The type of personal communication.</doc:summary>
552
					</xs:appinfo>
553
				</xs:annotation>
554
			</xs:element>
555
			<xs:element name="recipient" type="rp:ResponsibleParty" minOccurs="0" maxOccurs="unbounded">
556
				<xs:annotation>
557
					<xs:appinfo>
558
						<doc:tooltip>Recipient</doc:tooltip>
559
						<doc:summary>Recipient of the communication</doc:summary>
560
					</xs:appinfo>
561
				</xs:annotation>
562
			</xs:element>
563
		</xs:sequence>
564
	</xs:complexType>
565
	<xs:complexType name="Map">
566
		<xs:annotation>
567
			<xs:appinfo>
568
				<doc:tooltip>map</doc:tooltip>
569
				<doc:summary>This element desribes the map that is being cited or
570
        cataloged.</doc:summary>
571
			</xs:appinfo>
572
		</xs:annotation>
573
		<xs:sequence>
574
			<xs:element name="publisher" type="rp:ResponsibleParty" minOccurs="0">
575
				<xs:annotation>
576
					<xs:appinfo>
577
						<doc:tooltip>Publisher</doc:tooltip>
578
						<doc:summary>Organization that actually publishes the
579
            map</doc:summary>
580
					</xs:appinfo>
581
				</xs:annotation>
582
			</xs:element>
583
			<xs:element name="edition" type="xs:string" minOccurs="0">
584
				<xs:annotation>
585
					<xs:appinfo>
586
						<doc:tooltip>Map edition</doc:tooltip>
587
						<doc:summary>The edition of the map being described.</doc:summary>
588
					</xs:appinfo>
589
				</xs:annotation>
590
			</xs:element>
591
			<xs:element name="geographicCoverage" type="cov:GeographicCoverage" minOccurs="0" maxOccurs="unbounded">
592
				<xs:annotation>
593
					<xs:appinfo>
594
						<doc:tooltip>Geographic coverage</doc:tooltip>
595
						<doc:summary>Description of the geographic area which the map
596
            covers</doc:summary>
597
					</xs:appinfo>
598
				</xs:annotation>
599
			</xs:element>
600
			<xs:element name="scale" type="xs:string" minOccurs="0">
601
				<xs:annotation>
602
					<xs:appinfo>
603
						<doc:tooltip>Scale</doc:tooltip>
604
						<doc:summary>The Map's scale</doc:summary>
605
					</xs:appinfo>
606
				</xs:annotation>
607
			</xs:element>
608
		</xs:sequence>
609
	</xs:complexType>
610
	<xs:complexType name="AudioVisual">
611
		<xs:annotation>
612
			<xs:appinfo>
613
				<doc:tooltip>audio visual</doc:tooltip>
614
				<doc:summary>This reference type is meant to cover all forms of audio
615
        and visual media.</doc:summary>
616
			</xs:appinfo>
617
		</xs:annotation>
618
		<xs:sequence>
619
			<xs:element name="publisher" type="rp:ResponsibleParty">
620
				<xs:annotation>
621
					<xs:appinfo>
622
						<doc:tooltip>Publisher</doc:tooltip>
623
						<doc:summary>Organization which actually distributes the video,
624
            film, the broadcaster etc...</doc:summary>
625
					</xs:appinfo>
626
				</xs:annotation>
627
			</xs:element>
628
			<xs:element name="publicationPlace" type="xs:string" minOccurs="0" maxOccurs="unbounded">
629
				<xs:annotation>
630
					<xs:appinfo>
631
						<doc:tooltip>Publication Place</doc:tooltip>
632
						<doc:summary>The location at which the work was
633
            published.</doc:summary>
634
					</xs:appinfo>
635
				</xs:annotation>
636
			</xs:element>
637
			<xs:element name="performer" type="rp:ResponsibleParty" minOccurs="0" maxOccurs="unbounded">
638
				<xs:annotation>
639
					<xs:appinfo>
640
						<doc:tooltip>Performer</doc:tooltip>
641
						<doc:summary>The performers in the audio visual
642
            production</doc:summary>
643
					</xs:appinfo>
644
				</xs:annotation>
645
			</xs:element>
646
			<xs:element name="ISBN" type="xs:string" minOccurs="0">
647
				<xs:annotation>
648
					<xs:appinfo>
649
						<doc:tooltip>International Standard Book Number</doc:tooltip>
650
						<doc:summary>The unique Internation Standard Book
651
            Number</doc:summary>
652
					</xs:appinfo>
653
				</xs:annotation>
654
			</xs:element>
655
		</xs:sequence>
656
	</xs:complexType>
657
	<xs:complexType name="Generic">
658
		<xs:sequence>
659
			<xs:element name="publisher" type="rp:ResponsibleParty">
660
				<xs:annotation>
661
					<xs:appinfo>
662
						<doc:tooltip>Publisher</doc:tooltip>
663
						<doc:summary>Organization which actually publishes the
664
            reference</doc:summary>
665
					</xs:appinfo>
666
				</xs:annotation>
667
			</xs:element>
668
			<xs:element name="publicationPlace" type="xs:string" minOccurs="0">
669
				<xs:annotation>
670
					<xs:appinfo>
671
						<doc:tooltip>Publication Place</doc:tooltip>
672
						<doc:summary>The location at which the work was
673
            published.</doc:summary>
674
					</xs:appinfo>
675
				</xs:annotation>
676
			</xs:element>
677
			<xs:element name="referenceType" minOccurs="0">
678
				<xs:annotation>
679
					<xs:appinfo>
680
						<doc:tooltip>Reference Type</doc:tooltip>
681
						<doc:summary>The type of reference.</doc:summary>
682
					</xs:appinfo>
683
				</xs:annotation>
684
			</xs:element>
685
			<xs:element name="volume" type="xs:string" minOccurs="0">
686
				<xs:annotation>
687
					<xs:appinfo>
688
						<doc:tooltip>Reference volume</doc:tooltip>
689
						<doc:summary>The volume of the reference that is part of a
690
            series.</doc:summary>
691
					</xs:appinfo>
692
				</xs:annotation>
693
			</xs:element>
694
			<xs:element name="numberOfVolumes" type="xs:string" minOccurs="0">
695
				<xs:annotation>
696
					<xs:appinfo>
697
						<doc:tooltip>Number of Volumes</doc:tooltip>
698
						<doc:summary>Number of volumes in a collection</doc:summary>
699
					</xs:appinfo>
700
				</xs:annotation>
701
			</xs:element>
702
			<xs:element name="totalPages" type="xs:string" minOccurs="0">
703
				<xs:annotation>
704
					<xs:appinfo>
705
						<doc:tooltip>Total reference pages</doc:tooltip>
706
						<doc:summary>The total number of pages in the
707
            references.</doc:summary>
708
					</xs:appinfo>
709
				</xs:annotation>
710
			</xs:element>
711
			<xs:element name="totalFigures" type="xs:string" minOccurs="0">
712
				<xs:annotation>
713
					<xs:appinfo>
714
						<doc:tooltip>Number of figures in reference</doc:tooltip>
715
						<doc:summary>The total number of figures in the
716
            reference.</doc:summary>
717
					</xs:appinfo>
718
				</xs:annotation>
719
			</xs:element>
720
			<xs:element name="totalTables" type="xs:string" minOccurs="0">
721
				<xs:annotation>
722
					<xs:appinfo>
723
						<doc:tooltip>Number of tables in reference</doc:tooltip>
724
						<doc:summary>The total number of tables in a
725
            reference.</doc:summary>
726
					</xs:appinfo>
727
				</xs:annotation>
728
			</xs:element>
729
			<xs:element name="edition" type="xs:string" minOccurs="0">
730
				<xs:annotation>
731
					<xs:appinfo>
732
						<doc:tooltip>edition</doc:tooltip>
733
						<doc:summary>The edition of the generic reference being
734
            described.</doc:summary>
735
					</xs:appinfo>
736
				</xs:annotation>
737
			</xs:element>
738
			<xs:element name="originalPublication" type="xs:string" minOccurs="0">
739
				<xs:annotation>
740
					<xs:appinfo>
741
						<doc:tooltip>Original Publication</doc:tooltip>
742
						<doc:summary>References current publication to its
743
            original.</doc:summary>
744
					</xs:appinfo>
745
				</xs:annotation>
746
			</xs:element>
747
			<xs:element name="reprintEdition" type="xs:string" minOccurs="0">
748
				<xs:annotation>
749
					<xs:appinfo>
750
						<doc:tooltip>Reprint Edition</doc:tooltip>
751
						<doc:summary>Reference for current edition that was originally
752
            published under a different title.</doc:summary>
753
					</xs:appinfo>
754
				</xs:annotation>
755
			</xs:element>
756
			<xs:element name="reviewedItem" type="xs:string" minOccurs="0">
757
				<xs:annotation>
758
					<xs:appinfo>
759
						<doc:tooltip>Reviewed Item</doc:tooltip>
760
						<doc:summary>Reference types that are reviews of other
761
            references.</doc:summary>
762
					</xs:appinfo>
763
				</xs:annotation>
764
			</xs:element>
765
			<xs:choice minOccurs="0">
766
				<xs:element name="ISBN" type="xs:string">
767
					<xs:annotation>
768
						<xs:appinfo>
769
							<doc:tooltip>International Standard Book Number</doc:tooltip>
770
							<doc:summary>The unique Internation Standard Book
771
              Number</doc:summary>
772
						</xs:appinfo>
773
					</xs:annotation>
774
				</xs:element>
775
				<xs:element name="ISSN" type="xs:string">
776
					<xs:annotation>
777
						<xs:appinfo>
778
							<doc:tooltip>International Standard Serial Number</doc:tooltip>
779
							<doc:summary>The unique Internation Standard Serial
780
              Number</doc:summary>
781
						</xs:appinfo>
782
					</xs:annotation>
783
				</xs:element>
784
			</xs:choice>
785
		</xs:sequence>
786
	</xs:complexType>
787
	<xs:complexType name="Thesis">
788
		<xs:annotation>
789
			<xs:appinfo>
790
				<doc:tooltip>Thesis as part of a degree</doc:tooltip>
791
				<doc:summary>Information about a thesis that has been written as part
792
        of a degree requirement and is frequently published in small numbers by
793
        the degree awarding institution.</doc:summary>
794
			</xs:appinfo>
795
		</xs:annotation>
796
		<xs:sequence>
797
			<xs:element name="degree" type="xs:string">
798
				<xs:annotation>
799
					<xs:appinfo>
800
						<doc:tooltip>Degee name</doc:tooltip>
801
						<doc:summary>The name or degree level for which the thesis was
802
            completed.</doc:summary>
803
					</xs:appinfo>
804
				</xs:annotation>
805
			</xs:element>
806
			<xs:element name="institution" type="rp:ResponsibleParty">
807
				<xs:annotation>
808
					<xs:appinfo>
809
						<doc:tooltip>Degree awarding institution</doc:tooltip>
810
						<doc:summary>The name of the degree-awarding
811
            institution</doc:summary>
812
					</xs:appinfo>
813
				</xs:annotation>
814
			</xs:element>
815
			<xs:element name="totalPages" type="xs:string" minOccurs="0">
816
				<xs:annotation>
817
					<xs:appinfo>
818
						<doc:tooltip>Thesis Pages</doc:tooltip>
819
						<doc:summary>The total number of pages in the thesis.</doc:summary>
820
					</xs:appinfo>
821
				</xs:annotation>
822
			</xs:element>
823
		</xs:sequence>
824
	</xs:complexType>
825
	<xs:complexType name="Presentation">
826
		<xs:annotation>
827
			<xs:appinfo>
828
				<doc:tooltip>Unpublished Presentation</doc:tooltip>
829
				<doc:summary>An unpublished presentation from a conference, workshop,
830
        workgroup, symposium, etc.</doc:summary>
831
			</xs:appinfo>
832
		</xs:annotation>
833
		<xs:sequence>
834
			<xs:element name="conferenceName" type="xs:string" minOccurs="0">
835
				<xs:annotation>
836
					<xs:appinfo>
837
						<doc:tooltip>Conference Name</doc:tooltip>
838
						<doc:summary>The name of the conference at which this presentation
839
            was given.</doc:summary>
840
					</xs:appinfo>
841
				</xs:annotation>
842
			</xs:element>
843
			<xs:element name="conferenceDate" type="xs:string" minOccurs="0">
844
				<xs:annotation>
845
					<xs:appinfo>
846
						<doc:tooltip>Conference Date</doc:tooltip>
847
						<doc:summary>The date the conference was held.</doc:summary>
848
					</xs:appinfo>
849
				</xs:annotation>
850
			</xs:element>
851
			<xs:element name="conferenceLocation" type="rp:Address" minOccurs="0">
852
				<xs:annotation>
853
					<xs:appinfo>
854
						<doc:tooltip>Conference Location</doc:tooltip>
855
						<doc:summary>The location where the conference was
856
            held.</doc:summary>
857
					</xs:appinfo>
858
				</xs:annotation>
859
			</xs:element>
860
		</xs:sequence>
861
	</xs:complexType>
862
</xs:schema>
makeVegxModel/trunk/objects/Entity.php
1 1
<?php
2 2
require_once('util/utilityFunctions.php');
3 3
require_once('objects/types.php');
4
require_once('objects/lookups.php');
4 5

  
5 6
class Entity {
6 7
  private $references = array();
......
56 57
      }
57 58

  
58 59
      switch($cNodeName) {
59
        #Untested
60 60
        case 'any':
61 61
          $any_e = $eList->newEntity($tableName . "_any_nodes");
62 62
          $any_e->addMember("node_name","models.CharField(max_length=255)");
......
92 92
          }
93 93
          if($default != '') {
94 94
            if($use == 'optional' ||
95
               $def == 'models.CharField(max_length=255') { 
95
               $def == 'models.CharField(max_length=255') {
96 96
              $def .= ", "; 
97 97
            }
98 98
            $def .= "default = '$default'";
99 99
          }
100
          if(needsIndex("attr_$a_name")) {
101
            if($use == 'optional' ||
102
               $def == 'models.CharField(max_length=255' ||
103
               $default != '') {
104
              $def .= ", "; 
105
            }
106
            $def .= "db_index=True";
107
          }
100 108
          $def .= ")";
101 109
          if($guess) { $def .= " # This is a guess"; }
102 110
          $this->addMember("attr_$a_name",$def);
......
240 248
                   $def == 'models.CharField(max_length=255') { $def .= ", "; }
241 249
                $def .= "default = '$default'";
242 250
              }
251
              if(needsIndex("attr_$a_name")) {
252
                if($use == 'optional' ||
253
                   $def == 'models.CharField(max_length=255' ||
254
                   $default != '') {
255
                  $def .= ", "; 
256
                }
257
                $def .= "db_index=True";
258
              }
243 259
              $def .= ")";
244 260
              if($guess) { $def .= " # This is a guess"; }
245 261
              $this->addMember("attr_$a_name",$def);
......
248 264
            $this->addMember("primitive_type_value",$def);
249 265
          } else {
250 266
            $ref_e = $eList->getEntityForReference($base);
251
            $this->addOneToOneReference($base . "_extend",$ref_e);
267
//            $this->addOneToOneReference($base . "_extend",$ref_e);
268
             $this->addOneToManyReference($base . "_extend",$ref_e,False);
252 269
            $this->extensionType = $base;
253 270

  
254 271
            $grandchildNodesXPath = $xpath->query("child::node()",$childNode);
......
329 346
  public function determineRelationship($colName,$typeName,$node) {
330 347
    global $eList;
331 348
    global $primitiveTypes;
349
    global $nativeVegXPointers;
350
    global $manyToManyRelationships;
332 351

  
333 352
    $tableName = $this->tableName;
334 353

  
......
338 357
    $default = $node->getAttribute('default');
339 358
    $default = $node->getAttribute('use');
340 359

  
341
    if(isPrimitiveType($typeName)) {
360
    if(isNativePointer($colName)) {
361
      $def = $nativeVegXPointers[$colName]['def'];
362
      $this->addMember($colName,$def);
363
    } else if(isPrimitiveType($typeName)) {
342 364
      $def = $primitiveTypes[$typeName];
343 365
      if($use == 'optional' || $optional) {
344 366
        if($def == 'models.CharField(max_length=255') { $def .= ", "; }
......
351 373
        }
352 374
        $def .= "default = '$default'";
353 375
      }
376
      if(needsIndex("$colName")) {
377
        if($use == 'optional' || $optional ||
378
           $def == 'models.CharField(max_length=255' ||
379
           $default != '') {
380
          $def .= ", "; 
381
        }
382
        $def .= "db_index=True";
383
      }
354 384
      $def .= ")";
355 385

  
356 386
      if(((string)$maxOccurs) == '' || $maxOccurs == 1) {
......
365 395
    } else {
366 396
      $ref_e = $eList->getEntityForReference($typeName);
367 397
      if(((string)$maxOccurs) == '' || $maxOccurs == 1) {
368
        $this->addOneToOneReference($colName,$ref_e,$optional);
398
        //$this->addOneToOneReference($colName,$ref_e,$optional);
399
        $this->addOneToManyReference($colName,$ref_e,False,$optional);
369 400
      } else {
370 401
#        echo "Need to define relationship between:\n  $tableName <--> $typeName\n";
371 402
#        echo "    (O)ne to Many\n    (M)any to Many\n";
372 403
#        echo "    Your choice:  ";
373 404
#        $handle = fopen ("php://stdin","r");
374 405
#        $line = fgets($handle);
375
$line = 'M';
406
        $line = 'O';
407
        if($manyToManyRelationships[$tableName][$typeName]) {
408
          $line = 'M';
409
        }
376 410
        if(trim($line) == 'O' || trim($line) == 'o'){
377
          $ref_e->addOneToManyReference($colName,$this);
411
          $ref_e->addOneToManyReference($tableName . "_id",$this,False,$optional);
378 412
          $this->referrers[$colName] = $ref_e->getName();
379 413
        } else {
380 414
          $this->addManyToManyReference($colName,$ref_e,$tableName . "_" . $typeName . "_" . $colName);
......
399 433
  public function addOneToOneReference($colName,$e,$optional = False) {
400 434
    $eName = $e->getName();
401 435
    $relatedName = $this->tableName . "_" . $colName;
402
    #$def = "models.OneToOneField('$eName', primary_key=True,related_name='$relatedName'";
403 436
    $def = "models.ForeignKey('$eName', unique=True,related_name='$relatedName'";
404 437
    if($optional) {
405 438
      $def .= ", null=True, blank=True";
......
408 441
    $this->addReference($colName,$def); 
409 442
  }
410 443

  
411
  public function addOneToManyReference($colName,$e,$optional = False) {
444
  public function addOneToManyReference($colName,$e,$primitiveRef = True,$optional = False) {
412 445
    $eName = $e->getName();
413 446
    if($eName == $this->tableName) { 
414 447
      $eName = 'self'; 
415 448
    }
416 449
    $relatedName = $this->tableName . "_" . $colName;
417
    $def = "models.ForeignKey('$eName',related_name='$relatedName'";
450
    #$def = "models.OneToOneField('$eName', primary_key=True,related_name='$relatedName'";
451
    $def = "models.ForeignKey('$eName', related_name='$relatedName'";
418 452
    if($optional) {
419 453
      $def .= ", null=True, blank=True";
420 454
    }
421 455
    $def .= ")";
456
    if(!$primitiveRef) {
457
      $def .= " #Complex one2Many";
458
    }
422 459
    $this->addReference($colName,$def); 
423 460
  }
424 461

  
......
494 531

  
495 532
  public function toString() {
496 533
    $str = "class " . $this->tableName . "(models.Model):\n";
497
    #Needed to keep Django from choking:
498
    if(count($this->references) == 0 &&
499
       count($this->members) == 0) {
500
      $str .= "  id = models.AutoField(primary_key=True)";
501
    }
502 534

  
535
    #All entities need reference to their creation info since
536
    #VegX does not support unique identification for all types of information,
537
    #at least not as defined in BIEN3.
538
    $str .= "  entryInfo = models.ForeignKey('EntryInfo')\n";
539

  
503 540
    foreach(array_keys($this->references) as $colName) {
504 541
      $def = $this->references[$colName];
505 542
      $str .= "  $colName = $def\n";
......
509 546
      $str .= "  $colName = $def\n";
510 547
    }
511 548

  
549
    global $geoSpatialTypes;
550
    if($geoSpatialTypes[$this->tableName]) {
551
      //Only one geometry type per table currently so this works.
552
      $geoColDef = $geoSpatialTypes[$this->tableName]['colDef']; 
553
      $str .= "  \n  # GeoDjango-specific: a geometry field, and\n".
554
              "  # overriding the default manager with a GeoManager instance.\n".
555
              "  $geoColDef\n".
556
              "  objects = models.GeoManager()\n";
557

  
558
    }
559

  
512 560
    $str .= "\n" . $this->makeExportFunction();
513 561
    $str .= "\n" . $this->makeImportFunction();
514 562
    $str .= "\n" . $this->makeExportDummyDataFunction();
563
    $str .= "\n" . $this->makeRetrieveOrNewFunction();
515 564

  
516 565
    #truncate table names that are too long for Django/Postgre to support
517 566
    if(strlen($this->tableName) > 54) {
......
528 577
    if(count($this->references) == 0 &&
529 578
       count($this->members) == 0 &&
530 579
       count($this->referrers) == 0) {
531
      return "  def importVegX(self,node):\n"."    self.save()\n";
580
      return "  def importVegX(self,node,info):\n".
581
             "    self.entryInfo = info\n".
582
             "    self.save()\n";
532 583
    }
533 584

  
534
    $def =  "  def importVegX(self,node):\n";
585
    $def =  "  def importVegX(self,node,info):\n".
586
            "    self.entryInfo = info\n";
535 587

  
536 588
    if(preg_match_all("/([a-zA-Z]*)_extend/",implode(",",array_keys($this->references)),$matches) > 0) {
537 589
      $base = $matches[1][0];
538
      $def .= "    extendedEl = $base()\n".
539
              "    extendedEl.importVegX(node)\n".
590
      $def .= "    extendedEl = $base().retrieveOrNew(node)\n".
591
              "    extendedEl.importVegX(node,info)\n".
540 592
              "    self.$base"."_extend = extendedEl\n\n";
541 593
    }
542 594

  
......
579 631
                "        newEl.$tIDName = self\n".
580 632
                "        newEl.attr_name = attr\n".
581 633
                "        newEl.attr_value = aVal\n".
634
                "        newEl.entryInfo = info\n".
582 635
                "        newEl.save()\n";
583 636
      } else {
584 637
        $def .= "      newEl = $type()\n".
585 638
                "      newEl.$tIDName = self\n".
586 639
                "      newEl.attr_name = attr\n".
587 640
                "      newEl.attr_value = aVal\n".
641
                "      newEl.entryInfo = info\n".
588 642
                "      newEl.save()\n";
589 643
      }
590 644
    }
......
604 658
       preg_match_all("/primitive_type_value/",implode(",",array_keys($this->members)),$matches) > 0) {
605 659
      foreach(array_keys($this->members) as $colName) {
606 660
        if(preg_match("/^attr_/",$colName) > 0) { continue; }
607
        $ifStmt = $i == 0 ? 'if' : 'elif';
608
        $i += 1;
609
        $def .= "      $ifStmt cName == '$colName':\n".
610
                "        cVal = child.childNodes[0].nodeValue\n".
611
                "        self.$colName = cVal\n";
661
        else if(isNativePointer($colName)) {
662
          global $nativeVegXPointers;
663
          $ifStmt = $i == 0 ? 'if' : 'elif';
664
          $i += 1;
665
          $tabType = $nativeVegXPointers[$colName]['fk_type'];
666
          $toField = $nativeVegXPointers[$colName]['to_field'];
667
          $def .= "      $ifStmt cName == '$colName':\n".
668
                  "        if(len(child.childNodes) > 0):\n".
669
                  "          cVal = child.childNodes[0].nodeValue\n".
670
                  "          q = $tabType.objects.filter($toField" . "__exact = cVal)\n".
671
                  "          q = $tabType.objects.filter(entryInfo__id__exact = self.entryInfo.id)\n".
672
                  "          if len(q) > 0:\n".
673
                  "            self.$colName = q[0]\n";
674
        } else {
675
          $ifStmt = $i == 0 ? 'if' : 'elif';
676
          $i += 1;
677
          $def .= "      $ifStmt cName == '$colName':\n".
678
                  "        if(len(child.childNodes) > 0):\n".
679
                  "          cVal = child.childNodes[0].nodeValue\n".
680
                  "          self.$colName = cVal\n";
681
        }
612 682
      }
613 683
    }
614 684

  
615 685
    if(preg_match_all("/primitive_type_value/",implode(",",array_keys($this->members)),$matches) > 0) {
616
      $def .= "    cVal = node.childNodes[0].nodeValue\n".
617
              "    self.primitive_type_value = cVal\n";
686
      $def .= "    if(len(node.childNodes) > 0):\n".
687
              "      cVal = node.childNodes[0].nodeValue\n".
688
              "      self.primitive_type_value = cVal\n";
618 689
    }
619 690

  
620 691
    foreach(array_keys($this->references) as $colName) {
......
622 693
      $colDef = $this->references[$colName];
623 694

  
624 695
      if(preg_match("/(ForeignKey\(')([a-zA-Z]*)/",$colDef,$matches) > 0 &&
625
         preg_match("/unique/",$colDef) > 0 && preg_match("/_extend/",$colName) == 0) {
696
         preg_match("/Complex one2Many/",$colDef) > 0 && preg_match("/_extend/",$colDef) == 0) {
626 697
        $i += 1;
627 698
        $def .= "      $ifStmt cName == '$colName':\n".
628
                "        newEl = $matches[2]()\n".
629
                "        newEl.importVegX(child)\n".
699
                "        newEl = $matches[2]().retrieveOrNew(child)\n".
700
                "        newEl.importVegX(child,info)\n".
630 701
                "        self.$colName = newEl\n";
631 702
      }
632 703
      if(preg_match("/(ManyToManyField\(')([a-zA-Z]*)/",$colDef,$matches) > 0) {
633 704
        $i += 1;
634 705
        $def .= "      $ifStmt cName == '$colName':\n".
635
                "        newEl = $matches[2]()\n".
636
                "        newEl.importVegX(child)\n".
706
                "        newEl = $matches[2]().retrieveOrNew(child)\n".
707
                "        newEl.importVegX(child,info)\n".
637 708
                "        self.$colName.add(newEl)\n";
638 709
      }
639 710
    }
......
649 720
      $colDef = $this->referrers[$colName];
650 721
      $elReferenceBack = $this->tableName . '_id';
651 722
      $def .= "      $ifStmt cName == '$colName':\n".
652
              "        newEl = $colDef()\n".
723
              "        newEl = $colDef().retrieveOrNew(child)\n".
653 724
              "        newEl.$elReferenceBack = self\n".
654
              "        newEl.importVegX(child)\n";
725
              "        newEl.importVegX(child,info)\n";
655 726
    }
656 727
    if(preg_match("/anyNode/",implode(",",array_keys($this->referrers))) > 0) {
657 728
      $type = $this->referrers['anyNode'];
......
663 734
                "        newEl.node_name = cName\n".
664 735
                "        for grandchild in child.childNodes:\n".
665 736
                "          newEl.node_value += grandchild.toxml()\n".
737
                "        newEl.entryInfo = info\n".
666 738
                "        newEl.save()\n";
667 739
      } else {
668 740
        $def .= "      newEl = $type()\n".
......
670 742
                "      newEl.node_name = cName\n".
671 743
                "      for grandchild in child.childNodes:\n".
672 744
                "        newEl.node_value += grandchild.toxml()\n".
745
                "      newEl.entryInfo = info\n".
673 746
                "      newEl.save()\n";
674 747
      }
675 748
    }
676 749

  
750
    global $geoSpatialTypes;
751
    if($geoSpatialTypes[$this->tableName]) {
752
      //Only one geometry type per table currently so this works.
753
      $geoColImportDef = $geoSpatialTypes[$this->tableName]['importDef']; 
754
      $def .= "  \n    # Convert to geometry types to make use of GeoDjango's\n".
755
              "    # capabilities.\n".
756
              "  $geoColImportDef\n";
757

  
758
    }
759

  
677 760
    $def .= "\n    self.save()\n"; 
678 761
    return $def;
679 762
    
......
723 806
        $def .= "    if self.$colName != None:\n".
724 807
                "      newElText = doc.createTextNode(self.$colName)\n".
725 808
                "      myNode.appendChild(newElText)\n\n";
809
      }else if(isNativePointer($colName)) {
810
        global $nativeVegXPointers;
811
        $to_field = $nativeVegXPointers[$colName]['to_field'];
812
        $nodeText = "str(self.$colName.$to_field)";
813
        $def .= "    if self.$colName != None:\n".
814
                "      newEl = doc.createElement('$colName')\n".
815
                "      newElText = doc.createTextNode($nodeText)\n".
816
                "      newEl.appendChild(newElText)\n".
817
                "      myNode.appendChild(newEl)\n\n";
726 818
      }else {
727 819
/*
728 820
        if(preg_match("/DateField/",$this->members[$colName],$matches) > 0 ||
......
745 837
      $colDef = $this->references[$colName];
746 838

  
747 839
      if(preg_match("/(ForeignKey\(')([a-zA-Z]*)/",$colDef,$matches) > 0 &&
748
         preg_match("/unique/",$colDef) > 0) {
840
         (preg_match("/Complex one2Many/",$colDef) > 0 || preg_match("/_extend/",$colName) > 0)) {
749 841
        if(preg_match("/_extend/",$colName) == 0) {
750 842
          $def .= "    if self.$colName != None:\n".
751 843
                  "      newEl = doc.createElement('$colName')\n".
......
832 924
      #Need to explicitly convert to string so minidom doesn't
833 925
      #roll over in nasty convulsions
834 926
      $randomFun = "str($randomFun())";
927

  
835 928
      if(preg_match("/^attr_/",$colName,$matches) > 0) {
836 929
        $nodeName = preg_replace("/^attr_/","",$colName);
837 930
        $def .= "    newAttr = doc.createAttribute('$nodeName')\n".
......
852 945
      $colDef = $this->references[$colName];
853 946

  
854 947
      if(preg_match("/(ForeignKey\(')([a-zA-Z]*)/",$colDef,$matches) > 0 &&
855
         preg_match("/unique/",$colDef) > 0) {
948
         (preg_match("/Complex one2Many/",$colDef) > 0 || preg_match("/_extend/",$colName) > 0)) {
856 949
        if(preg_match("/_extend/",$colName) == 0) {
857 950
          $def .= "    if '$matches[2]' not in usedObjectsStack:\n".
858 951
                  "      usedObjectsStack.append('$matches[2]')\n".
......
901 994
    return $def;
902 995
  }
903 996

  
997
  public function makeRetrieveOrNewFunction() {
998
    global $idSysScope;
999
    global $idExtend;
1000
    global $adHoc;
1001
    global $adHocAttr;
1002

  
1003
    $tName = $this->tableName;
1004
    $def = "  def retrieveOrNew(self,node):\n";
1005

  
1006
    if($idExtend[$tName] != '' || $idSysScope[$tName] != ''){
1007
      $extendedId = '';
1008
      if($idExtend[$tName] != '') {$extendedId = $idExtend[$tName] . "__";}
1009
      $def .= "    a_id = None\n".
1010
              "    a_system = None\n".
1011
              "    a_scope = None\n".
1012
              "    for attr in node.attributes.keys():\n".
1013
              "      aVal = node.attributes[attr].nodeValue\n".
1014
              "      if attr == 'id':\n".
1015
              "        a_id = aVal\n".
1016
              "      elif attr == 'system':\n".
1017
              "        a_system = aVal\n".
1018
              "      elif attr == 'scope':\n".
1019
              "        a_scope = aVal\n".
1020
              "    if a_id != None:\n".
1021
              "      q = $tName.objects.filter($extendedId" . "attr_id__exact = a_id)\n".
1022
              "      if a_system != None:\n".
1023
              "        q = q.filter($extendedId" . "attr_system__exact = a_system)\n".
1024
              "      if a_scope != None:\n".
1025
              "        q = q.filter($extendedId" . "attr_scope__exact = a_scope)\n".
1026
              "      if len(q) > 0:\n".
1027
              "        return q[0]\n".
1028
              "      else:\n".
1029
              "        return $tName()\n".
1030
              "    else:\n".
1031
              "      return $tName()\n";
1032
    } else if($adHoc[$tName] != '') {
1033
      $def .= handleAdHoc($tName);
1034
    } else if($adHocAttr[$tName] != '') {
1035
      $def .= handleAdHocAttr($tName);
1036
    } else {
1037
      $def .= "    return $tName()\n";
1038
    }
1039
    return $def;
1040
  }
1041

  
904 1042
  public function makeSetupTestFunction() {
905 1043
    if(isPrimitiveType($this->tableName)) { return ""; }
906 1044

  
makeVegxModel/trunk/objects/lookups.php
1
<?php
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff