-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from jogrimst/master
#47 Add BootCompletedEvent
- Loading branch information
Showing
6 changed files
with
257 additions
and
2 deletions.
There are no files selected for viewing
131 changes: 131 additions & 0 deletions
131
app/src/main/java/org/literacyapp/analytics/dao/BootCompletedEventDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
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.BootCompletedEvent; | ||
|
||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. | ||
/** | ||
* DAO for table "BOOT_COMPLETED_EVENT". | ||
*/ | ||
public class BootCompletedEventDao extends AbstractDao<BootCompletedEvent, Long> { | ||
|
||
public static final String TABLENAME = "BOOT_COMPLETED_EVENT"; | ||
|
||
/** | ||
* Properties of entity BootCompletedEvent.<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"); | ||
} | ||
|
||
private final CalendarConverter timeConverter = new CalendarConverter(); | ||
|
||
public BootCompletedEventDao(DaoConfig config) { | ||
super(config); | ||
} | ||
|
||
public BootCompletedEventDao(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 + "\"BOOT_COMPLETED_EVENT\" (" + // | ||
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id | ||
"\"DEVICE_ID\" TEXT NOT NULL ," + // 1: deviceId | ||
"\"TIME\" INTEGER NOT NULL );"); // 2: time | ||
} | ||
|
||
/** Drops the underlying database table. */ | ||
public static void dropTable(Database db, boolean ifExists) { | ||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"BOOT_COMPLETED_EVENT\""; | ||
db.execSQL(sql); | ||
} | ||
|
||
@Override | ||
protected final void bindValues(DatabaseStatement stmt, BootCompletedEvent 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())); | ||
} | ||
|
||
@Override | ||
protected final void bindValues(SQLiteStatement stmt, BootCompletedEvent 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())); | ||
} | ||
|
||
@Override | ||
public Long readKey(Cursor cursor, int offset) { | ||
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); | ||
} | ||
|
||
@Override | ||
public BootCompletedEvent readEntity(Cursor cursor, int offset) { | ||
BootCompletedEvent entity = new BootCompletedEvent( // | ||
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id | ||
cursor.getString(offset + 1), // deviceId | ||
timeConverter.convertToEntityProperty(cursor.getLong(offset + 2)) // time | ||
); | ||
return entity; | ||
} | ||
|
||
@Override | ||
public void readEntity(Cursor cursor, BootCompletedEvent 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))); | ||
} | ||
|
||
@Override | ||
protected final Long updateKeyAfterInsert(BootCompletedEvent entity, long rowId) { | ||
entity.setId(rowId); | ||
return rowId; | ||
} | ||
|
||
@Override | ||
public Long getKey(BootCompletedEvent entity) { | ||
if(entity != null) { | ||
return entity.getId(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean hasKey(BootCompletedEvent entity) { | ||
return entity.getId() != null; | ||
} | ||
|
||
@Override | ||
protected final boolean isEntityUpdateable() { | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
app/src/main/java/org/literacyapp/analytics/model/BootCompletedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.literacyapp.analytics.model; | ||
|
||
import org.greenrobot.greendao.annotation.Convert; | ||
import org.greenrobot.greendao.annotation.Entity; | ||
import org.greenrobot.greendao.annotation.Generated; | ||
import org.greenrobot.greendao.annotation.Id; | ||
import org.greenrobot.greendao.annotation.NotNull; | ||
import org.literacyapp.analytics.dao.converter.CalendarConverter; | ||
|
||
import java.util.Calendar; | ||
|
||
@Entity | ||
public class BootCompletedEvent { | ||
|
||
@Id(autoincrement = true) | ||
private Long id; | ||
|
||
// TODO: replace with Device? | ||
@NotNull | ||
private String deviceId; | ||
|
||
@NotNull | ||
@Convert(converter = CalendarConverter.class, columnType = Long.class) | ||
private Calendar time; | ||
|
||
@Generated(hash = 1698024943) | ||
public BootCompletedEvent(Long id, @NotNull String deviceId, | ||
@NotNull Calendar time) { | ||
this.id = id; | ||
this.deviceId = deviceId; | ||
this.time = time; | ||
} | ||
|
||
@Generated(hash = 447047454) | ||
public BootCompletedEvent() { | ||
} | ||
|
||
public Long getId() { | ||
return this.id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getDeviceId() { | ||
return this.deviceId; | ||
} | ||
|
||
public void setDeviceId(String deviceId) { | ||
this.deviceId = deviceId; | ||
} | ||
|
||
public Calendar getTime() { | ||
return this.time; | ||
} | ||
|
||
public void setTime(Calendar time) { | ||
this.time = time; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters