001package org.cpsolver.studentsct.reservation;
002
003import java.util.Collection;
004
005import org.cpsolver.studentsct.model.Offering;
006
007
008/**
009 * Group reservation. This is basically a {@link IndividualReservation}, but
010 * students cannot be assigned over the limit and the priority is lower than on
011 * individual reservations. Also, a different limit than the number of students
012 * in the group can be provided.
013 * 
014 * <br>
015 * <br>
016 * 
017 * @version StudentSct 1.3 (Student Sectioning)<br>
018 *          Copyright (C) 2007 - 2014 Tomáš Müller<br>
019 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
020 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
021 * <br>
022 *          This library is free software; you can redistribute it and/or modify
023 *          it under the terms of the GNU Lesser General Public License as
024 *          published by the Free Software Foundation; either version 3 of the
025 *          License, or (at your option) any later version. <br>
026 * <br>
027 *          This library is distributed in the hope that it will be useful, but
028 *          WITHOUT ANY WARRANTY; without even the implied warranty of
029 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
030 *          Lesser General Public License for more details. <br>
031 * <br>
032 *          You should have received a copy of the GNU Lesser General Public
033 *          License along with this library; if not see
034 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
035 */
036public class GroupReservation extends IndividualReservation {
037    private double iLimit;
038    
039    /**
040     * Group reservations are of the second highest priority
041     */
042    public static final int DEFAULT_PRIORITY = 200;
043    /**
044     * Individual or group reservation must be used (unless it is expired)
045     */
046    public static final boolean DEFAULT_MUST_BE_USED = true;
047    /**
048     * Group reservations cannot be assigned over the limit.
049     */
050    public static final boolean DEFAULT_CAN_ASSIGN_OVER_LIMIT = false;
051    /**
052     * Overlaps are not allowed for group reservations. 
053     */
054    public static final boolean DEFAULT_ALLOW_OVERLAP = false;
055
056    /**
057     * Constructor
058     * @param id unique id
059     * @param limit reservation limit (-1 for unlimited)
060     * @param offering offering for which the reservation is
061     * @param studentIds one or more students
062     */
063    public GroupReservation(long id, double limit, Offering offering, Long... studentIds) {
064        super(id, offering, DEFAULT_PRIORITY, DEFAULT_MUST_BE_USED, DEFAULT_CAN_ASSIGN_OVER_LIMIT, DEFAULT_ALLOW_OVERLAP, studentIds);
065        iLimit = limit;
066    }
067    
068    /**
069     * Constructor
070     * @param id unique id
071     * @param limit reservation limit (-1 for unlimited)
072     * @param offering offering for which the reservation is
073     * @param studentIds one or more students
074     */
075    public GroupReservation(long id, double limit, Offering offering, Collection<Long> studentIds) {
076        super(id, offering, DEFAULT_PRIORITY, DEFAULT_MUST_BE_USED, DEFAULT_CAN_ASSIGN_OVER_LIMIT, DEFAULT_ALLOW_OVERLAP, studentIds);
077        iLimit = limit;
078    }
079    
080    /**
081     * Constructor
082     * @param id reservation unique id
083     * @param limit reservation limit (-1 for unlimited)
084     * @param offering instructional offering on which the reservation is set
085     * @param priority reservation priority
086     * @param mustBeUsed must this reservation be used
087     * @param canAssignOverLimit can assign over class / configuration / course limit
088     * @param allowOverlap does this reservation allow for overlaps
089     * @param studentIds one or more students
090     */
091    protected GroupReservation(long id, double limit, Offering offering, int priority, boolean mustBeUsed, boolean canAssignOverLimit, boolean allowOverlap, Long... studentIds) {
092        super(id, offering, priority, mustBeUsed, canAssignOverLimit, allowOverlap, studentIds);
093        iLimit = limit;
094    }
095    
096    /**
097     * Constructor
098     * @param id reservation unique id
099     * @param limit reservation limit (-1 for unlimited)
100     * @param offering instructional offering on which the reservation is set
101     * @param priority reservation priority
102     * @param mustBeUsed must this reservation be used
103     * @param canAssignOverLimit can assign over class / configuration / course limit
104     * @param allowOverlap does this reservation allow for overlaps
105     * @param studentIds one or more students
106     */
107    protected GroupReservation(long id, double limit, Offering offering, int priority, boolean mustBeUsed, boolean canAssignOverLimit, boolean allowOverlap, Collection<Long> studentIds) {
108        super(id, offering, priority, mustBeUsed, canAssignOverLimit, allowOverlap, studentIds);
109        iLimit = limit;
110    }
111
112    /**
113     * Reservation limit
114     */
115    @Override
116    public double getReservationLimit() {
117        return iLimit;
118    }
119    
120    /**
121     * Set reservation limit (-1 for unlimited)
122     * @param limit reservation limit, -1 if unlimited
123     */
124    public void setReservationLimit(double limit) {
125        iLimit = limit;
126    }
127}