    001package org.cpsolver.studentsct.online;
    002
    003import org.cpsolver.studentsct.model.Offering;
    004import org.cpsolver.studentsct.model.Student;
    005
    006/**
    007 * An online reservation. A simple class modeling any reservation of a student. This class is particularly useful when a model containing only the given
    008 * student is constructed (to provide him/her with a schedule or suggestions).
    009 *
    010 * @version StudentSct 1.3 (Student Sectioning)<br>
    011 *          Copyright (C) 2014 Tomáš Müller<br>
    012 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    013 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    014 * <br>
    015 *          This library is free software; you can redistribute it and/or modify
    016 *          it under the terms of the GNU Lesser General Public License as
    017 *          published by the Free Software Foundation; either version 3 of the
    018 *          License, or (at your option) any later version. <br>
    019 * <br>
    020 *          This library is distributed in the hope that it will be useful, but
    021 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    022 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    023 *          Lesser General Public License for more details. <br>
    024 * <br>
    025 *          You should have received a copy of the GNU Lesser General Public
    026 *          License along with this library; if not see <a href='http://www.gnu.org/licenses'>http://www.gnu.org/licenses</a>.
    027 *
    028 */
    029public class OnlineReservation extends org.cpsolver.studentsct.reservation.Reservation {
    030    private int iType;
    031    private int iLimit;
    032    private boolean iApply;
    033    private boolean iOverride;
    034
    035    /**
    036     * Constructor
    037     * @param type reservation type
    038     * @param id reservation unique id
    039     * @param offering reservation offering
    040     * @param priority reservation priority
    041     * @param over true when the reservation allows the student to be assigned over the limit
    042     * @param limit reservation limit
    043     * @param apply true if the reservation applies to the given student
    044     * @param mustUse true if the reservation must be used
    045     * @param allowOverlap true if the reservation allows for time overlaps
    046     * @param expired true if the reservation is expired
    047     * @param override true if the reservation is reservation override
    048     */
    049    public OnlineReservation(int type, long id, Offering offering, int priority, boolean over, int limit, boolean apply, boolean mustUse, boolean allowOverlap, boolean expired, boolean override) {
    050            super(id, offering, priority, mustUse, over, allowOverlap);
    051            iType = type;
    052            iLimit = limit;
    053            iApply = apply;
    054            iOverride = override;
    055            setExpired(expired);
    056    }
    057
    058    /**
    059     * Constructor
    060     * @param type reservation type
    061     * @param id reservation unique id
    062     * @param offering reservation offering
    063     * @param priority reservation priority
    064     * @param over true when the reservation allows the student to be assigned over the limit
    065     * @param limit reservation limit
    066     * @param apply true if the reservation applies to the given student
    067     * @param mustUse true if the reservation must be used
    068     * @param allowOverlap true if the reservation allows for time overlaps
    069     * @param expired true if the reservation is expired
    070     */
    071    public OnlineReservation(int type, long id, Offering offering, int priority, boolean over, int limit, boolean apply, boolean mustUse, boolean allowOverlap, boolean expired) {
    072        this(type, id, offering, priority, over, limit, apply, mustUse, allowOverlap, expired, false);
    073    }
    074
    075    public int getType() {
    076            return iType;
    077    }
    078
    079    @Override
    080    public double getReservationLimit() {
    081            return iLimit;
    082    }
    083
    084    @Override
    085    public boolean isApplicable(Student student) {
    086            return iApply;
    087    }
    088
    089    public boolean isOverride() {
    090        return iOverride;
    091    }
    092
    093    @Override
    094    public boolean mustBeUsed() {
    095        if (iOverride)
    096            return mustBeUsedIgnoreExpiration();
    097        return super.mustBeUsed();
    098    }
    099}