package com.wistronits.wh.annbot.data.greendao;

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.wistronits.wh.annbot.models.UserModel;

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

    public static final String TABLENAME = "USER_MODEL";

    /**
     * Properties of entity UserModel.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property CaseId = new Property(0, String.class, "caseId", true, "CASE_ID");
        public final static Property CaseNo = new Property(1, String.class, "caseNo", false, "CASE_NO");
        public final static Property IsInterrupt = new Property(2, String.class, "isInterrupt", false, "IS_INTERRUPT");
        public final static Property OrgCaseNo = new Property(3, String.class, "orgCaseNo", false, "ORG_CASE_NO");
        public final static Property Sex = new Property(4, String.class, "sex", false, "SEX");
        public final static Property BedNo = new Property(5, String.class, "bedNo", false, "BED_NO");
        public final static Property CaseName = new Property(6, String.class, "caseName", false, "CASE_NAME");
        public final static Property CaseNamePinyin = new Property(7, String.class, "caseNamePinyin", false, "CASE_NAME_PINYIN");
        public final static Property CostCode = new Property(8, String.class, "costCode", false, "COST_CODE");
        public final static Property CostDesc = new Property(9, String.class, "costDesc", false, "COST_DESC");
        public final static Property Birthday = new Property(10, String.class, "birthday", false, "BIRTHDAY");
        public final static Property OrgNo = new Property(11, String.class, "orgNo", false, "ORG_NO");
        public final static Property UpdateTime = new Property(12, String.class, "updateTime", false, "UPDATE_TIME");
        public final static Property CreateTime = new Property(13, String.class, "createTime", false, "CREATE_TIME");
    }


    public UserModelDao(DaoConfig config) {
        super(config);
    }
    
    public UserModelDao(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 + "\"USER_MODEL\" (" + //
                "\"CASE_ID\" TEXT PRIMARY KEY NOT NULL ," + // 0: caseId
                "\"CASE_NO\" TEXT," + // 1: caseNo
                "\"IS_INTERRUPT\" TEXT," + // 2: isInterrupt
                "\"ORG_CASE_NO\" TEXT," + // 3: orgCaseNo
                "\"SEX\" TEXT," + // 4: sex
                "\"BED_NO\" TEXT," + // 5: bedNo
                "\"CASE_NAME\" TEXT," + // 6: caseName
                "\"CASE_NAME_PINYIN\" TEXT," + // 7: caseNamePinyin
                "\"COST_CODE\" TEXT," + // 8: costCode
                "\"COST_DESC\" TEXT," + // 9: costDesc
                "\"BIRTHDAY\" TEXT," + // 10: birthday
                "\"ORG_NO\" TEXT," + // 11: orgNo
                "\"UPDATE_TIME\" TEXT," + // 12: updateTime
                "\"CREATE_TIME\" TEXT);"); // 13: createTime
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, UserModel entity) {
        stmt.clearBindings();
 
        String caseId = entity.getCaseId();
        if (caseId != null) {
            stmt.bindString(1, caseId);
        }
 
        String caseNo = entity.getCaseNo();
        if (caseNo != null) {
            stmt.bindString(2, caseNo);
        }
 
        String isInterrupt = entity.getIsInterrupt();
        if (isInterrupt != null) {
            stmt.bindString(3, isInterrupt);
        }
 
        String orgCaseNo = entity.getOrgCaseNo();
        if (orgCaseNo != null) {
            stmt.bindString(4, orgCaseNo);
        }
 
        String sex = entity.getSex();
        if (sex != null) {
            stmt.bindString(5, sex);
        }
 
        String bedNo = entity.getBedNo();
        if (bedNo != null) {
            stmt.bindString(6, bedNo);
        }
 
        String caseName = entity.getCaseName();
        if (caseName != null) {
            stmt.bindString(7, caseName);
        }
 
        String caseNamePinyin = entity.getCaseNamePinyin();
        if (caseNamePinyin != null) {
            stmt.bindString(8, caseNamePinyin);
        }
 
        String costCode = entity.getCostCode();
        if (costCode != null) {
            stmt.bindString(9, costCode);
        }
 
        String costDesc = entity.getCostDesc();
        if (costDesc != null) {
            stmt.bindString(10, costDesc);
        }
 
        String birthday = entity.getBirthday();
        if (birthday != null) {
            stmt.bindString(11, birthday);
        }
 
        String orgNo = entity.getOrgNo();
        if (orgNo != null) {
            stmt.bindString(12, orgNo);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(13, updateTime);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(14, createTime);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, UserModel entity) {
        stmt.clearBindings();
 
        String caseId = entity.getCaseId();
        if (caseId != null) {
            stmt.bindString(1, caseId);
        }
 
        String caseNo = entity.getCaseNo();
        if (caseNo != null) {
            stmt.bindString(2, caseNo);
        }
 
        String isInterrupt = entity.getIsInterrupt();
        if (isInterrupt != null) {
            stmt.bindString(3, isInterrupt);
        }
 
        String orgCaseNo = entity.getOrgCaseNo();
        if (orgCaseNo != null) {
            stmt.bindString(4, orgCaseNo);
        }
 
        String sex = entity.getSex();
        if (sex != null) {
            stmt.bindString(5, sex);
        }
 
        String bedNo = entity.getBedNo();
        if (bedNo != null) {
            stmt.bindString(6, bedNo);
        }
 
        String caseName = entity.getCaseName();
        if (caseName != null) {
            stmt.bindString(7, caseName);
        }
 
        String caseNamePinyin = entity.getCaseNamePinyin();
        if (caseNamePinyin != null) {
            stmt.bindString(8, caseNamePinyin);
        }
 
        String costCode = entity.getCostCode();
        if (costCode != null) {
            stmt.bindString(9, costCode);
        }
 
        String costDesc = entity.getCostDesc();
        if (costDesc != null) {
            stmt.bindString(10, costDesc);
        }
 
        String birthday = entity.getBirthday();
        if (birthday != null) {
            stmt.bindString(11, birthday);
        }
 
        String orgNo = entity.getOrgNo();
        if (orgNo != null) {
            stmt.bindString(12, orgNo);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(13, updateTime);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(14, createTime);
        }
    }

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

    @Override
    public UserModel readEntity(Cursor cursor, int offset) {
        UserModel entity = new UserModel( //
            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // caseId
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // caseNo
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // isInterrupt
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // orgCaseNo
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // sex
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // bedNo
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // caseName
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // caseNamePinyin
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // costCode
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // costDesc
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // birthday
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // orgNo
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // updateTime
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13) // createTime
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, UserModel entity, int offset) {
        entity.setCaseId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setCaseNo(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setIsInterrupt(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setOrgCaseNo(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setSex(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setBedNo(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setCaseName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setCaseNamePinyin(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setCostCode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setCostDesc(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setBirthday(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setOrgNo(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setUpdateTime(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setCreateTime(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
     }
    
    @Override
    protected final String updateKeyAfterInsert(UserModel entity, long rowId) {
        return entity.getCaseId();
    }
    
    @Override
    public String getKey(UserModel entity) {
        if(entity != null) {
            return entity.getCaseId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(UserModel entity) {
        return entity.getCaseId() != null;
    }

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