AssignmentUpdate#
An edit to one existing assignment of a live project. It goes in the update list of SchedulingChanges.assignments, which Project#apply and Project#preview take. Create it with new AssignmentUpdate(id) and set the fields to change with the withX setters.
Declaration#
;
Constructors#
AssignmentUpdate(Id)#
public
Creates an update for the assignment with the given id. Every other field is Patch.missing(), so the update changes nothing until a field is set.
| Name | Type | Description |
|---|---|---|
id |
Id |
Id of the assignment to edit. Build it with Id.num(...) or Id.str(...). |
Fields#
Every field except id is a Patch<T>. Patch.missing() (the default) keeps the stored value, Patch.of(value) sets it, and Patch.nullValue() clears it. The On nullValue() column shows what clearing does. For the meaning of each value, see the field of the same name on AssignmentData.
| Field | Type | On nullValue() |
Description |
|---|---|---|---|
id |
Id |
- | Id of the assignment to edit. |
task |
Patch<Id> |
rejected | Moves the assignment to another task. |
resource |
Patch<Id> |
rejected | Gives the assignment to another resource. |
value |
Patch<Double> |
rejected | New utilization rate. |
offset |
Patch<Double> |
null |
New start of the slice. null books from the task start. |
duration |
Patch<Double> |
null |
New length of the slice. null books up to the task end. |
Don't use Patch.of(null) on task, resource or value. It throws NullPointerException when the change is applied. Use Patch.nullValue() to clear offset or duration.
The edited assignment must still pass the AssignmentData checks: value and duration finite and greater than 0, offset finite and 0 or greater, and task and resource naming existing records.
Effect on dates#
offset,durationandvaluechange resource load only. They never move a task.taskandresourcemove dates only when the task then works on a different set of calendars, for example when the new resource has its own calendar inCalendarMode.RESOURCE.- An assignment moved to an unscheduled task stays in the project but books no load. Its id is listed in
ChangeEffects.droppedAssignments.
Methods#
withId, withTask, withResource, withValue, withOffset, withDuration#
public AssignmentUpdate
public AssignmentUpdate
public AssignmentUpdate
public AssignmentUpdate
public AssignmentUpdate
public AssignmentUpdate
Each sets the field of the same name and returns this instance for chaining.
deepClone#
public AssignmentUpdate
Returns a new AssignmentUpdate with the same field values. Id and Patch values are immutable, so the copy is fully independent.
copy#
public AssignmentUpdate
Returns a shallow copy. Because every field holds an immutable value, it behaves like deepClone().
equals, hashCode, toString#
Inherited from ValueRecord. Two updates are equal when all six fields are equal. toString() lists the fields, for logging; each patch prints only its kind, e.g. Patch{kind=VALUE}.
Errors#
An update is one operation, at path assignments.update[i]. A failing update goes into ApplyReport.rejected as a RejectedOperation; it isn't thrown. Project#apply describes what a rejection does to the project.
| Message | When it occurs |
|---|---|
unknown assignment id |
No assignment has id. |
required field cannot be null |
task, resource or value is Patch.nullValue(). |
| a validation message | The edited assignment fails an AssignmentData check, for example an unknown resource or a value of 0. |
Example#
Hand Ben's review to Cara and narrow it to the last day of the task.
;
;
Related#
AssignmentData- the stored record and its checksPatch<T>- the three-state type of every editable fieldSchedulingChanges- the change set that carries the update- Split assignment work - narrowing an assignment to a slice
- Data Updates - update records in a live project