|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.android.activityminer.persistence.DBManager
public final class DBManager
The database manager implemented as global singleton.
Field Summary | |
---|---|
private Context |
context
The context. |
private DBAdapter |
dbAdapter
The database adapter. |
private static DBManager |
instance
The singleton database manager instance |
Constructor Summary | |
---|---|
private |
DBManager(Context context)
Constructor |
Method Summary | ||
---|---|---|
boolean |
clearAllExtractedTrainingSampleData()
Does set the processing state for all recoding to new ( not processed ) and does delete all stored extracted feature vectors in the database. |
|
void |
deleteActivityLabel(ActivityLabel activityLabel)
Does delete the activity label in the database. |
|
void |
deleteAll()
Does delete all stored data. |
|
boolean |
deleteAllRecordings()
Does delete all stored recording data . |
|
boolean |
deleteRecording(long recordingId)
Does delete the recording with the given identifier from DB. |
|
boolean |
deleteRecordings(List<Long> recordingIds)
Does delete the recordings with the given identifiers and all related features. |
|
int |
deleteRecordingsForActivityLabel(ActivityLabel activityLabel)
Does delete the recording with the given activity label from DB. |
|
void |
deleteSamplesForActivityLabels(List<Long> activityLabelIds)
Does delete all existing samples for the given set of labels. |
|
void |
deleteSamplesForRecording(long idRecording)
Does delete the extracted samples for the given recording identifier |
|
void |
deleteSamplesForSequenceId(long sequenceId)
Does delete the extracted samples for the given sequence identifier |
|
int |
deleteSequence(long sid)
Does delete all recordings with the given sequence identifier |
|
boolean |
doDBUpgrade()
Simple db call on activity start to trigger db upgrades |
|
String |
getActivityLabelForId(Long id)
Getter for an activity label name for a given identifier. |
|
List<Long> |
getActivityLabelIdsWithSamplesIgnoreDependecies()
Getter for all activity labels with own extracted training samples. |
|
ActivityLabelMap |
getActivityLabels()
Does request all known activity labels from the database. |
|
List<Long> |
getAllRecordingIdentifiers()
Does request all available recording identifiers. |
|
List<Long> |
getAllSequenceIdentifiers()
Does request all available sequence identifiers. |
|
long |
getAvailableTrainingSampleCount()
Getter for the count of available training samples. |
|
List<Long> |
getAvailableTrainingSampleIds()
Does request all available training sample identifiers. |
|
List<Long> |
getAvailableTrainingSampleIdsForClassId(long selectedClassId)
Does request all available training sample identifiers for a given activity label. |
|
Configuration |
getConfigurationFromDB()
Does get the stored configuration from an sqlite database |
|
static int |
getDatabaseVersion()
Getter for the database version |
|
DBStatistic |
getDBRecordingStatisticsForAllActivities()
Getter for a recording count statistics for all activities. |
|
private DBStatistic |
getDBStatistics(boolean activitiesWithSamplesOnly,
boolean skipSampleCounts)
Getter for sample statistics. |
|
DBStatistic |
getDBStatisticsForAllActivities()
Getter for a complete database statistics (recording and sample counts for all activities). |
|
DBStatistic |
getDBStatisticsForAllActivitiesWithSamples()
Getter for a recording count statistics for all activities with extracted training samples. |
|
static DBManager |
getInstance(Context context)
Getter for the instance |
|
LabeledSample |
getLabeledSample(Long id)
Does request a labeled training sample for a given identifier. |
|
long |
getNewRecordingCount()
Does request the count of available new recordings. |
|
List<Long> |
getNewRecordingIdentifiers()
Does request all available new recording identifiers. |
|
List<Long> |
getNewSequenceIdentifiers()
Does request all available new continuous recording sequence identifiers. |
|
long |
getNextRecordingSequenceId()
Does determine the next unique sequence identifier for continuous recordings |
|
|
getRecording(Long recordingId)
Does request a recording by its unique identifier. |
|
long |
getRecordingCount()
Does request the count of available recordings. |
|
List<Long> |
getRecordingIdsForSequenceId(long sid)
Does look up the recording identifiers of a given sequence identifier |
|
DBRecordingStatistic |
getRecordingStatistics()
Does request statistic data for all available recordings. |
|
long |
getSampleRate()
Does determine the sample rate |
|
static long |
getSampleRateFromDB(SQLiteDatabase db)
Does get the sample rate from an sqlite database |
|
List<LabeledSample> |
getSamplesForRecording(long idRecording)
Does request all available labeled training samples for a given recording identifier. |
|
List<LabeledSample> |
getSamplesForSequence(long sId)
Does request all available labeled training samples for a given sequence identifier. |
|
List<DBSampleStatistic> |
getSampleStatistic(long[] activityLabelIds)
Method to get sample and recording statistics for the given activity labels |
|
List<ActivityLabel> |
getSelectedActivities(Configuration config)
Method to determine the classes of the identifier selection in configuration Attention: It can happen, that old activity identifiers remains in the selection stored in preferences due to deletion of activities. |
|
List<String> |
getSelectedActivitiesWithoutSamples(Configuration config)
Method to determine the count of configured activities without associated samples in the database. |
|
List<String> |
getSelectedActivitiesWithoutSamples(List<ActivityLabel> selectedActivities,
List<Long> activityIdsWithOwnSamples)
Method to determine the count of configured activities with samples in database. |
|
TrainingActivity |
getTrainingActivity(Long id)
Does request a training activity representation for an existing training sample from database. |
|
String |
getUuid()
Does get the stored UUID of the device the database was created on. |
|
boolean |
insertActivityLabel(String newActivityLabel)
Does insert the activity label in the database without dependencies. |
|
boolean |
renameSequence(long sid,
Long ActivityLabelId)
Does update the activity assignment for all recordings with the given sequence identifier |
|
static void |
resetDBVersion(Context context)
Method to reset database version preference for database imports |
|
void |
saveFeatureVectorForRecording(long idRecording,
FeatureVector featureVector)
Does save a feature vector associated to a given recording identifier. |
|
|
saveRecording(LabeledRecording<T> recording)
Does save a labeled recording in the database. |
|
boolean |
setRecordingProcessed(long recordingId)
Does change the processing state for a recoding to processed. |
|
void |
storeConfiguration(Configuration config)
Method to update the stored configuration |
|
static boolean |
testForDBUgrade(Context context)
Test method for an outstanding DB upgrade on next access |
|
void |
updateActivityLabel(ActivityLabel activityLabel)
Does update the activity label in the database. |
|
boolean |
updateRecordingData(DBRecording recording)
Method to update the recording data. |
|
void |
updateSampleRate(long sampleRate)
Method to update the sample rate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final DBAdapter dbAdapter
private static DBManager instance
private final Context context
Constructor Detail |
---|
private DBManager(Context context)
context
- the application contextMethod Detail |
---|
public static DBManager getInstance(Context context)
context
- the application context
public static final void resetDBVersion(Context context)
context
- the contextpublic static final boolean testForDBUgrade(Context context)
context
- the context
public static final int getDatabaseVersion()
public final boolean doDBUpgrade()
public final <T extends Enum<T> & Dimensions> Long saveRecording(LabeledRecording<T> recording) throws Exception
T
- the enumeration type for the dimensionsrecording
- the recording
Exception
public final ActivityLabelMap getActivityLabels()
public final void deleteActivityLabel(ActivityLabel activityLabel)
activityLabel
- the activity label to deletepublic final boolean insertActivityLabel(String newActivityLabel)
newActivityLabel
- the activity label to insert
public final void updateActivityLabel(ActivityLabel activityLabel)
activityLabel
- the activity label to updatepublic final long getRecordingCount()
public final DBRecordingStatistic getRecordingStatistics()
public final long getNewRecordingCount()
public final List<Long> getAllRecordingIdentifiers()
public List<Long> getAllSequenceIdentifiers()
public final List<Long> getNewRecordingIdentifiers()
public final List<Long> getNewSequenceIdentifiers()
public final <T extends Enum<T> & Dimensions> LabeledRecording<T> getRecording(Long recordingId)
T
- the enumeration type for the dimensionsrecordingId
- the recoding identifier
public final List<Long> getRecordingIdsForSequenceId(long sid)
sid
- the sequence identifier
public final boolean deleteRecording(long recordingId)
recordingId
- the recoding identifier
public final boolean deleteRecordings(List<Long> recordingIds)
recordingIds
- s list with unique identifiers of the recordings to delete
public final int deleteSequence(long sid)
sid
- the unique identifier of the recording to delete
public final boolean renameSequence(long sid, Long ActivityLabelId)
sid
- the unique identifier of the recording to deleteActivityLabelId
- the identifier of the new activity label
public final int deleteRecordingsForActivityLabel(ActivityLabel activityLabel)
activityLabel
- the activity label
public final boolean setRecordingProcessed(long recordingId)
recordingId
- the recoding identifier
public final boolean updateRecordingData(DBRecording recording)
recording
- the recording with the updated raw sensor data
public final boolean clearAllExtractedTrainingSampleData()
public final void saveFeatureVectorForRecording(long idRecording, FeatureVector featureVector) throws Exception
idRecording
- the associated recordings identifierfeatureVector
- the feature Vector to save
Exception
public final DBStatistic getDBStatisticsForAllActivitiesWithSamples()
public final DBStatistic getDBStatisticsForAllActivities()
public final DBStatistic getDBRecordingStatisticsForAllActivities()
private final DBStatistic getDBStatistics(boolean activitiesWithSamplesOnly, boolean skipSampleCounts)
activitiesWithSamplesOnly
- if true, only statistics for activities with existing samples will
be
createdskipSampleCounts
- flag if sample count calculation shall be skipped
public List<DBSampleStatistic> getSampleStatistic(long[] activityLabelIds)
activityLabelIds
- the activity labels identifiers to get sample statistics for
public final List<LabeledSample> getSamplesForRecording(long idRecording) throws Exception
idRecording
- the recordings identifier
Exception
public final List<LabeledSample> getSamplesForSequence(long sId) throws Exception
sId
- the sequence identifier
Exception
public final List<Long> getActivityLabelIdsWithSamplesIgnoreDependecies()
public final String getActivityLabelForId(Long id)
id
- the activity label identifier
public final long getAvailableTrainingSampleCount()
public final TrainingActivity getTrainingActivity(Long id) throws Exception
id
- the unique identifier of the database feature vector.
Exception
public final LabeledSample getLabeledSample(Long id) throws Exception
id
- the unique training sample identifier.
Exception
public final List<Long> getAvailableTrainingSampleIdsForClassId(long selectedClassId) throws Exception
selectedClassId
- the class activity label identifier to get sample identifier for
Exception
public final List<Long> getAvailableTrainingSampleIds()
public final void deleteAll()
public final boolean deleteAllRecordings()
public final void updateSampleRate(long sampleRate)
sampleRate
- the sample rate to updatepublic void deleteSamplesForRecording(long idRecording)
idRecording
- the associated recordings identifierpublic void deleteSamplesForSequenceId(long sequenceId)
sequenceId
- the associated sequence identifierpublic void deleteSamplesForActivityLabels(List<Long> activityLabelIds)
activityLabelIds
- the activity label identifiers to delete samples forpublic static final long getSampleRateFromDB(SQLiteDatabase db)
db
- the database to query
public long getSampleRate()
public final Configuration getConfigurationFromDB()
public final String getUuid()
public final void storeConfiguration(Configuration config)
config
- the configuration to update (can be null to clear stored
configuration)public long getNextRecordingSequenceId()
public final List<String> getSelectedActivitiesWithoutSamples(Configuration config)
config
- the current configuration
public final List<ActivityLabel> getSelectedActivities(Configuration config)
config
- the current configuration
public final List<String> getSelectedActivitiesWithoutSamples(List<ActivityLabel> selectedActivities, List<Long> activityIdsWithOwnSamples)
selectedActivities
- the selected activitiesactivityIdsWithOwnSamples
- the known activity identifiers with own samples
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |