}
public void generateReservations() {
- int days = 10;
+ int days = 30;
String descriptions[] = {
"Picking up guests from airport",
"Sightseeing with the guests",
Container resources = getResources(c);
Collection rIds = resources.getItemIds();
Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
//cal.add(Calendar.DAY_OF_MONTH, -days);
for (int i = 0;i<days;i++) {
for (Iterator rit = rIds.iterator();rit.hasNext();) {
Date start = new Date(cal.getTimeInMillis());
start.setHours(s);
Date end = new Date(cal.getTimeInMillis());
- start.setHours(e);
+ end.setHours(e);
addReservation(resource, 0, start, end, descriptions[(int)Math.floor(Math.random()*descriptions.length)]);
- break;
}
cal.add(Calendar.DAY_OF_MONTH, 1);
}
"w/ company logo. 12m3 storage space.", "Turku",
new Double(60.452171), new Double(22.2995) },
{ "03", "03 Saab 93",
- "Cabriolet<br/>Keys from the rental desk.", "Turku",
+ "Cabriolet. Keys from the rental desk.", "Turku",
new Double(60.4507), new Double(22.295551) },
{ "04", "04 Volvo S60", "Key from the rental desk.", "Turku",
new Double(60.434722), new Double(22.224398) },
\r
private class EntrySource implements CalendarPanel.CalendarEntrySource {\r
\r
- private HashMap items = new HashMap();\r
+ private HashMap dates = new HashMap();\r
\r
public void addItem(UIDL item) {\r
String styleName = item.getStringAttribute("styleName");\r
String title = item.getStringAttribute("title");\r
String desc = item.getStringAttribute("description");\r
boolean notime = item.getBooleanAttribute("notime");\r
- if (items.containsKey(id)) {\r
- items.remove(id);\r
+ CalendarEntry entry = new CalendarEntry(styleName, startDate,\r
+ endDate, title, desc, notime);\r
+\r
+ // TODO should remove+readd if the same entry (id) is added again\r
+ \r
+ for (Date d = entry.getStart(); d.getYear() <= entry.getEnd()\r
+ .getYear()\r
+ && d.getMonth() <= entry.getEnd().getYear()\r
+ && d.getDate() <= entry.getEnd().getDate(); d.setTime(d\r
+ .getTime() + 86400000)) {\r
+ String key = d.getYear() + "" + d.getMonth() + "" + d.getDate();\r
+ ArrayList l = (ArrayList) dates.get(key);\r
+ if (l == null) {\r
+ l = new ArrayList();\r
+ dates.put(key, l);\r
+ }\r
+ l.add(entry);\r
}\r
- items.put(id, new CalendarEntry(styleName, startDate, endDate,\r
- title, desc, notime));\r
}\r
\r
public List getEntries(Date date, int resolution) {\r
+ List entries = (List) dates.get(date.getYear() + "" + date.getMonth() + ""\r
+ + date.getDate());\r
ArrayList res = new ArrayList();\r
- for (Iterator it = this.items.values().iterator(); it.hasNext();) {\r
+ if (entries == null) {\r
+ return res;\r
+ }\r
+ for (Iterator it = entries.iterator(); it.hasNext();) {\r
CalendarEntry item = (CalendarEntry) it.next();\r
if (DateTimeService.isInRange(date, item.getStart(), item\r
.getEnd(), resolution)) {\r
}\r
\r
public void clear() {\r
- items.clear();\r
+ dates.clear();\r
}\r
\r
}\r