Policy failures:

Code warning
- failed on resource RolePK.java. Reason: The assignment to variable conference has no effect, line 26
- failed on resource User.java. Reason: The serializable class User does not declare a static final serialVersionUID field of type long, line 2
Override reason:   
f
This commit is contained in:
Maxime Dagnicourt
2008-01-08 17:01:08 +00:00
parent 723bd99607
commit d9fe0ac7fb
6 changed files with 85 additions and 98 deletions

View File

@@ -10,4 +10,7 @@ public interface IUsersManager {
public void addUser(User user);
public void removeUser(User user);
public User getUser(String login);
public void UpdateUser(User user);
public Boolean existe(User user);
}

View File

@@ -3,13 +3,14 @@ package org.yacos.core.users;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.yacos.core.conferences.Conference;
import org.yacos.core.users.RoleType.RoleTypeEnum;
/**
* An role of a given type (author,chairman,PCmember or referee)
@@ -18,81 +19,75 @@ import org.yacos.core.users.RoleType.RoleTypeEnum;
*
*/
@Entity
@IdClass(RolePK.class)
public class Role {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Integer id;
/**
* User for which this role is defined
* Primary Key
*/
@Id
@ManyToOne(targetEntity=User.class,optional=false)
@JoinColumn(name="user_id",nullable=false)
private User user;
/**
* Conference for which this role is defined
* Primary Key
*/
@Id
@ManyToOne(targetEntity=Conference.class,optional=false)
@JoinColumn(name="conference_id",nullable=false)
private Conference conference;
/**
* The type of this role
*/
@Enumerated(EnumType.ORDINAL)
private RoleTypeEnum type;
public enum RoleType {
AUTHOR,CHAIRMAN,PCMEMBER,REFEREE
}
public Role(RoleTypeEnum type,User user, Conference conference) {
@Enumerated(EnumType.ORDINAL)
private RoleType type;
public Role(RoleType type,User user, Conference conference) {
super();
setType(type);
setUser(user);
setConference(conference);
}
/**
* @return the id
*/
public Integer getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(Integer id) {
this.id = id;
}
/**
* @return the user who plays this role
*/
public User getUser() {
return user;
}
/**
* @param user the user who is to play this role
*/
public void setUser(User user) {
this.user = user;
}
/**
* @return the conference for which this role is defined
*/
public Conference getConference() {
return conference;
}
/**
* @param conference the conference for which this role is defined
*/
public void setConference(Conference conference) {
this.conference = conference;
}
/**
* @return the type of this role
*/
public RoleTypeEnum getType() {
public RoleType getType() {
return type;
}
/**
* @param type the type of this role
*/
public void setType(RoleTypeEnum type) {
public void setType(RoleType type) {
this.type = type;
}
}

View File

@@ -0,0 +1,30 @@
package org.yacos.core.users;
import java.io.Serializable;
import org.yacos.core.conferences.Conference;
public class RolePK implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private User user;
private Conference conference;
public User getUserId() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Conference getConference() {
return conference;
}
public void setConferenceId(Conference conferenceId) {
this.conference = conference;
}
}

View File

@@ -1,52 +0,0 @@
/**
*
*/
package org.yacos.core.users;
/**
* @author christiancorsano
*
*/
public class RoleType {
// TODO : see what we do with this class
public enum RoleTypeEnum {
AUTHOR,CHAIRMAN,PCMEMBER,REFEREE
}
/**
* Author constant role
*/
static public final RoleType author = new RoleType("author");
/**
* Chairman constant role
*/
static public final RoleType chairman = new RoleType("chairman");
/**
* PCMember constant role
*/
static public final RoleType PCmember = new RoleType("PCmember");
/**
* Referee constant role
*/
static public final RoleType Referee = new RoleType("referee");
/**
* Name of this role type
*/
private String name;
/**
* Private constructor : used to instanciate the constants
* @param name Name of the new RoleType
*/
private RoleType(String name){
this.name = name;
}
/**
* Return the name of this RoleType
* @return
*/
public String getName() {
return this.name;
}
}

View File

@@ -1,6 +1,7 @@
package org.yacos.core.users;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.Entity;
@@ -52,25 +53,20 @@ public class User implements Serializable{
private Collection<Role> roles;
public User(String login, String password, String firstName,
String lastName, String organization, String email,
Collection<Role> roles) {
super();
String lastName, String organization, String email) {
this();
this.login = login;
this.password = password;
this.firstName = firstName;
this.lastName = lastName;
this.organization = organization;
this.email = email;
this.roles = roles;
}
public User() {
this.roles = new ArrayList<Role>();
}
@Id
public String getLogin() {
return login;
@@ -116,7 +112,7 @@ public class User implements Serializable{
roles.add(role);
}
public void addRoleForConference(RoleType roleType, Conference conference){
public void addRoleForConference(Role.RoleType roleType, Conference conference){
if(! hasRoleForConference(roleType,conference)){
} else {
@@ -124,7 +120,7 @@ public class User implements Serializable{
}
}
public boolean hasRoleForConference(RoleType roleType, Conference conference){
public boolean hasRoleForConference(Role.RoleType roleType, Conference conference){
// TODO
return false;
}
@@ -156,4 +152,8 @@ public class User implements Serializable{
this.roles = roles;
}
public void AddRole(Role role){
roles.add(role);
}
}

View File

@@ -45,4 +45,15 @@ public class UsersManagerBean implements IUsersManager{
public User getUser(String login) {
return em.find(User.class, login);
}
public void UpdateUser(User user){
em.merge(user);
}
public Boolean existe(User user){
return (this.getUser(user.getLogin())!= null);
}
}