EnrollmentsQuery

public class EnrollmentsQuery

This is the Query builder for retrieving enrollments, provides methods for different query criteria. The order of criteria matters, as the first criterion is used to fetch the result from database and the other criterion are used to filter the results(in the specified sequence) fetched by the first criterion(in memory).

Methods

completedDuring

public EnrollmentsQuery completedDuring(DateTime start, DateTime end)

This adds the criteria using which enrollments are filtered based on them being completed in the given date range. The start and end dates are inclusive.

Parameters:
  • start – the start date
  • end – the end date
Returns:

returns the instance with completed during criteria added to the criteria list

currentlyInWindow

public EnrollmentsQuery currentlyInWindow(WindowName... windowNames)

This adds the criteria using which enrollments are filtered based on their current window(of current milestone) is in the given window name list.

Parameters:
  • windowNames – the window names
Returns:

returns the instance with currently in window criteria added to the criteria list

getCriteria

public List<Criterion> getCriteria()

This gives all the criterion which are present in the built query.

Returns:the list of the criteria

getPrimaryCriterion

public Criterion getPrimaryCriterion()

This gives the primary criterion in the built query, which is used to fetch the results from database.

Returns:the primary criteria

getSecondaryCriteria

public List<Criterion> getSecondaryCriteria()

This gives all the criterion other than primary criterion in the built query, which are used to filter the results of the primary criterion.

Returns:the list of secondary criteria

havingCurrentMilestone

public EnrollmentsQuery havingCurrentMilestone(String milestoneName)

This adds the criteria using which enrollments are filtered based on their current milestone name.

Parameters:
  • milestoneName – the milestone name
Returns:

returns the instance with current milestone criteria added to the criteria list

havingExternalId

public EnrollmentsQuery havingExternalId(String externalId)

This adds the criteria using which enrollments are filtered based on the client external id.

Parameters:
  • externalId – the client external id
Returns:

returns the instance with external id criteria added to the criteria list

havingMetadata

public EnrollmentsQuery havingMetadata(String key, String value)

This adds the criteria using which enrollments are filtered based on them having given metadata values in their metadata map.

Parameters:
  • key – the metadata key
  • value – the metadata value
Returns:

returns the instance with metadata criteria added to the criteria list

havingSchedule

public EnrollmentsQuery havingSchedule(String... scheduleNames)

This adds the criteria using which enrollments are filtered based on their schedule name.

Parameters:
  • scheduleNames – the schedule names
Returns:

returns the instance with schedule criteria added to the criteria list

havingState

public EnrollmentsQuery havingState(EnrollmentStatus enrollmentStatus)

This adds the criteria using which enrollments are filtered based on their status.

Parameters:
  • enrollmentStatus – the enrollment status
Returns:

returns the instance with status criteria added to the criteria list

havingWindowEndingDuring

public EnrollmentsQuery havingWindowEndingDuring(WindowName windowName, DateTime start, DateTime end)

This adds the criteria using which enrollments are filtered based on their given window end datetime falls during the given period. The start and end dates are inclusive.

Parameters:
  • windowName – the window name
  • start – the start date
  • end – the end date
Returns:

returns the instance with window end criteria added to the criteria list

havingWindowStartingDuring

public EnrollmentsQuery havingWindowStartingDuring(WindowName windowName, DateTime start, DateTime end)

This adds the criteria using which enrollments are filtered based on their given window start datetime falls during the given period. The start and end dates are inclusive.

Parameters:
  • windowName – the window name
  • start – the start date
  • end – the end date
Returns:

returns the instance with window start criteria added to the criteria list