package cn.jamesli.example.at89greendaotest.src_gen;

import android.database.sqlite.SQLiteDatabase;

import java.util.Map;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.AbstractDaoSession;
import de.greenrobot.dao.identityscope.IdentityScopeType;
import de.greenrobot.dao.internal.DaoConfig;

/**
 * Created by jamesli on 15-7-15.
 */
public class DaoSession extends AbstractDaoSession {

    private final DaoConfig noteDaoConfig;
//    private final DaoConfig customerDaoConfig;
//    private final DaoConfig orderDaoConfig;

    private final NoteDao noteDao;
//    private final CustomerDao customerDao;
//    private final OrderDao orderDao;

    public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
            daoConfigMap) {
        super(db);

        noteDaoConfig = daoConfigMap.get(NoteDao.class).clone();
        noteDaoConfig.initIdentityScope(type);

//        customerDaoConfig = daoConfigMap.get(CustomerDao.class).clone();
//        customerDaoConfig.initIdentityScope(type);
//
//        orderDaoConfig = daoConfigMap.get(OrderDao.class).clone();
//        orderDaoConfig.initIdentityScope(type);

        noteDao = new NoteDao(noteDaoConfig, this);
//        customerDao = new CustomerDao(customerDaoConfig, this);
//        orderDao = new OrderDao(orderDaoConfig, this);

        registerDao(Note.class, noteDao);
//        registerDao(Customer.class, customerDao);
//        registerDao(Order.class, orderDao);
    }

    public void clear() {
        noteDaoConfig.getIdentityScope().clear();
//        customerDaoConfig.getIdentityScope().clear();
//        orderDaoConfig.getIdentityScope().clear();
    }

    public NoteDao getNoteDao() {
        return noteDao;
    }

//    public CustomerDao getCustomerDao() {
//        return customerDao;
//    }
//
//    public OrderDao getOrderDao() {
//        return orderDao;
//    }

}
