<commit_before>package org.openlmis.core.repository.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.openlmis.core.domain.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RoleRightsMapper {

    @Insert("INSERT INTO role_rights(roleId, rightId) VALUES " +
            "(#{roleId}, #{right})")
    int createRoleRight(@Param(value = "roleId") Integer roleId, @Param(value = "right") Right right);

    @Insert("INSERT INTO roles" +
            "(name, description) VALUES " +
            "(#{name}, #{description})")
    @Options(useGeneratedKeys = true)
    int insertRole(Role role);

    @Select("SELECT RA.userId, RA.roleId, RA.programId " +
            "FROM role_assignments RA, users U, role_rights RR WHERE " +
            "U.user_name = #{userName} " +
            "AND U.id  = RA.user_id " +
            "AND RA.role_id = RR.roleId " +
            "AND RR.rightId = #{right} ")
    List<RoleAssignment> getRoleAssignmentsWithGivenRightForAUser(@Param(value = "right") Right right,
                                                                  @Param(value = "userName") String userName);

    @Insert("INSERT INTO role_assignments" +
            "(userId, roleId, programId) VALUES " +
            "(#{user.id}, #{role.id}, #{program.id})")
    int createRoleAssignment(@Param(value = "user") User user,
                             @Param(value = "role") Role role,
                             @Param(value = "program") Program program);
<commit_msg>|#000| role right mapper query corrected<commit_after>package org.openlmis.core.repository.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.openlmis.core.domain.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RoleRightsMapper {

    @Insert("INSERT INTO role_rights(roleId, rightId) VALUES " +
            "(#{roleId}, #{right})")
    int createRoleRight(@Param(value = "roleId") Integer roleId, @Param(value = "right") Right right);

    @Insert("INSERT INTO roles" +
            "(name, description) VALUES " +
            "(#{name}, #{description})")
    @Options(useGeneratedKeys = true)
    int insertRole(Role role);

    @Select("SELECT RA.userId, RA.roleId, RA.programId " +
            "FROM role_assignments RA, users U, role_rights RR WHERE " +
            "U.userName = #{userName} " +
            "AND U.id  = RA.userId " +
            "AND RA.roleId = RR.roleId " +
            "AND RR.rightId = #{right} ")
    List<RoleAssignment> getRoleAssignmentsWithGivenRightForAUser(@Param(value = "right") Right right,
                                                                  @Param(value = "userName") String userName);

    @Insert("INSERT INTO role_assignments" +
            "(userId, roleId, programId) VALUES " +
            "(#{user.id}, #{role.id}, #{program.id})")
    int createRoleAssignment(@Param(value = "user") User user,
                             @Param(value = "role") Role role,
                             @Param(value = "program") Program program);

{'fraction_non_alphanumeric': 0.1337485172004745, 'fraction_numerical': 0.0008896797153024911, 'mean_word_length': 2.6036324786324787, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4267940', 'n_tokens_mistral': 984, 'n_tokens_neox': 960, 'n_words': 213}