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

	import com.jasamedika.medifirst2000.entities.KelompokKompetensi;


import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.JenisKompetensiService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.entities.JenisKompetensi;
import com.jasamedika.medifirst2000.vo.JenisKompetensiVO;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.JenisKompetensiDao;

/**
 * Implement class for JenisKompetensiService
 * 
 * @author Generator
 * @param <T>
 */
@Service("jenisKompetensiService")
public class JenisKompetensiServiceImpl extends BaseVoServiceImpl implements JenisKompetensiService 
{	
	@Autowired
	private BaseConverterImpl<JenisKompetensiVO,JenisKompetensi>jenisKompetensiConverter;
	@Autowired
private BaseConverterImpl<KelompokKompetensiVO,KelompokKompetensi>kelompokKompetensiConverter;


	@Autowired
	private JenisKompetensiDao jenisKompetensiDao;

	
	@Override
	public Map<String, Object> saveJenisKompetensi(JenisKompetensiVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		JenisKompetensi model = new JenisKompetensi();
		model = jenisKompetensiConverter.transferVOToModel(vo,model);
		
		if (CommonUtil.isNotNullOrEmpty(vo.getKelompokKompetensi()))
		{
				model.setKelompokKompetensi(kelompokKompetensiConverter.transferVOToModel(vo.getKelompokKompetensi(), new KelompokKompetensi()));
		}

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

		return result;
	}
}