DataHandler updated
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / datahandler / DataHandler.java
1 /*
2 * Copyright (c) 2015 Berner Fachhochschule, Switzerland.
3 *
4 * Project Smart Reservation System.
5 *
6 * Distributable under GPL license. See terms of license at gnu.org.
7 */
8 package ch.bfh.ti.srs.datahandler;
9
10 import java.util.List;
11 import java.util.Set;
12 import java.util.UUID;
13
14 import ch.bfh.ti.daterange.DateRange;
15 import ch.bfh.ti.srs.dataschema.Reservation;
16 import ch.bfh.ti.srs.dataschema.Resource;
17 import ch.bfh.ti.srs.dataschema.User;
18
19 /**
20 * @author Michael Grossen
21 */
22 public interface DataHandler {
23
24 /**
25 * Finds the user by userName param in the Datacontext and returns the User
26 * object or null if not found
27 * @param userName
28 * userName of the user you are looking for
29 * @return <code>User</code>user object <code>null</code>if no user found
30 * with this userName
31 */
32 public User findUser(String userName);
33
34 /**
35 * Adds a user to the Datacontext from a given User object
36 * @param user
37 * User object
38 * @return returns a boolean whether the user was made or not
39 * @throws Exception if some property of the specified element
40 * prevents it from being added the Datacontext
41 */
42 public boolean addUser(User user) throws Exception;
43
44 /**
45 * Finds the resourceName in the Datacontext and returns the Resource object
46 * or null if not found
47 * @param resourceName
48 * resource name of the resource you are looking for
49 * @return <code>Resource</code>resource object <code>null</code>if no
50 * resource found with this recourceName
51 */
52 public Resource findResource(String resourceName);
53
54 /**
55 * Adds a resource to the Datacontext from a given Recource object
56 * @param resource
57 * Resource object
58 * @return returns a boolean whether the resource was made or not
59 * @throws Exception if some property of the specified element
60 * prevents it from being added the Datacontext
61 */
62 public boolean addResource(Resource resource) throws Exception;
63
64 /**
65 * Finds the reservation by the id param in the Datacontext and returns the
66 * Reservation object or null if not found
67 * @param id
68 * id of the Reservation you are looking for
69 * @return <code>Reservation</code>reservation object <code>null</code>if no
70 * reservation found with this ID
71 */
72 public Reservation findReservation(UUID id);
73
74 /**
75 * Finds a group of reservations by their GroupId param in the Datacontext
76 * and returns the Reservation object or null if not found
77 * @param groupId
78 * id of the Group Reservations you are looking for
79 * @return <code>List</code> with the reservation objects
80 */
81 public List<Reservation> findGroupReservations(UUID groupId);
82
83 /**
84 * Finds reservations that overlaps with the given DateRange and returns the
85 * Reservation objects or null if not found
86 * @param range
87 * the range you want to get overlapping reservations for
88 * @return <code>List</code> with the reservation objects
89 */
90 public List<Reservation> overlaps(DateRange range);
91
92 /**
93 * Finds all reservations for the specific User
94 * @param user
95 * the user you want to get all the reservations for
96 * @return <code>List</code> with the reservation objects
97 */
98 public List<Reservation> userReservations(User user);
99
100 /**
101 * Finds all reservations
102 * @return <code>List</code> with the all reservation
103 * objects
104 */
105 public List<Reservation> findAllReservations();
106
107 /**
108 * Adds a reservation to the Datacontext from a given Reservation object
109 * @param reservation
110 * Reservation object
111 *
112 * @return a boolean whether the reservation was made or not
113 * @throws Exception if some property of the specified element
114 * prevents it from being added the Datacontext
115 */
116 public boolean addReservation(Reservation reservation) throws Exception;
117
118 /**
119 * Saves the current changes on the local data to the datastorage
120 */
121 public void saveChanges();
122
123 /**
124 * Synchronizes the local data with the datastorage
125 *
126 * @param discardChanges
127 * <code>true</code> do not try to save the changes
128 * <code>false</code> try to save the changes
129 * @throws Exception no implementation for <code>true</code> in this DataHandler possible
130 */
131 public void refresh(boolean discardChanges) throws Exception;
132
133
134 public boolean editReservation(Reservation reservation);
135
136 public boolean deleteReservation(Reservation reservation);
137
138 public Set<Resource> getAllResources();
139 }