package com.tofly.data.sql.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 com.tofly.ghrq_route.module.job.domain.JobBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "DB_MY_JOB_BEAN".
*/
public class JobBeanDao extends AbstractDao<JobBean, String> {

    public static final String TABLENAME = "DB_MY_JOB_BEAN";

    /**
     * Properties of entity JobBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, String.class, "id", true, "ID");
        public final static Property Caption = new Property(1, String.class, "caption", false, "CAPTION");
        public final static Property Longitude = new Property(2, double.class, "longitude", false, "LONGITUDE");
        public final static Property Latitude = new Property(3, double.class, "latitude", false, "LATITUDE");
        public final static Property X = new Property(4, double.class, "x", false, "X");
        public final static Property Y = new Property(5, double.class, "y", false, "Y");
        public final static Property DispatchRealname = new Property(6, String.class, "dispatchRealname", false, "DISPATCH_REALNAME");
        public final static Property DispatchDate = new Property(7, String.class, "dispatchDate", false, "DISPATCH_DATE");
        public final static Property PlanFinishDate = new Property(8, String.class, "planFinishDate", false, "PLAN_FINISH_DATE");
        public final static Property FinishDate = new Property(9, String.class, "finishDate", false, "FINISH_DATE");
        public final static Property TaskStatus = new Property(10, int.class, "taskStatus", false, "TASK_STATUS");
        public final static Property Userid = new Property(11, String.class, "userid", false, "USERID");
        public final static Property Content = new Property(12, String.class, "content", false, "CONTENT");
        public final static Property Taskbh = new Property(13, String.class, "taskbh", false, "TASKBH");
        public final static Property HandleRecord = new Property(14, String.class, "handleRecord", false, "HANDLE_RECORD");
        public final static Property Address = new Property(15, String.class, "address", false, "ADDRESS");
        public final static Property Commit_status = new Property(16, int.class, "commit_status", false, "COMMIT_STATUS");
    }


    public JobBeanDao(DaoConfig config) {
        super(config);
    }
    
    public JobBeanDao(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 + "\"DB_MY_JOB_BEAN\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"CAPTION\" TEXT," + // 1: caption
                "\"LONGITUDE\" REAL NOT NULL ," + // 2: longitude
                "\"LATITUDE\" REAL NOT NULL ," + // 3: latitude
                "\"X\" REAL NOT NULL ," + // 4: x
                "\"Y\" REAL NOT NULL ," + // 5: y
                "\"DISPATCH_REALNAME\" TEXT," + // 6: dispatchRealname
                "\"DISPATCH_DATE\" TEXT," + // 7: dispatchDate
                "\"PLAN_FINISH_DATE\" TEXT," + // 8: planFinishDate
                "\"FINISH_DATE\" TEXT," + // 9: finishDate
                "\"TASK_STATUS\" INTEGER NOT NULL ," + // 10: taskStatus
                "\"USERID\" TEXT," + // 11: userid
                "\"CONTENT\" TEXT," + // 12: content
                "\"TASKBH\" TEXT," + // 13: taskbh
                "\"HANDLE_RECORD\" TEXT," + // 14: handleRecord
                "\"ADDRESS\" TEXT," + // 15: address
                "\"COMMIT_STATUS\" INTEGER NOT NULL );"); // 16: commit_status
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, JobBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String caption = entity.getCaption();
        if (caption != null) {
            stmt.bindString(2, caption);
        }
        stmt.bindDouble(3, entity.getLongitude());
        stmt.bindDouble(4, entity.getLatitude());
        stmt.bindDouble(5, entity.getX());
        stmt.bindDouble(6, entity.getY());
 
        String dispatchRealname = entity.getDispatchRealname();
        if (dispatchRealname != null) {
            stmt.bindString(7, dispatchRealname);
        }
 
        String dispatchDate = entity.getDispatchDate();
        if (dispatchDate != null) {
            stmt.bindString(8, dispatchDate);
        }
 
        String planFinishDate = entity.getPlanFinishDate();
        if (planFinishDate != null) {
            stmt.bindString(9, planFinishDate);
        }
 
        String finishDate = entity.getFinishDate();
        if (finishDate != null) {
            stmt.bindString(10, finishDate);
        }
        stmt.bindLong(11, entity.getTaskStatus());
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(12, userid);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(13, content);
        }
 
        String taskbh = entity.getTaskbh();
        if (taskbh != null) {
            stmt.bindString(14, taskbh);
        }
 
        String handleRecord = entity.getHandleRecord();
        if (handleRecord != null) {
            stmt.bindString(15, handleRecord);
        }
 
        String address = entity.getAddress();
        if (address != null) {
            stmt.bindString(16, address);
        }
        stmt.bindLong(17, entity.getCommit_status());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, JobBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String caption = entity.getCaption();
        if (caption != null) {
            stmt.bindString(2, caption);
        }
        stmt.bindDouble(3, entity.getLongitude());
        stmt.bindDouble(4, entity.getLatitude());
        stmt.bindDouble(5, entity.getX());
        stmt.bindDouble(6, entity.getY());
 
        String dispatchRealname = entity.getDispatchRealname();
        if (dispatchRealname != null) {
            stmt.bindString(7, dispatchRealname);
        }
 
        String dispatchDate = entity.getDispatchDate();
        if (dispatchDate != null) {
            stmt.bindString(8, dispatchDate);
        }
 
        String planFinishDate = entity.getPlanFinishDate();
        if (planFinishDate != null) {
            stmt.bindString(9, planFinishDate);
        }
 
        String finishDate = entity.getFinishDate();
        if (finishDate != null) {
            stmt.bindString(10, finishDate);
        }
        stmt.bindLong(11, entity.getTaskStatus());
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(12, userid);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(13, content);
        }
 
        String taskbh = entity.getTaskbh();
        if (taskbh != null) {
            stmt.bindString(14, taskbh);
        }
 
        String handleRecord = entity.getHandleRecord();
        if (handleRecord != null) {
            stmt.bindString(15, handleRecord);
        }
 
        String address = entity.getAddress();
        if (address != null) {
            stmt.bindString(16, address);
        }
        stmt.bindLong(17, entity.getCommit_status());
    }

    @Override
    public String readKey(Cursor cursor, int offset) {
        return cursor.getString(offset + 0);
    }    

    @Override
    public JobBean readEntity(Cursor cursor, int offset) {
        JobBean entity = new JobBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // caption
            cursor.getDouble(offset + 2), // longitude
            cursor.getDouble(offset + 3), // latitude
            cursor.getDouble(offset + 4), // x
            cursor.getDouble(offset + 5), // y
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // dispatchRealname
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // dispatchDate
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // planFinishDate
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // finishDate
            cursor.getInt(offset + 10), // taskStatus
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // userid
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // content
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // taskbh
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // handleRecord
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // address
            cursor.getInt(offset + 16) // commit_status
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, JobBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setCaption(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setLongitude(cursor.getDouble(offset + 2));
        entity.setLatitude(cursor.getDouble(offset + 3));
        entity.setX(cursor.getDouble(offset + 4));
        entity.setY(cursor.getDouble(offset + 5));
        entity.setDispatchRealname(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setDispatchDate(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setPlanFinishDate(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setFinishDate(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setTaskStatus(cursor.getInt(offset + 10));
        entity.setUserid(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setContent(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setTaskbh(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setHandleRecord(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setAddress(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setCommit_status(cursor.getInt(offset + 16));
     }
    
    @Override
    protected final String updateKeyAfterInsert(JobBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(JobBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(JobBean entity) {
        throw new UnsupportedOperationException("Unsupported for entities with a non-null key");
    }

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