You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
2.8 KiB
124 lines
2.8 KiB
package com.redhat.pctsec.model; |
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
import com.fasterxml.jackson.annotation.JsonProperty; |
|
import jakarta.persistence.*; |
|
import jakarta.transaction.Transactional; |
|
import jakarta.validation.constraints.Email; |
|
import jakarta.validation.constraints.NotNull; |
|
import org.hibernate.annotations.CreationTimestamp; |
|
import org.hibernate.annotations.UpdateTimestamp; |
|
|
|
import java.time.Instant; |
|
import java.util.UUID; |
|
|
|
enum ScanState { |
|
CREATED, TRIGGERED, RUNNING, SUCCESS, FAIL; |
|
} |
|
@Entity |
|
public class Scan { |
|
|
|
@Id |
|
@GeneratedValue(strategy = GenerationType.AUTO) |
|
public UUID id; |
|
|
|
|
|
/* |
|
@OneToOne |
|
@NotNull |
|
@JoinColumn(name = "product_id", referencedColumnName = "id") |
|
private String productName; |
|
*/ |
|
@Column(name="proudct_name") |
|
private String productName; |
|
|
|
//@Temporal(TemporalType.TIMESTAMP) |
|
|
|
@CreationTimestamp |
|
@JsonIgnore |
|
@Column(name="creation_timestamp") |
|
//@NotNull |
|
private Instant creationTimestamp; |
|
|
|
@UpdateTimestamp |
|
@JsonIgnore |
|
@Column(name="update_timestamp") |
|
//@NotNull |
|
private Instant updateTimestamp; |
|
|
|
@Column(name="state") |
|
@Enumerated(EnumType.STRING) |
|
private ScanState state; |
|
|
|
@Column(name="requestor") |
|
@NotNull |
|
private String requestor; |
|
|
|
@Column(name="report_email") |
|
@Email |
|
private String email; |
|
|
|
@OneToOne(cascade = CascadeType.ALL, fetch=FetchType.EAGER) |
|
@JoinColumn(name = "scan_requests_id", referencedColumnName = "id") |
|
public ScanRequests scanRequests = new ScanRequests(); |
|
|
|
public Scan() { |
|
this.scanRequests = new ScanRequests(); |
|
} |
|
|
|
public Instant getCreationTimestamp() { |
|
return creationTimestamp; |
|
} |
|
|
|
public void setCreationTimestamp(Instant creationTimestamp) { |
|
this.creationTimestamp = creationTimestamp; |
|
} |
|
|
|
public ScanState getState() { |
|
return state; |
|
} |
|
|
|
public void setState(ScanState state) { |
|
this.state = state; |
|
} |
|
|
|
public String getProductName() { |
|
return productName; |
|
} |
|
|
|
public void setProductName(String productName) { |
|
this.productName = productName; |
|
} |
|
|
|
public String getRequestor() { |
|
return requestor; |
|
} |
|
|
|
public void setRequestor(String requestor) { |
|
this.requestor = requestor; |
|
} |
|
|
|
@JsonProperty("email") |
|
@Access(AccessType.PROPERTY) |
|
@Email |
|
public String getEmail() { |
|
if(email != null) |
|
return email; |
|
if(getRequestor() != null) |
|
return getRequestor() + "@redhat.com"; |
|
return email; |
|
} |
|
|
|
public void setEmail(String email) { |
|
this.email = email; |
|
} |
|
|
|
|
|
public ScanRequests getScanRequests() { |
|
return scanRequests; |
|
} |
|
|
|
public void setScanRequests(ScanRequests scanRequests) { |
|
this.scanRequests = scanRequests; |
|
} |
|
}
|
|
|