/*
 * 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.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import sikd.ikonsol.model.WorksheetView;

/**
 *
 * @author Imam Bhoim
 */
public class WorksheetViewDao implements IDAO<WorksheetView>, Serializable {

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

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

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

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

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

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

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

    @Override
    public WorksheetView update(WorksheetView 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<WorksheetView> findAllByTahunBasProvinsi(int tahun,int idbas,String kdpemda,String kdperiode) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
         Map<String, Object> map = new HashMap<>();
        map.put("tahun", tahun);
        map.put("idbas", idbas);
        map.put("kdpemda", kdpemda);
        map.put("kdperiode", kdperiode);
        List<WorksheetView> list = new ArrayList<WorksheetView>();

        session = sqlSessionFactory.openSession();
        try {
            list = session.selectList("WorksheetViewMapper.selectData", map);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.close();
        }

        return list;
    }
    
      public WorksheetView selectEliminasi(String kdLvl1, String kdLvl2, String kdLvl3, 
              String kdLvl4,int idbas, String kdperiode,
            String kdprov, int tahun) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("kdLvl2", kdLvl2);
        map.put("kdLvl3", kdLvl3);
        map.put("kdLvl4", kdLvl4);
        map.put("idBas", idbas);
        map.put("idPriode", kdperiode);
        map.put("kdProv", kdprov);
        map.put("tahun", tahun);
        session = sqlSessionFactory.openSession();
        WorksheetView obj = null;
        try {
            obj = session.selectOne("WorksheetViewMapper.selectEliminasi", map);

        } finally {
            session.close();
        }
        return obj;
    }
      
      public WorksheetView selectDK(String kdLvl1, String kdLvl2, String kdLvl3, 
              String kdLvl4, int idbas, String kdperiode,
            String kdprov, int tahun) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("kdLvl2", kdLvl2);
        map.put("kdLvl3", kdLvl3);
         map.put("kdLvl4", kdLvl4);
        map.put("idBas", idbas);
        map.put("idPriode", kdperiode);
        map.put("kdProv", kdprov);
        map.put("tahun", tahun);
        session = sqlSessionFactory.openSession();
        WorksheetView obj = null;
        try {
            obj = session.selectOne("WorksheetViewMapper.selectDK", map);

        } finally {
            session.close();
        }
        return obj;
    }
      
        public WorksheetView selectEliminasiManual(String kdLvl1, String kdLvl2, String kdLvl3, 
              String kdLvl4,int idbas, String kdperiode,
            String kdprov, int tahun) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("kdLvl2", kdLvl2);
        map.put("kdLvl3", kdLvl3);
        map.put("kdLvl4", kdLvl4);
        map.put("idBas", idbas);
        map.put("idPriode", kdperiode);
        map.put("kdProv", kdprov);
        map.put("tahun", tahun);
        session = sqlSessionFactory.openSession();
        WorksheetView obj = null;
        try {
            obj = session.selectOne("WorksheetViewMapper.selectEliminasiManual", map);

        } finally {
            session.close();
        }
        return obj;
    }
      
      public WorksheetView selectDKManual(String kdLvl1, String kdLvl2, String kdLvl3, 
              String kdLvl4, int idbas, String kdperiode,
            String kdprov, int tahun) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        Map<String, Object> map = new HashMap<>();
        map.put("kdLvl1", kdLvl1);
        map.put("kdLvl2", kdLvl2);
        map.put("kdLvl3", kdLvl3);
         map.put("kdLvl4", kdLvl4);
        map.put("idBas", idbas);
        map.put("idPriode", kdperiode);
        map.put("kdProv", kdprov);
        map.put("tahun", tahun);
        session = sqlSessionFactory.openSession();
        WorksheetView obj = null;
        try {
            obj = session.selectOne("WorksheetViewMapper.selectDKManual", map);

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

}
