// Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAO.java
// public interface OccurrenceAutoCompleteDAO {
// 	
// 	/**
// 	 * Returns suggestions as JSON string for a field and a current value.
// 	 * @param field
// 	 * @param currValue
// 	 * @param useSanitizedValue compare with sanitized value instead of real value
// 	 * @return result as JSON string
// 	 */
// 	public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue);
// 	
// 	/**
// 	 * Returns all possible values as UniqueValuesModel list.
// 	 * @param field
// 	 * @return
// 	 */
// 	public List<UniqueValuesModel> getAllPossibleValues(String field);
// 
// }
// 
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/UniqueValuesModel.java
// @Entity
// @Table(name = "unique_values")
// public class UniqueValuesModel {
// 	
// 	@Id
// 	private int id;
// 	
// 	@Column(name = "key")
// 	private String key;
// 	
// 	@Column(name = "occurrence_count")
// 	private int occurrence_count;
// 	
// 	@Column(name = "value")
// 	private String value;
// 
// 	@Column(name = "unaccented_value")
// 	private String unaccented_value;
// 	
// 	public int getId() {
// 		return id;
// 	}
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 	
// 	public String getKey() {
// 		return key;
// 	}
// 	public void setKey(String key) {
// 		this.key = key;
// 	}
// 	
// 	public int getOccurrence_count() {
// 		return occurrence_count;
// 	}
// 	public void setOccurrence_count(int occurrence_count) {
// 		this.occurrence_count = occurrence_count;
// 	}
// 	
// 	public String getValue() {
// 		return value;
// 	}
// 	public void setValue(String value) {
// 		this.value = value;
// 	}
// 	
// 	public String getUnaccented_value() {
// 		return unaccented_value;
// 	}
// 	public void setUnaccented_value(String unaccented_value) {
// 		this.unaccented_value = unaccented_value;
// 	}
// }


import java.io.IOException;
import java.util.List;
import net.canadensys.dataportal.occurrence.dao.OccurrenceAutoCompleteDAO;
import net.canadensys.dataportal.occurrence.model.UniqueValuesModel;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
package net.canadensys.dataportal.occurrence.dao.impl;





/**
 * Implementation for accessing UniqueValuesModel through Hibernate technology.
 * @author canadensys
 *
 */
@Repository("occDAO")
public class HibernateOccurrenceAutoCompleteDAO implements OccurrenceAutoCompleteDAO{
	
	//get log4j handler
	private static final Logger LOGGER = Logger.getLogger(HibernateOccurrenceAutoCompleteDAO.class);
	
	@Autowired
	private SessionFactory sessionFactory;
	
	//this object is expensive to create so only create one and reuse it. This object
	//is thread safe after configuration.
	private ObjectMapper jacksonMapper = new ObjectMapper();
	
	/**
	 * TODO : get rid of the Wrapper
	 */
	@Override
	public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue) {
// Path: src/main/java/net/canadensys/dataportal/occurrence/dao/OccurrenceAutoCompleteDAO.java
// public interface OccurrenceAutoCompleteDAO {
// 	
// 	/**
// 	 * Returns suggestions as JSON string for a field and a current value.
// 	 * @param field
// 	 * @param currValue
// 	 * @param useSanitizedValue compare with sanitized value instead of real value
// 	 * @return result as JSON string
// 	 */
// 	public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue);
// 	
// 	/**
// 	 * Returns all possible values as UniqueValuesModel list.
// 	 * @param field
// 	 * @return
// 	 */
// 	public List<UniqueValuesModel> getAllPossibleValues(String field);
// 
// }
// 
// Path: src/main/java/net/canadensys/dataportal/occurrence/model/UniqueValuesModel.java
// @Entity
// @Table(name = "unique_values")
// public class UniqueValuesModel {
// 	
// 	@Id
// 	private int id;
// 	
// 	@Column(name = "key")
// 	private String key;
// 	
// 	@Column(name = "occurrence_count")
// 	private int occurrence_count;
// 	
// 	@Column(name = "value")
// 	private String value;
// 
// 	@Column(name = "unaccented_value")
// 	private String unaccented_value;
// 	
// 	public int getId() {
// 		return id;
// 	}
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 	
// 	public String getKey() {
// 		return key;
// 	}
// 	public void setKey(String key) {
// 		this.key = key;
// 	}
// 	
// 	public int getOccurrence_count() {
// 		return occurrence_count;
// 	}
// 	public void setOccurrence_count(int occurrence_count) {
// 		this.occurrence_count = occurrence_count;
// 	}
// 	
// 	public String getValue() {
// 		return value;
// 	}
// 	public void setValue(String value) {
// 		this.value = value;
// 	}
// 	
// 	public String getUnaccented_value() {
// 		return unaccented_value;
// 	}
// 	public void setUnaccented_value(String unaccented_value) {
// 		this.unaccented_value = unaccented_value;
// 	}
// }


// Path: src/main/java/net/canadensys/dataportal/occurrence/dao/impl/HibernateOccurrenceAutoCompleteDAO.java
import java.io.IOException;
import java.util.List;
import net.canadensys.dataportal.occurrence.dao.OccurrenceAutoCompleteDAO;
import net.canadensys.dataportal.occurrence.model.UniqueValuesModel;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

package net.canadensys.dataportal.occurrence.dao.impl;





/**
 * Implementation for accessing UniqueValuesModel through Hibernate technology.
 * @author canadensys
 *
 */
@Repository("occDAO")
public class HibernateOccurrenceAutoCompleteDAO implements OccurrenceAutoCompleteDAO{
	
	//get log4j handler
	private static final Logger LOGGER = Logger.getLogger(HibernateOccurrenceAutoCompleteDAO.class);
	
	@Autowired
	private SessionFactory sessionFactory;
	
	//this object is expensive to create so only create one and reuse it. This object
	//is thread safe after configuration.
	private ObjectMapper jacksonMapper = new ObjectMapper();
	
	/**
	 * TODO : get rid of the Wrapper
	 */
	@Override
	public String getSuggestionsFor(String field, String currValue, boolean useSanitizedValue) {
		Criteria suggestionCriteria = sessionFactory.getCurrentSession().createCriteria(UniqueValuesModel.class)