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