@ -1,6 +1,7 @@
package com.redhat.pctsec.model ;
package com.redhat.pctsec.model ;
import com.fasterxml.jackson.annotation.JsonIgnore ;
import com.fasterxml.jackson.annotation.JsonIgnore ;
import com.fasterxml.jackson.annotation.JsonProperty ;
import jakarta.persistence.* ;
import jakarta.persistence.* ;
import jakarta.transaction.Transactional ;
import jakarta.transaction.Transactional ;
import jakarta.validation.constraints.Email ;
import jakarta.validation.constraints.Email ;
@ -17,6 +18,50 @@ enum ScanState {
@Entity
@Entity
public class Scan {
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 . LAZY )
@JoinColumn ( name = "scan_requests_id" , referencedColumnName = "id" )
public ScanRequests scanRequests ;
public Scan ( ) {
public Scan ( ) {
this . scanRequests = new ScanRequests ( ) ;
this . scanRequests = new ScanRequests ( ) ;
}
}
@ -53,7 +98,14 @@ public class Scan {
this . requestor = requestor ;
this . requestor = requestor ;
}
}
@JsonProperty ( "email" )
@Access ( AccessType . PROPERTY )
@Email
public String getEmail ( ) {
public String getEmail ( ) {
if ( email ! = null )
return email ;
if ( getRequestor ( ) ! = null )
return getRequestor ( ) + "@redhat.com" ;
return email ;
return email ;
}
}
@ -69,48 +121,4 @@ public class Scan {
public void setScanRequests ( ScanRequests scanRequests ) {
public void setScanRequests ( ScanRequests scanRequests ) {
this . scanRequests = scanRequests ;
this . scanRequests = scanRequests ;
}
}
@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 . LAZY )
@JoinColumn ( name = "scan_requests_id" , referencedColumnName = "id" )
public ScanRequests scanRequests ;
}
}