/*
 * 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.SusunKonsolidasiDao;
import sikd.ikonsol.model.SusunKonsolidasi;
import sikd.sikd5.sikd5ejb.session.util.MyBatisConnectionFactory;

/**
 *
 * @author Imam Bhoim
 */
@Stateless
public class SusunKonsolidasiEjbHomeImpl implements SusunKonsolidasiEjbHome {

    private SqlSessionFactory sqlSessionFactory;
    private SqlSession session = null;

    private SusunKonsolidasiDao dao;

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

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

    @Override
    public SusunKonsolidasi findByID(int id) {
        return dao.findByID(id);
    }

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

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

    @Override
    public SusunKonsolidasi update(SusunKonsolidasi 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<SusunKonsolidasi> findAllByTahun(int tahun) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        return dao.findAllByTahun(tahun);
    }

    @Override
    public SusunKonsolidasi updatePemda(SusunKonsolidasi obj) {
        return dao.updatePemda(obj);
    }

    @Override
    public SusunKonsolidasi updateStatus(SusunKonsolidasi obj) {
  return dao.updateStatus(obj);}

}
