Bázová třída pro data bez vlastníka
This commit is contained in:
@@ -0,0 +1,65 @@
|
|||||||
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
@MappedSuperclass
|
||||||
|
public abstract class BaseSimpleData implements DataModel {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name="ID")
|
||||||
|
@GeneratedValue
|
||||||
|
private int id;
|
||||||
|
@Column(name="CREATED")
|
||||||
|
private Date created;
|
||||||
|
@Column(name="MODIFIED")
|
||||||
|
private Date modified;
|
||||||
|
@Transient
|
||||||
|
private boolean valid;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getCreated() {
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCreated(Date created) {
|
||||||
|
this.created = created;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getModified() {
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setModified(Date modified) {
|
||||||
|
this.modified = modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid() {
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValid(boolean valid) {
|
||||||
|
this.valid = valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,40 +1,25 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Transient;
|
|
||||||
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="ROLE")
|
@Table(name="ROLE")
|
||||||
public class Role implements GrantedAuthority, DataModel {
|
public class Role extends BaseSimpleData implements GrantedAuthority, DataModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 5677876140880991163L;
|
private static final long serialVersionUID = 5677876140880991163L;
|
||||||
|
|
||||||
@Id
|
|
||||||
@Column(name="ID")
|
|
||||||
@GeneratedValue
|
|
||||||
private int id;
|
|
||||||
@Column(name="AUTHORITY", unique=true)
|
@Column(name="AUTHORITY", unique=true)
|
||||||
private String authority;
|
private String authority;
|
||||||
@Column(name="DESCRIPTION")
|
@Column(name="DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
@Column(name="CREATED")
|
|
||||||
private Date created;
|
|
||||||
@Column(name="MODIFIED")
|
|
||||||
private Date modified;
|
|
||||||
@Transient
|
|
||||||
private boolean valid;
|
|
||||||
|
|
||||||
public Role(String authority, String description) {
|
public Role(String authority, String description) {
|
||||||
this.authority = authority;
|
this.authority = authority;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@@ -49,14 +34,6 @@ public class Role implements GrantedAuthority, DataModel {
|
|||||||
return authority;
|
return authority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
@@ -69,33 +46,9 @@ public class Role implements GrantedAuthority, DataModel {
|
|||||||
this.authority = authority;
|
this.authority = authority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValid() {
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValid(boolean valid) {
|
|
||||||
this.valid = valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if ((o instanceof Role) && ((Role)o).getId() == this.id) {
|
if ((o instanceof Role) && ((Role)o).getId() == this.getId()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,35 +1,27 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.JoinTable;
|
import javax.persistence.JoinTable;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Transient;
|
|
||||||
|
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="USER")
|
@Table(name="USER")
|
||||||
public class User implements UserDetails, DataModel {
|
public class User extends BaseSimpleData implements UserDetails, DataModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 5421234421833765433L;
|
private static final long serialVersionUID = 5421234421833765433L;
|
||||||
|
|
||||||
@Id
|
|
||||||
@Column(name="ID")
|
|
||||||
@GeneratedValue
|
|
||||||
private int id;
|
|
||||||
@Column(name="USERNAME", unique=true)
|
@Column(name="USERNAME", unique=true)
|
||||||
private String username;
|
private String username;
|
||||||
@Column(name="PASSWORD")
|
@Column(name="PASSWORD")
|
||||||
@@ -49,13 +41,7 @@ public class User implements UserDetails, DataModel {
|
|||||||
@ManyToMany(fetch=FetchType.EAGER)
|
@ManyToMany(fetch=FetchType.EAGER)
|
||||||
@JoinTable(name="USER_ROLE", joinColumns={@JoinColumn(name="USER_ID")}, inverseJoinColumns={@JoinColumn(name="ROLE_ID")})
|
@JoinTable(name="USER_ROLE", joinColumns={@JoinColumn(name="USER_ID")}, inverseJoinColumns={@JoinColumn(name="ROLE_ID")})
|
||||||
private List<Role> authorities;
|
private List<Role> authorities;
|
||||||
@Column(name="CREATED")
|
|
||||||
private Date created;
|
|
||||||
@Column(name="MODIFIED")
|
|
||||||
private Date modified;
|
|
||||||
@Transient
|
|
||||||
private boolean valid;
|
|
||||||
|
|
||||||
public User() {
|
public User() {
|
||||||
authorities = new ArrayList<Role>();
|
authorities = new ArrayList<Role>();
|
||||||
}
|
}
|
||||||
@@ -95,14 +81,6 @@ public class User implements UserDetails, DataModel {
|
|||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(String password) {
|
public void setPassword(String password) {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
@@ -123,30 +101,6 @@ public class User implements UserDetails, DataModel {
|
|||||||
this.authorities.add(role);
|
this.authorities.add(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValid() {
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValid(boolean valid) {
|
|
||||||
this.valid = valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFullName() {
|
public String getFullName() {
|
||||||
String ret = "";
|
String ret = "";
|
||||||
if (firstName != null && !firstName.isEmpty()) {
|
if (firstName != null && !firstName.isEmpty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user