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.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PersyaratanPelamarService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.JsonUtil;
import com.jasamedika.medifirst2000.entities.PersyaratanPelamar;
import com.jasamedika.medifirst2000.vo.PersyaratanPelamarVO;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.PersyaratanPelamarDao;

/**
 * Implement class for PersyaratanPelamarService
 * 
 * @author Generator
 * @param <T>
 */
@Service("persyaratanPelamarService")
public class PersyaratanPelamarServiceImpl extends BaseVoServiceImpl implements PersyaratanPelamarService 
{	
	@Autowired
	private BaseConverterImpl<PersyaratanPelamarVO,PersyaratanPelamar>persyaratanPelamarConverter;
	
	@Autowired
	private PersyaratanPelamarDao persyaratanPelamarDao;	
	
	@Override
	public Map<String, Object> savePersyaratanPelamar(PersyaratanPelamarVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		PersyaratanPelamar model = new PersyaratanPelamar();
		model = persyaratanPelamarConverter.transferVOToModel(vo,model);
		

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

		return result;
	}

	@Override
	public Map<String, Object> findByName(String nama) {
		 Map<String, Object> result = new HashMap<String, Object>();
		 try {
			result.put("items", JsonUtil.ToMaps(persyaratanPelamarDao.findByUraianContaining(nama)));
		} catch (IllegalArgumentException | IllegalAccessException e) {
			e.printStackTrace();
		}
		return result;
	}
}