package com.adins.mss.dao;

import android.database.Cursor;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;
import de.greenrobot.dao.database.Database;
import de.greenrobot.dao.database.DatabaseStatement;

import com.adins.mss.dao.TaskSummary;

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

    public static final String TABLENAME = "TR_TASK_SUMMARY";

    /**
     * Properties of entity TaskSummary.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Uuid_task_summary = new Property(0, String.class, "uuid_task_summary", true, "UUID_TASK_SUMMARY");
        public final static Property Uuid_task_h = new Property(1, String.class, "uuid_task_h", false, "UUID_TASK_H");
        public final static Property Uuid_user = new Property(2, String.class, "uuid_user", false, "UUID_USER");
        public final static Property Task_status = new Property(3, String.class, "task_status", false, "TASK_STATUS");
        public final static Property Dtm_crt = new Property(4, java.util.Date.class, "dtm_crt", false, "DTM_CRT");
    };


    public TaskSummaryDao(DaoConfig config) {
        super(config);
    }
    
    public TaskSummaryDao(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 + "\"TR_TASK_SUMMARY\" (" + //
                "\"UUID_TASK_SUMMARY\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_task_summary
                "\"UUID_TASK_H\" TEXT," + // 1: uuid_task_h
                "\"UUID_USER\" TEXT," + // 2: uuid_user
                "\"TASK_STATUS\" TEXT," + // 3: task_status
                "\"DTM_CRT\" INTEGER);"); // 4: dtm_crt
    }

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

    /** @inheritdoc */
    @Override
    protected void bindValues(DatabaseStatement stmt, TaskSummary entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getUuid_task_summary());
 
        String uuid_task_h = entity.getUuid_task_h();
        if (uuid_task_h != null) {
            stmt.bindString(2, uuid_task_h);
        }
 
        String uuid_user = entity.getUuid_user();
        if (uuid_user != null) {
            stmt.bindString(3, uuid_user);
        }
 
        String task_status = entity.getTask_status();
        if (task_status != null) {
            stmt.bindString(4, task_status);
        }
 
        java.util.Date dtm_crt = entity.getDtm_crt();
        if (dtm_crt != null) {
            stmt.bindLong(5, dtm_crt.getTime());
        }
    }

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

    /** @inheritdoc */
    @Override
    public TaskSummary readEntity(Cursor cursor, int offset) {
        TaskSummary entity = new TaskSummary( //
            cursor.getString(offset + 0), // uuid_task_summary
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // uuid_task_h
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // uuid_user
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // task_status
            cursor.isNull(offset + 4) ? null : new java.util.Date(cursor.getLong(offset + 4)) // dtm_crt
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, TaskSummary entity, int offset) {
        entity.setUuid_task_summary(cursor.getString(offset + 0));
        entity.setUuid_task_h(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setUuid_user(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setTask_status(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setDtm_crt(cursor.isNull(offset + 4) ? null : new java.util.Date(cursor.getLong(offset + 4)));
     }
    
    /** @inheritdoc */
    @Override
    protected String updateKeyAfterInsert(TaskSummary entity, long rowId) {
        return entity.getUuid_task_summary();
    }
    
    /** @inheritdoc */
    @Override
    public String getKey(TaskSummary entity) {
        if(entity != null) {
            return entity.getUuid_task_summary();
        } else {
            return null;
        }
    }

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