001: /*
002: * Copyright 2005-2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005: * in compliance with the License. You may obtain a copy of the License at
006: *
007: * http://www.apache.org/licenses/LICENSE-2.0
008: *
009: * Unless required by applicable law or agreed to in writing, software distributed under the License
010: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011: * or implied. See the License for the specific language governing permissions and limitations under
012: * the License.
013: */
014:
015: package org.strecks.holidaybooking.service.dummy;
016:
017: import java.util.ArrayList;
018: import java.util.Calendar;
019: import java.util.Collection;
020: import java.util.HashMap;
021: import java.util.List;
022: import java.util.Map;
023:
024: import org.strecks.holidaybooking.domain.HolidayBooking;
025: import org.strecks.holidaybooking.domain.LeaveType;
026: import org.strecks.holidaybooking.service.HolidayBookingService;
027:
028: /**
029: * @author Phil Zoio
030: */
031: public class DummyHolidayBookingService implements
032: HolidayBookingService {
033:
034: private static Map<Long, HolidayBooking> holidayBookings = new HashMap<Long, HolidayBooking>();
035:
036: private static long counter = 0;
037:
038: public DummyHolidayBookingService() {
039: init();
040: }
041:
042: public void init() {
043:
044: holidayBookings.clear();
045:
046: counter = 1;
047:
048: HolidayBooking booking = new HolidayBooking();
049: booking.setTitle("Go to Alaska");
050: Calendar cal = Calendar.getInstance();
051: cal.set(2006, 5, 20);
052: booking.setStartDate(cal.getTime());
053: booking.setDays(5);
054: addHolidayBooking(booking);
055:
056: booking = new HolidayBooking();
057: booking.setTitle("Weekend break to Venice");
058: cal = Calendar.getInstance();
059: cal.set(2006, 2, 7);
060: booking.setStartDate(cal.getTime());
061: booking.setDays(5);
062: addHolidayBooking(booking);
063:
064: booking = new HolidayBooking();
065: booking.setTitle("Camping in Cornwall");
066: cal = Calendar.getInstance();
067: cal.set(2006, 8, 11);
068: booking.setStartDate(cal.getTime());
069: booking.setDays(7);
070: addHolidayBooking(booking);
071:
072: booking = new HolidayBooking();
073: booking.setTitle("Sailing to Holland");
074: cal = Calendar.getInstance();
075: cal.set(2006, 9, 21);
076: booking.setStartDate(cal.getTime());
077: booking.setDays(7);
078: addHolidayBooking(booking);
079: }
080:
081: public void addHolidayBooking(HolidayBooking booking) {
082: booking.setEntryId(counter++);
083: holidayBookings.put(booking.getEntryId(), booking);
084: }
085:
086: public HolidayBooking getHolidayBooking(long i) {
087: return (HolidayBooking) holidayBookings.get(i);
088: }
089:
090: public List listHolidayBookings() {
091: return new ArrayList<HolidayBooking>(holidayBookings.values());
092: }
093:
094: public void updateHolidayBooking(HolidayBooking holidayBooking) {
095: holidayBookings
096: .put(holidayBooking.getEntryId(), holidayBooking);
097: }
098:
099: public Collection<LeaveType> getLeaveTypes() {
100: List<LeaveType> list = new ArrayList<LeaveType>();
101: list.add(new LeaveType(1, "Vacation"));
102: list.add(new LeaveType(2, "Personal Day"));
103: list.add(new LeaveType(3, "Jolly"));
104: return list;
105: }
106:
107: public void reset() {
108: init();
109: }
110:
111: }
|