package com.jasamedika.medifirst2000.service.impl;

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.PapSirkulasiConverter;
import com.jasamedika.medifirst2000.dao.PapSirkulasiDao;
import com.jasamedika.medifirst2000.entities.PapSirkulasi;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PapSirkulasiService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.PapSirkulasiVO;

/**
 * Implement class for PAPSirkulasiService
 * 
 * @author Askur
 */
@Service("PAPSirkulasiService")
public class PapSirkulasiServiceImpl implements PapSirkulasiService {
	@Autowired
	private PapSirkulasiDao papSirkulasiDao;
	@Autowired
	private PapSirkulasiConverter papSirkulasiConverter;
	
	@Override
	public Map<String,Object> addSirkulasi(PapSirkulasiVO vo) throws JpaSystemException, ServiceVOException {
		Map<String,Object> result=new HashMap<String,Object>();
		PapSirkulasi model=papSirkulasiConverter.transferVOToModel(vo, new PapSirkulasi());
		PapSirkulasi resultModel=papSirkulasiDao.save(model);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("papSirkulasi", resultModel);
		}
		return result;
	}

	@Override
	public Map<String,Object> updateSirkulasi(PapSirkulasiVO vo) throws JpaSystemException, ServiceVOException {
		Map<String,Object> result=new HashMap<String,Object>();
		PapSirkulasi model=papSirkulasiConverter.transferVOToModel(vo, new PapSirkulasi());
		PapSirkulasi resultModel=papSirkulasiDao.save(model);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("papSirkulasi", resultModel);
			result.put("dataFound", true);
		}else{
			result.put("dataFound", false);
		}
		return result;
	}

	@Override
	public Map<String,Object> findByNoCmAndTglInput(String noCm, Date tglInput) {
		Map<String,Object> result=new HashMap<String,Object>();
		PapSirkulasi resultModel=papSirkulasiDao.findPapSirkulasiByNoCmAndTglInput(noCm, tglInput);
		if(CommonUtil.isNotNullOrEmpty(resultModel)){
			result.put("papSirkulasi", 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;
	}

}
