package com.jasamedika.medifirst2000.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service;

import com.jasamedika.medifirst2000.converter.RisikoKerjaRuanganConverter;
import com.jasamedika.medifirst2000.dao.RisikoKerjaRuanganDao;
import com.jasamedika.medifirst2000.entities.PapKeluhanTambahan;
import com.jasamedika.medifirst2000.entities.RisikoKerjaRuangan;
import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.RisikoKerjaRuanganService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.RisikoKerjaRuanganVO;
import com.jasamedika.medifirst2000.vo.RuanganVO;

/**
 * Implement class for RisikoKerjaRuanganService
 * 
 * @author Askur
 */
@Service("RisikoKerjaRuanganService")
public class RisikoKerjaRuanganServiceImpl implements RisikoKerjaRuanganService {
	@Autowired
	private RisikoKerjaRuanganDao risikoKerjaRuanganDao;
	@Autowired
	private RisikoKerjaRuanganConverter risikoKerjaRuanganConverter;
	
	@Override
	public Map<String,Object> addRisikoKerjaRuangan(RisikoKerjaRuanganVO vo) throws JpaSystemException, ServiceVOException {
		Map<String,Object> result=new HashMap<String,Object>();
		RisikoKerjaRuangan model=risikoKerjaRuanganConverter.transferVOToModel(vo, new RisikoKerjaRuangan());
		RisikoKerjaRuangan resultModel=risikoKerjaRuanganDao.save(model);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("risikoKerjaRuangan", resultModel);
		}
		return result;
	}
	
	@Override
	public boolean deleteRisikoKerjaRuangan(Integer id){
		if (CommonUtil.isNotNullOrEmpty(id)){
		RisikoKerjaRuangan model=risikoKerjaRuanganDao.findOne(id);
		risikoKerjaRuanganDao.delete(model);
		return true;
		}
		else{
			return false;
		}
		
		
	}

	@Override
	public Map<String,Object> findAllRisikoKerjaRuangan() {
		Map<String,Object> result=new HashMap<String,Object>();
		List<RisikoKerjaRuangan> resultModel= risikoKerjaRuanganDao.findAllRisikoKerjaRuangan();
		if(CommonUtil.isNotNullOrEmpty(resultModel)){			
			result.put("data", resultModel);
			result.put("dataFound", true);			
		}else{
			result.put("dataFound", false);
		}		
		return result;
	}

	@Override
	public Object add(Object vo) throws JpaSystemException, ServiceVOException {
		return null;
	}

	@Override
	public Object update(Object vo) throws JpaSystemException, ServiceVOException {
		return null;
	}

	@Override
	public Boolean delete(Object key) throws JpaSystemException {
		return null;
	}

	@Override
	public Object findById(Object key) throws JpaSystemException {
		return null;
	}

	@Override
	public List findAll() throws JpaSystemException {
		return null;
	}

	@Override
	public Map findAllWithPageAndLimitAndSortByAndDirectionParameter(Integer page, Integer limit, String sort,
			String dir) {
		return null;
	}


}
