Skip to content

Commit

Permalink
Merge pull request #52 from jogrimst/master
Browse files Browse the repository at this point in the history
#51 Add StoryBookLearningEvent
  • Loading branch information
literacyapp committed Jun 4, 2017
2 parents 49e4ed0 + 83289e4 commit af89bb2
Show file tree
Hide file tree
Showing 10 changed files with 401 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId "org.literacyapp.analytics"
minSdkVersion 21
targetSdkVersion 23
versionCode 1000008
versionName "1.0.8"
versionCode 1000009
versionName "1.0.9"
}

buildTypes {
Expand Down Expand Up @@ -50,7 +50,7 @@ dependencies {

testCompile 'junit:junit:4.12'

compile 'org.literacyapp:literacyapp-model:1.1.45'
compile 'org.literacyapp:literacyapp-model:1.1.48'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'commons-io:commons-io:2.5'
compile 'org.greenrobot:greendao:3.2.0'
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@
</intent-filter>
</receiver>

<receiver
android:name=".receiver.StoryBookLearningEventReceiver"
android:enabled="true"
android:exported="true">

<intent-filter>
<action android:name="literacyapp.intent.action.STORYBOOK_LEARNING_EVENT" />
</intent-filter>
</receiver>

<receiver
android:name=".receiver.StudentUpdatedReceiver"
android:enabled="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public void onUpgrade(Database db, int oldVersion, int newVersion) {
BootCompletedEventDao.class
);
}

if (oldVersion < 1000009) {
DbMigrationHelper.migrate(db,
StoryBookLearningEventDao.class
);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 1000008): knows all DAOs.
* Master of DAO (schema version 1000009): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 1000008;
public static final int SCHEMA_VERSION = 1000009;

/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
ApplicationOpenedEventDao.createTable(db, ifNotExists);
BootCompletedEventDao.createTable(db, ifNotExists);
LetterLearningEventDao.createTable(db, ifNotExists);
NumberLearningEventDao.createTable(db, ifNotExists);
StoryBookLearningEventDao.createTable(db, ifNotExists);
VideoLearningEventDao.createTable(db, ifNotExists);
}

Expand All @@ -34,6 +35,7 @@ public static void dropAllTables(Database db, boolean ifExists) {
BootCompletedEventDao.dropTable(db, ifExists);
LetterLearningEventDao.dropTable(db, ifExists);
NumberLearningEventDao.dropTable(db, ifExists);
StoryBookLearningEventDao.dropTable(db, ifExists);
VideoLearningEventDao.dropTable(db, ifExists);
}

Expand All @@ -57,6 +59,7 @@ public DaoMaster(Database db) {
registerDaoClass(BootCompletedEventDao.class);
registerDaoClass(LetterLearningEventDao.class);
registerDaoClass(NumberLearningEventDao.class);
registerDaoClass(StoryBookLearningEventDao.class);
registerDaoClass(VideoLearningEventDao.class);
}

Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/org/literacyapp/analytics/dao/DaoSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
import org.literacyapp.analytics.model.BootCompletedEvent;
import org.literacyapp.analytics.model.LetterLearningEvent;
import org.literacyapp.analytics.model.NumberLearningEvent;
import org.literacyapp.analytics.model.StoryBookLearningEvent;
import org.literacyapp.analytics.model.VideoLearningEvent;

import org.literacyapp.analytics.dao.ApplicationOpenedEventDao;
import org.literacyapp.analytics.dao.BootCompletedEventDao;
import org.literacyapp.analytics.dao.LetterLearningEventDao;
import org.literacyapp.analytics.dao.NumberLearningEventDao;
import org.literacyapp.analytics.dao.StoryBookLearningEventDao;
import org.literacyapp.analytics.dao.VideoLearningEventDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
Expand All @@ -33,12 +35,14 @@ public class DaoSession extends AbstractDaoSession {
private final DaoConfig bootCompletedEventDaoConfig;
private final DaoConfig letterLearningEventDaoConfig;
private final DaoConfig numberLearningEventDaoConfig;
private final DaoConfig storyBookLearningEventDaoConfig;
private final DaoConfig videoLearningEventDaoConfig;

private final ApplicationOpenedEventDao applicationOpenedEventDao;
private final BootCompletedEventDao bootCompletedEventDao;
private final LetterLearningEventDao letterLearningEventDao;
private final NumberLearningEventDao numberLearningEventDao;
private final StoryBookLearningEventDao storyBookLearningEventDao;
private final VideoLearningEventDao videoLearningEventDao;

public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
Expand All @@ -57,19 +61,24 @@ public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends Abstr
numberLearningEventDaoConfig = daoConfigMap.get(NumberLearningEventDao.class).clone();
numberLearningEventDaoConfig.initIdentityScope(type);

storyBookLearningEventDaoConfig = daoConfigMap.get(StoryBookLearningEventDao.class).clone();
storyBookLearningEventDaoConfig.initIdentityScope(type);

videoLearningEventDaoConfig = daoConfigMap.get(VideoLearningEventDao.class).clone();
videoLearningEventDaoConfig.initIdentityScope(type);

applicationOpenedEventDao = new ApplicationOpenedEventDao(applicationOpenedEventDaoConfig, this);
bootCompletedEventDao = new BootCompletedEventDao(bootCompletedEventDaoConfig, this);
letterLearningEventDao = new LetterLearningEventDao(letterLearningEventDaoConfig, this);
numberLearningEventDao = new NumberLearningEventDao(numberLearningEventDaoConfig, this);
storyBookLearningEventDao = new StoryBookLearningEventDao(storyBookLearningEventDaoConfig, this);
videoLearningEventDao = new VideoLearningEventDao(videoLearningEventDaoConfig, this);

registerDao(ApplicationOpenedEvent.class, applicationOpenedEventDao);
registerDao(BootCompletedEvent.class, bootCompletedEventDao);
registerDao(LetterLearningEvent.class, letterLearningEventDao);
registerDao(NumberLearningEvent.class, numberLearningEventDao);
registerDao(StoryBookLearningEvent.class, storyBookLearningEventDao);
registerDao(VideoLearningEvent.class, videoLearningEventDao);
}

Expand All @@ -78,6 +87,7 @@ public void clear() {
bootCompletedEventDaoConfig.clearIdentityScope();
letterLearningEventDaoConfig.clearIdentityScope();
numberLearningEventDaoConfig.clearIdentityScope();
storyBookLearningEventDaoConfig.clearIdentityScope();
videoLearningEventDaoConfig.clearIdentityScope();
}

Expand All @@ -97,6 +107,10 @@ public NumberLearningEventDao getNumberLearningEventDao() {
return numberLearningEventDao;
}

public StoryBookLearningEventDao getStoryBookLearningEventDao() {
return storyBookLearningEventDao;
}

public VideoLearningEventDao getVideoLearningEventDao() {
return videoLearningEventDao;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
package org.literacyapp.analytics.dao;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import java.util.Calendar;
import org.literacyapp.analytics.dao.converter.CalendarConverter;

import org.literacyapp.analytics.model.StoryBookLearningEvent;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "STORY_BOOK_LEARNING_EVENT".
*/
public class StoryBookLearningEventDao extends AbstractDao<StoryBookLearningEvent, Long> {

public static final String TABLENAME = "STORY_BOOK_LEARNING_EVENT";

/**
* Properties of entity StoryBookLearningEvent.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property DeviceId = new Property(1, String.class, "deviceId", false, "DEVICE_ID");
public final static Property Time = new Property(2, long.class, "time", false, "TIME");
public final static Property PackageName = new Property(3, String.class, "packageName", false, "PACKAGE_NAME");
public final static Property StudentId = new Property(4, String.class, "studentId", false, "STUDENT_ID");
public final static Property StoryBookId = new Property(5, Long.class, "storyBookId", false, "STORY_BOOK_ID");
}

private final CalendarConverter timeConverter = new CalendarConverter();

public StoryBookLearningEventDao(DaoConfig config) {
super(config);
}

public StoryBookLearningEventDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}

/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"STORY_BOOK_LEARNING_EVENT\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"\"DEVICE_ID\" TEXT NOT NULL ," + // 1: deviceId
"\"TIME\" INTEGER NOT NULL ," + // 2: time
"\"PACKAGE_NAME\" TEXT NOT NULL ," + // 3: packageName
"\"STUDENT_ID\" TEXT," + // 4: studentId
"\"STORY_BOOK_ID\" INTEGER);"); // 5: storyBookId
}

/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STORY_BOOK_LEARNING_EVENT\"";
db.execSQL(sql);
}

@Override
protected final void bindValues(DatabaseStatement stmt, StoryBookLearningEvent entity) {
stmt.clearBindings();

Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindString(2, entity.getDeviceId());
stmt.bindLong(3, timeConverter.convertToDatabaseValue(entity.getTime()));
stmt.bindString(4, entity.getPackageName());

String studentId = entity.getStudentId();
if (studentId != null) {
stmt.bindString(5, studentId);
}

Long storyBookId = entity.getStoryBookId();
if (storyBookId != null) {
stmt.bindLong(6, storyBookId);
}
}

@Override
protected final void bindValues(SQLiteStatement stmt, StoryBookLearningEvent entity) {
stmt.clearBindings();

Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindString(2, entity.getDeviceId());
stmt.bindLong(3, timeConverter.convertToDatabaseValue(entity.getTime()));
stmt.bindString(4, entity.getPackageName());

String studentId = entity.getStudentId();
if (studentId != null) {
stmt.bindString(5, studentId);
}

Long storyBookId = entity.getStoryBookId();
if (storyBookId != null) {
stmt.bindLong(6, storyBookId);
}
}

@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}

@Override
public StoryBookLearningEvent readEntity(Cursor cursor, int offset) {
StoryBookLearningEvent entity = new StoryBookLearningEvent( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.getString(offset + 1), // deviceId
timeConverter.convertToEntityProperty(cursor.getLong(offset + 2)), // time
cursor.getString(offset + 3), // packageName
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // studentId
cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5) // storyBookId
);
return entity;
}

@Override
public void readEntity(Cursor cursor, StoryBookLearningEvent entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setDeviceId(cursor.getString(offset + 1));
entity.setTime(timeConverter.convertToEntityProperty(cursor.getLong(offset + 2)));
entity.setPackageName(cursor.getString(offset + 3));
entity.setStudentId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setStoryBookId(cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5));
}

@Override
protected final Long updateKeyAfterInsert(StoryBookLearningEvent entity, long rowId) {
entity.setId(rowId);
return rowId;
}

@Override
public Long getKey(StoryBookLearningEvent entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}

@Override
public boolean hasKey(StoryBookLearningEvent entity) {
return entity.getId() != null;
}

@Override
protected final boolean isEntityUpdateable() {
return true;
}

}
Loading

0 comments on commit af89bb2

Please sign in to comment.