Finding Units Of Work by date

The finding Units Of Work (UOWs) example shows how to find UOWs based on a date range.

The date range can be given as explicit dates (as in this example) or relative to the current date/time. The search can be done for all work submitted by the user, or for all work submitted by any user in the current user's groups. Additionally, search filters for the work state can be set, among other criteria.

ApiSession session;
ResourceManager rMgr;
WorkflowManager wMgr;
Date startDate;
Date endDate;
.
.
.
//it is assumed the session has been established
rMgr = session.resourceManager();
wMgr = session.workflowManager();
.
.
.
//set up search criterion based on the date range
//it is assumed the date variables have been set
UnitOfWorkSearch uowSearch = rMgr.dataFactory().newUnitOfWorkSearch();
//The WorkState class has fields for each work state and
//a field for all states; it is highly recommended to use them.
//To only search for completed work, for example, use WorkState.FINISHED
uowSearch.setWorkStates(Arrays.asList(WorkState.ALL_STATES));
uowSearch.setAssociation(WorkAssociation.SUBMITTER);
//or if you want to find work from all users in the current user's group
//uowSearch.setAssociation(WorkAssociation.GROUP);
uowSearch.setStartDate(startDate);
uowSearch.setEndDate(endDate);
//now do the search
Collection<Work> workColl = wMgr.getAllWork(uowSearch);
if (workColl == null || workColl.isEmpty()) {
//handle case of no matches
}