package com.jasamedika.medifirst2000.converter;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.google.gson.Gson;
import com.jasamedika.medifirst2000.converter.base.BaseVoConverter;
import com.jasamedika.medifirst2000.dao.custom.base.impl.FindConverterDao;
import com.jasamedika.medifirst2000.entities.KelompokEvaluasi;
import com.jasamedika.medifirst2000.util.ExtendedSpringBeanUtil;
import com.jasamedika.medifirst2000.vo.KelompokEvaluasiVO;

/**
 * Converter class between KelompokEvaluasi and KelompokEvaluasiVO
 * 
 * @author Lukman Hakim
 */
@Component
public class KelompokEvaluasiConverter extends FindConverterDao implements
		BaseVoConverter<KelompokEvaluasiVO, KelompokEvaluasi> {

	public KelompokEvaluasi transferVOToModel(KelompokEvaluasiVO vo, KelompokEvaluasi model) {
		if (null == model)
			model = new KelompokEvaluasi();

		try {
			String[] fieldsToInclude = null;
			Map<String, Object> serialized = vo.serialize(fieldsToInclude,vo.getClass().getName());
			Gson gson = new Gson();
	        String json = gson.toJson(serialized);
	        model = gson.fromJson(json, KelompokEvaluasi.class);
		} catch (Exception e) {
		 	e.printStackTrace();
		}
		return model;

	}

	public List<KelompokEvaluasiVO> transferListOfModelToListOfVO(List<KelompokEvaluasi> models,
			List<KelompokEvaluasiVO> vos) {
		if (null == vos)
			vos = new ArrayList<KelompokEvaluasiVO>();

		if (null == models)
			return vos;

		for (KelompokEvaluasi agama : models) {
			KelompokEvaluasiVO agamaVO = new KelompokEvaluasiVO();
			transferModelToVO(agama, agamaVO);
			vos.add(agamaVO);
		}

		return vos;
	}

	public KelompokEvaluasiVO transferModelToVO(KelompokEvaluasi model, KelompokEvaluasiVO vo) {
		if (null == vo)
			vo = new KelompokEvaluasiVO();
 
		ExtendedSpringBeanUtil.copySpecificProperties(model, vo,
				new String[] { "KelompokEvaluasi", }, new String[] { "KelompokEvaluasi" });
 
		return vo;
	}
	
 

}
