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.util.JsonUtil;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.DesignDashboardService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.entities.DesignDashboard;
import com.jasamedika.medifirst2000.vo.DesignDashboardVO;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.DesignDashboardDao;

/**
 * Implement class for DesignDashboardService
 * 
 * @author Generator
 * @param <T>
 */
@Service("designDashboardService")
public class DesignDashboardServiceImpl extends BaseVoServiceImpl implements DesignDashboardService 
{	
	@Autowired
	private BaseConverterImpl<DesignDashboardVO,DesignDashboard>designDashboardConverter;
	
	@Autowired
	private DesignDashboardDao designDashboardDao;	
	
	@Override
	public Map<String, Object> saveDesignDashboard(DesignDashboardVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		DesignDashboard model = new DesignDashboard();
		model = designDashboardConverter.transferVOToModel(vo,model);
		

		DesignDashboard resultDomain = designDashboardDao.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(designDashboardDao.findByKelompokContainingOrQueryContainingOrTypeContainingOrTitleContainingOrSpanContainingOrSeriesContainingOrDetailContaining(nama,nama,nama,nama,nama,nama,nama)));
		} catch (IllegalArgumentException | IllegalAccessException e) {
			e.printStackTrace();
		}
		return result;
	}
}