Package com.batch.android.tracker
Class TrackerDatasource
- java.lang.Object
-
- com.batch.android.tracker.TrackerDatasource
-
public final class TrackerDatasource extends java.lang.ObjectTracker datasource. Wraps SQLite queries (DAO).
-
-
Constructor Summary
Constructors Constructor Description TrackerDatasource(android.content.Context context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddEvent(Event event)Add an event to the databasevoidclearDB()Clear all contentvoidclose()Close the datasource.intdeleteEvents(java.lang.String[] eventIDs)Delete events by their IDintdeleteOverflowEvents(int limit)Delete events if there's too much in DBjava.util.List<Event>extractEventsToSend(int limit)Extract a set of events and set their state toEvent.State.SENDINGprotected java.util.List<Event>getAllEvents()Retrieve all events in DB (for test purpose)booleanresetEventStatus()Reset all event toEvent.State.OLDstatebooleanupdateEventsToNew(java.lang.String[] eventIDs)Set the State to NEW for the given events idsbooleanupdateEventsToOld(java.lang.String[] eventIDs)Set the State to OLD for the given events ids
-
-
-
Method Detail
-
getAllEvents
protected java.util.List<Event> getAllEvents()
Retrieve all events in DB (for test purpose)- Returns:
-
clearDB
public void clearDB()
Clear all content
-
addEvent
public boolean addEvent(Event event)
Add an event to the database- Parameters:
event- Event to add
-
extractEventsToSend
public java.util.List<Event> extractEventsToSend(int limit)
Extract a set of events and set their state toEvent.State.SENDING- Parameters:
limit-- Returns:
- a list of events (can be empty on error)
-
updateEventsToNew
public boolean updateEventsToNew(java.lang.String[] eventIDs)
Set the State to NEW for the given events ids- Parameters:
eventIDs-- Returns:
- true on success, false otherwise
-
updateEventsToOld
public boolean updateEventsToOld(java.lang.String[] eventIDs)
Set the State to OLD for the given events ids- Parameters:
eventIDs-- Returns:
- true on success, false otherwise
-
deleteEvents
public int deleteEvents(java.lang.String[] eventIDs)
Delete events by their ID- Parameters:
eventIDs- IDs of the events to delete- Returns:
- int number of raws deleted (-1 on error)
-
deleteOverflowEvents
public int deleteOverflowEvents(int limit)
Delete events if there's too much in DB- Parameters:
limit- maximum number of events wanted- Returns:
- the number of events deleted
-
close
public void close()
Close the datasource. You should not make any other call to this datasource once this has been called.
-
resetEventStatus
public boolean resetEventStatus()
Reset all event toEvent.State.OLDstate- Returns:
-
-