001 /* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2011 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * Sonar is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 019 */ 020 package org.sonar.api.security; 021 022 import org.apache.commons.lang.builder.ToStringBuilder; 023 import org.apache.commons.lang.builder.ToStringStyle; 024 import org.sonar.api.database.BaseIdentifiable; 025 026 import javax.persistence.Column; 027 import javax.persistence.Entity; 028 import javax.persistence.Table; 029 030 /** 031 * This JPA model maps the table user_roles 032 * 033 * @since 1.12 034 */ 035 @Entity 036 @Table(name = "user_roles") 037 public class UserRole extends BaseIdentifiable { 038 039 @Column(name = "user_id") 040 private Integer userId; 041 042 @Column(name = "role") 043 private String role; 044 045 @Column(name = "resource_id") 046 private Integer resourceId; 047 048 public UserRole(Integer userId, String role, Integer resourceId) { 049 this.userId = userId; 050 this.role = role; 051 this.resourceId = resourceId; 052 } 053 054 public UserRole() { 055 } 056 057 public Integer getUserId() { 058 return userId; 059 } 060 061 public UserRole setUserId(Integer userId) { 062 this.userId = userId; 063 return this; 064 } 065 066 public String getRole() { 067 return role; 068 } 069 070 public UserRole setRole(String role) { 071 this.role = role; 072 return this; 073 } 074 075 public Integer getResourceId() { 076 return resourceId; 077 } 078 079 public UserRole setResourceId(Integer resourceId) { 080 this.resourceId = resourceId; 081 return this; 082 } 083 084 @Override 085 public String toString() { 086 return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 087 } 088 }