Roster#

The skill-free view of a project's accepted state: its scheduled leaf tasks, its resources and its active assignments. Each list is in model order. Project#roster returns a new instance, and SkillLayer.validatePool takes one. Use it to build your own Slot list for Project#suggestAssignments.

Declaration#

public class Roster extends ValueRecord implements DeepCloneable<Roster>

Constructors#

Roster()#

public Roster()

Creates a roster with three empty lists.

Fields#

Field Type Default Description
tasks Vec<Id> empty IDs of the scheduled leaf tasks. Summary tasks aren't listed.
resources Vec<Id> empty IDs of the resources.
assignments Vec<RosterAssignment> empty The active assignments.

Each ID is the Id value from the project's input data.

Methods#

withTasks#

public Roster withTasks(Vec<Id> value)
public Roster withTasks(Collection<? extends Id> value)

Sets tasks and returns this instance for chaining. The Collection overload copies the items into a new Vec, so List.of(...) works. null stays null.

Returns: this Roster.

withResources#

public Roster withResources(Vec<Id> value)
public Roster withResources(Collection<? extends Id> value)

Sets resources and returns this instance for chaining. The Collection overload copies the items into a new Vec. null stays null.

Returns: this Roster.

withAssignments#

public Roster withAssignments(Vec<RosterAssignment> value)
public Roster withAssignments(Collection<? extends RosterAssignment> value)

Sets assignments and returns this instance for chaining. The Collection overload copies the items into a new Vec. null stays null.

Returns: this Roster.

deepClone#

public Roster deepClone()

Returns a copy with new tasks, resources and assignments lists. Each RosterAssignment is cloned with its own deepClone(). Id values are immutable and are shared.

Returns: a new Roster.

copy#

public Roster copy()

Returns a shallow copy. The copy and the original share the three lists.

Returns: a new Roster.

equals, hashCode, toString#

public boolean equals(Object other)
public int hashCode()
public String toString()

Inherited from ValueRecord. Two rosters are equal when all three fields are equal. toString() lists the fields, for logging.

RosterAssignment#

One active assignment in a Roster: the assignment ID, its task and its resource.

public class RosterAssignment extends ValueRecord implements DeepCloneable<RosterAssignment>
Member Type Default Description
id Id null Assignment ID.
task Id null ID of the assigned task.
resource Id null ID of the booked resource.
RosterAssignment() constructor Creates an instance with every field null.
withId(Id), withTask(Id), withResource(Id) RosterAssignment Set the field and return this instance for chaining.
deepClone(), copy() RosterAssignment Return a copy with the same field values. All fields are immutable Id values, so both copies are independent.

equals, hashCode and toString are inherited from ValueRecord and compare or list all three fields.

Example#

import java.util.List;
import org.dhtmlx.plen.*;

public class RosterExample {
  public static void main(String[] args) throws Exception {
    Moment monday = Moment.fromYmdHm(2026, 8, 10, 8, 0);
    ProjectData data = new ProjectData()
        .withTasks(List.of(
            new TaskData(Id.str("a")).withStartDate(monday).withDuration(2.0),
            new TaskData(Id.str("b")).withStartDate(monday).withDuration(2.0)))
        .withResources(List.of(
            new ResourceData().withId(Id.str("dev1")),
            new ResourceData().withId(Id.str("dev2"))))
        .withAssignments(List.of(
            new AssignmentData().withId(Id.str("x")).withTask(Id.str("a")).withResource(Id.str("dev1")).withValue(1.0)));

    Project project = new Project();
    project.solve(data, new SolveOptions());

    Roster roster = project.roster();
    System.out.println(roster.tasks.size() + " tasks, " + roster.resources.size() + " resources");
    for (RosterAssignment a : roster.assignments) {
      System.out.println(a.id + ": " + a.task + " -> " + a.resource);
    }
  }
}