removed all checkstyle errors, updated sprint backlog
[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 /**
a1e3ab08
D
46 * Finds the resourceName in the Datacontext and returns the Resource object
47 * or null if not found
48 * @param resourceName
795555be 49 * resource name of the resource you are looking for
a1e3ab08
D
50 * @return <code>Resource</code>resource object <code>null</code>if no
51 * resource found with this recourceName
7903e50e
M
52 */
53 public Resource findResource(String resourceName);
a1e3ab08 54
7903e50e
M
55 /**
56 * Adds a resource to the Datacontext from a given Recource object
a1e3ab08
D
57 * @param resource
58 * Resource object
5ff98db0 59 * @return returns a boolean whether the resource was made or not
66cc653d
D
60 * @throws Exception
61 * if some property of the specified element prevents it from
62 * being added the Datacontext
7903e50e 63 */
5ff98db0 64 public boolean addResource(Resource resource) throws Exception;
a1e3ab08 65
7903e50e 66 /**
a1e3ab08
D
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
25d43fa9 72 * reservation found with this ID
7903e50e 73 */
be594ada 74 public Reservation findReservation(UUID id);
a1e3ab08 75
be594ada 76 /**
a77189a6 77 * Finds a group of reservations by their GroupId param in the Datacontext
a1e3ab08 78 * and returns the Reservation object or null if not found
a77189a6 79 * @param groupId
a1e3ab08 80 * id of the Group Reservations you are looking for
f5515c18 81 * @return <code>List</code> with the reservation objects
be594ada 82 */
a77189a6 83 public List<Reservation> findGroupReservations(UUID groupId);
a1e3ab08 84
25d43fa9
M
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
f5515c18 90 * @return <code>List</code> with the reservation objects
25d43fa9 91 */
be594ada 92 public List<Reservation> overlaps(DateRange range);
a1e3ab08 93
7903e50e 94 /**
a77189a6
M
95 * Finds all reservations for the specific User
96 * @param user
97 * the user you want to get all the reservations for
f5515c18 98 * @return <code>List</code> with the reservation objects
a77189a6
M
99 */
100 public List<Reservation> userReservations(User user);
101
102 /**
103 * Finds all reservations
66cc653d 104 * @return <code>List</code> with the all reservation objects
a77189a6
M
105 */
106 public List<Reservation> findAllReservations();
107
108 /**
7903e50e 109 * Adds a reservation to the Datacontext from a given Reservation object
a1e3ab08
D
110 * @param reservation
111 * Reservation object
e86af888 112 * @return a boolean whether the reservation was made or not
66cc653d
D
113 * @throws Exception
114 * if some property of the specified element prevents it from
115 * being added the Datacontext
7903e50e 116 */
5ff98db0 117 public boolean addReservation(Reservation reservation) throws Exception;
66cc653d 118
795555be
M
119 /**
120 * Saves the current changes on the local data to the datastorage
121 */
122 public void saveChanges();
66cc653d 123
795555be
M
124 /**
125 * Synchronizes the local data with the datastorage
795555be 126 * @param discardChanges
66cc653d
D
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
795555be 132 */
003130bd 133 public void refresh(boolean discardChanges) throws Exception;
e16f8b0c 134
e16f8b0c
M
135 public boolean editReservation(Reservation reservation);
136
137 public boolean deleteReservation(Reservation reservation);
138
e86af888 139 public Set<Resource> getAllResources();
7903e50e 140}