package id.ac.itats.skripsi.orm;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;
import id.ac.itats.skripsi.orm.Node;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table NODE.
*/
public class NodeDao extends AbstractDao<Node, Long> {
public static final String TABLENAME = "NODE";
/**
* Properties of entity Node.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property NodeID = new Property(0, Long.class, "nodeID", true, "NODE_ID");
public final static Property Latitude = new Property(1, String.class, "latitude", false, "LATITUDE");
public final static Property Longitude = new Property(2, String.class, "longitude", false, "LONGITUDE");
};
private DaoSession daoSession;
public NodeDao(DaoConfig config) {
super(config);
}
public NodeDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
this.daoSession = daoSession;
}
/** Creates the underlying database table. */
public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "'NODE' (" + //
"'NODE_ID' INTEGER PRIMARY KEY ," + // 0: nodeID
"'LATITUDE' TEXT," + // 1: latitude
"'LONGITUDE' TEXT);"); // 2: longitude
// Add Indexes
db.execSQL("CREATE INDEX " + constraint + "IDX_NODE_NODE_ID ON NODE" +
" (NODE_ID);");
}
/** Drops the underlying database table. */
public static void dropTable(SQLiteDatabase db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'NODE'";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, Node entity) {
stmt.clearBindings();
Long nodeID = entity.getNodeID();
if (nodeID != null) {
stmt.bindLong(1, nodeID);
}
String latitude = entity.getLatitude();
if (latitude != null) {
stmt.bindString(2, latitude);
}
String longitude = entity.getLongitude();
if (longitude != null) {
stmt.bindString(3, longitude);
}
}
@Override
protected void attachEntity(Node entity) {
super.attachEntity(entity);
entity.__setDaoSession(daoSession);
}
/** @inheritdoc */
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
/** @inheritdoc */
@Override
public Node readEntity(Cursor cursor, int offset) {
Node entity = new Node( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // nodeID
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // latitude
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2) // longitude
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, Node entity, int offset) {
entity.setNodeID(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setLatitude(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setLongitude(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
}
/** @inheritdoc */
@Override
protected Long updateKeyAfterInsert(Node entity, long rowId) {
entity.setNodeID(rowId);
return rowId;
}
/** @inheritdoc */
@Override
public Long getKey(Node entity) {
if(entity != null) {
return entity.getNodeID();
} else {
return null;
}
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
}