package gov.va.med.mpn.dao;

// Generated Sep 16, 2014 1:53:04 PM by Hibernate Tools 4.3.1

import java.util.HashMap;

import java.util.List;

import gov.va.med.mpn.dao.constants.CodedControlDataConstants;
import gov.va.med.mpn.dao.core.CodedControlDataDAOCoreImpl;
import gov.va.med.mpn.dao.interfaces.CodedControlDataDAO;
import gov.va.med.mpn.entity.pojo.CodedControlData;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.stereotype.Repository;

/**
 * DAO Implementation for CodedControlData.
 *
 */
@Repository
@ManagedResource
public class CodedControlDataDAOImpl extends CodedControlDataDAOCoreImpl
		implements CodedControlDataDAO {

	/** The slf4j logger. */
	private final Logger slf4jLogger = LoggerFactory
			.getLogger(CodedControlDataDAOImpl.class);

	@ManagedOperation
	public CodedControlData findAllWithUUID(String uuid) {

		CodedControlData returnValue = null;
		HashMap<String, Object> qryParms = new HashMap<String, Object>();

		qryParms.put("uuid", uuid);

		CodedControlData codedControlData = super
				.findUniqueByNamedQueryAndNamedParam(
						"codedcontroldata.findRowWithUUID", qryParms);

		// if there are actions for status, set returnValue to list
		if (codedControlData != null) {
			returnValue = codedControlData;
		}

		return returnValue;
	}

	@ManagedOperation
	public List<CodedControlData> findCodedControlDataWithControlName(
			String controlName) {
		slf4jLogger.info("findCodedControlDataWithControlName :" + controlName);
		List<CodedControlData> returnValue = null;
		HashMap<String, Object> qryParms = new HashMap<String, Object>();

		qryParms.put("controlName", "%" + controlName + "%");

		returnValue = super.findByNamedQueryAndNamedParam(
				"codedcontroldata.findCodedControlDataWithControlName",
				qryParms);

		return returnValue;
	}

	@ManagedOperation
	public List<CodedControlData> findCodedControlDataWithClassId(
			Integer classId) {
		slf4jLogger.info("findCodedControlDataWithClassId :" + classId);
		List<CodedControlData> returnValue = null;
		HashMap<String, Object> qryParms = new HashMap<String, Object>();

		qryParms.put("classId", classId);

		returnValue = super.findByNamedQueryAndNamedParam(
				"codedcontroldata.findCodedControlDataWithClassId", qryParms);

		return returnValue;
	}

	@ManagedOperation
	public List<CodedControlData> findCodedControlDataWithCategoryId(
			Integer catId) {
		slf4jLogger.info("findCodedControlDataWithCategoryId :" + catId);
		List<CodedControlData> returnValue = null;
		HashMap<String, Object> qryParms = new HashMap<String, Object>();

		qryParms.put("catId", catId);

		returnValue = super
				.findByNamedQueryAndNamedParam(
						"codedcontroldata.findCodedControlDataWithCategoryId",
						qryParms);

		return returnValue;
	}

	@ManagedOperation
	public List<CodedControlData> findCodedControlDataWithCategoryIdAndName(
			Integer catId, String controlName) {
		slf4jLogger
				.info("findCodedControlDataWithCategoryIdAndName CategoryId:"
						+ catId + "ControlName:" + controlName);
		List<CodedControlData> returnValue = null;
		HashMap<String, Object> qryParms = new HashMap<String, Object>();

		qryParms.put("catId", catId);
		qryParms.put("controlName", "%" + controlName + "%");

		returnValue = super.findByNamedQueryAndNamedParam(
				"codedcontroldata.findCodedControlDataWithCategoryIdAndName",
				qryParms);

		return returnValue;
	}

	@ManagedOperation
	public List<CodedControlData> findCodedControlDataWithClassificationIdAndName(
			Integer classId, String controlName) {
		slf4jLogger
				.info("findCodedControlDataWithClassificationIdAndName ClassificationId:"
						+ classId + "ControlName:" + controlName);
		List<CodedControlData> returnValue = null;
		HashMap<String, Object> qryParms = new HashMap<String, Object>();

		qryParms.put("classId", classId);
		qryParms.put("controlName", "%" + controlName + "%");

		returnValue = super
				.findByNamedQueryAndNamedParam(
						"codedcontroldata.findCodedControlDataWithClassificationIdAndName",
						qryParms);

		return returnValue;
	}

	@ManagedOperation
	public List<CodedControlData> findCodedControlDataWithClassificationIdAndCategoryId(
			Integer classId, Integer catId) {
		slf4jLogger
				.info("findCodedControlDataWithClassificationIdAndCategoryId ClassificationId:"
						+ classId + "CategoryId:" + catId);
		List<CodedControlData> returnValue = null;
		HashMap<String, Object> qryParms = new HashMap<String, Object>();

		qryParms.put("classId", classId);
		qryParms.put("catId", catId);

		returnValue = super
				.findByNamedQueryAndNamedParam(
						"codedcontroldata.findCodedControlDataWithClassificationIdAndCategoryId",
						qryParms);

		return returnValue;
	}

	@ManagedOperation
	public List<CodedControlData> findCodedControlDataWithClassificationIdAndCategoryIdAndName(
			Integer classId, Integer catId, String controlName) {
		slf4jLogger
				.info("findCodedControlDataWithClassificationIdAndCategoryId ClassificationId:"
						+ classId
						+ "CategoryId:"
						+ catId
						+ " contromName:"
						+ controlName);
		List<CodedControlData> returnValue = null;
		HashMap<String, Object> qryParms = new HashMap<String, Object>();

		qryParms.put("classId", classId);
		qryParms.put("catId", catId);
		qryParms.put("controlName", "%" + controlName + "%");

		returnValue = super
				.findByNamedQueryAndNamedParam(
						"codedcontroldata.findCodedControlDataWithClassificationIdAndCategoryIdAndName",
						qryParms);

		return returnValue;
	}

}
