argos/dmp-backend/data/src/main/java/eu/eudat/data/entities/UserRole.java

70 lines
1.4 KiB
Java
Raw Normal View History

2018-03-21 11:57:56 +01:00
package eu.eudat.data.entities;
2018-01-31 16:39:16 +01:00
import eu.eudat.data.entities.helpers.EntityBinder;
2018-03-21 11:16:32 +01:00
import eu.eudat.queryable.queryableentity.DataEntity;
2018-01-31 16:39:16 +01:00
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
2018-10-02 16:33:58 +02:00
import java.util.List;
2018-01-31 16:39:16 +01:00
import java.util.UUID;
2018-02-01 10:08:06 +01:00
2018-01-31 16:39:16 +01:00
@Entity
@Table(name = "\"UserRole\"")
2018-02-20 08:50:17 +01:00
public class UserRole implements DataEntity<UserRole, UUID> {
2018-01-31 16:39:16 +01:00
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
2018-01-31 16:39:16 +01:00
@Column(name = "\"Role\"", nullable = false)
private int role;
2018-01-31 16:39:16 +01:00
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"UserId\"", nullable = false)
private UserInfo userInfo;
2018-01-31 16:39:16 +01:00
public UUID getId() {
return id;
}
2018-01-31 16:39:16 +01:00
public void setId(UUID id) {
this.id = id;
}
2018-01-31 16:39:16 +01:00
public int getRole() {
return role;
}
2018-01-31 16:39:16 +01:00
public void setRole(int role) {
this.role = role;
}
2018-01-31 16:39:16 +01:00
public UserInfo getUserInfo() {
return userInfo;
}
2018-01-31 16:39:16 +01:00
public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo;
}
2018-01-31 16:39:16 +01:00
@Override
public void update(UserRole entity) {
2018-01-31 16:39:16 +01:00
}
2018-01-31 16:39:16 +01:00
@Override
public UUID getKeys() {
return this.id;
}
2018-10-02 16:33:58 +02:00
@Override
public UserRole buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
2018-01-31 16:39:16 +01:00
}