package com.temenos.ebank.dao.impl.nomencl;

import java.util.List;

import org.hibernate.criterion.Example;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import com.temenos.ebank.dao.interfaces.nomencl.INomenclDao;
import com.temenos.ebank.domain.Nomencl;

@Repository
public class NomenclDaoImpl extends HibernateDaoSupport implements INomenclDao {
	private NomenclDaoHelper daoHelper;
	
	public NomenclDaoImpl() {
		daoHelper = new NomenclDaoHelper();
	}
	
	@Transactional(readOnly = true)
	public List<Nomencl> getNomencl(String language, String group) {
		String urlResource = "http://localhost:8080/responder/rest/nomencl";
		String filter = "$filter=language eq '" + language + "'";
		filter += " and groupCode eq '" + group + "'";
		String orderby = "$orderby=sortOrder,label asc";
		return daoHelper.getEntities(urlResource + "?" + filter + "&" + orderby);
		/*
		return getSession().createCriteria(Nomencl.class).add(Restrictions.eq("language", language))
				.add(Restrictions.eq("groupCode", group)).addOrder(Order.asc("sortOrder")).addOrder(Order.asc("label"))
				.list();
				*/
	}

	@Transactional
	public void insertNomencl(Nomencl nomencl) {
		createHibernateTemplate(getSessionFactory()).saveOrUpdate(nomencl);
	}

	@SuppressWarnings("rawtypes")
	public Nomencl findNomencl(Nomencl nomencl) {
		List result = (List) getSession().createCriteria(Nomencl.class).add(Example.create(nomencl)).list();
		if (!CollectionUtils.isEmpty(result)) {
			return (Nomencl) result.get(0);
		}
		return null;
	}

}

@@ -803,17 +803,17 @@
 er/rest/
-n
+N
 omencl%22;

Change the Acquisition project to invoke the URL of the Nomencl service as generated by the interaction SDK.