package in.techware.carrefour.dbUtils;

import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.arch.persistence.room.TypeConverters;

import in.techware.carrefour.app.App;
import in.techware.carrefour.dbUtils.dao.FacingDao;
import in.techware.carrefour.dbUtils.dao.InternalSalesCorrectionDao;
import in.techware.carrefour.dbUtils.dao.InternalSalesDao;
import in.techware.carrefour.dbUtils.dao.ItemListDao;
import in.techware.carrefour.dbUtils.dao.LabelSurveyDao;
import in.techware.carrefour.dbUtils.dao.MinStockDao;
import in.techware.carrefour.dbUtils.dao.OutOfStockDao;
import in.techware.carrefour.dbUtils.dao.PrintLabelDao;
import in.techware.carrefour.dbUtils.dao.PromotionDao;
import in.techware.carrefour.dbUtils.dao.StockTakeDao;
import in.techware.carrefour.dbUtils.dao.TransformQuantityDao;
import in.techware.carrefour.dbUtils.dao.WasteDao;
import in.techware.carrefour.dbUtils.entity.FacingEntity;
import in.techware.carrefour.dbUtils.entity.InternalSalesCorrectionEntity;
import in.techware.carrefour.dbUtils.entity.InternalSalesEntity;
import in.techware.carrefour.dbUtils.entity.ItemListEntity;
import in.techware.carrefour.dbUtils.entity.LabelSurveyEntity;
import in.techware.carrefour.dbUtils.entity.MinStockEntity;
import in.techware.carrefour.dbUtils.entity.OutOfStockEntity;
import in.techware.carrefour.dbUtils.entity.PrintLabelEntity;
import in.techware.carrefour.dbUtils.entity.PromotionEntity;
import in.techware.carrefour.dbUtils.entity.StockTakeEntity;
import in.techware.carrefour.dbUtils.entity.TransformQuantityEntity;
import in.techware.carrefour.dbUtils.entity.WasteEntity;


/**
 * Created by Jemsheer K D on 02 January, 2018.
 * Package in.techware.afcetcbus.database
 * Project AFS_Bus_App
 */

@Database(entities = {
        WasteEntity.class,
        LabelSurveyEntity.class,
        StockTakeEntity.class,
        MinStockEntity.class,
        FacingEntity.class,
        PromotionEntity.class,
        PrintLabelEntity.class,
        OutOfStockEntity.class,
        TransformQuantityEntity.class,
        ItemListEntity.class,
        InternalSalesEntity.class,
        InternalSalesCorrectionEntity.class
}, version = 1)
@TypeConverters({DataTypeConverters.class})
public abstract class CarrefourRoomDatabase extends RoomDatabase {


    public abstract WasteDao wasteDao();

    public abstract LabelSurveyDao labelSurveyDao();

    public abstract StockTakeDao stockTakeDao();

    public abstract MinStockDao minStockDao();

    public abstract FacingDao facingDao();

    public abstract PromotionDao promotionDao();

    public abstract PrintLabelDao printLabelDao();

    public abstract OutOfStockDao outOfStockDao();

    public abstract TransformQuantityDao transformQuantityDao();

    public abstract ItemListDao itemListDao();

    public abstract InternalSalesDao internalSalesDao();

    public abstract InternalSalesCorrectionDao internalSalesCorrectionDao();

    private static CarrefourRoomDatabase INSTANCE;


    public static CarrefourRoomDatabase getDatabase() {
        if (INSTANCE == null) {
            synchronized (CarrefourRoomDatabase.class) {
                if (INSTANCE == null) {
                    INSTANCE = Room.databaseBuilder(App.getInstance(),
                            CarrefourRoomDatabase.class, "carrefour_database")
                            .fallbackToDestructiveMigration()
                            .build();
                }
            }
        }
        return INSTANCE;
    }

}
