[Canonical page](<https://docs.dhtmlx.com/planning-engine/java/api/resources/profile-query/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# 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`](<https://docs.dhtmlx.com/planning-engine/java/api/resources/load-profile-options.md>) for [`Project#loadProfile`](<https://docs.dhtmlx.com/planning-engine/java/api/project-load-profile.md>), or set it as [`PreviewOptions.profile`](<https://docs.dhtmlx.com/planning-engine/java/api/project/preview-options.md#profile>).

## Declaration

```java
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)

```java
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`](<https://docs.dhtmlx.com/planning-engine/java/api/data/moment.md>) | 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`](<https://docs.dhtmlx.com/planning-engine/java/api/data/moment.md>) | 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`](<https://docs.dhtmlx.com/planning-engine/java/api/data/id.md>)`>` | `null` | Resources to profile, in this order. `null` profiles every resource. |
| `basis` | [`Basis`](<https://docs.dhtmlx.com/planning-engine/java/api/data/basis.md>) | `null` | Bucket size. `null` derives it from [`SchedulingConfig.durationUnit`](<https://docs.dhtmlx.com/planning-engine/java/api/data/scheduling-config.md#durationunit>). |
| `tasks` | [`ProfileTasks`](<https://docs.dhtmlx.com/planning-engine/java/api/resources/profile-tasks.md>) | `ProfileTasks.NONE` | Which buckets list their booked tasks in [`LoadBucket.tasks`](<https://docs.dhtmlx.com/planning-engine/java/api/resources/load-profile.md#loadbucket>). |

### Validation

[`Project#loadProfile`](<https://docs.dhtmlx.com/planning-engine/java/api/project-load-profile.md>) and [`Project#preview`](<https://docs.dhtmlx.com/planning-engine/java/api/project-preview.md>) throw an [`InputException`](<https://docs.dhtmlx.com/planning-engine/java/api/errors/input-exception.md>) 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

```java
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

```java
public ProfileQuery copy()
```

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

### deepClone

```java
public ProfileQuery deepClone()
```

Returns a copy with its own `resources` list.

## Example

```java
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 []
        // ...
    }
}
```

## Related

- [`LoadProfileOptions`](<https://docs.dhtmlx.com/planning-engine/java/api/resources/load-profile-options.md>) - options of `loadProfile` that wrap the query
- [`LoadProfile`](<https://docs.dhtmlx.com/planning-engine/java/api/resources/load-profile.md>) - the profile the query produces
- [`ProfileTasks`](<https://docs.dhtmlx.com/planning-engine/java/api/resources/profile-tasks.md>) - which buckets list their tasks
- [Resource load](<https://docs.dhtmlx.com/planning-engine/java/resources-and-assignment/resource-load.md#querying-a-profile>) - querying a profile
