187 lines
4.4 KiB
Java
187 lines
4.4 KiB
Java
package eu.eudat.data;
|
|
|
|
import eu.eudat.commons.enums.ProviderType;
|
|
import eu.eudat.commons.enums.IsActive;
|
|
import eu.eudat.data.converters.DateToUTCConverter;
|
|
|
|
import eu.eudat.data.converters.enums.ProviderTypeConverter;
|
|
import eu.eudat.data.converters.enums.IsActiveConverter;
|
|
import eu.eudat.data.helpers.EntityBinder;
|
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
|
import jakarta.persistence.*;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
|
|
|
|
@Entity
|
|
@Table(name = "\"Credential\"")
|
|
//@NamedEntityGraphs({
|
|
// @NamedEntityGraph(
|
|
// name = "credentialUserInfo",
|
|
// attributeNodes = {@NamedAttributeNode("userInfo")})
|
|
//})
|
|
public class CredentialEntity implements DataEntity<CredentialEntity, UUID> {
|
|
|
|
@Id
|
|
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
private UUID id;
|
|
public final static String _id = "id";
|
|
|
|
@Column(name = "\"UserId\"", columnDefinition = "uuid", nullable = false)
|
|
private UUID userId;
|
|
public final static String _userId = "userId";
|
|
|
|
@Column(name = "\"Status\"", nullable = false)
|
|
@Convert(converter = IsActiveConverter.class)
|
|
private IsActive isActive;
|
|
public final static String _isActive = "isActive";
|
|
|
|
@Column(name = "\"Provider\"", nullable = false)
|
|
@Convert(converter = ProviderTypeConverter.class)
|
|
private ProviderType provider;
|
|
public final static String _provider = "provider";
|
|
|
|
@Column(name = "\"Public\"", nullable = false)
|
|
private String publicValue;
|
|
public final static String _publicValue = "public";
|
|
|
|
@Column(name = "\"Email\"")
|
|
private String email;
|
|
public final static String _email = "email";
|
|
|
|
@Column(name = "\"Secret\"", nullable = false)
|
|
private String secret;
|
|
public final static String _secret = "secret";
|
|
|
|
@Column(name = "\"CreationTime\"", nullable = false)
|
|
@Convert(converter = DateToUTCConverter.class)
|
|
private Date creationTime;
|
|
public final static String _creationTime = "creationTime";
|
|
|
|
@Column(name = "\"LastUpdateTime\"", nullable = false)
|
|
@Convert(converter = DateToUTCConverter.class)
|
|
private Date lastUpdateTime;
|
|
public final static String _lastUpdateTime = "lastUpdateTime";
|
|
|
|
@Column(name = "\"ExternalId\"", nullable = false)
|
|
private String externalId;
|
|
public final static String _externalId = "externalId";
|
|
|
|
public UUID getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(UUID id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public UUID getUserId() {
|
|
return userId;
|
|
}
|
|
|
|
public void setUserId(UUID userId) {
|
|
this.userId = userId;
|
|
}
|
|
|
|
public IsActive getIsActive() {
|
|
return isActive;
|
|
}
|
|
|
|
public void setIsActive(IsActive isActive) {
|
|
this.isActive = isActive;
|
|
}
|
|
|
|
public ProviderType getProvider() {
|
|
return provider;
|
|
}
|
|
|
|
public void setProvider(ProviderType provider) {
|
|
this.provider = provider;
|
|
}
|
|
|
|
public String getPublicValue() {
|
|
return publicValue;
|
|
}
|
|
|
|
public void setPublicValue(String publicValue) {
|
|
this.publicValue = publicValue;
|
|
}
|
|
|
|
public String getEmail() {
|
|
return email;
|
|
}
|
|
|
|
public void setEmail(String email) {
|
|
this.email = email;
|
|
}
|
|
|
|
public String getSecret() {
|
|
return secret;
|
|
}
|
|
|
|
public void setSecret(String secret) {
|
|
this.secret = secret;
|
|
}
|
|
|
|
public Date getCreationTime() {
|
|
return creationTime;
|
|
}
|
|
|
|
public void setCreationTime(Date creationTime) {
|
|
this.creationTime = creationTime;
|
|
}
|
|
|
|
public Date getLastUpdateTime() {
|
|
return lastUpdateTime;
|
|
}
|
|
|
|
public void setLastUpdateTime(Date lastUpdateTime) {
|
|
this.lastUpdateTime = lastUpdateTime;
|
|
}
|
|
|
|
public String getExternalId() {
|
|
return externalId;
|
|
}
|
|
|
|
public void setExternalId(String externalId) {
|
|
this.externalId = externalId;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) return true;
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
CredentialEntity that = (CredentialEntity) o;
|
|
|
|
return provider.getValue() == that.provider.getValue();
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return provider.getValue();
|
|
}
|
|
|
|
@Override
|
|
public void update(CredentialEntity entity) {
|
|
this.isActive = entity.isActive;
|
|
this.publicValue = entity.getPublicValue();
|
|
this.email = entity.getEmail();
|
|
this.secret = entity.getSecret();
|
|
this.lastUpdateTime = new Date();
|
|
}
|
|
|
|
@Override
|
|
public UUID getKeys() {
|
|
return this.id;
|
|
}
|
|
|
|
@Override
|
|
public CredentialEntity 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;
|
|
}
|
|
}
|