Introduction

Activity repositories are used by rows to store and lookup activities. Each Row by default owns an IntervalTreeActivityRepository. This default repository can be replaced with a custom one, for example if your application requires a lazy loading strategy. You can access the ActivityRepository of a given Row by calling the following method: row.getRepository()

Queries

The most important functionality of any repository is the ability to query the repository for activities within a given time interval. For this purpose the ActivityRepository interface defines the following method:

repository.getActivities(layer: Layer, startTime: number, endTime: number, temporalUnit: TemporalUnit, zoneId: ZoneId)
ParameterDescription
layer

Whenever the user scrolls left or right the row will query the repository several times. Once for each layer.

startTime

The start time of the time interval for which the row is querying activities.

endTime

The end time of the time interval for which the row is querying activities.

temporalUnit

The current value of the primary temporal unit currently displayed by the dateline. This is the unit shown at the bottom of the dateline, e.g. days. This parameter can be used to control how fine-grained the result will be. If we know that the user is currently looking at months then it might make sense to aggregate daily activities.

zoneId
The timezone shown by the row.

Earliest / Latest Time Used

Each repository implementation needs to be able to answer the question for the earliest and latest times used (earliest start time / latest end time of any activity stored in the repository). This allows the UI to provide controls for easy navigation: "show earliest", "show latest". For this purpose repositories need to implement repository.getEarliestTimeUsed() and repository.getLatestTimeUsed() methods.

Updating Activities

Activities need to be removed with activityRef.detachFromRow() from their repository before they are being changed and added back activityRef.attachToRow() after they have been changed. This is the only way to ensure that a repository will always have its underlying data structure in sync with the activities. Example: the interval tree data structure only works properly if all its nodes are in their correct location. This can only be guaranteed if the nodes are removed from the tree before they are being changed (otherwise the tree will not find them) and then reinserted with their new value.