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.NamaPegawaiVO;
import com.jasamedika.medifirst2000.vo.NamaAsuransiVO;

	import com.jasamedika.medifirst2000.entities.NamaPegawai;
import com.jasamedika.medifirst2000.entities.NamaAsuransi;


import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AsuransiNakerService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.entities.AsuransiNaker;
import com.jasamedika.medifirst2000.vo.AsuransiNakerVO;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.AsuransiNakerDao;

/**
 * Implement class for AsuransiNakerService
 * 
 * @author Generator
 * @param <T>
 */
@Service("asuransiNakerService")
public class AsuransiNakerServiceImpl extends BaseVoServiceImpl implements AsuransiNakerService 
{	
	@Autowired
	private BaseConverterImpl<AsuransiNakerVO,AsuransiNaker>asuransiNakerConverter;
	@Autowired
private BaseConverterImpl<NamaPegawaiVO,NamaPegawai>namaPegawaiConverter;

@Autowired
private BaseConverterImpl<NamaAsuransiVO,NamaAsuransi>namaAsuransiConverter;


	@Autowired
	private AsuransiNakerDao asuransiNakerDao;

	
	@Override
	public Map<String, Object> saveAsuransiNaker(AsuransiNakerVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		AsuransiNaker model = new AsuransiNaker();
		model = asuransiNakerConverter.transferVOToModel(vo,model);
		
		if (CommonUtil.isNotNullOrEmpty(vo.getNamaPegawai()))
		{
				model.setNamaPegawai(namaPegawaiConverter.transferVOToModel(vo.getNamaPegawai(), new NamaPegawai()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.getNamaAsuransi()))
		{
				model.setNamaAsuransi(namaAsuransiConverter.transferVOToModel(vo.getNamaAsuransi(), new NamaAsuransi()));
		}

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

		return result;
	}
}