Skip to content

Commit dd5d64e

Browse files
committed
Added example models
1 parent 8cdfbc5 commit dd5d64e

File tree

2 files changed

+377
-0
lines changed

2 files changed

+377
-0
lines changed

examples/Contact.js

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
var package = "com.example.models";
2+
var models = {
3+
4+
//**************************************************************************
5+
//** Person
6+
//**************************************************************************
7+
/** Used to represent an individual.
8+
*/
9+
Person: {
10+
fields: [
11+
{name: 'gender', type: 'string'}, //M,F
12+
{name: 'birthday', type: 'int'}, //yyyymmdd
13+
{name: 'info', type: 'json'}
14+
],
15+
hasMany: [
16+
{model: 'Name', name: 'names'},
17+
{model: 'Phone', name: 'phoneNumbers'},
18+
{model: 'Email', name: 'emails'},
19+
{model: 'Address', name: 'addresses'}
20+
],
21+
constraints: [
22+
{name: 'names', required: true},
23+
{name: 'gender', length: 1}
24+
]
25+
},
26+
27+
28+
//**************************************************************************
29+
//** Name
30+
//**************************************************************************
31+
/** Used to represent a name of a person or place
32+
*/
33+
Name: {
34+
fields: [
35+
{name: 'name', type: 'string'},
36+
{name: 'primary', type: 'boolean'}
37+
],
38+
constraints: [
39+
{name: 'name', required: true, length: 75}
40+
]
41+
},
42+
43+
44+
//**************************************************************************
45+
//** Phone
46+
//**************************************************************************
47+
/** Used to represent a phone number.
48+
*/
49+
Phone: {
50+
fields: [
51+
{name: 'number', type: 'string'},
52+
{name: 'type', type: 'string'}, //home, mobile, work
53+
{name: 'primary', type: 'boolean'} //is primary phone?
54+
],
55+
constraints: [
56+
{name: 'number', required: true, length: 20},
57+
{name: 'type', length: 15}
58+
]
59+
},
60+
61+
62+
//**************************************************************************
63+
//** Physical Address
64+
//**************************************************************************
65+
/** Used to represent a physical address.
66+
*/
67+
Address: {
68+
fields: [
69+
{name: 'type', type: 'string'}, //home, work, etc
70+
{name: 'street', type: 'string'},
71+
{name: 'city', type: 'string'},
72+
{name: 'state', type: 'string'},
73+
{name: 'postalCode', type: 'string'},
74+
{name: 'coordinates', type: 'geo'},
75+
{name: 'primary', type: 'boolean'}
76+
]
77+
},
78+
79+
80+
//**************************************************************************
81+
//** Email Address
82+
//**************************************************************************
83+
/** Used to represent an email address.
84+
*/
85+
Email: {
86+
fields: [
87+
{name: 'type', type: 'string'}, //personal, work, etc.
88+
{name: 'address', type: 'string'}, //name@server.com
89+
{name: 'primary', type: 'boolean'} //is primary email?
90+
],
91+
constraints: [
92+
{name: 'address', required: true}
93+
]
94+
}
95+
96+
};

examples/Photos.js

+281
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
var package = "javaxt.photos";
2+
var models = {
3+
4+
//**************************************************************************
5+
//** Contact
6+
//**************************************************************************
7+
/** Used to represent an individual or company.
8+
*/
9+
Contact: {
10+
fields: [
11+
{name: 'id', type: 'int'},
12+
{name: 'firstName', type: 'string'},
13+
{name: 'lastName', type: 'string'},
14+
{name: 'fullName', type: 'string'},
15+
{name: 'gender', type: 'string'},
16+
{name: 'dob', type: 'string'},
17+
{name: 'lastModified', type: 'date'}
18+
],
19+
hasMany: [
20+
{model: 'Phone', name: 'phoneNumbers'},
21+
{model: 'Email', name: 'emails'},
22+
{model: 'Address', name: 'addresses'},
23+
{model: 'Alias', name: 'aliases'}
24+
]
25+
},
26+
27+
28+
//**************************************************************************
29+
//** Phone
30+
//**************************************************************************
31+
/** Used to represent a contact's phone number.
32+
*/
33+
Phone: {
34+
fields: [
35+
{name: 'number', type: 'string'},
36+
{name: 'type', type: 'string'}, //home, mobile, work
37+
{name: 'primary', type: 'boolean'} //is primary phone?
38+
]
39+
},
40+
41+
42+
//**************************************************************************
43+
//** Physical Address
44+
//**************************************************************************
45+
/** Used to represent a contact's physical address.
46+
*/
47+
Address: {
48+
fields: [
49+
{name: 'type', type: 'string'}, //home, work, etc
50+
{name: 'street', type: 'string'},
51+
{name: 'city', type: 'string'},
52+
{name: 'state', type: 'string'},
53+
{name: 'postalCode', type: 'string'},
54+
{name: 'coordinates', type: 'geo'},
55+
{name: 'primary', type: 'boolean'} //is principle address?
56+
]
57+
},
58+
59+
60+
//**************************************************************************
61+
//** Email Address
62+
//**************************************************************************
63+
/** Used to represent an email address.
64+
*/
65+
Email: {
66+
fields: [
67+
{name: 'type', type: 'string'}, //personal, work, etc.
68+
{name: 'address', type: 'string'}, //name@server.com
69+
{name: 'primary', type: 'boolean'} //is primary email?
70+
],
71+
constraints: [
72+
{name: 'address', required: true}
73+
]
74+
},
75+
76+
77+
//**************************************************************************
78+
//** Alias
79+
//**************************************************************************
80+
/** Used to represent an alias associated with a contact.
81+
*/
82+
Alias: {
83+
fields: [
84+
{name: 'name', type: 'string'}
85+
],
86+
constraints: [
87+
{name: 'name', required: true, length: 255, unique: true}
88+
]
89+
},
90+
91+
92+
//**************************************************************************
93+
//** UserAccount
94+
//**************************************************************************
95+
UserAccount: {
96+
fields: [
97+
{name: 'username', type: 'string'},
98+
{name: 'password', type: 'password'},
99+
{name: 'accessLevel', type: 'int'},
100+
{name: 'active', type: 'boolean'},
101+
{name: 'contact', type: 'Contact'},
102+
{name: 'auth', type: 'json'}
103+
],
104+
constraints: [
105+
{name: 'username', required: true, length: 255, unique: true},
106+
{name: 'password', required: true},
107+
{name: 'active', required: true}
108+
],
109+
defaults: [
110+
{name: 'active', value: true}
111+
]
112+
},
113+
114+
115+
//**************************************************************************
116+
//** Path
117+
//**************************************************************************
118+
Path: {
119+
fields: [
120+
{name: 'dir', type: 'string'},
121+
{name: 'host', type: 'Host'},
122+
{name: 'lastIndexed', type: 'date'}
123+
],
124+
constraints: [
125+
{name: 'dir', required: true}
126+
]
127+
},
128+
129+
130+
//**************************************************************************
131+
//** Host
132+
//**************************************************************************
133+
Host: {
134+
fields: [
135+
{name: 'name', type: 'string'},
136+
{name: 'description', type: 'string'},
137+
{name: 'metadata', type: 'json'}
138+
]
139+
},
140+
141+
142+
//**************************************************************************
143+
//** File
144+
//**************************************************************************
145+
File: {
146+
fields: [
147+
{name: 'name', type: 'string'},
148+
{name: 'description', type: 'string'},
149+
{name: 'path', type: 'Path'},
150+
{name: 'type', type: 'string'}, //photo, video, etc
151+
{name: 'date', type: 'date'},
152+
{name: 'size', type: 'long'},
153+
{name: 'location', type: 'geo'},
154+
{name: 'metadata', type: 'json'}
155+
],
156+
hasMany: [
157+
{model: 'Rating', name: 'ratings'},
158+
{model: 'Keyword', name: 'keywords'},
159+
{model: 'Face', name: 'faces'},
160+
{model: 'Access', name: 'accesses'}
161+
],
162+
constraints: [
163+
{name: 'name', required: true},
164+
{name: 'path', required: true}
165+
]
166+
},
167+
168+
169+
//**************************************************************************
170+
//** Rating
171+
//**************************************************************************
172+
Rating: {
173+
fields: [
174+
{name: 'user', type: 'UserAccount'},
175+
{name: 'rating', type: 'int'},
176+
{name: 'comment', type: 'string'},
177+
{name: 'date', type: 'date'}
178+
]
179+
},
180+
181+
182+
//**************************************************************************
183+
//** Keyword
184+
//**************************************************************************
185+
Keyword: {
186+
fields: [
187+
{name: 'keyword', type: 'string'},
188+
{name: 'category', type: 'string'}
189+
]
190+
},
191+
192+
193+
//**************************************************************************
194+
//** Face
195+
//**************************************************************************
196+
/** Used to represent a face extracted from a photo.
197+
*/
198+
Face: {
199+
fields: [
200+
{name: 'coordinates', type: 'string'},
201+
{name: 'contact', type: 'Contact'},
202+
{name: 'metadata', type: 'json'}
203+
]
204+
},
205+
206+
207+
//**************************************************************************
208+
//** Access
209+
//**************************************************************************
210+
/** Used to log access to individual files.
211+
*/
212+
Access: {
213+
fields: [
214+
{name: 'type', type: 'string'}, //view, download, share, etc
215+
{name: 'user', type: 'UserAccount'},
216+
{name: 'date', type: 'date'},
217+
{name: 'metadata', type: 'json'}
218+
]
219+
},
220+
221+
222+
//**************************************************************************
223+
//** Place
224+
//**************************************************************************
225+
/** Used to represent a location on the earth. Can be used to represent a
226+
* descrete location such as a GPS point, a route, an area (e.g. park,
227+
* country, state, etc).
228+
*/
229+
Place: {
230+
fields: [
231+
{name: 'name', type: 'string'},
232+
{name: 'description', type: 'string'},
233+
{name: 'location', type: 'geo'}
234+
]
235+
},
236+
237+
238+
//**************************************************************************
239+
//** Album
240+
//**************************************************************************
241+
/** A collection of photos, videos, documents, etc.
242+
*/
243+
Album: {
244+
fields: [
245+
{name: 'name', type: 'string'},
246+
{name: 'description', type: 'string'},
247+
{name: 'place', type: 'Place'},
248+
{name: 'parent', type: 'Album'}
249+
],
250+
hasMany: [
251+
{model: 'Item', name: 'items'},
252+
{model: 'Privilege', name: 'users'}
253+
]
254+
},
255+
256+
257+
//**************************************************************************
258+
//** Item
259+
//**************************************************************************
260+
/** Used to represent an individual item in an Album.
261+
*/
262+
Item: {
263+
fields: [
264+
{name: 'file', type: 'File'},
265+
{name: 'index', type: 'long'}
266+
]
267+
},
268+
269+
270+
//**************************************************************************
271+
//** Privilege
272+
//**************************************************************************
273+
Privilege: {
274+
fields: [
275+
{name: 'user', type: 'UserAccount'},
276+
{name: 'edit', type: 'boolean'},
277+
{name: 'share', type: 'boolean'}
278+
]
279+
}
280+
281+
};

0 commit comments

Comments
 (0)