<commit_before>package com.cyb.tms.dao.impl;

import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Repository;

import com.cyb.tms.dao.TmsUsersDAO;
import com.cyb.tms.entity.TmsUsers;
import com.cyb.tms.util.HibernateUtil;

@Repository
public class TmsUsersDAOImpl implements TmsUsersDAO {

private static final String USER_NAME = "userName";
	
	@Autowired
    private HibernateUtil hibernateUtil;
	
	@Autowired
	private BCryptPasswordEncoder passwordEncoder;

	@Override
	public TmsUsers findByUsername(String username) {
		return hibernateUtil.findByUsername(USER_NAME, username, TmsUsers.class);
	}

	@Override
	public long createUser(TmsUsers user) {
		user.setPassword(passwordEncoder.encode(user.getPassword()));
		return (Long) hibernateUtil.create(user);
	}

	@Override
	public TmsUsers updateUser(TmsUsers tmsUser) {
		return hibernateUtil.update(tmsUser);
	}

	@Override
	public void deleteUser(long id) {
		TmsUsers user = new TmsUsers();
		user.setId(id);
        hibernateUtil.delete(user);
	}

	@Override
	public List<TmsUsers> getAllUsers() {
		return hibernateUtil.fetchAll(TmsUsers.class);
	}

	@Override
	public TmsUsers getUser(long id) {
		return hibernateUtil.fetchById(id, TmsUsers.class);
	}
	

	@SuppressWarnings("unchecked")
	@Override
	public List<TmsUsers> getUsersByStatus(long projectId) {
		List<TmsUsers> users = hibernateUtil.getCurrentSession().createCriteria(TmsUsers.class, "tu")
				              .createAlias("tmsProject", "proj")
			                  .add(Restrictions.eq("proj.pid", projectId))
			                  .add(Restrictions.ne("userRole", "MANAGER"))
			                  .add(Restrictions.eq("tu.isActive", "ACTIVE")).list();
		return users;
	}


}<commit_msg>Update userlist query<commit_after>package com.cyb.tms.dao.impl;

import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Repository;

import com.cyb.tms.dao.TmsUsersDAO;
import com.cyb.tms.entity.TmsUsers;
import com.cyb.tms.util.HibernateUtil;

@Repository
public class TmsUsersDAOImpl implements TmsUsersDAO {

private static final String USER_NAME = "userName";
	
	@Autowired
    private HibernateUtil hibernateUtil;
	
	@Autowired
	private BCryptPasswordEncoder passwordEncoder;

	@Override
	public TmsUsers findByUsername(String username) {
		return hibernateUtil.findByUsername(USER_NAME, username, TmsUsers.class);
	}

	@Override
	public long createUser(TmsUsers user) {
		user.setPassword(passwordEncoder.encode(user.getPassword()));
		return (Long) hibernateUtil.create(user);
	}

	@Override
	public TmsUsers updateUser(TmsUsers tmsUser) {
		return hibernateUtil.update(tmsUser);
	}

	@Override
	public void deleteUser(long id) {
		TmsUsers user = new TmsUsers();
		user.setId(id);
        hibernateUtil.delete(user);
	}

	@Override
	public List<TmsUsers> getAllUsers() {
		return hibernateUtil.fetchAll(TmsUsers.class);
	}

	@Override
	public TmsUsers getUser(long id) {
		return hibernateUtil.fetchById(id, TmsUsers.class);
	}
	

	@SuppressWarnings("unchecked")
	@Override
	public List<TmsUsers> getUsersByStatus(long projectId) {
		Object[] roles = {"MANAGER", "ADMIN"};
		List<TmsUsers> users = hibernateUtil.getCurrentSession().createCriteria(TmsUsers.class, "tu")
				              .createAlias("tmsProject", "proj")
			                  .add(Restrictions.eq("proj.pid", projectId))
			                  .add(Restrictions.not(Restrictions.in("userRole", roles)))
			                  .add(Restrictions.eq("tu.isActive", "ACTIVE")).list();
		return users;
	}


}
{'fraction_non_alphanumeric': 0.111830183794978, 'fraction_numerical': 0.0, 'mean_word_length': 4.527896995708154, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3833775', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1248, 'n_words': 222}