DataHandler angepasst
authorMatthias <balmm1@bfh.ch>
Wed, 18 Nov 2015 09:26:04 +0000 (10:26 +0100)
committerMatthias <balmm1@bfh.ch>
Wed, 18 Nov 2015 09:26:04 +0000 (10:26 +0100)
src/main/java/ch/bfh/ti/srs/datahandler/DataHandler.java
src/main/java/ch/bfh/ti/srs/datahandler/DataHandlerForTests.java
src/main/java/ch/bfh/ti/srs/noTest/DataHandlerForExcel.java

index 4cbf576..5ccef0b 100644 (file)
@@ -7,6 +7,10 @@
  */
 package ch.bfh.ti.srs.datahandler;
 
+import java.util.HashSet;
+import java.util.List;
+import java.util.UUID;
+
 import ch.bfh.ti.daterange.DateRange;
 import ch.bfh.ti.srs.dataschema.Reservation;
 import ch.bfh.ti.srs.dataschema.Resource;
@@ -52,14 +56,27 @@ public interface DataHandler {
        public void addResource(Resource resource) throws Exception;
        
        /**
-        * Finds the reservation by resource and daterange param in the Datacontext and returns the Reservation object or null if not found
+        * Finds the reservation by the id param in the Datacontext and returns the Reservation object or null if not found
         * 
-        * @param       resource        resource of the Reservation you are looking for
-        *                      daterange       daterange of the Reservation you are looking for
+        * @param       id                      id of the Reservation you are looking for
+        *      
         * @return                              <code>Reservation</code>reservation object
         *                                              <code>null</code>if no reservation found with this resource and this daterange
         */
-       public Reservation findReservation(Resource resource, DateRange daterange);
+       public Reservation findReservation(UUID id);
+       
+       /**
+        * Finds a group of reservations by their GroupID param in the Datacontext and returns the Reservation object or null if not found
+        * 
+        * @param       groupID         id of the Group Reservations you are looking for
+        *      
+        * @return                              <code>Reservation</code>reservation object
+        *                                              <code>null</code>if no reservation found with this resource and this daterange
+        */
+       public List<Reservation> findGroupReservations(UUID groupID);
+       
+       
+       public List<Reservation> overlaps(DateRange range);
        
        /**
         * Adds a reservation to the Datacontext from a given Reservation object
index 65199a6..8f33e83 100644 (file)
@@ -7,8 +7,11 @@
  */
 package ch.bfh.ti.srs.datahandler;
 
+import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
+import java.util.UUID;
 
 import ch.bfh.ti.daterange.DateRange;
 import ch.bfh.ti.srs.dataschema.Reservation;
@@ -69,12 +72,29 @@ public class DataHandlerForTests implements DataHandler{
         * @see ch.bfh.ti.srs.dataschema.DataHandler#findReservation(java.lang.String)
         */
        @Override
-       public Reservation findReservation(Resource resource, DateRange daterange) {
+       public Reservation findReservation(UUID id) {
                for (Reservation reservation : reservationList) {
-                       if(reservation.getResource().equals(resource) && reservation.getDateRange().equals(daterange)) return reservation;
+                       if(reservation.getId().equals(id)) return reservation;
                }
                return null;
        }
+       
+       @Override
+       public List<Reservation> findGroupReservations(UUID groupID) {
+               List<Reservation> groupReservations = new ArrayList<Reservation>();
+               for (Reservation reservation : reservationList) {
+                       if(reservation.getGroupId().equals(groupID))
+                               groupReservations.add(reservation);
+               }
+               return groupReservations;
+       }
+
+       @Override
+       public List<Reservation> overlaps(DateRange range) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+       
        /* (non-Javadoc)
         * @see ch.bfh.ti.srs.dataschema.DataHandler#addReservation(ch.bfh.ti.srs.dataschema.Reservation)
         */
@@ -84,4 +104,5 @@ public class DataHandlerForTests implements DataHandler{
                if(resourceList.contains(reservation)) throw new IllegalArgumentException("Reservation already  exists!");
                reservationList.add(reservation);       
        }
+
 }
index 9e08681..94d8e2f 100644 (file)
@@ -5,7 +5,9 @@ import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.Statement;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
+import java.util.UUID;
 
 import ch.bfh.ti.daterange.DateRange;
 import ch.bfh.ti.srs.datahandler.DataHandler;
@@ -136,14 +138,26 @@ public class DataHandlerForExcel implements DataHandler{
        }
 
        @Override
-       public Reservation findReservation(Resource resource, DateRange daterange) {
+       public void addReservation(Reservation reservation) throws Exception {
+               // TODO Auto-generated method stub
+               
+       }
+
+       @Override
+       public Reservation findReservation(UUID id) {
                // TODO Auto-generated method stub
                return null;
        }
 
        @Override
-       public void addReservation(Reservation reservation) throws Exception {
+       public List<Reservation> findGroupReservations(UUID groupID) {
                // TODO Auto-generated method stub
-               
+               return null;
+       }
+
+       @Override
+       public List<Reservation> overlaps(DateRange range) {
+               // TODO Auto-generated method stub
+               return null;
        }
 }