ResourceUpdate#
An edit to one existing resource of a live project. It goes in the update list of SchedulingChanges.resources, which Project#apply and Project#preview take. Create it with new ResourceUpdate(id) and set the fields to change with the fluent withX setters. To add a resource, put a ResourceData in SchedulingChanges.resources.add instead.
Declaration#
;
Constructors#
ResourceUpdate(Id)#
public
Creates an update for the resource with the given id. capacity and calendarId start as Patch.missing(), so the update changes nothing until one of them is set.
| Name | Type | Description |
|---|---|---|
id |
Id |
Id of the resource to edit, e.g. Id.str("dev1") or Id.num(1). |
Fields#
All fields are public and mutable. capacity and calendarId are Patch<T> values: 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 leaves behind. For the meaning of each value, see the field of the same name on ResourceData.
Patch.of(null) on either field stores null, the same as Patch.nullValue().
| Field | Type | On nullValue() |
Description |
|---|---|---|---|
id |
Id |
required | Id of the resource to edit. |
capacity |
Patch<Double> |
null, so SchedulingConfig.defaultResourceCapacity applies |
New capacity, in assignment value units (1.0 = 100 %). |
calendarId |
Patch<Id> |
null, no calendar of its own |
New working calendar of the resource. |
Dates after an update#
In CalendarMode.RESOURCE with useCalendars on, a calendarId change can change the calendars that a leaf task's assignments work on. Each leaf task whose set of working calendars changes keeps its start and duration, and its end is derived again. In the TASK and TASK_INHERITED modes, the update doesn't move any dates. For how a resource calendar combines with a task calendar, see Working-time calendars.
Methods#
withId, withCapacity, withCalendarId#
public ResourceUpdate
public ResourceUpdate
public ResourceUpdate
Each setter assigns its field and returns this instance.
Returns - this ResourceUpdate.
deepClone#
public ResourceUpdate
Returns a new ResourceUpdate with the same id, capacity and calendarId.
Returns - a new ResourceUpdate.
copy#
public ResourceUpdate
Returns a shallow copy of this instance.
Returns - a new ResourceUpdate with the same field values.
equals, hashCode, toString#
public boolean
public int
public String
Inherited from ValueRecord. Two updates are equal when id, capacity and calendarId are equal; patches compare by kind and carried value. toString() lists the fields, for logging; each patch shows only its kind.
Errors#
An update is rejected as a single operation, at path resources.update[i]. Project#apply and Project#preview describe how a rejection is reported.
| Message | When it occurs |
|---|---|
unknown resource id |
No resource has id. |
| a validation message | The edited resource breaks a ResourceData rule: capacity is negative, NaN or infinite, or, in CalendarMode.RESOURCE, calendarId names no calendar. |
Example#
Double a resource's capacity and drop its own calendar:
;
;
Related#
ResourceData- the stored record and its rulesPatch<T>- the three-state type ofcapacityandcalendarIdSchedulingChanges- the change set that carries the update- Resources and assignments - resource capacity
- Data Updates - update records in a live project