cancel
Showing results for 
Search instead for 
Did you mean: 

Find operation with range of dates in entity services

Former Member
0 Kudos

Hello,

I created an entity service called A with 3 attributes: description (string), startDate (date) and endDate (date). I need to have a find operation that retrieves all A instances where startDate and endDate are in specific ranges of date.

For example, operation needs to return all instances where startDate is between 01/03/2007 and 05/03/2007 and/or my endDate is between 10/03/2007 and 15/03/2007.

Is it possible to do using entity services operations ? If yes, how can I do that ?

Thanks in advance,

View Entire Topic
former_member4529
Active Contributor
0 Kudos

Hi Helder,

Create a findBy method (findbyDateRange) for the entity service with the fromDate and toDate as input parameters. In the app service create a method with four input parameters of type caf.core.timestamp/date (fromdateStart, fromdateEnd and todateStart and todateEnd). In the method implementation write :

//instantiate query filters

QueryFilter qfInputfromDate = new QueryFilter(fromdateStart, fromdateEnd);

QueryFilter qfInputtoDate = new QueryFilter(todateStart, todateEnd);

//get entity service instance

myEntityServiceLocal entityServiceInstance = this.getmyEntityService();

//call entity service method

List dataList = entityServiceInstance.findbyDateRange(qfInputfromDate, qfInputtoDate);

for(int i=0; i<dataList.size();i++)

{

myEntityService data = (myEntityService) dataList.get(i);

//do your custom processing

}

retValue = dataList;

Hope this helps.

Thanks,

Dipankar