package com.cc.infosur.greendao;

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;



// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table DANGEROUS.
*/
public class DangerousDao extends AbstractDao<Dangerous, Long> {

    public static final String TABLENAME = "DANGEROUS";

    /**
     * Properties of entity Dangerous.<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 MessageId = new Property(1, Long.class, "messageId", false, "MESSAGE_ID");
        public final static Property Selected = new Property(2, Boolean.class, "selected", false, "SELECTED");
        public final static Property Text = new Property(3, String.class, "text", false, "TEXT");
        public final static Property Lat = new Property(4, String.class, "lat", false, "LAT");
        public final static Property Lon = new Property(5, String.class, "lon", false, "LON");
        public final static Property PhotoPath = new Property(6, String.class, "photoPath", false, "PHOTO_PATH");
        public final static Property Date = new Property(7, java.util.Date.class, "date", false, "DATE");
        public final static Property Sent = new Property(8, Boolean.class, "sent", false, "SENT");
        public final static Property Status = new Property(9, String.class, "status", false, "STATUS");
        public final static Property Rock7Id = new Property(10, Long.class, "rock7Id", false, "ROCK7_ID");
        public final static Property TosendOrder = new Property(11, Long.class, "tosendOrder", false, "TOSEND_ORDER");
    };


    public DangerousDao(DaoConfig config) {
        super(config);
    }
    
    public DangerousDao(DaoConfig config, DaoSession daoSession) {
        super(config, 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 + "'DANGEROUS' (" + //
                "'_id' INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "'MESSAGE_ID' INTEGER," + // 1: messageId
                "'SELECTED' INTEGER," + // 2: selected
                "'TEXT' TEXT," + // 3: text
                "'LAT' TEXT," + // 4: lat
                "'LON' TEXT," + // 5: lon
                "'PHOTO_PATH' TEXT," + // 6: photoPath
                "'DATE' INTEGER," + // 7: date
                "'SENT' INTEGER," + // 8: sent
                "'STATUS' TEXT," + // 9: status
                "'ROCK7_ID' INTEGER," + // 10: rock7Id
                "'TOSEND_ORDER' INTEGER);"); // 11: tosendOrder
    }

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

    /** @inheritdoc */
    @Override
    protected void bindValues(SQLiteStatement stmt, Dangerous entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Long messageId = entity.getMessageId();
        if (messageId != null) {
            stmt.bindLong(2, messageId);
        }
 
        Boolean selected = entity.getSelected();
        if (selected != null) {
            stmt.bindLong(3, selected ? 1l: 0l);
        }
 
        String text = entity.getText();
        if (text != null) {
            stmt.bindString(4, text);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(5, lat);
        }
 
        String lon = entity.getLon();
        if (lon != null) {
            stmt.bindString(6, lon);
        }
 
        String photoPath = entity.getPhotoPath();
        if (photoPath != null) {
            stmt.bindString(7, photoPath);
        }
 
        java.util.Date date = entity.getDate();
        if (date != null) {
            stmt.bindLong(8, date.getTime());
        }
 
        Boolean sent = entity.getSent();
        if (sent != null) {
            stmt.bindLong(9, sent ? 1l: 0l);
        }
 
        String status = entity.getStatus();
        if (status != null) {
            stmt.bindString(10, status);
        }
 
        Long rock7Id = entity.getRock7Id();
        if (rock7Id != null) {
            stmt.bindLong(11, rock7Id);
        }
 
        Long tosendOrder = entity.getTosendOrder();
        if (tosendOrder != null) {
            stmt.bindLong(12, tosendOrder);
        }
    }

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

    /** @inheritdoc */
    @Override
    public Dangerous readEntity(Cursor cursor, int offset) {
        Dangerous entity = new Dangerous( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // messageId
            cursor.isNull(offset + 2) ? null : cursor.getShort(offset + 2) != 0, // selected
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // text
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // lat
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // lon
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // photoPath
            cursor.isNull(offset + 7) ? null : new java.util.Date(cursor.getLong(offset + 7)), // date
            cursor.isNull(offset + 8) ? null : cursor.getShort(offset + 8) != 0, // sent
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // status
            cursor.isNull(offset + 10) ? null : cursor.getLong(offset + 10), // rock7Id
            cursor.isNull(offset + 11) ? null : cursor.getLong(offset + 11) // tosendOrder
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, Dangerous entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setMessageId(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setSelected(cursor.isNull(offset + 2) ? null : cursor.getShort(offset + 2) != 0);
        entity.setText(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setLat(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setLon(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setPhotoPath(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setDate(cursor.isNull(offset + 7) ? null : new java.util.Date(cursor.getLong(offset + 7)));
        entity.setSent(cursor.isNull(offset + 8) ? null : cursor.getShort(offset + 8) != 0);
        entity.setStatus(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setRock7Id(cursor.isNull(offset + 10) ? null : cursor.getLong(offset + 10));
        entity.setTosendOrder(cursor.isNull(offset + 11) ? null : cursor.getLong(offset + 11));
     }
    
    /** @inheritdoc */
    @Override
    protected Long updateKeyAfterInsert(Dangerous entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    /** @inheritdoc */
    @Override
    public Long getKey(Dangerous entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    /** @inheritdoc */
    @Override    
    protected boolean isEntityUpdateable() {
        return true;
    }
    
}
