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

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

    public static final String TABLENAME = "TR_LOGO_PRINT";

    /**
     * Properties of entity LogoPrint.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Uuid_logo_print = new Property(0, String.class, "uuid_logo_print", true, "UUID_LOGO_PRINT");
        public final static Property Tenant = new Property(1, String.class, "tenant", false, "TENANT");
        public final static Property Image_bitmap = new Property(2, byte[].class, "image_bitmap", false, "IMAGE_BITMAP");
    };


    public LogoPrintDao(DaoConfig config) {
        super(config);
    }
    
    public LogoPrintDao(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_LOGO_PRINT\" (" + //
                "\"UUID_LOGO_PRINT\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_logo_print
                "\"TENANT\" TEXT NOT NULL ," + // 1: tenant
                "\"IMAGE_BITMAP\" BLOB);"); // 2: image_bitmap
    }

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

    /** @inheritdoc */
    @Override
    protected void bindValues(DatabaseStatement stmt, LogoPrint entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getUuid_logo_print());
        stmt.bindString(2, entity.getTenant());
 
        byte[] image_bitmap = entity.getImage_bitmap();
        if (image_bitmap != null) {
            stmt.bindBlob(3, image_bitmap);
        }
    }

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

    /** @inheritdoc */
    @Override
    public LogoPrint readEntity(Cursor cursor, int offset) {
        LogoPrint entity = new LogoPrint( //
            cursor.getString(offset + 0), // uuid_logo_print
            cursor.getString(offset + 1), // tenant
            cursor.isNull(offset + 2) ? null : cursor.getBlob(offset + 2) // image_bitmap
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, LogoPrint entity, int offset) {
        entity.setUuid_logo_print(cursor.getString(offset + 0));
        entity.setTenant(cursor.getString(offset + 1));
        entity.setImage_bitmap(cursor.isNull(offset + 2) ? null : cursor.getBlob(offset + 2));
     }
    
    /** @inheritdoc */
    @Override
    protected String updateKeyAfterInsert(LogoPrint entity, long rowId) {
        return entity.getUuid_logo_print();
    }
    
    /** @inheritdoc */
    @Override
    public String getKey(LogoPrint entity) {
        if(entity != null) {
            return entity.getUuid_logo_print();
        } else {
            return null;
        }
    }

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