Spaces:
Build error
Build error
| package com.dalab.policyengine.model; | |
| import java.time.Instant; | |
| import java.util.Map; | |
| import java.util.UUID; | |
| import org.hibernate.annotations.JdbcTypeCode; | |
| import org.hibernate.type.SqlTypes; | |
| import jakarta.persistence.Column; | |
| import jakarta.persistence.Entity; | |
| import jakarta.persistence.FetchType; | |
| import jakarta.persistence.GeneratedValue; | |
| import jakarta.persistence.GenerationType; | |
| import jakarta.persistence.Id; | |
| import jakarta.persistence.JoinColumn; | |
| import jakarta.persistence.ManyToOne; | |
| import jakarta.persistence.PrePersist; | |
| import jakarta.persistence.PreUpdate; | |
| import jakarta.persistence.Table; | |
| import jakarta.validation.constraints.NotBlank; | |
| import jakarta.validation.constraints.Size; | |
| /** | |
| * Entity representing a filtering rule for event subscriptions. | |
| * Uses MVEL expressions to define conditions for event matching. | |
| */ | |
| public class EventRule { | |
| private UUID id; | |
| private String name; | |
| private String description; | |
| private EventSubscription subscription; | |
| /** | |
| * MVEL expression for evaluating events | |
| * Example: "eventType == 'POLICY_VIOLATION' && severity == 'HIGH' && assetId.startsWith('prod-')" | |
| */ | |
| private String condition; | |
| /** | |
| * Rule priority (lower number = higher priority) | |
| */ | |
| private Integer priority = 1; | |
| /** | |
| * Whether this rule is enabled | |
| */ | |
| private Boolean enabled = true; | |
| /** | |
| * Additional parameters for the rule | |
| */ | |
| private Map<String, Object> parameters; | |
| private Instant createdAt; | |
| private Instant updatedAt; | |
| private UUID createdByUserId; | |
| private UUID updatedByUserId; | |
| // Constructors | |
| public EventRule() {} | |
| public EventRule(String name, String condition) { | |
| this.name = name; | |
| this.condition = condition; | |
| } | |
| // Getters and Setters | |
| public UUID getId() { | |
| return id; | |
| } | |
| public void setId(UUID id) { | |
| this.id = id; | |
| } | |
| public String getName() { | |
| return name; | |
| } | |
| public void setName(String name) { | |
| this.name = name; | |
| } | |
| public String getDescription() { | |
| return description; | |
| } | |
| public void setDescription(String description) { | |
| this.description = description; | |
| } | |
| public EventSubscription getSubscription() { | |
| return subscription; | |
| } | |
| public void setSubscription(EventSubscription subscription) { | |
| this.subscription = subscription; | |
| } | |
| public String getCondition() { | |
| return condition; | |
| } | |
| public void setCondition(String condition) { | |
| this.condition = condition; | |
| } | |
| public Integer getPriority() { | |
| return priority; | |
| } | |
| public void setPriority(Integer priority) { | |
| this.priority = priority; | |
| } | |
| public Boolean getEnabled() { | |
| return enabled; | |
| } | |
| public void setEnabled(Boolean enabled) { | |
| this.enabled = enabled; | |
| } | |
| public Map<String, Object> getParameters() { | |
| return parameters; | |
| } | |
| public void setParameters(Map<String, Object> parameters) { | |
| this.parameters = parameters; | |
| } | |
| public Instant getCreatedAt() { | |
| return createdAt; | |
| } | |
| public void setCreatedAt(Instant createdAt) { | |
| this.createdAt = createdAt; | |
| } | |
| public Instant getUpdatedAt() { | |
| return updatedAt; | |
| } | |
| public void setUpdatedAt(Instant updatedAt) { | |
| this.updatedAt = updatedAt; | |
| } | |
| public UUID getCreatedByUserId() { | |
| return createdByUserId; | |
| } | |
| public void setCreatedByUserId(UUID createdByUserId) { | |
| this.createdByUserId = createdByUserId; | |
| } | |
| public UUID getUpdatedByUserId() { | |
| return updatedByUserId; | |
| } | |
| public void setUpdatedByUserId(UUID updatedByUserId) { | |
| this.updatedByUserId = updatedByUserId; | |
| } | |
| protected void onCreate() { | |
| createdAt = Instant.now(); | |
| updatedAt = Instant.now(); | |
| } | |
| protected void onUpdate() { | |
| updatedAt = Instant.now(); | |
| } | |
| public boolean equals(Object o) { | |
| if (this == o) return true; | |
| if (!(o instanceof EventRule)) return false; | |
| EventRule eventRule = (EventRule) o; | |
| return id != null && id.equals(eventRule.getId()); | |
| } | |
| public int hashCode() { | |
| return getClass().hashCode(); | |
| } | |
| public String toString() { | |
| return "EventRule{" + | |
| "id=" + id + | |
| ", name='" + name + '\'' + | |
| ", condition='" + condition + '\'' + | |
| ", priority=" + priority + | |
| ", enabled=" + enabled + | |
| '}'; | |
| } | |
| } |