LoadProfileOptions#

Options for Project#loadProfile. They hold the ProfileQuery that selects the range, resources, basis and task lists of the LoadProfile, and the baseline the call expects. Create one with new LoadProfileOptions(query), then chain the fluent withX setters.

Declaration#

public class LoadProfileOptions extends ValueRecord implements DeepCloneable<LoadProfileOptions>

Constructors#

LoadProfileOptions(ProfileQuery)#

public LoadProfileOptions(ProfileQuery query)

Creates options for the given query, with baselineId set to null.

Parameters

Name Type Description
query ProfileQuery What the profile covers. Required

Fields#

Field Type Default Description
query ProfileQuery set by the constructor Range, resources, basis and task lists of the profile.
baselineId String null The baseline the call expects. null skips the check.

query#

public ProfileQuery query = null;

The ProfileQuery that describes the profile: from and to, an optional resource list, an optional basis, and which task ids each bucket lists. It sets the shape of the returned LoadProfile. The field must not be null when the options are passed to Project#loadProfile.

baselineId#

public String baselineId = null;

A baseline token taken from the latest ScheduleResult.baselineId. When it isn't null and doesn't name the project's current baseline, Project#loadProfile throws a ProjectException with code STALE_BASELINE. This keeps a profile from being read over a baseline that changed after the caller last solved.

Methods#

withQuery, withBaselineId#

public LoadProfileOptions withQuery(ProfileQuery value)
public LoadProfileOptions withBaselineId(String value)

Each setter assigns its field and returns this instance for chaining.

Returns - this LoadProfileOptions.

deepClone#

public LoadProfileOptions deepClone()

Returns a copy with its own ProfileQuery.

Returns - a new LoadProfileOptions with the same values.

Errors - throws NullPointerException when query is null.

copy#

public LoadProfileOptions copy()

Returns a shallow copy. The copy shares the query object with this instance.

Returns - a new LoadProfileOptions with the same field values.

equals, hashCode, toString#

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

Inherited from ValueRecord. Two LoadProfileOptions are equal when their public fields are equal. toString() lists the fields in the form LoadProfileOptions{query=…, baselineId=…}.

Example#

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

public class LoadProfileOptionsExample {
  public static void main(String[] args) throws Exception {
    ProjectData data = new ProjectData()
        .withTasks(List.of(
            new TaskData(Id.str("a")).withStartDate(Moment.fromYmdHm(2026, 1, 1, 0, 0)).withDuration(2.0)))
        .withResources(List.of(new ResourceData().withId(Id.str("dev"))))
        .withAssignments(List.of(
            new AssignmentData().withTask(Id.str("a")).withResource(Id.str("dev")).withValue(1.0)));
    data.config.useCalendars = false;

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

    ProfileQuery query = new ProfileQuery(Moment.fromYmdHm(2026, 1, 1, 0, 0), Moment.fromYmdHm(2026, 1, 4, 0, 0))
        .withResources(List.of(Id.str("dev")))
        .withTasks(ProfileTasks.ALL);
    LoadProfileOptions options = new LoadProfileOptions(query)
        .withBaselineId(solved.baselineId);

    LoadProfile profile = project.loadProfile(options);
    System.out.println(profile.resources.get(0).buckets.size()); // 3
  }
}