DataHandler Error fixed
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / datahandler / DataHandler.java
... / ...
CommitLineData
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 */
8package ch.bfh.ti.srs.datahandler;
9
10import java.util.List;
11import java.util.Set;
12import java.util.UUID;
13
14import ch.bfh.ti.daterange.DateRange;
15import ch.bfh.ti.srs.dataschema.Reservation;
16import ch.bfh.ti.srs.dataschema.Resource;
17import ch.bfh.ti.srs.dataschema.User;
18
19/**
20 * @author Michael Grossen
21 */
22public 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
40 * if some property of the specified element prevents it from
41 * being added the Datacontext
42 */
43 public boolean addUser(User user) throws Exception;
44
45 /**
46 * Edit a User with the same Name.
47 * @param user
48 * the new User
49 * @return a boolean whether the user was edited or not
50 */
51 public boolean editUser(User user);
52
53 /**
54 * Finds the resourceName in the Datacontext and returns the Resource object
55 * or null if not found
56 * @param resourceName
57 * resource name of the resource you are looking for
58 * @return <code>Resource</code>resource object <code>null</code>if no
59 * resource found with this recourceName
60 */
61 public Resource findResource(String resourceName);
62
63 /**
64 * Adds a resource to the Datacontext from a given Recource object
65 * @param resource
66 * Resource object
67 * @return returns a boolean whether the resource was made or not
68 * @throws Exception
69 * if some property of the specified element prevents it from
70 * being added the Datacontext
71 */
72 public boolean addResource(Resource resource) throws Exception;
73
74 /**
75 * Finds the reservation by the id param in the Datacontext and returns the
76 * Reservation object or null if not found
77 * @param id
78 * id of the Reservation you are looking for
79 * @return <code>Reservation</code>reservation object <code>null</code>if no
80 * reservation found with this ID
81 */
82 public Reservation findReservation(UUID id);
83
84 /**
85 * Finds a group of reservations by their GroupId param in the Datacontext
86 * and returns the Reservation object or null if not found
87 * @param groupId
88 * id of the Group Reservations you are looking for
89 * @return <code>List</code> with the reservation objects
90 */
91 public List<Reservation> findGroupReservations(UUID groupId);
92
93 /**
94 * Finds reservations that overlaps with the given DateRange and returns the
95 * Reservation objects or null if not found
96 * @param range
97 * the range you want to get overlapping reservations for
98 * @return <code>List</code> with the reservation objects
99 */
100 public List<Reservation> overlaps(DateRange range);
101
102 /**
103 * Finds all reservations for the specific User
104 * @param user
105 * the user you want to get all the reservations for
106 * @return <code>List</code> with the reservation objects
107 */
108 public List<Reservation> userReservations(User user);
109
110 /**
111 * Finds all reservations
112 * @return <code>List</code> with the all reservation objects
113 */
114 public List<Reservation> findAllReservations();
115
116 /**
117 * Adds a reservation to the Datacontext from a given Reservation object
118 * @param reservation
119 * Reservation object
120 * @return a boolean whether the reservation was made or not
121 * @throws Exception
122 * if some property of the specified element prevents it from
123 * being added the Datacontext
124 */
125 public boolean addReservation(Reservation reservation) throws Exception;
126
127 /**
128 * Saves the current changes on the local data to the datastorage
129 */
130 public void saveChanges();
131
132 /**
133 * Synchronizes the local data with the datastorage
134 * @param discardChanges
135 * <code>true</code> do not try to save the changes
136 * <code>false</code> try to save the changes
137 * @throws Exception
138 * no implementation for <code>true</code> in this DataHandler
139 * possible
140 */
141 public void refresh(boolean discardChanges) throws Exception;
142
143 /**
144 * Edit a Reservation with the same ID.
145 * @param reservation
146 * the new Reservation
147 * @return a boolean whether the reservation was edited or not
148 */
149 public boolean editReservation(Reservation reservation);
150
151 /**
152 * deletes a Reservation from the datastorage
153 * @param reservation
154 * the Reservation to remove
155 * @return a boolean whether the reservation was deleted or not
156 */
157 public boolean deleteReservation(Reservation reservation);
158
159 /**
160 * Edit a Resource with the same ID.
161 * @param resource
162 * the new Resource
163 * @return a boolean whether the resource was edited or not
164 */
165 public boolean editResource(Resource resource);
166
167 /**
168 * deletes a Resource from the datastorage
169 * @param resource
170 * the Resource to remove
171 * @return a boolean whether the resource was deleted or not
172 */
173 public boolean deleteResource(Resource resource);
174
175 /**
176 * get all the Resources from the datastorage
177 *
178 * @return a set of Resources
179 */
180 public Set<Resource> getAllResources();
181}
182
183