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 java.util.UUID;

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

import com.jasamedika.medifirst2000.vo.JenisCutiVO;

	import com.jasamedika.medifirst2000.entities.JenisCuti;


import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PermohonanCutiPegawaiService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.entities.PermohonanCutiPegawai;
import com.jasamedika.medifirst2000.vo.PermohonanCutiPegawaiVO;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.PermohonanCutiPegawaiDao;

/**
 * Implement class for PermohonanCutiPegawaiService
 * 
 * @author Generator
 * @param <T>
 */
@Service("permohonanCutiPegawaiService")
public class PermohonanCutiPegawaiServiceImpl extends BaseVoServiceImpl implements PermohonanCutiPegawaiService 
{	
	@Autowired
	private BaseConverterImpl<PermohonanCutiPegawaiVO,PermohonanCutiPegawai>permohonanCutiPegawaiConverter;
	@Autowired
private BaseConverterImpl<JenisCutiVO,JenisCuti>jenisCutiConverter;


	@Autowired
	private PermohonanCutiPegawaiDao permohonanCutiPegawaiDao;

	
	@Override
	public Map<String, Object> savePermohonanCutiPegawai(PermohonanCutiPegawaiVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		PermohonanCutiPegawai model = new PermohonanCutiPegawai();
		model = permohonanCutiPegawaiConverter.transferVOToModel(vo,model);
		if (CommonUtil.isNotNullOrEmpty(vo.getJenisCuti()))
		{
				model.setJenisCuti(jenisCutiConverter.transferVOToModel(vo.getJenisCuti(), new JenisCuti()));
		}

		PermohonanCutiPegawai resultDomain = permohonanCutiPegawaiDao.save(model);
		if (CommonUtil.isNotNullOrEmpty(resultDomain)) {
			result.put("noRec", resultDomain.getNoRec());
		}

		return result;
	}
}