/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.csu.sdmx.dao;

import cz.csu.sdmx.validation.model.dsds.Dsd;
import cz.csu.sdmx.validation.model.LogicCondition;
import java.util.List;
import org.hibernate.Query;
import org.springframework.stereotype.Component;

/**
 *
 * @author themi
 */
@Component
public class LogicConditionsDaoImp extends DaoSupportImp<LogicCondition, Integer> implements LogicConditionsDao{

    public LogicConditionsDaoImp() {
       super(LogicCondition.class);
    }

    @Override
    public List<LogicCondition> getByDsd(Dsd dsd) {
        return getByDsdUrn(dsd.getURN());
    }

    @Override
    public List<LogicCondition> getByDsdUrn(String DsdUrn) {
        String sql = "FROM "+getClassName()+" WHERE dsdName=:dsdName";
        Query q = getCurrentSession().createQuery(sql);
        q.setParameter("dsdName", DsdUrn);
        
        return q.list();
    }
    
    @Override
    public List<String> getDsds() {
        String sql = "SELECT dsdName FROM "+getClassName()+" GROUP BY dsdName";
        Query q = getCurrentSession().createQuery(sql);
        
        return q.list();
    }
    
}
