File size: 2,364 Bytes
688925d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.dalab.autocompliance.model.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.Builder;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Entity
@Table(name = "compliance_control_evaluation_jobs", indexes = {
    @Index(name = "idx_ctrl_eval_job_control_id", columnList = "controlId"),
    @Index(name = "idx_ctrl_eval_job_status", columnList = "status")
})
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ControlEvaluationJobEntity extends AbstractAuditableEntity {

    @Id
    @Column(length = 36) // UUID length
    private String jobId;

    @Column(nullable = false, length = 100)
    private String controlId; // Foreign key to ComplianceControlEntity.controlId

    @Column(nullable = false, length = 50)
    private String status; // e.g., QUEUED, PROCESSING, COMPLETED_SUCCESS, COMPLETED_FAILURE, PARTIAL_FAILURE

    private LocalDateTime submittedAt;
    private LocalDateTime startedAt;
    private LocalDateTime completedAt;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    private String message; // Overall message for the job execution

    @ElementCollection(fetch = FetchType.LAZY) // Store targeted asset IDs
    @CollectionTable(name = "control_eval_job_target_assets", joinColumns = @JoinColumn(name = "job_id"))
    @Column(name = "asset_id")
    private List<String> targetAssetIds;

    @JdbcTypeCode(SqlTypes.JSON)
    @Column(columnDefinition = "jsonb")
    private Map<String, Object> evaluationParameters; // Parameters used for this specific evaluation run
    
    private boolean forceReevaluation;

    @Column(length = 255)
    private String triggeredBy;

    @Column(length = 255)
    private String notificationEmail;

    // In a more detailed model, you might have a list of ControlEvaluationResultEntity linked here.
    // For now, the results (findings) would likely be new entries in the main GeneratedReport or a similar table,
    // or a dedicated ControlFindingEntity. This part needs further thought based on how results are stored/queried.
    // For simplicity, this job entity primarily tracks the execution.
}