<commit_before>package gov.va.med.srcalc.db;

import gov.va.med.srcalc.domain.model.RiskModel;

import java.util.List;

import javax.inject.Inject;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;

@Repository
public class RiskModelDao
{
    private final SessionFactory fSessionFactory;
    
    private static final Logger fLogger = LoggerFactory.getLogger(RiskModelDao.class);

    @Inject // Allow arguments to be autowired.
    public RiskModelDao(final SessionFactory sessionFactory)
    {
        fSessionFactory = sessionFactory;
    }
    
    protected Session getCurrentSession()
    {
        return fSessionFactory.getCurrentSession();
    }
    
    /**
     * Returns all RiskModels in the database, in arbitrary order.
     * @return an ImmutableCollection
     */
	public ImmutableCollection<RiskModel> getAllRiskModels()
    {
        Query q = getCurrentSession().createQuery("from RiskModel");
        @SuppressWarnings("unchecked")
        final List<RiskModel> list = q.list();
        return ImmutableList.copyOf(list);
    }
    
    /**
     * Returns the RiskModel in the database for the given Id
     * @return an RiskModel
     */
    public RiskModel getRiskModelForId( final int mid ) 
    {
    	return (RiskModel)getCurrentSession().get(RiskModel.class, mid);
    }
    
    public RiskModel saveRiskModel( final RiskModel rm )
    {
        fLogger.debug("Merging RiskModel {} into persistence context.", rm.getDisplayName() );

        return (RiskModel)getCurrentSession().merge( rm );
    }
}<commit_msg>289 sorting models alphabetically <commit_after>package gov.va.med.srcalc.db;

import gov.va.med.srcalc.domain.model.RiskModel;

import java.util.Collections;
import java.util.List;

import javax.inject.Inject;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;

@Repository
public class RiskModelDao
{
    private final SessionFactory fSessionFactory;
    
    private static final Logger fLogger = LoggerFactory.getLogger(RiskModelDao.class);

    @Inject // Allow arguments to be autowired.
    public RiskModelDao(final SessionFactory sessionFactory)
    {
        fSessionFactory = sessionFactory;
    }
    
    protected Session getCurrentSession()
    {
        return fSessionFactory.getCurrentSession();
    }
    
    /**
     * Returns all RiskModels in the database, in arbitrary order.
     * @return an ImmutableCollection
     */
	public ImmutableCollection<RiskModel> getAllRiskModels()
    {
        Query q = getCurrentSession().createQuery("from RiskModel");
        @SuppressWarnings("unchecked")
        final List<RiskModel> list = q.list();
        // sort alphabetically by name
        Collections.sort( list );
        return ImmutableList.copyOf(list);
    }
    
    /**
     * Returns the RiskModel in the database for the given Id
     * @return an RiskModel
     */
    public RiskModel getRiskModelForId( final int mid ) 
    {
    	return (RiskModel)getCurrentSession().get(RiskModel.class, mid);
    }
    
    public RiskModel saveRiskModel( final RiskModel rm )
    {
        fLogger.debug("Merging RiskModel {} into persistence context.", rm.getDisplayName() );

        return (RiskModel)getCurrentSession().merge( rm );
    }
}
{'fraction_non_alphanumeric': 0.09166666666666666, 'fraction_numerical': 0.001881720430107527, 'mean_word_length': 3.3267441860465117, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3313354', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1045, 'n_words': 248}