DataHandler updated
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / datahandler / DataHandler.java
CommitLineData
7903e50e
M
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
be594ada 10import java.util.List;
e86af888 11import java.util.Set;
be594ada
M
12import java.util.UUID;
13
7903e50e
M
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 {
a1e3ab08 23
7903e50e 24 /**
a1e3ab08
D
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
7903e50e
M
31 */
32 public User findUser(String userName);
a1e3ab08 33
7903e50e
M
34 /**
35 * Adds a user to the Datacontext from a given User object
a1e3ab08
D
36 * @param user
37 * User object
5ff98db0 38 * @return returns a boolean whether the user was made or not
66cc653d
D
39 * @throws Exception
40 * if some property of the specified element prevents it from
41 * being added the Datacontext
7903e50e 42 */
5ff98db0 43 public boolean addUser(User user) throws Exception;
a1e3ab08 44
7903e50e 45 /**
53a4cb7f
M
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 /**
a1e3ab08
D
54 * Finds the resourceName in the Datacontext and returns the Resource object
55 * or null if not found
56 * @param resourceName
795555be 57 * resource name of the resource you are looking for
a1e3ab08
D
58 * @return <code>Resource</code>resource object <code>null</code>if no
59 * resource found with this recourceName
7903e50e
M
60 */
61 public Resource findResource(String resourceName);
a1e3ab08 62
7903e50e
M
63 /**
64 * Adds a resource to the Datacontext from a given Recource object
a1e3ab08
D
65 * @param resource
66 * Resource object
5ff98db0 67 * @return returns a boolean whether the resource was made or not
66cc653d
D
68 * @throws Exception
69 * if some property of the specified element prevents it from
70 * being added the Datacontext
7903e50e 71 */
5ff98db0 72 public boolean addResource(Resource resource) throws Exception;
a1e3ab08 73
7903e50e 74 /**
a1e3ab08
D
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
25d43fa9 80 * reservation found with this ID
7903e50e 81 */
be594ada 82 public Reservation findReservation(UUID id);
a1e3ab08 83
be594ada 84 /**
a77189a6 85 * Finds a group of reservations by their GroupId param in the Datacontext
a1e3ab08 86 * and returns the Reservation object or null if not found
a77189a6 87 * @param groupId
a1e3ab08 88 * id of the Group Reservations you are looking for
f5515c18 89 * @return <code>List</code> with the reservation objects
be594ada 90 */
a77189a6 91 public List<Reservation> findGroupReservations(UUID groupId);
a1e3ab08 92
25d43fa9
M
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
f5515c18 98 * @return <code>List</code> with the reservation objects
25d43fa9 99 */
be594ada 100 public List<Reservation> overlaps(DateRange range);
a1e3ab08 101
7903e50e 102 /**
a77189a6
M
103 * Finds all reservations for the specific User
104 * @param user
105 * the user you want to get all the reservations for
f5515c18 106 * @return <code>List</code> with the reservation objects
a77189a6
M
107 */
108 public List<Reservation> userReservations(User user);
109
110 /**
111 * Finds all reservations
66cc653d 112 * @return <code>List</code> with the all reservation objects
a77189a6
M
113 */
114 public List<Reservation> findAllReservations();
115
116 /**
7903e50e 117 * Adds a reservation to the Datacontext from a given Reservation object
a1e3ab08
D
118 * @param reservation
119 * Reservation object
e86af888 120 * @return a boolean whether the reservation was made or not
66cc653d
D
121 * @throws Exception
122 * if some property of the specified element prevents it from
123 * being added the Datacontext
7903e50e 124 */
5ff98db0 125 public boolean addReservation(Reservation reservation) throws Exception;
66cc653d 126
795555be
M
127 /**
128 * Saves the current changes on the local data to the datastorage
129 */
130 public void saveChanges();
66cc653d 131
795555be
M
132 /**
133 * Synchronizes the local data with the datastorage
795555be 134 * @param discardChanges
66cc653d
D
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
795555be 140 */
003130bd 141 public void refresh(boolean discardChanges) throws Exception;
e16f8b0c 142
53a4cb7f
M
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 */
e16f8b0c
M
149 public boolean editReservation(Reservation reservation);
150
53a4cb7f
M
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 */
e16f8b0c 157 public boolean deleteReservation(Reservation reservation);
53a4cb7f
M
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 */
5fca88b4 165 public boolean editResource(Resource resource);
53a4cb7f
M
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 */
5fca88b4 173 public boolean deleteResource(Resource resource);
e16f8b0c 174
53a4cb7f
M
175 /**
176 * get all the Resources from the datastorage
177 *
178 * @return a set of Resources
179 */
e86af888 180 public Set<Resource> getAllResources();
7903e50e 181}
53a4cb7f
M
182
183