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.NilaiKelompokJabatanVO;

	import com.jasamedika.medifirst2000.entities.NilaiKelompokJabatan;


import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.RangeKmkService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.entities.RangeKmk;
import com.jasamedika.medifirst2000.vo.RangeKmkVO;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.RangeKmkDao;

/**
 * Implement class for RangeKmkService
 * 
 * @author Generator
 * @param <T>
 */
@Service("rangeKmkService")
public class RangeKmkServiceImpl extends BaseVoServiceImpl implements RangeKmkService 
{	
	@Autowired
	private BaseConverterImpl<RangeKmkVO,RangeKmk>rangeKmkConverter;
	@Autowired
private BaseConverterImpl<NilaiKelompokJabatanVO,NilaiKelompokJabatan>kelompokJabatanConverter;


	@Autowired
	private RangeKmkDao rangeKmkDao;	
	
	@Override
	public Map<String, Object> saveRangeKmk(RangeKmkVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		RangeKmk model = new RangeKmk();
		model = rangeKmkConverter.transferVOToModel(vo,model);
		
		if (CommonUtil.isNotNullOrEmpty(vo.getKelompokJabatan()))
		{
				model.setKelompokJabatan(kelompokJabatanConverter.transferVOToModel(vo.getKelompokJabatan(), new NilaiKelompokJabatan()));
		}

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

		return result;
	}
}