Skip to content

Commit

Permalink
[backend] Remove hypersistence type to use native array type
Browse files Browse the repository at this point in the history
  • Loading branch information
RomuDeuxfois authored and savacano28 committed Aug 30, 2024
1 parent ee9ee7e commit 0cb0dc1
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.logging.Level;

import static java.time.Instant.now;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.hypersistence.utils.hibernate.type.array.StringArrayType;
import io.openbas.annotation.Queryable;
import io.openbas.database.audit.ModelBaseListener;
import io.openbas.helper.MonoIdDeserializer;
import io.openbas.helper.MultiIdListDeserializer;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.UuidGenerator;

import java.time.Instant;
Expand Down Expand Up @@ -56,12 +54,10 @@ public class AttackPattern implements Base {
@NotBlank
private String externalId;

@Type(StringArrayType.class)
@Column(name = "attack_pattern_platforms", columnDefinition = "text[]")
@JsonProperty("attack_pattern_platforms")
private String[] platforms = new String[0];

@Type(StringArrayType.class)
@Column(name = "attack_pattern_permissions_required", columnDefinition = "text[]")
@JsonProperty("attack_pattern_permissions_required")
private String[] permissionsRequired = new String[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.hypersistence.utils.hibernate.type.array.StringArrayType;
import io.openbas.database.audit.ModelBaseListener;
import io.openbas.helper.MonoIdDeserializer;
import io.openbas.helper.MultiIdListDeserializer;
import jakarta.persistence.*;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.annotations.UuidGenerator;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.UuidGenerator;

Expand Down Expand Up @@ -63,7 +64,6 @@ public class Communication implements Base {
@JsonProperty("communication_content_html")
private String contentHtml;

@Type(StringArrayType.class)
@Column(name = "communication_attachments", columnDefinition = "text[]")
@JsonProperty("communication_attachments")
private String[] attachments;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.openbas.database.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.hypersistence.utils.hibernate.type.array.StringArrayType;
import io.openbas.annotation.Ipv4OrIpv6Constraint;
import io.openbas.annotation.Queryable;
import io.openbas.database.audit.ModelBaseListener;
Expand All @@ -10,7 +9,6 @@
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;

@EqualsAndHashCode(callSuper = true)
@Data
Expand Down Expand Up @@ -52,7 +50,6 @@ public enum PLATFORM_TYPE {
@Queryable(filterable = true)
@NotEmpty
@Ipv4OrIpv6Constraint
@Type(StringArrayType.class)
@Column(name = "endpoint_ips")
@JsonProperty("endpoint_ips")
private String[] ips;
Expand Down Expand Up @@ -81,7 +78,6 @@ public enum PLATFORM_TYPE {
@NotNull
private PLATFORM_ARCH arch;

@Type(StringArrayType.class)
@Column(name = "endpoint_mac_addresses")
@JsonProperty("endpoint_mac_addresses")
private String[] macAddresses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.hypersistence.utils.hibernate.type.array.StringArrayType;
import io.openbas.database.audit.ModelBaseListener;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Type;

import java.time.Instant;
import java.util.Objects;
Expand Down Expand Up @@ -39,7 +37,7 @@ public class Executor implements Base {
@NotBlank
private String type;

@Type(StringArrayType.class)
@Getter
@Column(name = "executor_platforms", columnDefinition = "text[]")
@JsonProperty("executor_platforms")
private String[] platforms = new String[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.hypersistence.utils.hibernate.type.array.StringArrayType;
import io.hypersistence.utils.hibernate.type.basic.PostgreSQLHStoreType;
import io.openbas.annotation.Queryable;
import io.openbas.database.audit.ModelBaseListener;
Expand Down Expand Up @@ -63,7 +62,6 @@ public class InjectorContract implements Base {
@JsonProperty("injector_contract_needs_executor")
private Boolean needsExecutor = false;

@Type(StringArrayType.class)
@Enumerated(EnumType.STRING)
@Column(name = "injector_contract_platforms", columnDefinition = "text[]")
@JsonProperty("injector_contract_platforms")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public class Mitigation implements Base {
@NotBlank
private String externalId;

@Type(StringArrayType.class)
@Column(name = "mitigation_log_sources", columnDefinition = "text[]")
@JsonProperty("mitigation_log_sources")
private String[] logSources = new String[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public enum PAYLOAD_STATUS {
private String description;

@Queryable(filterable = true, searchable = true)
@Type(StringArrayType.class)
@Column(name = "payload_platforms", columnDefinition = "text[]")
@JsonProperty("payload_platforms")
private PLATFORM_TYPE[] platforms = new PLATFORM_TYPE[0];
Expand Down

0 comments on commit 0cb0dc1

Please sign in to comment.