Menu

MSF DAO Instance

Gabor Novak

MSF DAO

The MSF DAO is the only class where you can connect directly to the phone's database for events or self-reports. This is the only place where you can load/save events/self-reports.
The MSF DAO is a singleton class, you can get the instance from every MsfActivity, MsfFragmentActivity, and MsfFragment class with the following code:

MsfDao dao = getMsfDao();

Methods in MSF DAO

With the MSF DAO instance you can load events, load/update/save/delete self-reports.

Load Events

For the full list of the available event classes and descriptions please visit this page: [Events]

// Load all event as a List
List<BaseEvent> allEvent = dao.getAllEvent();

// Load events for one specific class
List<BrowserHistoryEvent> allBrowserHistoryEvent = dao.getAllEvent(BrowserHistoryEvent.class);

// Load all event from the last 24 hours with MsfQuery
MsfQuery query = new MsfQuery();
query.betweenTime(new Date(System.currentTimeMillis() - ONE_DAY_IN_MILLIS), new Date());
List<BaseEvent> allEvent = dao.getAllEvent(query);

// Load every incoming call event which is longer than 10 sec with MsfQuery
MsfQuery query = new MsfQuery();
query.gt("duration", 10000);
List<IncomingCallEvent> incomingCallEvents = dao.getAllEvent(IncomingCallEvent.class, query);

For more information about the MsfQuery mechanism visit this page: [MSF Queries]

Manage Self Reports

If you are not familiar with the self-reports please first visit this page: [Self Report Management]

// Load all self-report as a List
List<BaseSelfReport> allSelfReport = dao.getAllSelfReport();

// Load self-report for one specific class
List<PadSelfReport> allPadSelfReport = dao.getAllSelfReport(PadSelfReport.class);

// Load all self-report from the last 24 hours with MsfQuery
MsfQuery query = new MsfQuery();
query.betweenTime(new Date(System.currentTimeMillis() - ONE_DAY_IN_MILLIS), new Date());
List<BaseSelfReport> allSelfReport = dao.getAllSelfReport(query);

// Load every PAD self-report where the valance grater than 5 with MsfQuery
MsfQuery query = new MsfQuery();
query.gt("valence", 5);
List<PadSelfReport> padSelfReports = dao.getAllSelfReport(PadSelfReport.class, query);


// Save self report instance
PadSelfReport pasSelfReport = new PadSelfReport();
//... fill the fields
dao.saveSelfReport(PadSelfReport.class, padSelfReport);

// Update
dao.updateSelfReport(PadSelfReport.class, padSelfReport);

// Delete
dao.deleteSelfReport(PadSelfReport.class, padSelfReport);

Related

Wiki: Home
Wiki: MSF Queries
Wiki: Self Report Management