001package org.cpsolver.studentsct.reservation; 002 003import java.util.Collection; 004 005import org.cpsolver.studentsct.model.Offering; 006 007/** 008 * Reservation override. A special instance of the {@link IndividualReservation} 009 * for a particular student (or students) that allows for defining whether 010 * it must be used, whether time conflicts are allowed, and whether it 011 * is allowed to assign the student over the limit. This class is intended to be used 012 * to model student overrides. 013 * 014 * <br> 015 * <br> 016 * 017 * @version StudentSct 1.3 (Student Sectioning)<br> 018 * Copyright (C) 2007 - 2014 Tomas Muller<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 ReservationOverride extends IndividualReservation { 037 private boolean iMustBeUsed = false; 038 private boolean iAllowOverlap = false; 039 private boolean iAllowOverLimit = false; 040 041 /** 042 * Constructor 043 * @param id unique id 044 * @param offering offering for which the reservation is 045 * @param studentIds one or more students 046 */ 047 public ReservationOverride(long id, Offering offering, Long... studentIds) { 048 super(id, offering, studentIds); 049 } 050 051 /** 052 * Constructor 053 * @param id unique id 054 * @param offering offering for which the reservation is 055 * @param studentIds one or more students 056 */ 057 public ReservationOverride(long id, Offering offering, Collection<Long> studentIds) { 058 super(id, offering, studentIds); 059 } 060 061 /** 062 * Set if the override must be used 063 * @param mustBeUsed true if the override must be used (if not expired) 064 */ 065 public void setMustBeUsed(boolean mustBeUsed) { iMustBeUsed = mustBeUsed; } 066 067 /** 068 * Return if the override must be used (unless it is expired) 069 * @return true if must be used and not expired 070 */ 071 @Override 072 public boolean mustBeUsed() { 073 return iMustBeUsed && !isExpired(); 074 } 075 076 /** 077 * Set if the override allows for time conflicts 078 * @param allowOverlap true if time overlaps are allowed 079 */ 080 public void setAllowOverlap(boolean allowOverlap) { 081 iAllowOverlap = allowOverlap; 082 } 083 084 /** 085 * Overlaps are allowed for individual reservations. 086 */ 087 @Override 088 public boolean isAllowOverlap() { 089 return iAllowOverlap; 090 } 091 092 /** 093 * Set if the override allows for over the limit assignment 094 * @param allowOverLimit true if the student can get into the course, configuration, or class over the limit 095 */ 096 public void setCanAssignOverLimit(boolean allowOverLimit) { 097 iAllowOverLimit = allowOverLimit; 098 } 099 100 /** 101 * Individual reservations are the only reservations that can be assigned over the limit. 102 */ 103 @Override 104 public boolean canAssignOverLimit() { 105 return iAllowOverLimit; 106 } 107 108 /** 109 * Overrides comes just after individual and group reservations 110 */ 111 @Override 112 public int getPriority() { 113 return 300; 114 } 115}