-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jo Grimstad
committed
Jun 22, 2017
1 parent
67485a9
commit 006a6c9
Showing
6 changed files
with
341 additions
and
1 deletion.
There are no files selected for viewing
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
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
169 changes: 169 additions & 0 deletions
169
contentprovider/src/main/java/org/literacyapp/contentprovider/dao/SyllableDao.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,169 @@ | ||
package org.literacyapp.contentprovider.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.contentprovider.dao.converter.CalendarConverter; | ||
import org.literacyapp.contentprovider.dao.converter.ContentStatusConverter; | ||
import org.literacyapp.contentprovider.dao.converter.LocaleConverter; | ||
import org.literacyapp.model.enums.Locale; | ||
import org.literacyapp.model.enums.content.ContentStatus; | ||
|
||
import org.literacyapp.contentprovider.model.content.Syllable; | ||
|
||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. | ||
/** | ||
* DAO for table "SYLLABLE". | ||
*/ | ||
public class SyllableDao extends AbstractDao<Syllable, Long> { | ||
|
||
public static final String TABLENAME = "SYLLABLE"; | ||
|
||
/** | ||
* Properties of entity Syllable.<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 Locale = new Property(1, String.class, "locale", false, "LOCALE"); | ||
public final static Property TimeLastUpdate = new Property(2, Long.class, "timeLastUpdate", false, "TIME_LAST_UPDATE"); | ||
public final static Property RevisionNumber = new Property(3, Integer.class, "revisionNumber", false, "REVISION_NUMBER"); | ||
public final static Property ContentStatus = new Property(4, String.class, "contentStatus", false, "CONTENT_STATUS"); | ||
public final static Property Text = new Property(5, String.class, "text", false, "TEXT"); | ||
public final static Property UsageCount = new Property(6, int.class, "usageCount", false, "USAGE_COUNT"); | ||
} | ||
|
||
private final LocaleConverter localeConverter = new LocaleConverter(); | ||
private final CalendarConverter timeLastUpdateConverter = new CalendarConverter(); | ||
private final ContentStatusConverter contentStatusConverter = new ContentStatusConverter(); | ||
|
||
public SyllableDao(DaoConfig config) { | ||
super(config); | ||
} | ||
|
||
public SyllableDao(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 + "\"SYLLABLE\" (" + // | ||
"\"_id\" INTEGER PRIMARY KEY ," + // 0: id | ||
"\"LOCALE\" TEXT NOT NULL ," + // 1: locale | ||
"\"TIME_LAST_UPDATE\" INTEGER," + // 2: timeLastUpdate | ||
"\"REVISION_NUMBER\" INTEGER NOT NULL ," + // 3: revisionNumber | ||
"\"CONTENT_STATUS\" TEXT NOT NULL ," + // 4: contentStatus | ||
"\"TEXT\" TEXT NOT NULL ," + // 5: text | ||
"\"USAGE_COUNT\" INTEGER NOT NULL );"); // 6: usageCount | ||
} | ||
|
||
/** Drops the underlying database table. */ | ||
public static void dropTable(Database db, boolean ifExists) { | ||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"SYLLABLE\""; | ||
db.execSQL(sql); | ||
} | ||
|
||
@Override | ||
protected final void bindValues(DatabaseStatement stmt, Syllable entity) { | ||
stmt.clearBindings(); | ||
|
||
Long id = entity.getId(); | ||
if (id != null) { | ||
stmt.bindLong(1, id); | ||
} | ||
stmt.bindString(2, localeConverter.convertToDatabaseValue(entity.getLocale())); | ||
|
||
Calendar timeLastUpdate = entity.getTimeLastUpdate(); | ||
if (timeLastUpdate != null) { | ||
stmt.bindLong(3, timeLastUpdateConverter.convertToDatabaseValue(timeLastUpdate)); | ||
} | ||
stmt.bindLong(4, entity.getRevisionNumber()); | ||
stmt.bindString(5, contentStatusConverter.convertToDatabaseValue(entity.getContentStatus())); | ||
stmt.bindString(6, entity.getText()); | ||
stmt.bindLong(7, entity.getUsageCount()); | ||
} | ||
|
||
@Override | ||
protected final void bindValues(SQLiteStatement stmt, Syllable entity) { | ||
stmt.clearBindings(); | ||
|
||
Long id = entity.getId(); | ||
if (id != null) { | ||
stmt.bindLong(1, id); | ||
} | ||
stmt.bindString(2, localeConverter.convertToDatabaseValue(entity.getLocale())); | ||
|
||
Calendar timeLastUpdate = entity.getTimeLastUpdate(); | ||
if (timeLastUpdate != null) { | ||
stmt.bindLong(3, timeLastUpdateConverter.convertToDatabaseValue(timeLastUpdate)); | ||
} | ||
stmt.bindLong(4, entity.getRevisionNumber()); | ||
stmt.bindString(5, contentStatusConverter.convertToDatabaseValue(entity.getContentStatus())); | ||
stmt.bindString(6, entity.getText()); | ||
stmt.bindLong(7, entity.getUsageCount()); | ||
} | ||
|
||
@Override | ||
public Long readKey(Cursor cursor, int offset) { | ||
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); | ||
} | ||
|
||
@Override | ||
public Syllable readEntity(Cursor cursor, int offset) { | ||
Syllable entity = new Syllable( // | ||
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id | ||
localeConverter.convertToEntityProperty(cursor.getString(offset + 1)), // locale | ||
cursor.isNull(offset + 2) ? null : timeLastUpdateConverter.convertToEntityProperty(cursor.getLong(offset + 2)), // timeLastUpdate | ||
cursor.getInt(offset + 3), // revisionNumber | ||
contentStatusConverter.convertToEntityProperty(cursor.getString(offset + 4)), // contentStatus | ||
cursor.getString(offset + 5), // text | ||
cursor.getInt(offset + 6) // usageCount | ||
); | ||
return entity; | ||
} | ||
|
||
@Override | ||
public void readEntity(Cursor cursor, Syllable entity, int offset) { | ||
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); | ||
entity.setLocale(localeConverter.convertToEntityProperty(cursor.getString(offset + 1))); | ||
entity.setTimeLastUpdate(cursor.isNull(offset + 2) ? null : timeLastUpdateConverter.convertToEntityProperty(cursor.getLong(offset + 2))); | ||
entity.setRevisionNumber(cursor.getInt(offset + 3)); | ||
entity.setContentStatus(contentStatusConverter.convertToEntityProperty(cursor.getString(offset + 4))); | ||
entity.setText(cursor.getString(offset + 5)); | ||
entity.setUsageCount(cursor.getInt(offset + 6)); | ||
} | ||
|
||
@Override | ||
protected final Long updateKeyAfterInsert(Syllable entity, long rowId) { | ||
entity.setId(rowId); | ||
return rowId; | ||
} | ||
|
||
@Override | ||
public Long getKey(Syllable entity) { | ||
if(entity != null) { | ||
return entity.getId(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean hasKey(Syllable entity) { | ||
return entity.getId() != null; | ||
} | ||
|
||
@Override | ||
protected final boolean isEntityUpdateable() { | ||
return true; | ||
} | ||
|
||
} |
Oops, something went wrong.