Create ResourceManagerController, create Modify interface in dataschema,
[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
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 * Finds the resourceName in the Datacontext and returns the Resource object
47 * or null if not found
48 * @param resourceName
49 * resource name of the resource you are looking for
50 * @return <code>Resource</code>resource object <code>null</code>if no
51 * resource found with this recourceName
52 */
53 public Resource findResource(String resourceName);
54
55 /**
56 * Adds a resource to the Datacontext from a given Recource object
57 * @param resource
58 * Resource object
59 * @return returns a boolean whether the resource was made or not
60 * @throws Exception
61 * if some property of the specified element prevents it from
62 * being added the Datacontext
63 */
64 public boolean addResource(Resource resource) throws Exception;
65
66 /**
67 * Finds the reservation by the id param in the Datacontext and returns the
68 * Reservation object or null if not found
69 * @param id
70 * id of the Reservation you are looking for
71 * @return <code>Reservation</code>reservation object <code>null</code>if no
72 * reservation found with this ID
73 */
74 public Reservation findReservation(UUID id);
75
76 /**
77 * Finds a group of reservations by their GroupId param in the Datacontext
78 * and returns the Reservation object or null if not found
79 * @param groupId
80 * id of the Group Reservations you are looking for
81 * @return <code>List</code> with the reservation objects
82 */
83 public List<Reservation> findGroupReservations(UUID groupId);
84
85 /**
86 * Finds reservations that overlaps with the given DateRange and returns the
87 * Reservation objects or null if not found
88 * @param range
89 * the range you want to get overlapping reservations for
90 * @return <code>List</code> with the reservation objects
91 */
92 public List<Reservation> overlaps(DateRange range);
93
94 /**
95 * Finds all reservations for the specific User
96 * @param user
97 * the user you want to get all the reservations for
98 * @return <code>List</code> with the reservation objects
99 */
100 public List<Reservation> userReservations(User user);
101
102 /**
103 * Finds all reservations
104 * @return <code>List</code> with the all reservation objects
105 */
106 public List<Reservation> findAllReservations();
107
108 /**
109 * Adds a reservation to the Datacontext from a given Reservation object
110 * @param reservation
111 * Reservation object
112 * @return a boolean whether the reservation was made or not
113 * @throws Exception
114 * if some property of the specified element prevents it from
115 * being added the Datacontext
116 */
117 public boolean addReservation(Reservation reservation) throws Exception;
118
119 /**
120 * Saves the current changes on the local data to the datastorage
121 */
122 public void saveChanges();
123
124 /**
125 * Synchronizes the local data with the datastorage
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
130 * no implementation for <code>true</code> in this DataHandler
131 * possible
132 */
133 public void refresh(boolean discardChanges) throws Exception;
134
135 public boolean editReservation(Reservation reservation);
136
137 public boolean deleteReservation(Reservation reservation);
138
139 public boolean editResource(Resource resource);
140
141 public boolean deleteResource(Resource resource);
142
143 public Set<Resource> getAllResources();
144 }