ResourceData#
A resource that assignments book: its id, its capacity and an optional working calendar. Put resources in ProjectData.resources and reference them from AssignmentData.resource. Create one with new ResourceData() and the fluent withX setters, or decode JSON with Decode.fromJson.
Declaration#
Constructors#
ResourceData()#
public
Creates a resource with every field null. Set id before passing it on.
Fields#
| Field | Type | Default | Description |
|---|---|---|---|
id |
Id |
null |
Resource id. Required, and unique among the project's resources. |
capacity |
Double |
null |
Units available per time unit, in assignment value units (1.0 = 100 %). null uses SchedulingConfig.defaultResourceCapacity (default 1.0). Must be finite and >= 0. |
calendarId |
Id |
null |
Working calendar of the resource. Used in CalendarMode.RESOURCE (the default), where it must name a calendar in ProjectData.calendars. null means the resource has no calendar of its own. |
In CalendarMode.RESOURCE an assignment of this resource works on the resource calendar intersected with the task calendar. In the TASK and TASK_INHERITED modes the engine doesn't read calendarId, and only its format is checked. See Working-time calendars.
Methods#
withId, withCapacity, withCalendarId#
public ResourceData
public ResourceData
public ResourceData
Each setter assigns its field and returns this instance.
Returns - this ResourceData.
deepClone#
public ResourceData
Returns a new ResourceData with the same field values.
Returns - a new ResourceData.
copy#
public ResourceData
Returns a shallow copy of this instance.
Returns - a new ResourceData with the same field values.
equals, hashCode, toString#
public boolean
public int
public String
Inherited from ValueRecord. Two ResourceData are equal when all three fields are equal. toString() lists the fields.
Validation#
The calls that take a ProjectData check its resources. A failure throws an InputException at the field's path:
| Path | When |
|---|---|
resources[i].id |
Another resource has the same id. |
resources[i].capacity |
capacity is negative or not finite. |
resources[i].calendar_id |
In CalendarMode.RESOURCE, calendarId names no calendar. |
With Validation.REPAIR, a duplicate id replaces the earlier resource at the earlier position and adds a repair note.
To change a resource of a solved project, use ResourceUpdate.
Example#
;
;
Related#
AssignmentData- bookings of the resourceCalendarData- the resource's working calendarResourceUpdate- editing a resource in a live project- Resources and capacity - capacity and resource calendars