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

	import com.jasamedika.medifirst2000.entities.StatusMeninggalDunia;


import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.MasterJenisSantunanService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.entities.MasterJenisSantunan;
import com.jasamedika.medifirst2000.vo.MasterJenisSantunanVO;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.MasterJenisSantunanDao;

/**
 * Implement class for MasterJenisSantunanService
 * 
 * @author Generator
 * @param <T>
 */
@Service("masterJenisSantunanService")
public class MasterJenisSantunanServiceImpl extends BaseVoServiceImpl implements MasterJenisSantunanService 
{	
	@Autowired
	private BaseConverterImpl<MasterJenisSantunanVO,MasterJenisSantunan>masterJenisSantunanConverter;
	@Autowired
private BaseConverterImpl<StatusMeninggalDuniaVO,StatusMeninggalDunia>statusMeninggalDuniaConverter;


	@Autowired
	private MasterJenisSantunanDao masterJenisSantunanDao;

	
	@Override
	public Map<String, Object> saveMasterJenisSantunan(MasterJenisSantunanVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		MasterJenisSantunan model = new MasterJenisSantunan();
		model = masterJenisSantunanConverter.transferVOToModel(vo,model);
		
		if (CommonUtil.isNotNullOrEmpty(vo.getStatusMeninggal()))
		{
				model.setStatusMeninggal(statusMeninggalDuniaConverter.transferVOToModel(vo.getStatusMeninggal(), new StatusMeninggalDunia()));
		}

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

		return result;
	}
}