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.GroupTask;

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

    public static final String TABLENAME = "MS_GROUPTASK";

    /**
     * Properties of entity GroupTask.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Uuid_group_task = new Property(0, String.class, "uuid_group_task", true, "UUID_GROUP_TASK");
        public final static Property Group_task_id = new Property(1, String.class, "group_task_id", false, "GROUP_TASK_ID");
        public final static Property Uuid_account = new Property(2, String.class, "uuid_account", false, "UUID_ACCOUNT");
        public final static Property Last_status = new Property(3, String.class, "last_status", false, "LAST_STATUS");
        public final static Property Product_name = new Property(4, String.class, "product_name", false, "PRODUCT_NAME");
        public final static Property Project_nett = new Property(5, Integer.class, "project_nett", false, "PROJECT_NETT");
        public final static Property Dtm_crt = new Property(6, java.util.Date.class, "dtm_crt", false, "DTM_CRT");
    };


    public GroupTaskDao(DaoConfig config) {
        super(config);
    }
    
    public GroupTaskDao(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 + "\"MS_GROUPTASK\" (" + //
                "\"UUID_GROUP_TASK\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_group_task
                "\"GROUP_TASK_ID\" TEXT," + // 1: group_task_id
                "\"UUID_ACCOUNT\" TEXT," + // 2: uuid_account
                "\"LAST_STATUS\" TEXT," + // 3: last_status
                "\"PRODUCT_NAME\" TEXT," + // 4: product_name
                "\"PROJECT_NETT\" INTEGER," + // 5: project_nett
                "\"DTM_CRT\" INTEGER);"); // 6: dtm_crt
    }

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

    /** @inheritdoc */
    @Override
    protected void bindValues(DatabaseStatement stmt, GroupTask entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getUuid_group_task());
 
        String group_task_id = entity.getGroup_task_id();
        if (group_task_id != null) {
            stmt.bindString(2, group_task_id);
        }
 
        String uuid_account = entity.getUuid_account();
        if (uuid_account != null) {
            stmt.bindString(3, uuid_account);
        }
 
        String last_status = entity.getLast_status();
        if (last_status != null) {
            stmt.bindString(4, last_status);
        }
 
        String product_name = entity.getProduct_name();
        if (product_name != null) {
            stmt.bindString(5, product_name);
        }
 
        Integer project_nett = entity.getProject_nett();
        if (project_nett != null) {
            stmt.bindLong(6, project_nett);
        }
 
        java.util.Date dtm_crt = entity.getDtm_crt();
        if (dtm_crt != null) {
            stmt.bindLong(7, dtm_crt.getTime());
        }
    }

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

    /** @inheritdoc */
    @Override
    public GroupTask readEntity(Cursor cursor, int offset) {
        GroupTask entity = new GroupTask( //
            cursor.getString(offset + 0), // uuid_group_task
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // group_task_id
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // uuid_account
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // last_status
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // product_name
            cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // project_nett
            cursor.isNull(offset + 6) ? null : new java.util.Date(cursor.getLong(offset + 6)) // dtm_crt
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, GroupTask entity, int offset) {
        entity.setUuid_group_task(cursor.getString(offset + 0));
        entity.setGroup_task_id(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setUuid_account(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setLast_status(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setProduct_name(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setProject_nett(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
        entity.setDtm_crt(cursor.isNull(offset + 6) ? null : new java.util.Date(cursor.getLong(offset + 6)));
     }
    
    /** @inheritdoc */
    @Override
    protected String updateKeyAfterInsert(GroupTask entity, long rowId) {
        return entity.getUuid_group_task();
    }
    
    /** @inheritdoc */
    @Override
    public String getKey(GroupTask entity) {
        if(entity != null) {
            return entity.getUuid_group_task();
        } else {
            return null;
        }
    }

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