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
e86af888
M
39 * @throws Exception if some property of the specified element
40 * prevents it from being added the Datacontext
7903e50e 41 */
5ff98db0 42 public boolean addUser(User user) throws Exception;
a1e3ab08 43
7903e50e 44 /**
a1e3ab08
D
45 * Finds the resourceName in the Datacontext and returns the Resource object
46 * or null if not found
47 * @param resourceName
795555be 48 * resource name of the resource you are looking for
a1e3ab08
D
49 * @return <code>Resource</code>resource object <code>null</code>if no
50 * resource found with this recourceName
7903e50e
M
51 */
52 public Resource findResource(String resourceName);
a1e3ab08 53
7903e50e
M
54 /**
55 * Adds a resource to the Datacontext from a given Recource object
a1e3ab08
D
56 * @param resource
57 * Resource object
5ff98db0 58 * @return returns a boolean whether the resource was made or not
e86af888
M
59 * @throws Exception if some property of the specified element
60 * prevents it from being added the Datacontext
7903e50e 61 */
5ff98db0 62 public boolean addResource(Resource resource) throws Exception;
a1e3ab08 63
7903e50e 64 /**
a1e3ab08
D
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
25d43fa9 70 * reservation found with this ID
7903e50e 71 */
be594ada 72 public Reservation findReservation(UUID id);
a1e3ab08 73
be594ada 74 /**
a77189a6 75 * Finds a group of reservations by their GroupId param in the Datacontext
a1e3ab08 76 * and returns the Reservation object or null if not found
a77189a6 77 * @param groupId
a1e3ab08 78 * id of the Group Reservations you are looking for
f5515c18 79 * @return <code>List</code> with the reservation objects
be594ada 80 */
a77189a6 81 public List<Reservation> findGroupReservations(UUID groupId);
a1e3ab08 82
25d43fa9
M
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
f5515c18 88 * @return <code>List</code> with the reservation objects
25d43fa9 89 */
be594ada 90 public List<Reservation> overlaps(DateRange range);
a1e3ab08 91
7903e50e 92 /**
a77189a6
M
93 * Finds all reservations for the specific User
94 * @param user
95 * the user you want to get all the reservations for
f5515c18 96 * @return <code>List</code> with the reservation objects
a77189a6
M
97 */
98 public List<Reservation> userReservations(User user);
99
100 /**
101 * Finds all reservations
f5515c18 102 * @return <code>List</code> with the all reservation
a77189a6
M
103 * objects
104 */
105 public List<Reservation> findAllReservations();
106
107 /**
7903e50e 108 * Adds a reservation to the Datacontext from a given Reservation object
a1e3ab08
D
109 * @param reservation
110 * Reservation object
5ff98db0 111 *
e86af888
M
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
7903e50e 115 */
5ff98db0 116 public boolean addReservation(Reservation reservation) throws Exception;
795555be
M
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
e86af888 129 * @throws Exception no implementation for <code>true</code> in this DataHandler possible
795555be 130 */
003130bd 131 public void refresh(boolean discardChanges) throws Exception;
e16f8b0c
M
132
133
134 public boolean editReservation(Reservation reservation);
135
136 public boolean deleteReservation(Reservation reservation);
137
e86af888 138 public Set<Resource> getAllResources();
7903e50e 139}