package com.tofly.data.sql.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.util.Log;

import org.greenrobot.greendao.AbstractDaoMaster;
import org.greenrobot.greendao.database.StandardDatabase;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseOpenHelper;
import org.greenrobot.greendao.identityscope.IdentityScopeType;


// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
 * Master of DAO (schema version 9): knows all DAOs.
 */
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 9;

    /** Creates underlying database table using DAOs. */
    public static void createAllTables(Database db, boolean ifNotExists) {
        OfflineJobNeedDataDao.createTable(db, ifNotExists);
        OfflineWorkJobBeanDao.createTable(db, ifNotExists);
        BuildExamineBeanDao.createTable(db, ifNotExists);
        BuildFileBeanDao.createTable(db, ifNotExists);
        BuildHandleDataBeanDao.createTable(db, ifNotExists);
        BuildLogBeanDao.createTable(db, ifNotExists);
        BuildManageBeanDao.createTable(db, ifNotExists);
        BuildManageFileBeanDao.createTable(db, ifNotExists);
        BuildProcessManageBeanDao.createTable(db, ifNotExists);
        BuildProjectTypeBeanDao.createTable(db, ifNotExists);
        BuildReportBeanDao.createTable(db, ifNotExists);
        BuildSignDataBeanDao.createTable(db, ifNotExists);
        BuildTypeBeanDao.createTable(db, ifNotExists);
        DepartmentBeanDao.createTable(db, ifNotExists);
        UserListBeanDao.createTable(db, ifNotExists);
        DeviceInfoBeanDao.createTable(db, ifNotExists);
        DownloadDataDao.createTable(db, ifNotExists);
        EmergencyOverDataDao.createTable(db, ifNotExists);
        CheckGPSDataBeanDao.createTable(db, ifNotExists);
        GPSDataBeanDao.createTable(db, ifNotExists);
        LocationGPSDataBeanDao.createTable(db, ifNotExists);
        JobBeanDao.createTable(db, ifNotExists);
        NotifyManageBeanDao.createTable(db, ifNotExists);
        FieldsBeanDao.createTable(db, ifNotExists);
        MaintainAdjustParamDao.createTable(db, ifNotExists);
        MaintainCommonParamDao.createTable(db, ifNotExists);
        PlanPointRepairDao.createTable(db, ifNotExists);
        RepairSysDeviceSettingDao.createTable(db, ifNotExists);
        OfflinePathBeanDao.createTable(db, ifNotExists);
        OfflinePointLineBeanDao.createTable(db, ifNotExists);
        PlanBeanDao.createTable(db, ifNotExists);
        RushRepairBeanDao.createTable(db, ifNotExists);
        RushRepairExamineBeanDao.createTable(db, ifNotExists);
        RushRepairFileBeanDao.createTable(db, ifNotExists);
        RushRepairProcessBeanDao.createTable(db, ifNotExists);
        SignDataBeanDao.createTable(db, ifNotExists);
        SignHistoryDataBeanDao.createTable(db, ifNotExists);
        SketchBeanDao.createTable(db, ifNotExists);
        ServerSysConfigBeanDao.createTable(db, ifNotExists);
        SystemConfigBeanDao.createTable(db, ifNotExists);
        PipeTypeBeanDao.createTable(db, ifNotExists);
        SysDeviceTypeBeanDao.createTable(db, ifNotExists);
        TroubleRiskLevelBeanDao.createTable(db, ifNotExists);
        TroubleTypeBeanDao.createTable(db, ifNotExists);
        LocalPlanRecordBeanDao.createTable(db, ifNotExists);
        TroubleAudioBeanDao.createTable(db, ifNotExists);
        TroubleBeanDao.createTable(db, ifNotExists);
        TroublePictureBeanDao.createTable(db, ifNotExists);
        UploadPhotoBeanDao.createTable(db, ifNotExists);
        DepartListBeanDao.createTable(db, ifNotExists);
        DepartUserListBeanDao.createTable(db, ifNotExists);
        MapUrlConfigDataBeanDao.createTable(db, ifNotExists);
        UserBeanDao.createTable(db, ifNotExists);
        UserMapDataBeanDao.createTable(db, ifNotExists);
        UserMenuBeanDao.createTable(db, ifNotExists);
        UserOnlineMapDataBeanDao.createTable(db, ifNotExists);
    }

    /** Drops underlying database table using DAOs. */
    public static void dropAllTables(Database db, boolean ifExists) {
        OfflineJobNeedDataDao.dropTable(db, ifExists);
        OfflineWorkJobBeanDao.dropTable(db, ifExists);
        BuildExamineBeanDao.dropTable(db, ifExists);
        BuildFileBeanDao.dropTable(db, ifExists);
        BuildHandleDataBeanDao.dropTable(db, ifExists);
        BuildLogBeanDao.dropTable(db, ifExists);
        BuildManageBeanDao.dropTable(db, ifExists);
        BuildManageFileBeanDao.dropTable(db, ifExists);
        BuildProcessManageBeanDao.dropTable(db, ifExists);
        BuildProjectTypeBeanDao.dropTable(db, ifExists);
        BuildReportBeanDao.dropTable(db, ifExists);
        BuildSignDataBeanDao.dropTable(db, ifExists);
        BuildTypeBeanDao.dropTable(db, ifExists);
        DepartmentBeanDao.dropTable(db, ifExists);
        UserListBeanDao.dropTable(db, ifExists);
        DeviceInfoBeanDao.dropTable(db, ifExists);
        DownloadDataDao.dropTable(db, ifExists);
        EmergencyOverDataDao.dropTable(db, ifExists);
        CheckGPSDataBeanDao.dropTable(db, ifExists);
        GPSDataBeanDao.dropTable(db, ifExists);
        LocationGPSDataBeanDao.dropTable(db, ifExists);
        JobBeanDao.dropTable(db, ifExists);
        NotifyManageBeanDao.dropTable(db, ifExists);
        FieldsBeanDao.dropTable(db, ifExists);
        MaintainAdjustParamDao.dropTable(db, ifExists);
        MaintainCommonParamDao.dropTable(db, ifExists);
        PlanPointRepairDao.dropTable(db, ifExists);
        RepairSysDeviceSettingDao.dropTable(db, ifExists);
        OfflinePathBeanDao.dropTable(db, ifExists);
        OfflinePointLineBeanDao.dropTable(db, ifExists);
        PlanBeanDao.dropTable(db, ifExists);
        RushRepairBeanDao.dropTable(db, ifExists);
        RushRepairExamineBeanDao.dropTable(db, ifExists);
        RushRepairFileBeanDao.dropTable(db, ifExists);
        RushRepairProcessBeanDao.dropTable(db, ifExists);
        SignDataBeanDao.dropTable(db, ifExists);
        SignHistoryDataBeanDao.dropTable(db, ifExists);
        SketchBeanDao.dropTable(db, ifExists);
        ServerSysConfigBeanDao.dropTable(db, ifExists);
        SystemConfigBeanDao.dropTable(db, ifExists);
        PipeTypeBeanDao.dropTable(db, ifExists);
        SysDeviceTypeBeanDao.dropTable(db, ifExists);
        TroubleRiskLevelBeanDao.dropTable(db, ifExists);
        TroubleTypeBeanDao.dropTable(db, ifExists);
        LocalPlanRecordBeanDao.dropTable(db, ifExists);
        TroubleAudioBeanDao.dropTable(db, ifExists);
        TroubleBeanDao.dropTable(db, ifExists);
        TroublePictureBeanDao.dropTable(db, ifExists);
        UploadPhotoBeanDao.dropTable(db, ifExists);
        DepartListBeanDao.dropTable(db, ifExists);
        DepartUserListBeanDao.dropTable(db, ifExists);
        MapUrlConfigDataBeanDao.dropTable(db, ifExists);
        UserBeanDao.dropTable(db, ifExists);
        UserMapDataBeanDao.dropTable(db, ifExists);
        UserMenuBeanDao.dropTable(db, ifExists);
        UserOnlineMapDataBeanDao.dropTable(db, ifExists);
    }

    /**
     * WARNING: Drops all table on Upgrade! Use only during development.
     * Convenience method using a {@link DevOpenHelper}.
     */
    public static DaoSession newDevSession(Context context, String name) {
        Database db = new DevOpenHelper(context, name).getWritableDb();
        DaoMaster daoMaster = new DaoMaster(db);
        return daoMaster.newSession();
    }

    public DaoMaster(SQLiteDatabase db) {
        this(new StandardDatabase(db));
    }

    public DaoMaster(Database db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(OfflineJobNeedDataDao.class);
        registerDaoClass(OfflineWorkJobBeanDao.class);
        registerDaoClass(BuildExamineBeanDao.class);
        registerDaoClass(BuildFileBeanDao.class);
        registerDaoClass(BuildHandleDataBeanDao.class);
        registerDaoClass(BuildLogBeanDao.class);
        registerDaoClass(BuildManageBeanDao.class);
        registerDaoClass(BuildManageFileBeanDao.class);
        registerDaoClass(BuildProcessManageBeanDao.class);
        registerDaoClass(BuildProjectTypeBeanDao.class);
        registerDaoClass(BuildReportBeanDao.class);
        registerDaoClass(BuildSignDataBeanDao.class);
        registerDaoClass(BuildTypeBeanDao.class);
        registerDaoClass(DepartmentBeanDao.class);
        registerDaoClass(UserListBeanDao.class);
        registerDaoClass(DeviceInfoBeanDao.class);
        registerDaoClass(DownloadDataDao.class);
        registerDaoClass(EmergencyOverDataDao.class);
        registerDaoClass(CheckGPSDataBeanDao.class);
        registerDaoClass(GPSDataBeanDao.class);
        registerDaoClass(LocationGPSDataBeanDao.class);
        registerDaoClass(JobBeanDao.class);
        registerDaoClass(NotifyManageBeanDao.class);
        registerDaoClass(FieldsBeanDao.class);
        registerDaoClass(MaintainAdjustParamDao.class);
        registerDaoClass(MaintainCommonParamDao.class);
        registerDaoClass(PlanPointRepairDao.class);
        registerDaoClass(RepairSysDeviceSettingDao.class);
        registerDaoClass(OfflinePathBeanDao.class);
        registerDaoClass(OfflinePointLineBeanDao.class);
        registerDaoClass(PlanBeanDao.class);
        registerDaoClass(RushRepairBeanDao.class);
        registerDaoClass(RushRepairExamineBeanDao.class);
        registerDaoClass(RushRepairFileBeanDao.class);
        registerDaoClass(RushRepairProcessBeanDao.class);
        registerDaoClass(SignDataBeanDao.class);
        registerDaoClass(SignHistoryDataBeanDao.class);
        registerDaoClass(SketchBeanDao.class);
        registerDaoClass(ServerSysConfigBeanDao.class);
        registerDaoClass(SystemConfigBeanDao.class);
        registerDaoClass(PipeTypeBeanDao.class);
        registerDaoClass(SysDeviceTypeBeanDao.class);
        registerDaoClass(TroubleRiskLevelBeanDao.class);
        registerDaoClass(TroubleTypeBeanDao.class);
        registerDaoClass(LocalPlanRecordBeanDao.class);
        registerDaoClass(TroubleAudioBeanDao.class);
        registerDaoClass(TroubleBeanDao.class);
        registerDaoClass(TroublePictureBeanDao.class);
        registerDaoClass(UploadPhotoBeanDao.class);
        registerDaoClass(DepartListBeanDao.class);
        registerDaoClass(DepartUserListBeanDao.class);
        registerDaoClass(MapUrlConfigDataBeanDao.class);
        registerDaoClass(UserBeanDao.class);
        registerDaoClass(UserMapDataBeanDao.class);
        registerDaoClass(UserMenuBeanDao.class);
        registerDaoClass(UserOnlineMapDataBeanDao.class);
    }

    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }

    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }

    /**
     * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
     */
    public static abstract class OpenHelper extends DatabaseOpenHelper {
        public OpenHelper(Context context, String name) {
            super(context, name, SCHEMA_VERSION);
        }

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(Database db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }

    /** WARNING: Drops all table on Upgrade! Use only during development. */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name) {
            super(context, name);
        }

        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(Database db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

}
