/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sikd.ikonsol.ejb.session;

import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.Stateless;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import sikd.ikonsol.ejb.dao.AkunResiprokalDao;
import sikd.ikonsol.model.AkunResiprokal;
import sikd.sikd5.sikd5ejb.session.util.MyBatisConnectionFactory;

/**
 *
 * @author Imam Bhoim
 */
@Stateless
public class AkunResiprokalEjbHomeImpl implements AkunResiprokalEjbHome {

    private SqlSessionFactory sqlSessionFactory;
    private SqlSession session = null;

    private AkunResiprokalDao dao;

    @PostConstruct
    public void init() {
        try {
            System.out.println("-------- Load MyBatis Factory IKonsol ------- ");
            sqlSessionFactory = MyBatisConnectionFactory.getSqlSessionFactoryIkonsol();
            dao = new AkunResiprokalDao(sqlSessionFactory);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    @Override
    public List<AkunResiprokal> findAll() {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        return dao.findAll();
    }

    @Override
    public AkunResiprokal findByID(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        return dao.findByID(id);
    }

    @Override
    public AkunResiprokal createNew() {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        return new AkunResiprokal();
    }

    @Override
    public AkunResiprokal save(AkunResiprokal obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        return dao.save(obj);
    }

    @Override
    public AkunResiprokal findByKode(String kode) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public AkunResiprokal update(AkunResiprokal obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        return dao.update(obj);
    }

    @Override
    public void delete(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        dao.deleteByID(id);
    }

    @Override
    public List<AkunResiprokal> findByIdHeader(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        return dao.findByIdHeader(id);
    }

    @Override
    public AkunResiprokal findByKodeAkunHeader(int lvl1, int lvl2, int lvl3, String lvl4, String lvl5, int idbas, int idheaderres) {
        return dao.findKodeAkunHeader(lvl1, lvl2, lvl3, lvl4, lvl5, idbas, idheaderres);
    }

    @Override
    public AkunResiprokal findByKodeAkunHeaderLengkap(int lvl1, int lvl2, int lvl3, String lvl4, String lvl5, int idbas, int idheaderres, String dk, int kategoripemdaid,
            String flag) {
        return dao.findKodeAkunHeaderLengkap(lvl1, lvl2, lvl3, lvl4, lvl5, idbas, idheaderres, dk, kategoripemdaid, flag);
    }

}
