/*
 * 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.dao;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import sikd.ikonsol.model.Informasi;

/**
 *
 * @author Imam Bhoim
 */
public class InformasiDao implements IDAO<Informasi>, Serializable {

    private SqlSessionFactory sqlSessionFactory = null;
    private SqlSession session = null;

    public InformasiDao(SqlSessionFactory sqlSessionFactory) {
        this.sqlSessionFactory = sqlSessionFactory;
    }

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

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

    @Override
    public List<Informasi> findByCriteria(String sql) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

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

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

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

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

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

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

    public List<Informasi> findAllInfoApp() {
        List<Informasi> list = new ArrayList<Informasi>();

        session = sqlSessionFactory.openSession();
        try {
            list = session.selectList("InformasiMapper.selectAllInfo");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }

        return list;
    }

    public List<Informasi> findAllDokApp() {
        List<Informasi> list = new ArrayList<Informasi>();

        session = sqlSessionFactory.openSession();
        try {
            list = session.selectList("InformasiMapper.selectAllDok");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }

        return list;
    }

    public List<Informasi> findAllPeraturanApp() {
        List<Informasi> list = new ArrayList<Informasi>();

        session = sqlSessionFactory.openSession();
        try {
            list = session.selectList("InformasiMapper.selectAllPer");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }

        return list;
    }

    public Informasi findByIDOverview(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        Informasi obj = null;
        try {
            obj = session.selectOne("InformasiMapper.selectIdOverview", id);

        } finally {
            session.close();
        }
        return obj;
    }

    public Informasi findByIDDisclaimer(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        Informasi obj = null;
        try {
            obj = session.selectOne("InformasiMapper.selectIdDisclaimer", id);

        } finally {
            session.close();
        }
        return obj;
    }

    public Informasi saveInfoApp(Informasi obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.insert("InformasiMapper.insertOneInfoApp", obj);
        session.commit();
        session.close();
        return obj;
    }

    public Informasi saveDokApp(Informasi obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.insert("InformasiMapper.insertOneDokApp", obj);
        session.commit();
        session.close();
        return obj;
    }

    public Informasi savePeraturanApp(Informasi obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.insert("InformasiMapper.insertOnePeraturanApp", obj);
        session.commit();
        session.close();
        return obj;
    }

    public Informasi findByIDInfoApp(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        Informasi obj = null;
        try {
            obj = session.selectOne("InformasiMapper.selectIdVersi", id);

        } finally {
            session.close();
        }
        return obj;
    }

    public Informasi findByIDDokApp(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        Informasi obj = null;
        try {
            obj = session.selectOne("InformasiMapper.selectIdDok", id);

        } finally {
            session.close();
        }
        return obj;
    }

    public Informasi findByIDPeraturanApp(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        Informasi obj = null;
        try {
            obj = session.selectOne("InformasiMapper.selectIdPer", id);

        } finally {
            session.close();
        }
        return obj;
    }
    
     public Informasi updateInfoApp(Informasi obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.insert("InformasiMapper.updateOneInfoApp", obj);
        session.commit();
        session.close();
        return obj;
    }
     
      public Informasi updateDokApp(Informasi obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.insert("InformasiMapper.updateOneDokApp", obj);
        session.commit();
        session.close();
        return obj;
    }
      
       public Informasi updatePeraturanApp(Informasi obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.insert("InformasiMapper.updateOnePerApp", obj);
        session.commit();
        session.close();
        return obj;
    }
       
       public void deleteOneInfoApp(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.delete("InformasiMapper.deleteOneInfoApp", id);
        session.commit();
        session.close();
    }
       
       public void deleteOneDokApp(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.delete("InformasiMapper.deleteOneDokApp", id);
        session.commit();
        session.close();
    }
       
       public void deleteOnePerApp(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.delete("InformasiMapper.deleteOnePerApp", id);
        session.commit();
        session.close();
    }
       
       public Informasi updateOverviewApp(Informasi obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.insert("InformasiMapper.updateOneOverviewApp", obj);
        session.commit();
        session.close();
        return obj;
    }
       
       public Informasi updateDisclaimerApp(Informasi obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.insert("InformasiMapper.updateOneDisclaimerApp", obj);
        session.commit();
        session.close();
        return obj;
    }
       
        public Informasi updateFileDok(Informasi obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.insert("InformasiMapper.updateFileDok", obj);
        session.commit();
        session.close();
        return obj;
    }
        
           public Informasi updateFilePer(Informasi obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.insert("InformasiMapper.updateFilePer", obj);
        session.commit();
        session.close();
        return obj;
    }
           
           public Informasi updateKontak(Informasi obj) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        session.insert("InformasiMapper.updateOneKontak", obj);
        session.commit();
        session.close();
        return obj;
    }
           
             public Informasi findByIDKontak(int id) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        session = sqlSessionFactory.openSession();
        Informasi obj = null;
        try {
            obj = session.selectOne("InformasiMapper.selectIdKontak", id);

        } finally {
            session.close();
        }
        return obj;
    }

}
