DataHandler angepasst
authorMatthias <balmm1@bfh.ch>
Wed, 18 Nov 2015 11:48:23 +0000 (12:48 +0100)
committerMatthias <balmm1@bfh.ch>
Wed, 18 Nov 2015 11:48:23 +0000 (12:48 +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 ded3ff3..6fc44bd 100644 (file)
@@ -68,26 +68,39 @@ public interface DataHandler {
        public Reservation findReservation(UUID id);
 
        /**
-        * Finds a group of reservations by their GroupID param in the Datacontext
+        * Finds a group of reservations by their GroupId param in the Datacontext
         * and returns the Reservation object or null if not found
-        * @param groupID
+        * @param groupId
         *            id of the Group Reservations you are looking for
-        * @return <code>Reservation</code>reservation objects <code>null</code>if
-        *         no reservation found with this groupID
+        * @return <code>ArrayList</code> with the reservation objects
         */
-       public List<Reservation> findGroupReservations(UUID groupID);
+       public List<Reservation> findGroupReservations(UUID groupId);
 
        /**
         * Finds reservations that overlaps with the given DateRange and returns the
         * Reservation objects or null if not found
         * @param range
         *            the range you want to get overlapping reservations for
-        * @return <code>Reservation</code>reservation object <code>null</code>if no
-        *         overlapping reservation found with this range
+        * @return <code>ArrayList</code> with the reservation objects
         */
        public List<Reservation> overlaps(DateRange range);
 
        /**
+        * Finds all reservations for the specific User
+        * @param user
+        *            the user you want to get all the reservations for
+        * @return <code>ArrayList</code> with the reservation objects
+        */
+       public List<Reservation> userReservations(User user);
+
+       /**
+        * Finds all reservations
+        * @return <code>ArrayList</code> with the all reservation
+        *         objects
+        */
+       public List<Reservation> findAllReservations();
+
+       /**
         * Adds a reservation to the Datacontext from a given Reservation object
         * @param reservation
         *            Reservation object
index 911bc74..78d9126 100644 (file)
@@ -27,9 +27,8 @@ public class DataHandlerForTests implements DataHandler {
 
        }
 
-       /*
-        * (non-Javadoc)
-        * @see ch.bfh.ti.srs.dataschema.DataHandler#findUser(java.lang.String)
+       /**
+        * {@inheritDoc}
         */
        @Override
        public User findUser(String userName) {
@@ -40,11 +39,8 @@ public class DataHandlerForTests implements DataHandler {
                return null;
        }
 
-       /*
-        * (non-Javadoc)
-        * @see
-        * ch.bfh.ti.srs.dataschema.DataHandler#addUser(ch.bfh.ti.srs.dataschema.
-        * User)
+       /**
+        * {@inheritDoc}
         */
        @Override
        public void addUser(User user) throws Exception {
@@ -55,9 +51,8 @@ public class DataHandlerForTests implements DataHandler {
                userList.add(user);
        }
 
-       /*
-        * (non-Javadoc)
-        * @see ch.bfh.ti.srs.dataschema.DataHandler#findResource(java.lang.String)
+       /**
+        * {@inheritDoc}
         */
        @Override
        public Resource findResource(String resourceName) {
@@ -68,11 +63,8 @@ public class DataHandlerForTests implements DataHandler {
                return null;
        }
 
-       /*
-        * (non-Javadoc)
-        * @see
-        * ch.bfh.ti.srs.dataschema.DataHandler#addResource(ch.bfh.ti.srs.dataschema
-        * .Resource)
+       /**
+        * {@inheritDoc}
         */
        @Override
        public void addResource(Resource resource) throws Exception {
@@ -83,10 +75,8 @@ public class DataHandlerForTests implements DataHandler {
                resourceList.add(resource);
        }
 
-       /*
-        * (non-Javadoc)
-        * @see
-        * ch.bfh.ti.srs.dataschema.DataHandler#findReservation(java.lang.String)
+       /**
+        * {@inheritDoc}
         */
        @Override
        public Reservation findReservation(UUID id) {
@@ -97,30 +87,43 @@ public class DataHandlerForTests implements DataHandler {
                return null;
        }
 
-       /*
-        * (non-Javadoc)
-        * @see
-        * ch.bfh.ti.srs.dataschema.DataHandler#findGroupReservations(ch.bfh.ti.srs.
-        * dataschema.Reservation)
+       /**
+        * {@inheritDoc}
         */
        @Override
-       public List<Reservation> findGroupReservations(UUID groupID) {
+       public List<Reservation> findGroupReservations(UUID groupId) {
+               if (groupId == null)
+                       throw new IllegalArgumentException("DateRange object must not be null!");
                List<Reservation> groupReservations = new ArrayList<Reservation>();
                for (Reservation reservation : reservationList) {
-                       if (reservation.getGroupId().equals(groupID))
+                       if (reservation.getGroupId().equals(groupId))
                                groupReservations.add(reservation);
                }
                return groupReservations;
        }
 
-       /*
-        * (non-Javadoc)
-        * @see
-        * ch.bfh.ti.srs.dataschema.DataHandler#overlaps(ch.bfh.ti.srs.dataschema.
-        * Reservation)
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public List<Reservation> userReservations(User user) {
+               if (user == null)
+                       throw new IllegalArgumentException("User object must not be null!");
+               List<Reservation> allUserReservations = new ArrayList<Reservation>();
+               for (Reservation reservation : reservationList) {
+                       if (reservation.getUser().equals(user))
+                               allUserReservations.add(reservation);
+               }
+               return allUserReservations;
+       }
+
+       /**
+        * {@inheritDoc}
         */
        @Override
        public List<Reservation> overlaps(DateRange range) {
+               if (range == null)
+                       throw new IllegalArgumentException("DateRange object must not be null!");
                List<Reservation> overlappingReservations = new ArrayList<Reservation>();
                for (Reservation reservation : reservationList) {
                        if (reservation.getDateRange().overlaps(range))
@@ -129,10 +132,20 @@ public class DataHandlerForTests implements DataHandler {
                return overlappingReservations;
        }
 
-       /*
-        * (non-Javadoc)
-        * @see ch.bfh.ti.srs.dataschema.DataHandler#addReservation(ch.bfh.ti.srs.
-        * dataschema.Reservation)
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public List<Reservation> findAllReservations() {
+               List<Reservation> allReservations = new ArrayList<Reservation>();
+               for (Reservation reservation : reservationList) {
+                       allReservations.add(reservation);
+               }
+               return allReservations;
+       }
+
+       /**
+        * {@inheritDoc}
         */
        @Override
        public void addReservation(Reservation reservation) throws Exception {
index e751ccb..8e98d97 100644 (file)
@@ -151,4 +151,16 @@ public class DataHandlerForExcel implements DataHandler {
                // TODO Auto-generated method stub
                return null;
        }
+
+       @Override
+       public List<Reservation> userReservations(User user) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public List<Reservation> findAllReservations() {
+               // TODO Auto-generated method stub
+               return null;
+       }
 }