1   package hudsonfog.voc.model;
2   
3   import com.fogx.webdav.DavResource;
4   import com.fogx.webdav.DavClass;
5   import com.fogx.webdav.DavBean;
6   import com.fogx.webdav.DavProperty;
7   import static com.fogx.webdav.DavProperty.*;
8   import com.fogx.webdav.packages.DavBeanPackage;
9   import com.fogx.webdav.util.DavResourceSupport;
10  import com.fogx.webdav.util.UrlUtil;
11  import java.util.Date;
12  import java.util.Map;
13  import java.util.HashMap;
14  import java.util.List;
15  import java.util.Collections;
16  import java.util.Arrays;
17  
18  import hudsonfog.voc.system.changeHistory.*;
19  import hudsonfog.voc.model.company.*;
20  import hudsonfog.voc.system.readHistory.*;
21  import hudsonfog.voc.system.classusage.*;
22  import hudsonfog.voc.media.gallery.*;
23  import hudsonfog.voc.model.accounting.*;
24  import hudsonfog.voc.system.behavior.*;
25  import hudsonfog.voc.model.portal.*;
26  import hudsonfog.voc.finance.banking.*;
27  import hudsonfog.voc.system.parse.*;
28  import hudsonfog.voc.system.identity.*;
29  import hudsonfog.voc.model.work.*;
30  import hudsonfog.voc.model.crm.*;
31  import hudsonfog.voc.classifieds.jobs.*;
32  import hudsonfog.voc.system.primitiveTypes.*;
33  import hudsonfog.voc.model.delivery.*;
34  import hudsonfog.voc.system.scheduler.*;
35  import hudsonfog.voc.model.workflow.*;
36  import hudsonfog.voc.system.security.*;
37  import hudsonfog.voc.system.XMLSchema.*;
38  
39  import hudsonfog.voc.system.fog.*;
40  
41  
42  public abstract class company {
43  
44    /**
45   * A Party - person or an organization
46   */
47    public static class Party {
48           @_backLink("party")
49           public PartyAddress[]                addresses;
50           @_maxSize(250)
51           public String                        name;
52    }
53  
54    @DavClass._copyByReference
55    public static class Organization extends Party implements Address {
56      @k@s public String                        name;
57           @_maxSize(10)
58           public String                        nickName;
59        @c public String                        postalCode; //* Zip code or Postal code
60        @c public String                        address1; //* street address, building number, PO Box, etc.
61        @c public String                        address2; //* second part of address string
62        @c public String                        city; //* city, town, village, township
63        @c public String                        region; //* state, province, territory or other country subdivision
64        @c public Country                       country;
65           @_readOnly
66           public Contact                       submittedBy = writeJS("submittedBy ? submittedBy : getRequest().getHeader('hudsonfog.bulk-operations') ? submittedBy : getContact()");
67    }
68  
69    @DavClass._icon("icons/classes/Money.gif")
70    @DavClass._alwaysInlined
71    public static class Money {
72           @_mainValue
73           @_scale(2)
74           public Float                         value;
75           @_maxSize(3)
76           public String                        currency;
77    }
78  
79    @DavClass._uniquePropertySet("name, registeredOrganization")
80    @DavClass._gridCols("name, contacts")
81    @DavClass._skipAccessControl
82    public static class ExternalOrganization extends Organization {
83           @_displayNameElm
84           @_alphabeticIndex
85      @k@s public String                        name;
86           @_maxSize(200)
87           public String                        longName;
88           @_maxSize(1000)
89           public href                          logoIcon;
90           @_backLink("organization")
91           @_dataLocationPortal
92           public Contact[]                     contacts;
93           @_displayNameElm
94        @s public String                        city;
95           @_displayNameElm
96        @s public Country                       country;
97           @_showAllOrganizations
98           @_dataLocationIndexServer
99           public ExternalOrganization          registeredOrganization;
100          @_maxSize(40)
101          @_label("VAT ID")
102          public String                        vatCode;
103          @_label("VAT percent")
104          public Percent                       vatPercent;
105          public String                        taxId;
106          @_label("Tel")
107          public phone                         phone;
108          @_maxSize(100)
109          @_icon("icons/fax.gif")
110          public String                        fax;
111          @_allowRoles("owner")
112          public Contact                       billToContact;
113          @_allowRoles("owner")
114          public BankAccount                   billToBankAccount; //* it is not this company account it is account of the company this company has to pay bills to
115   }
116 
117   @DavClass._dataLocationIndexServer(false)
118   public static class Company extends ExternalOrganization {
119          @_alphabeticIndex
120     @k@s public String                        name;
121   }
122 
123   public static class InternalOrganization extends Organization {
124          @_displayNameElm
125     @k@s public String                        name;
126       @k public ExternalOrganization          within;
127          @_backLink("organization")
128          public AccountingPeriod[]            accountingPeriods;
129          @_backLink("organization")
130          public OrganizationGlAccount[]       GLAccounts;
131          public OrganizationType              organizationType;
132   }
133 
134   public static enum OrganizationType {
135     department, branch, group;
136   }
137 
138   @DavClass._aView
139   @DavClass._where("organizationType == 'department'")
140   @DavClass._filterView
141   public static class Department extends InternalOrganization {
142          @_displayNameElm
143       @s public String                        name;
144       @s public ExternalOrganization          within;
145          @_backLink("organization")
146     @h@s public AccountingPeriod[]            accountingPeriods;
147          @_backLink("organization")
148     @h@s public OrganizationGlAccount[]       GLAccounts;
149     @h@s public OrganizationType              organizationType;
150     @h@s public String                        nickName;
151     @h@s public String                        postalCode;
152     @h@s public String                        address1;
153     @h@s public String                        address2;
154     @h@s public String                        city;
155     @h@s public String                        region;
156     @h@s public Country                       country;
157     @h@s public Contact                       submittedBy;
158          @_backLink("party")
159     @h@s public PartyAddress[]                addresses;
160   }
161 
162   @DavClass._aView
163   @DavClass._where("organizationType == 'branch'")
164   @DavClass._filterView
165   public static class Branch extends InternalOrganization {
166          @_displayNameElm
167       @s public String                        name;
168       @s public ExternalOrganization          within;
169          @_backLink("organization")
170     @h@s public AccountingPeriod[]            accountingPeriods;
171          @_backLink("organization")
172     @h@s public OrganizationGlAccount[]       GLAccounts;
173     @h@s public OrganizationType              organizationType;
174     @h@s public String                        nickName;
175     @h@s public String                        postalCode;
176     @h@s public String                        address1;
177     @h@s public String                        address2;
178     @h@s public String                        city;
179     @h@s public String                        region;
180     @h@s public Country                       country;
181     @h@s public Contact                       submittedBy;
182          @_backLink("party")
183     @h@s public PartyAddress[]                addresses;
184   }
185 
186   /*
187 class Person extends Party implements PersonIdentifier p1 {
188 //  !int                                         partyId :: partyId;
189   #string                                      lastName      :: p1.lastName;
190      -displayNameElm : true;
191   #string                                      firstName     :: p1.firstName;
192      -displayNameElm : true;
193 
194    string                                      middleName    :: p1.middleName;
195    Title                                       personalTitle :: p1.personalTitle;
196    string                                      suffix        :: p1.suffix;
197    Sex                                         sex           :: p1.sex;
198    p.ExternalFile                              photo         :: p1.photo;
199 
200    string                                      nickname      :: p1.nickName;
201    date                                        birthDate;
202    string(5)                                   height;
203 //   kg                                          weight;
204    string(40)                                  previousLastName;
205    string(40)                                  mothersMaidenName;
206    string(1)                                   maritalStatus;
207    string(12)                                  socialSecurityNo;
208    string(20)                                  passportNo;
209    date                                        passportExpireDate;
210    float                                       totalYearsWorkExperience;
211    string(2000)                                personalComment;
212 }
213 
214 class UnqualifiedPerson, "Person" extends Person {
215   #int                                         personId;
216     -autoincrement: true;
217 
218    string                                      lastName      :: lastName;
219      -displayNameElm : true;
220    string                                      firstName     :: firstName;
221      -displayNameElm : true;
222 }
223 */
224   @DavClass._avoidIndexing
225   public static class B2bRelationship extends PartyRelationship {
226     @k@s public ExternalOrganization          from;
227          @_displayNameElm
228     @k@s public ExternalOrganization          to;
229     @k@s public String                        role;
230       @k public DavClass                      forClass;
231       @s public Long                          fromDate;
232       @s public Long                          thruDate;
233   }
234 
235   @DavClass._avoidIndexing
236   @DavClass._skipAccessControl
237   public static class B2bRelationshipReplica {
238       @k public ExternalOrganization          owner;
239       @k public ExternalOrganization          from;
240       @k public ExternalOrganization          to;
241       @k public String                        role;
242       @k public DavClass                      forClass;
243          public Long                          fromDate;
244          public Long                          thruDate;
245   }
246 
247   @DavClass._cachable
248   public static class PartyRelationship implements GenericMessageAccount {
249          @_cloneOf("organization")
250     @k@c public Party                         from;
251          @_displayNameElm
252       @k public Party                         to;
253          @_maxSize(25)
254       @k public String                        role;
255          @_readOnly
256          public Long                          fromDate = writeJS("fromDate ? fromDate : new Date().getTime()"); //* effective date
257          @_allowRoles("admin")
258          public Long                          thruDate; //* inactive after this date
259          public PartyRelationshipStatus       status;
260          @_maxSize(1000)
261          public String                        comment;
262   }
263 
264   @DavClass._avoidIndexing
265   public static class OrgRelationship extends PartyRelationship {
266     @k@s public ExternalOrganization          from;
267          @_displayNameElm
268     @k@s public ExternalOrganization          to;
269     @k@s public String                        role;
270   }
271 
272   @DavClass._aView
273   @DavClass._viewCols("to, fromDate, thruDate, status, industry")
274   @DavClass._where("role == 'client'")
275   @DavClass._filterView
276   public static class Client extends B2bRelationship {
277          @_subPropertyOf("from")
278       @s public ExternalOrganization          customerOf;
279          @_displayNameElm
280          @_subPropertyOf("to")
281       @s public ExternalOrganization          customerDetails;
282       @s public Long                          fromDate;
283       @s public Long                          thruDate;
284       @s public PartyRelationshipStatus       status;
285          @_subPropertyOf("comment")
286       @s public String                        industry;
287     @h@s public String                        role;
288     @h@s public DavClass                      forClass;
289   }
290 
291   @DavClass._aView
292   @DavClass._viewCols("to, fromDate, thruDate, status, products")
293   @DavClass._where("role == 'supplier'")
294   @DavClass._filterView
295   public static class Supplier extends OrgRelationship {
296          @_subPropertyOf("from")
297       @s public ExternalOrganization          supplierOf;
298          @_displayNameElm
299          @_subPropertyOf("to")
300       @s public ExternalOrganization          supplierDetails;
301       @s public Long                          fromDate;
302       @s public Long                          thruDate;
303       @s public PartyRelationshipStatus       status;
304          @_subPropertyOf("comment")
305       @s public String                        products;
306     @h@s public String                        role;
307   }
308 
309   public static enum PartyRelationshipStatus {
310     active, inactive, pending, terminated;
311   }
312 
313   /**
314  * Method by which a person can be contacted
315  */
316   public static interface ContactMethod {
317          @_icon("icons/email.gif")
318          public emailAddress                  email = null;
319          @_icon("icons/mobileEmail.gif")
320          public emailAddress                  mobilePhoneEmail = null;
321          @_icon("icons/email-additional.gif")
322          public emailAddress                  additionalEmail = null;
323          @_maxSize(100)
324          @_icon("icons/phone.gif")
325          public phone                         directWorkPhone = null;
326          @_maxSize(100)
327          @_icon("icons/operator.gif")
328          public phone                         generalOfficePhone = null; //* office operator
329          @_maxSize(100)
330          @_icon("icons/personalPhone.gif")
331          public phone                         personalPhone = null;
332          @_maxSize(100)
333          @_icon("icons/mobilePhone.gif")
334          public mobilePhone                   mobilePhone = null;
335          @_maxSize(100)
336          @_icon("icons/fax.gif")
337          public String                        fax = null;
338          public ContactMethod                 mainContactMethod = null;
339          @_backLink("mainContactMethod")
340          public ContactMethod[]               otherContactMethods = null;
341   }
342 
343   /**
344  * A person that is a contact for some organization
345  */
346   @DavClass._viewCols("firstName, lastName, nickName, organization, email, directWorkPhone, mobilePhone, issuesAssignedToMe, myProjects, myAssignments, myTodo")
347   @DavClass._largeIcon("icons/classes/Contact-large.gif")
348   @DavClass._copyByReference
349   @DavClass._showTreeControlInView
350   @DavClass._allowReadWhere("organization == 'owner'")
351   @DavClass._resourceIcon("organization.logoIcon")
352   @DavClass._delegatedAccessControl
353   @DavClass._icon("icons/classes/Contact.gif")
354   @DavClass._nmbGroupColsInEditMode(2)
355   public static class Contact extends PartyRelationship implements PersonIdentifier, ContactMethod, Annotated, Address1 {
356          @_sortAscending
357          @_showAllOrganizations
358          @_subPropertyOf("from")
359     @k@s public ExternalOrganization          organization = writeJS("location ? location.party : organization"); //* organization this person represents
360          @_allowRoles("admin")
361     @k@s public ContactRole                   role = writeJS("role == null ? 'contact' : role"); //* person's role towards this web site
362          @_where("party == organization")
363          @_onCreate
364          public HostCompanyAddress            location;
365          @_displayNameElm
366          @_avoidEnumValidation
367          @_cloneOf("personalTitle")
368       @c public Title                         prefix; //* like Phd., Esq., Junior, Senior, I, II, III, etc.
369          @_propertyGroupList("firstName, middleName, lastName, nickName, gender")
370          @_abstract
371          @_propertyGroup("true")
372          public Boolean                       personal;
373          @_displayNameElm
374          @_alphabeticIndex
375     @k@c public String                        lastName;
376          @_displayNameElm
377     @k@c public String                        firstName;
378       @c public String                        middleName;
379          @_maxSize(100)
380          @_displayNameShort
381          @_cloneOf("nickname")
382       @c public String                        nickName;
383          @_cloneOf("sex")
384       @c public Sex                           gender = writeJS("getSex()");
385          @_propertyGroupList("personalPhone, mobilePhone, directWorkPhone, generalOfficePhone, fax, email, mobilePhoneEmail, additionalEmail")
386          @_abstract
387          @_propertyGroup("true")
388          public Boolean                       contactInfo;
389       @c public emailAddress                  email;
390       @c public emailAddress                  mobilePhoneEmail;
391       @c public emailAddress                  additionalEmail;
392          @_maxDisplayInplace(5)
393          @_backLink("contact")
394          @_cloneOf("otherContactMethods")
395       @c public ContactEmail[]                otherEmails;
396       @c public phone                         generalOfficePhone; //* office operator or switchboard
397       @c public phone                         directWorkPhone;
398       @c public phone                         personalPhone;
399       @c public mobilePhone                   mobilePhone;
400       @c public String                        fax;
401          @_icon("icons/classes/ContactPhone.gif")
402          @_maxDisplayInplace(5)
403          @_backLink("contact")
404          @_cloneOf("otherContactMethods")
405       @c public ContactPhone[]                otherPhones;
406          @_label("Address")
407          @_propertyGroupList("address1, address2, city, region, postalCode, country")
408          @_abstract
409          @_propertyGroup("true")
410          public Boolean                       addressGroup;
411          @_cloneOf("country1")
412       @c public Country                       country;
413          public Country                       numberFormat = writeJS("numberFormat ? numberFormat : (country != null ? country : numberFormat)");
414          @_avoidDisplaying
415          public String                        numberFormatCode = formula("numberFormat.code");
416          @_cloneOf("region1")
417       @c public String                        region;
418          @_cloneOf("city1")
419       @c public String                        city; //* city, town, village, township
420          @_cloneOf("postalCode1")
421       @c public String                        postalCode;
422          @_cloneOf("address11")
423       @c public String                        address1; //* street address, building number, PO Box, etc.
424          @_cloneOf("address21")
425       @c public String                        address2; //* second part of address string
426     @h@s public Party                         to;
427          @_readOnly
428          @_where("percentComplete != 100")
429          @_backLink("contact")
430          @_allowRoles("owner,self")
431          public TaskAssignment[]              myAssignments; //* assignments to Tasks in Projects
432          @_readOnly
433          @_backLink("contact")
434          @_allowRoles("owner,self")
435          public MyProject[]                   myProjects; //* projects in which this Contact participates
436          @_readOnly
437          @_backLink("contact")
438          @_allowRoles("owner,self")
439          public TimeEntryPerMessage[]         workflowTimeEntries; //* Those granular time entries are per each message in inbox or outbox (sent). To add - find a message first.
440          @_backLink("contact")
441          @_allowRoles("owner,self")
442          public TimeEntry[]                   myTimeEntries; //* TIme entries related to some work efforts.
443          @_backLink("creator")
444          public Dashboard[]                   myDashboards;
445          @_backLink("recepient")
446          @_allowRoles("self")
447          public ScheduledReport[]             myScheduledReports;
448          @_backLink("owner")
449          @_allowRoles("admin")
450          public UserJob[]                     mySystemJobs;
451          @_readOnly
452          @_sortAscending(false)
453          @_backLink("submitter")
454          public Comment[]                     commentsSubmittedByMe;
455          @_where("percentWorkComplete != 100")
456          @_backLink("assignedTo")
457          public Todo[]                        myTodo;
458          @_readOnly
459          @_backLink("submittedBy")
460          public Issue[]                       submittedByMe;
461          @_readOnly
462          @_where("status != 'Closed'")
463          @_backLink("assignedTo")
464          @_allowRoles("owner,self")
465          public Issue[]                       issuesAssignedToMe;
466          @_backLink("belongsTo")
467          @_allowRoles("self")
468          public MessageFolder[]               customFolders;
469          @_avoidDisplayingInControlPanel
470          @_backLink("to")
471          @_allowRoles("self")
472          public IncomingMessage[]             inbox; //* my inbox - where I receive all workflow and email messages
473          @_where("markedAsRead == false")
474          @_avoidDisplayingInControlPanel
475          @_backLink("to")
476          @_allowRoles("self")
477          public IncomingMessage[]             unread; //* unread messages in my inbox
478          @_readOnly
479          @_avoidDisplaying
480          @_allowRoles("self")
481          public Integer                       unreadCount = writeJS("getThisChange().inbox ? unread.COUNT() : unreadCount");
482          @_avoidDisplayingInControlPanel
483          @_backLink("sender")
484          @_allowRoles("self")
485          public IncomingMessage[]             sent;
486          @_where("markedAsRead == false")
487          @_avoidDisplayingInControlPanel
488          @_backLink("sender")
489          @_allowRoles("self")
490          public IncomingMessage[]             sentUnread;
491          @_maxDisplayInplace(5)
492          @_backLink("contact")
493          @_allowRoles("admin,self")
494          public User[]                        myScreenNames; //* my user ids to login into the system
495          @_where("subscribed == true")
496          @_backLink("owner")
497          public MySubscription[]              mySubscriptions;
498          @_backLink("contact")
499          @_allowRoles("owner,self")
500          public MyMeeting[]                   myMeetings;
501          @_readOnly
502          @_where("accepted != true")
503          @_backLink("to")
504          @_allowRoles("self")
505          public InvitationAlert[]             pendingInvitations; //* invitations that I did not yet accept
506          @_backLink("owner")
507          @_allowRoles("self")
508          public MyWatch[]                     myWatches;
509          @_avoidDisplayingInControlPanel
510          @_backLink("creator")
511          public Bookmark[]                    myBookmarks; //* my personal bookmarks
512          @_oldName("url")
513       @c public String                        attachmentsUrl;
514          @_backLink("forResource")
515          @_allowRoles("self")
516          @_cloneOf("attachments")
517       @c public ExternalFile[]                myFiles;
518          @_avoidDisplayingInControlPanel
519          @_backLink("sender")
520          public Photo[]                       myPhotos;
521          @_label("My SL Postcards")
522          @_backLink("sender")
523       @h public SL[]                          mySLPostcards;
524          @_sortAscending(false)
525          @_backLink("forum")
526          @_allowRoles("self")
527          @_displayInline
528          @_cloneOf("comments")
529       @c public Annotation[]                  notes;
530          @_allowRoles("self")
531          @_cloneOf("lastComment")
532       @c public Annotation                    lastNote;
533          @_dateFormat("~MMM-dd, yyyy HH:mm")
534          @_readOnly
535          @_allowRoles("self")
536          public ComplexDate                   lastNoteTime = formula("lastNote.submitTime");
537          @_backLink("contact")
538          @_allowRoles("self")
539          public TrackedRead[]                 myViewingHistory;
540          @_backLink("person")
541          @_allowRoles("self, admin")
542          public Resume[]                      resumes; //* my resumes (each resume is designed to meet qualifications of a certain Job/Position)
543          @_backLink("person")
544          @_allowRoles("self, admin")
545          public CoverLetter[]                 coverLetters; //* my cover letters (when applying for a Job choose an appropriate cover letter from this list)
546          @_backLink("applicant")
547          @_allowRoles("self, admin")
548          public JobApplication[]              jobApplications; //* my applications for Jobs
549          @_propertyGroupList("notificationMode, sendShortcut, autoStartChat, soundViaApplet, chatSoundPresent, onlineStatus")
550          @_abstract
551          @_allowRoles("admin")
552          @_propertyGroup("true")
553          public Boolean                       chatOptions; //* @group chatConfiguration
554          @_allowRoles("admin")
555          public NotificationMode              notificationMode = writeJS("(notificationMode == null) ? 'None' : notificationMode"); //* Mechanism by which user is alerted of a new chat message when chat window is hidden behind other applications or its window is minimized
556          @_allowRoles("admin")
557          public SendShortcut                  sendShortcut = writeJS("(sendShortcut == null) ? 'Ctrl-Enter' : sendShortcut"); //* Shortcut for send operation in chat client
558          @_allowRoles("admin")
559          public Boolean                       autoStartChat; //* chat window will automatically pop-up on login if set to true
560          @_allowRoles("admin")
561          public Boolean                       soundViaApplet; //* Java Applet is used for sound if 'yes';
562          @_allowRoles("admin")
563          public Boolean                       chatSoundPresent; //* Java Applet is used for sound if 'yes';;
564          @_backLink("forResource")
565          @_allowRoles("self")
566          @_displayInline
567       @c public ChatHistoryFile[]             chatHistory;
568          @_allowRoles("admin")
569          public OnlineStatus                  onlineStatus = writeJS("(onlineStatus == null) ? 'online' : onlineStatus"); //* online status of the contact
570          public Boolean                       supportGroup; //* defines whether the contact belongs to the support group
571          public ResourceCalendar              calendar;
572          @_avoidDisplayingInSideBar
573          @_avoidDisplaying
574          @_backLink("contact")
575          public ResourceCalendar[]            myCalendars;
576          public Boolean                       sendAlertsToSender; //* If Emailable gets created creator will be notified by email. Default is company specific.
577          @_notSearchable
578          @_backLink("modifiedBy")
579          public Modification[]                myChanges;
580          @_readOnly
581          @_avoidDisplaying
582          public Boolean                       menuMode; // temporary switch from menu to dashboardMenu
583          @_oldName("memeberOfAutologinGroup")
584          @_allowRoles("admin")
585          public Boolean                       memberOfAutologinGroup;
586   }
587 
588   public static enum NotificationMode {
589     None, Focusing, Alert, Popup;
590   }
591 
592   public static enum SendShortcut {
593     @_label("Ctrl-Enter") Ctrl_Enter, Enter;
594   }
595 
596   public static enum OnlineStatus {
597     online, away, dnd, na, offline;
598   }
599 
600   public static enum ContactRole {
601     admin, contact;
602   }
603 
604   public static class ContactByEmail extends Contact {
605     @k@s public emailAddress                  email;
606       @s public ExternalOrganization          organization;
607       @s public ContactRole                   role;
608       @s public Title                         prefix;
609       @s public String                        lastName;
610       @s public String                        firstName;
611          public Contact                       createdBy;
612   }
613 
614   public static class Person extends Contact {
615          @_allowRoles("self, admin")
616       @k public User                          user;
617          @_allowRoles("admin")
618       @s public ContactRole                   role;
619          @_displayNameElm
620       @s public String                        lastName;
621          @_displayNameElm
622       @s public String                        firstName;
623       @s public ExternalOrganization          organization;
624     @h@s public String                        nickName;
625   }
626 
627   @DavClass._abstract
628   public static abstract class ContactAccess {
629          @_readOnly
630          public Integer                       seq;
631       @k public Contact                       contact;
632   }
633 
634   @DavClass._largeIcon("icons/classes/ContactPhone-large.gif")
635   @DavClass._icon("icons/classes/ContactPhone.gif")
636   public static class ContactPhone extends ContactAccess implements TelecomNumber {
637     @k@s public Contact                       contact; //* redefine super's primary keys
638       @c public String                        countryCode;
639       @c public String                        areaCode;
640          @_cloneOf("contactNumber")
641     @k@c public String                        number;
642       @s public Integer                       seq;
643   }
644 
645   public static class ContactMobile extends ContactAccess implements TelecomNumber {
646     @k@s public Contact                       contact; //* redefine super's primary keys
647       @c public String                        countryCode;
648       @c public String                        areaCode;
649          @_cloneOf("contactNumber")
650     @k@c public String                        number;
651       @s public Integer                       seq;
652   }
653 
654   public static class ContactFax extends ContactAccess implements TelecomNumber {
655     @k@s public Contact                       contact; //* redefine super's primary keys
656       @c public String                        countryCode;
657       @c public String                        areaCode;
658          @_cloneOf("contactNumber")
659     @k@c public String                        number;
660       @s public Integer                       seq;
661   }
662 
663   @DavClass._largeIcon("icons/classes/email-large.gif")
664   @DavClass._icon("icons/classes/email.gif")
665   public static class ContactEmail extends ContactAccess implements ElectronicAddress {
666     @k@s public Contact                       contact; //* redefine super's primary keys
667          @_displayNameElm
668          @_cloneOf("value")
669     @k@c public String                        address;
670       @s public Integer                       seq;
671   }
672 
673   @DavClass._label("Address")
674   public static class PartyAddress {
675          @_displayNameElm
676       @k public Party                         party;
677          @_maxSize(50)
678       @k public String                        roleCode;
679          public Long                          fromDate;
680          public Long                          thruDate;
681          @_maxSize(240)
682          public String                        comment;
683   }
684 
685   @DavClass._label("Address")
686   public static class HostPartyAddress extends PartyAddress implements Address {
687          @_displayNameElm
688     @k@s public ExternalOrganization          party;
689     @k@s public String                        roleCode;
690       @c public String                        postalCode; //* Zip code or Postal code
691       @c public String                        address1; //* street address, building number, PO Box, etc.
692       @c public String                        address2; //* second part of address string
693       @c public String                        city; //* city, town, village, township
694       @c public String                        region; //* state, province, territory or other country subdivision
695       @c public Country                       country;
696   }
697 
698   @DavClass._dataLocationIndexServer
699   @DavClass._skipAccessControl
700   public static class HostCompanyAddress extends HostPartyAddress {
701          @_displayNameElm
702     @k@s public ExternalOrganization          party;
703     @k@s public String                        roleCode;
704          @_displayNameElm
705       @s public String                        city;
706          @_displayNameElm
707       @s public Country                       country;
708   }
709 
710   public static class GuestPartyAddress extends PartyAddress {
711          @_displayNameElm
712     @k@s public ExternalOrganization          party;
713     @k@s public String                        roleCode;
714          @_displayNameElm
715       @k public Party                         host;
716          @_maxSize(50)
717          public String                        locationCode;
718   }
719 
720   @DavClass._dataLocationIndexServer
721   public static class GuestCompanyAddress extends GuestPartyAddress {
722          @_displayNameElm
723     @k@s public ExternalOrganization          party;
724     @k@s public String                        roleCode;
725          @_displayNameElm
726     @k@s public ExternalOrganization          host;
727   }
728 
729   public static interface ContactMechanism {
730          @_label("contact mechanism id")
731          @_readOnly
732       @k public Integer                       ide = null;
733   }
734 
735   public static interface TelecomNumber extends ContactMechanism {
736     @h@s public Integer                       ide = null;
737          @_maxSize(10)
738       @k public String                        areaCode = null;
739          @_maxSize(100)
740       @k public String                        contactNumber = null;
741          @_maxSize(5)
742       @k public String                        countryCode = null;
743   }
744 
745   public static interface ElectronicAddress extends ContactMechanism {
746     @h@s public Integer                       ide = null;
747          @_maxSize(100)
748       @k public String                        value = null;
749   }
750 
751   /**
752  * Representative - a person that represents his/her company for a customer or partner
753  */
754   public static class Representative {
755          @_displayNameElm
756       @k public Contact                       contact;
757       @k public ExternalOrganization          representativeForCompany;
758       @k public Area                          area;
759          @_avoidDisplaying
760          public ExternalOrganization          representsCompany = formula("contact.organization");
761   }
762 
763   public static enum Area {
764     sales, marketing, purchasing, @_label("customer support") customerSupport;
765   }
766 
767   @DavClass._dataLocationAdminServer
768   @DavClass._skipAccessControl
769   public static class GeographicBoundary {
770   }
771 
772   public static class City extends GeographicBoundary {
773          @_maxSize(100)
774          @_displayNameElm
775       @k public String                        name;
776          @_maxSize(100)
777          public String                        longName;
778       @k public Region                        within;
779   }
780 
781   public static class Region extends GeographicBoundary {
782          @_maxSize(100)
783          @_displayNameElm
784       @k public String                        name;
785       @k public Country                       within;
786          @_maxSize(10)
787          public String                        code;
788          public Region                        region;
789          public City                          capital;
790   }
791 
792   public static class Country extends GeographicBoundary {
793          @_maxSize(2)
794          public String                        code;
795          @_maxSize(3)
796          @_sortAscending
797          @_displayNameShort
798       @k public String                        altCode;
799          @_maxSize(3)
800          public String                        numberCode;
801          @_maxSize(50)
802          @_displayNameElm
803          public String                        name;
804          @_maxSize(256)
805          public String                        formalName;
806          @_maxSize(256)
807          public String                        comment;
808          @_backLink("within")
809          public Region[]                      regions;
810          @_maxSize(40)
811          public String                        regionName; //* how regions are named in this country - e.g. State, Province
812          @_maxSize(40)
813          public String                        altRegionName; //* how sub-regions are named in this country - e.g. County
814   }
815 
816   public static interface Distance {
817          @_readOnly
818          @_icon("icons/distance.gif")
819          @_enumeration("10, 20, 30, 50, 100")
820          public km                            radius = null; //* ex. within 10 miles from certain zip code
821          @_readOnly
822          @_icon("icons/distance.gif")
823          @_notSearchable
824          @_scale(1)
825          public km                            distance = null; //* distance of this location from the specified zip code
826          @_avoidDisplayingInView
827          @_alwaysReturnToClient
828          @_allowRoles("admin")
829          public Float                         latitude = null;
830          @_avoidDisplayingInView
831          @_alwaysReturnToClient
832          @_allowRoles("admin")
833          public Float                         longitude = null;
834   }
835 
836   public static interface Address extends Distance {
837          @_icon("icons/classes/Country.gif")
838          public Country                       country = null;
839          @_maxSize(25)
840          @_icon("icons/size.gif")
841          @_index
842          public String                        postalCode = null; //* Zip code or Postal code
843          @_maxSize(250)
844          public String                        address1 = null; //* street address, building number, PO Box, etc.
845          @_maxSize(250)
846          public String                        address2 = null; //* second part of address string
847          @_maxSize(100)
848          public String                        city = null; //* city, town, village, township
849          @_maxSize(100)
850          public String                        region = null; //* state, province, territory or other country subdivision
851          @_label("County")
852          @_maxSize(100)
853          public String                        subregion = null; //* county or other subregion
854          @_maxSize(100)
855          @_label("Community/Neighbourhood")
856          public String                        subsubregion = null; //* area within city, county, e.g. Upper East Side, Downtown
857   }
858 
859   @DavClass._lookupFrom("http://www.hudsonfog.com/voc/model/company/GeoLocation")
860   public static interface Address1 extends Address {
861          @_icon("icons/classes/Country.gif")
862          @_subPropertyOf("country")
863       @s public Country                       country1 = null;
864          @_maxSize(25)
865          @_icon("icons/size.gif")
866          @_index
867          @_subPropertyOf("postalCode")
868       @s public String                        postalCode1 = null;
869          @_maxSize(250)
870          @_subPropertyOf("address1")
871       @s public String                        address11 = null; //* street address, building number, PO Box, etc.
872          @_maxSize(250)
873          @_subPropertyOf("address2")
874       @s public String                        address21 = null; //* second part of address string
875          @_maxSize(100)
876          @_subPropertyOf("city")
877       @s public String                        city1 = null; //* city, town, village, township
878          @_maxSize(100)
879          @_subPropertyOf("region")
880       @s public String                        region1 = null;
881          @_maxSize(100)
882          @_subPropertyOf("subregion")
883       @s public String                        subregion1 = null;
884          @_maxSize(100)
885          @_subPropertyOf("subsubregion")
886       @s public String                        subsubregion1 = null;
887   }
888 
889   @DavClass._dataLocationAdminServer
890   @DavClass._skipAccessControl
891   public static class Currency {
892          @_maxSize(3)
893       @k public String                        code;
894          @_maxSize(20)
895       @r public String                        name;
896          @_maxSize(10)
897          public String                        symbol;
898   }
899 
900   @DavClass._largeIcon("icons/classes/CreditCard-large.gif")
901   @DavClass._icon("icons/classes/CreditCard.gif")
902   public static interface CreditCard extends BrowserState {
903          @_maxSize(20)
904          @_readOnly
905          public String                        cardType = formulaJS("getCardType(number)");
906          @_clientScript("onKeyUp: processCreditCardTracks(this)")
907          @_allowRoles("positionTitle==General Manager")
908          @_uiFocus
909          @_maxSize(16)
910          @_alwaysReturnToClient
911          public creditCardNumber              number = writeJS("setCardNumber()"); //* card number
912          @_clientScript("onKeyUp: processCreditCardTracks(this)")
913          public String                        cardholderVerificationCode = null; //*? 3-digit code located on the back of card next to the account number on signature panel. <br> For American Express it is a 4-digit code located on the front of the card, above on left of account number.
914          public expirationDate                expirationDate = null;
915          @_maxSize(200)
916          @_clientScript("onKeyUp: processCreditCardTracks(this)")
917          public String                        nameOnCard = null;
918          @_min(0)
919          @_clientScript("onKeyUp: processCreditCardTracks(this)")
920          public Money                         chargeAmount = null; //* amount of money that will be charged on a credit card
921          @_readOnly
922          public Money                         chargeTaxAmount = null;
923          @_maxSize(100)
924          @_invisibleInput
925          @_parameter
926          public String                        track1 = null; //* track1 on the (magnetic) card
927          @_maxSize(50)
928          @_invisibleInput
929          @_parameter
930          public String                        track2 = null; //* track2 on the (magnetic) card
931   }
932 
933   public static interface CreditCardResponse {
934          @_readOnly
935          public Integer                       responseCode = null; //* this code and reason code are important if transaction failed (assigned by card processor)
936          @_readOnly
937          public Integer                       reasonCode = null; //* this code is important if transaction failed (assigned by card processor)
938          @_maxSize(120)
939          @_readOnly
940          public String                        reasonText = null; //* descripton of the transaction status (assigned by card processor)
941          @_maxSize(6)
942          @_readOnly
943          public String                        authorizationCode = null; //* authorization code of the approved transaction (assigned by card processor)
944          @_maxSize(1)
945          @_readOnly
946          public String                        AVSCode = null;
947          @_maxSize(1)
948          @_readOnly
949          public String                        cardCodeResponse = null; //* (assigned by card processor)
950          @_maxSize(60)
951          @_readOnly
952          public String                        transactionId = null; //* unique transaction id (assigned by card processor)
953          @_readOnly
954          @_invisibleInput
955          public dateTime                      processed = null;
956          @_maxSize(4)
957          @_readOnly
958          @_invisibleInput
959          public String                        terminal = null;
960          @_readOnly
961          @_styleSheet("font-size:200%; color: red; font-weight: bold ")
962          public Boolean                       transactionFailed = null; //* true if this transaction did not go through. See Reason Text for details.
963   }
964 
965   public static interface CardNotPresent {
966   }
967 
968   public static class FixedAsset {
969          @_onCreate
970       @k public String                        assetId = writeJS("assetId != null ? assetId : id");
971          @_autoincrement
972          public Integer                       id;
973          @_maxSize(40)
974          public String                        assetName;
975          public Long                          dateAcquired;
976          public Organization                  manufacturer;
977          public Organization                  previousOwner;
978          public Long                          dateLastServiced;
979          public Long                          dateNextService;
980          public Organization                  organization; //* organization responsible for this asset
981          @_maxSize(40)
982          public String                        description;
983          @_backLink("fixedAsset")
984          public Depreciation[]                depreciations;
985   }
986 
987   public static class Equipment extends FixedAsset {
988          @_subPropertyOf("assetId")
989     @k@s public String                        number;
990   }
991 
992   /**
993  * ResourceBase specifies URI of the server that is a portal for an Organization
994  */
995   @DavClass._avoidIndexing
996   @DavClass._dataLocationIndexServer
997   @DavClass._skipAccessControl
998   public static class ResourceBase {
999       @k public ExternalOrganization          organization;
1000         @_maxSize(200)
1001      @r public String                        urlBase;
1002  }
1003
1004  /********************** Locations **************************/
1005  public static class Location {
1006      @k public Country                       country;
1007         @_maxSize(25)
1008      @k public String                        name;
1009         @_label("State/Province")
1010         public Region                        region;
1011         @_maxSize(100)
1012         public String                        longName;
1013         @_maxSize(100)
1014         public String                        simpleLongName; // e.g. U um-lyaut becomes U
1015         @_maxSize(100)
1016         public String                        altLongName;
1017         @_maxSize(15)
1018      @k public String                        subsidiaryLocation; // areas of a port, different railway stations at the same location, or terminals at the same airport, etc. (N/A if not applicable)
1019         @_maxSize(20)
1020         public String                        geoPosition; // e.g. 3642N 08159W
1021  }
1022
1023  @DavClass._dataLocationAdminServer
1024  @DavClass._skipAccessControl
1025  public static class GeoLocation implements Address {
1026    @k@c public Country                       country;
1027         @_index
1028    @k@c public String                        postalCode; //* Zip code or Postal code
1029         @_label("State")
1030         @_index
1031      @c public String                        region; //* state, province, territory or other country subdivision
1032         @_index
1033      @c public String                        city; //* city, town, village, township
1034         @_index
1035         public Float                         latitude;
1036         @_index
1037         public Float                         longitude;
1038  }
1039
1040  public static interface DataEntry {
1041         public Boolean                       completed = null;
1042         public Contact                       contact = null;
1043         public ComplexDate                   date = null;
1044  }
1045}
1046