permission set, get/add/remove and hasPermission added
[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
M
10import java.util.HashSet;
11import java.util.List;
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
7903e50e
M
39 * @throws Exception
40 */
5ff98db0 41 public boolean addUser(User user) throws Exception;
a1e3ab08 42
7903e50e 43 /**
a1e3ab08
D
44 * Finds the resourceName in the Datacontext and returns the Resource object
45 * or null if not found
46 * @param resourceName
795555be 47 * resource name of the resource you are looking for
a1e3ab08
D
48 * @return <code>Resource</code>resource object <code>null</code>if no
49 * resource found with this recourceName
7903e50e
M
50 */
51 public Resource findResource(String resourceName);
a1e3ab08 52
7903e50e
M
53 /**
54 * Adds a resource to the Datacontext from a given Recource object
a1e3ab08
D
55 * @param resource
56 * Resource object
5ff98db0 57 * @return returns a boolean whether the resource was made or not
7903e50e
M
58 * @throws Exception
59 */
5ff98db0 60 public boolean addResource(Resource resource) throws Exception;
a1e3ab08 61
7903e50e 62 /**
a1e3ab08
D
63 * Finds the reservation by the id param in the Datacontext and returns the
64 * Reservation object or null if not found
65 * @param id
66 * id of the Reservation you are looking for
67 * @return <code>Reservation</code>reservation object <code>null</code>if no
25d43fa9 68 * reservation found with this ID
7903e50e 69 */
be594ada 70 public Reservation findReservation(UUID id);
a1e3ab08 71
be594ada 72 /**
a77189a6 73 * Finds a group of reservations by their GroupId param in the Datacontext
a1e3ab08 74 * and returns the Reservation object or null if not found
a77189a6 75 * @param groupId
a1e3ab08 76 * id of the Group Reservations you are looking for
f5515c18 77 * @return <code>List</code> with the reservation objects
be594ada 78 */
a77189a6 79 public List<Reservation> findGroupReservations(UUID groupId);
a1e3ab08 80
25d43fa9
M
81 /**
82 * Finds reservations that overlaps with the given DateRange and returns the
83 * Reservation objects or null if not found
84 * @param range
85 * the range you want to get overlapping reservations for
f5515c18 86 * @return <code>List</code> with the reservation objects
25d43fa9 87 */
be594ada 88 public List<Reservation> overlaps(DateRange range);
a1e3ab08 89
7903e50e 90 /**
a77189a6
M
91 * Finds all reservations for the specific User
92 * @param user
93 * the user you want to get all the reservations for
f5515c18 94 * @return <code>List</code> with the reservation objects
a77189a6
M
95 */
96 public List<Reservation> userReservations(User user);
97
98 /**
99 * Finds all reservations
f5515c18 100 * @return <code>List</code> with the all reservation
a77189a6
M
101 * objects
102 */
103 public List<Reservation> findAllReservations();
104
105 /**
7903e50e 106 * Adds a reservation to the Datacontext from a given Reservation object
a1e3ab08
D
107 * @param reservation
108 * Reservation object
5ff98db0
M
109 *
110 * @return returns a boolean whether the reservation was made or not
7903e50e
M
111 * @throws Exception
112 */
5ff98db0 113 public boolean addReservation(Reservation reservation) throws Exception;
795555be
M
114
115 /**
116 * Saves the current changes on the local data to the datastorage
117 */
118 public void saveChanges();
119
120 /**
121 * Synchronizes the local data with the datastorage
122 *
123 * @param discardChanges
124 * <code>true</code> do not try to save the changes
125 * <code>false</code> try to save the changes
126 */
003130bd 127 public void refresh(boolean discardChanges) throws Exception;
7903e50e 128}