DateFactory._pike
Go to the documentation of this file.
1 /* Copyright (C) 2000-2006 Thomas Bopp, Thorsten Hampel, Ludger Merkens
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */
17 inherit "/factories/ObjectFactory";
18 #include <macros.h>
19 #include <classes.h>
20 #include <database.h>
21 #include <assert.h>
22 #include <events.h>
23 #include <attributes.h>
24 #include <types.h>
25 #include <macros.h>
26 class DateFactory : public ObjectFactory{
27 public:
28 
29 
30 // Wir wissen nicht wirklich welche includes werden muessen.
31 
32 
33 private:
34  void init_factory()
35 {
36  ::init_factory();
37 
38 private:
39  init_class_attribute(DATE_KIND_OF_ENTRY, CMD_TYPE_UNKNOWN,
40  "the kind of this entry", 0,
41  EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER,-1);
42 
43 private:
44  init_class_attribute(DATE_IS_SERIAL, CMD_TYPE_INT,
45  "is this entry serial or not", 0,
46  EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER,-1);
47 
48 private:
49  init_class_attribute(DATE_PRIORITY, CMD_TYPE_INT,
50  "the priority of this entry", 0,
51  EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER,-1);
52 
53 private:
54  init_class_attribute(DATE_TITLE, CMD_TYPE_STRING,
55  "the title of this entry", 0,
56  EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER,"");
57 
58 private:
59  init_class_attribute(DATE_DESCRIPTION, CMD_TYPE_STRING,
60  "the description of this entry",
61  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER,"");
62 
63 private:
64  init_class_attribute(DATE_START_TIME, CMD_TYPE_INT, "start time of date",
65  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
66 private:
67  init_class_attribute(DATE_END_TIME, CMD_TYPE_INT, "end time of date",
68  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
69 
70 private:
71  init_class_attribute(DATE_START_DATE, CMD_TYPE_INT, "start date of date",
72  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
73 
74 private:
75  init_class_attribute(DATE_END_DATE, CMD_TYPE_INT, "end date of date",
76  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
77 
78 private:
79  init_class_attribute(DATE_INTERVALL, CMD_TYPE_STRING,
80  "intervall of date (day, week, month, year)",
81  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER,"");
82 
83 private:
84  init_class_attribute(DATE_LOCATION, CMD_TYPE_STRING, "location of date",
85  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER,"");
86 private:
87  init_class_attribute(DATE_WEBSITE, CMD_TYPE_STRING, "website",
88  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER,"");
89 private:
90  init_class_attribute(DATE_NOTICE, CMD_TYPE_STRING, "notice",
91  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER,"");
92 private:
93  init_class_attribute(DATE_TYPE, CMD_TYPE_INT, "type of date",
94  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
95 private:
96  init_class_attribute(DATE_ATTACHMENT, CMD_TYPE_OBJECT, "attachement",
97  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
98 
99 
100 private:
101  init_class_attribute(DATE_PARTICIPANTS, CMD_TYPE_ARRAY, "participating users",
102  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
103 private:
104  init_class_attribute(DATE_ORGANIZERS, CMD_TYPE_ARRAY, "organizing user",
105  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
106 private:
107  init_class_attribute(DATE_ACCEPTED, CMD_TYPE_ARRAY, "accepting users",
108  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
109 private:
110  init_class_attribute(DATE_CANCELLED, CMD_TYPE_ARRAY, "cancelling users",
111  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
112 
113 private:
114  init_class_attribute(DATE_STATUS, CMD_TYPE_INT, "date status",
115  0, EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER, 0);
116 
117 
118 private:
119  init_class_attribute(DATE_RANGE, CMD_TYPE_OBJECT,
120  "an mapping, which includes all the dates informations",
121  0,
122  EVENT_ATTRIBUTES_CHANGE, 0, CONTROL_ATTR_USER,0);
123 
124 }
125 
126 object execute(mapping vars)
127 {
128  object obj;
129  try_event(EVENT_EXECUTE, CALLER, obj);
130  if ( vars->transient ) {
131  if ( mappingp(vars->attributes) )
132  vars->attributes[OBJ_TEMP] = 1;
133  else
134  vars->attributes = ([ OBJ_TEMP : 1 ]);
135  }
136 
137  obj = ::object_create(vars["name"], CLASS_NAME_DATE, 0,
138  vars["attributes"],
139  vars["attributesAcquired"],
140  vars["attributesLocked"],
141  vars["sanction"],
142  vars["sanctionMeta"]);
143 
144  run_event(EVENT_EXECUTE, CALLER, obj);
145 
146  object start = Calendar.Second(vars->start);
147  object end = Calendar.Second(vars->end);
148  if ( objectp(start) && objectp(end) ) {
149  object rangeObject = start->range(end);
150  obj->set_attribute(DATE_RANGE, rangeObject);
151  }
152 }
153 
154 public:
155 
156 
157 string get_identifier() { return "Date.factory"; }
158 string get_class_name() { return CLASS_NAME_DATE;}
159 int get_class_id() { return CLASS_DATE; }
160 
161 void test () {
162 }
163 
164 
165 };