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 committed Aug 2, 2024
1 parent d2bf0a3 commit 7f7ba89
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 20 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,13 @@
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 org.apache.commons.lang3.StringUtils;
import org.hibernate.annotations.UuidGenerator;
import org.hibernate.annotations.Type;

import jakarta.persistence.*;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -55,7 +53,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,13 +2,11 @@

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 lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Type;

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

@Getter
@Type(StringArrayType.class)
@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)
@Column(name = "injector_contract_platforms", columnDefinition = "text[]")
@JsonProperty("injector_contract_platforms")
private String[] platforms = new String[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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 @@ -65,7 +65,6 @@ public enum PAYLOAD_STATUS {
@JsonProperty("payload_description")
private String description;

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

0 comments on commit 7f7ba89

Please sign in to comment.