Menu

MSF Queries

Gabor Novak

MSF Queries

You can load events/self-reports from the MSF's database with a special object-based query mechanism.

Build Queries

To create a query first you need to create a new MsfQuery instance. (If you want to use it more than once you can cache it).

MsfQuery query = new MsfQuery();

Because every Event and SelfReport class contains a "timeStamp" and "id" field, the query has methods to create restrictions about this fields. Like this:

MsfQuery query = new MsfQuery();

// Restriction for timeStamp (long)
query.betweenTime(new Date(System.currentTimeMillis() - ONE_DAY_IN_MILLIS), new Date());

// Restriction for id
query.eqId(11);

The query support every basic SQL operation. The first parameter in every method is the name of the field. You can check the event classes field names on the following page: [Events]

In the following code you can see an example how does it work:

MsfQuery query = new MsfQuery();

// duration value between 0 and 100 sec (duration is available in Calls)
query.between("duration", 0, 100000); 
query.eq("contactNumberHash", "cad77c7dffc10fcacc77ff0690f2897a");
query.like("applicationName", "com.facebook", likeType.START); //Also available: ANYWHERE, END, EXACT
query.notEq(...);
query.gt(...);
query.lt(...);


query.limit(10);
query.orderByAsc("id");

// The query class is a fluent interface, you can also use like this...
query.between("duration", 0, 100000).lt(...).limit(10).orderByAsc("id");

To see how to load events and self-reports with Query visit this page: [MSF DAO Instance]


Related

Wiki: Events
Wiki: MSF DAO Instance
Wiki: Self Report Management