public class Schedule
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
Schedule() |
Modifier and Type | Method and Description |
---|---|
void |
addAssignment(Position position,
Assistant assistant)
Adds a new assignment (with accompanying "unseen" response).
|
boolean |
canFinalize()
Checks to see is a schedule can be published and is approved
If so it signals that the schedule can be finalized.
|
boolean |
canPublish()
A schedule can be published if all of it's positions have been filled.
|
void |
clean(java.util.ArrayList<Position> positions,
java.util.ArrayList<Assistant> assistants)
Consumes the positions and assistants in the system and checks if this
schedule references resources that are missing.
|
void |
clean(Position[] positions,
java.util.ArrayList<Assistant> assistants)
Removes all of the positions and assistants in the supplied array of positions and ArrayList of asssistants
|
java.lang.String[] |
compare(java.util.ArrayList<Pair<java.lang.String,java.lang.String>> oldAssignments)
Consumes a schedule represented by an arraylist of Assignments, and returns
the username (Strings) of all the assistants who have had their assignment
changed.
|
Schedule |
copy()
Returns a copy of the Schedule, including it's internal data
structures (assignments and responses).
|
java.lang.String |
exportToString()
Returns a string representation of the file, suitable for publishing
and finalization.
|
boolean |
filled(Position position)
Checks whether a position has been filled.
|
void |
finalize()
Finalizes this schedule
|
void |
finalizeResponses()
Changes all responses so that they have been finalized.
|
Assistant |
getAssignment(Position position)
Returns the assistant assigned to a given position
|
java.util.HashMap<Position,Assistant> |
getAssignments()
Simple accessor for assignments.
|
java.lang.String[] |
getAssistants()
Returns an array of strings containing the usernames of all the
Assistants that have been assigned in this schedule.
|
java.lang.String |
getName()
Simple accessor for the name of a Schedule.
|
Response |
getResponse(Position position)
Returns the response given to this schedule by the assistant
assigned to that position.
|
java.util.HashMap<Position,Response> |
getResponses()
Simple accessor for the responses of this schedule.
|
boolean |
isApproved()
Whether a schedule has had each response to an assignment set to
accept or override.
|
boolean |
isAssigned(Position position,
Assistant assistant)
Returns whether the given assistant is assigned to that position
|
boolean |
isFinalized()
Has this schedule been finalized.
|
boolean |
isPublished()
Has this schedule been published.
|
void |
publish()
Publishes this schedule
|
boolean |
resetResponse(Position position)
Changes the response to unseen.
|
void |
restore(Schedule backup)
Overwrites a schedule based on a given backup.
|
void |
setAssignments(java.util.HashMap<Position,Assistant> assignments)
Simple mutator for the assignments of this schedule.
|
void |
setFinalized(boolean finalized)
Sets whether a schedule has been finalized.
|
void |
setName(java.lang.String name)
Simple mutator for the name
|
void |
setPublished(boolean published)
Sets whether a schedule has been published.
|
boolean |
setResponse(Position position,
Response response)
Changes the response for a certain assignment.
|
void |
setResponses(java.util.HashMap<Position,Response> responses)
Simple mutator for the responses of this schedule.
|
java.lang.String |
toString()
Returns the name of the schedule.
|
void |
unassign(Position p)
Removes the assignment of an Assistant to a Position.
|
void |
unassignAssistant(Assistant a)
Removes any references to the assistant from the schedule.
|
void |
unassignPosition(Position p)
Removes the specified position from the schedule.
|
void |
unassignSection(Section s)
Removes any references to the section from the schedule.
|
void |
unfinalize()
Unfinalizes this schedule
|
void |
unpublish()
Unpublishes this schedule
|
void |
unseeResponses()
Changes all responses so that they haven't been seen.
|
boolean |
uses(Assistant assistant)
Checks whether a given assistant is used at all in the schedule.
|
boolean |
uses(Position position)
Checks whether a given position is used at all in the schedule
|
boolean |
uses(Section section)
Checks whether a given Section is used at all in the schedule
|
public Schedule copy()
public void clean(java.util.ArrayList<Position> positions, java.util.ArrayList<Assistant> assistants)
positions
- assistants
- public void clean(Position[] positions, java.util.ArrayList<Assistant> assistants)
positions
- assistants
- public void restore(Schedule backup)
backup
- public void addAssignment(Position position, Assistant assistant)
position
- assistant
- public boolean isFinalized()
public boolean isPublished()
public boolean filled(Position position)
position
- public Assistant getAssignment(Position position)
position
- public Response getResponse(Position position)
position
- public java.util.HashMap<Position,Assistant> getAssignments()
public void unassignAssistant(Assistant a)
a
- Assistant to be removedpublic void unassignPosition(Position p)
p
- public void unassign(Position p)
p
- public void unassignSection(Section s)
s
- public java.lang.String exportToString()
public void setName(java.lang.String name)
name
- public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String[] getAssistants()
public java.lang.String[] compare(java.util.ArrayList<Pair<java.lang.String,java.lang.String>> oldAssignments)
oldAssignments
- public java.lang.String getName()
public void setPublished(boolean published)
published
- public void setFinalized(boolean finalized)
finalized
- public java.util.HashMap<Position,Response> getResponses()
public void setResponses(java.util.HashMap<Position,Response> responses)
responses
- public void setAssignments(java.util.HashMap<Position,Assistant> assignments)
assignments
- public void publish()
public void unseeResponses()
public void finalizeResponses()
public void unpublish()
public void finalize()
finalize
in class java.lang.Object
public void unfinalize()
public boolean canPublish()
public boolean uses(Assistant assistant)
assistant
- public boolean uses(Position position)
position
- public boolean uses(Section section)
section
- public boolean isAssigned(Position position, Assistant assistant)
position
- assistant
- public boolean setResponse(Position position, Response response)
position
- response
- public boolean resetResponse(Position position)
position
- response
- public boolean canFinalize()
public boolean isApproved()