ProfileQuery#

Describes what a load profile covers: a date range, the resources, the bucket size and which buckets list their tasks. Create one with new ProfileQuery(from, to), then wrap it in LoadProfileOptions for Project#loadProfile, or set it as PreviewOptions.profile.

Declaration#

package org.dhtmlx.plen;

public class ProfileQuery extends ValueRecord implements DeepCloneable<ProfileQuery> {
    public ProfileQuery(Moment from, Moment to)

    public Moment from;
    public Moment to;
    public Vec<Id> resources = null;
    public Basis basis = null;
    public ProfileTasks tasks = ProfileTasks.NONE;
}

ProfileQuery is a mutable record. equals and hashCode compare the public fields, and toString() prints them as ProfileQuery{from=…, to=…, …}.

Constructors#

ProfileQuery(Moment, Moment)#

public ProfileQuery(Moment from, Moment to)

Creates a query over [from, to) for every resource, on the derived basis, with no task lists.

Name Type Description
from Moment Start of the range (inclusive).
to Moment End of the range (exclusive).

The constructor doesn't validate the range. The call that reads the query checks it.

Fields#

Field Type Default Description
from Moment constructor argument Start of the range. The profile holds every bucket whose start lies in [from, to).
to Moment constructor argument End of the range (exclusive).
resources Vec<Id> null Resources to profile, in this order. null profiles every resource.
basis Basis null Bucket size. null derives it from SchedulingConfig.durationUnit.
tasks ProfileTasks ProfileTasks.NONE Which buckets list their booked tasks in LoadBucket.tasks.

Validation#

Project#loadProfile and Project#preview throw an InputException for an invalid query:

Path When
to to <= from, or the range holds more than 100 000 buckets per resource
resources resources names a resource that isn't in the project

Methods#

withFrom, withTo, withResources, withBasis, withTasks#

public ProfileQuery withFrom(Moment value)
public ProfileQuery withTo(Moment value)
public ProfileQuery withResources(Vec<Id> value)
public ProfileQuery withResources(java.util.Collection<? extends Id> value)
public ProfileQuery withBasis(Basis value)
public ProfileQuery withTasks(ProfileTasks value)

Set the field and return this query, for chaining. The Collection overload of withResources copies the elements into a new Vec, so List.of(...) works; null sets the field to null.

copy#

public ProfileQuery copy()

Returns a shallow copy. The copy shares the resources list with this query.

deepClone#

public ProfileQuery deepClone()

Returns a copy with its own resources list.

Example#

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

public class ProfileQueryExample {
    public static void main(String[] args) throws Exception {
        Moment monday = Moment.fromYmdHm(2026, 1, 5, 0, 0);
        Moment nextMonday = Moment.fromYmdHm(2026, 1, 12, 0, 0);

        ProjectData data = new ProjectData()
            .withTasks(List.of(
                new TaskData(Id.str("design")).withStartDate(monday).withDuration(3.0),
                new TaskData(Id.str("review")).withStartDate(monday).withDuration(2.0)))
            .withResources(List.of(new ResourceData().withId(Id.str("dev1"))))
            .withAssignments(List.of(
                new AssignmentData().withTask(Id.str("design")).withResource(Id.str("dev1")).withValue(1.0),
                new AssignmentData().withTask(Id.str("review")).withResource(Id.str("dev1")).withValue(0.5)));

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

        ProfileQuery query = new ProfileQuery(monday, nextMonday)
            .withResources(List.of(Id.str("dev1")))
            .withBasis(Basis.DAY)
            .withTasks(ProfileTasks.OVER);

        LoadProfile profile = project.loadProfile(new LoadProfileOptions(query));
        for (LoadBucket bucket : profile.resources.get(0).buckets) {
            System.out.println(bucket.start + ": " + bucket.load + " / " + bucket.capacity + " " + bucket.tasks);
        }
        // 2026-01-05 00:00: 1.5 / 1.0 [design, review]
        // 2026-01-06 00:00: 1.5 / 1.0 [design, review]
        // 2026-01-07 00:00: 1.0 / 1.0 []
        // ...
    }
}