Skip to content

Commit

Permalink
[backend] fix setters
Browse files Browse the repository at this point in the history
  • Loading branch information
savacano28 committed Sep 30, 2024
1 parent 183d140 commit 729a7ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,13 @@ public Payload duplicate(@NotBlank final String payloadId) {
return duplicate;
}

private <T extends Payload> void duplicateCommonProperties(@org.jetbrains.annotations.NotNull final T origin,
@org.jetbrains.annotations.NotNull T duplicate) {
BeanUtils.copyProperties(origin, duplicate);
duplicate.setId(null);
duplicate.setName(StringUtils.duplicateString(origin.getName()));
duplicate.setAttackPatterns(new ArrayList<>(origin.getAttackPatterns()));
duplicate.setTags(new HashSet<>(origin.getTags()));
duplicate.setExternalId(null);
duplicate.setSource(MANUAL);
duplicate.setStatus(VERIFIED);
duplicate.setCollector(null);
}
private <T extends Payload> void duplicateCommonProperties(@org.jetbrains.annotations.NotNull final T origin, @org.jetbrains.annotations.NotNull T duplicate) {
BeanUtils.copyProperties(origin, duplicate);
duplicate.setId(null);
duplicate.setName(StringUtils.duplicateString(origin.getName()));
duplicate.setAttackPatterns(new ArrayList<>(origin.getAttackPatterns()));
duplicate.setTags(new HashSet<>(origin.getTags()));
duplicate.setExternalId(null);
duplicate.setCollector(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,12 @@ public enum PAYLOAD_STATUS {
private String externalId;

@Queryable(filterable = true, sortable = true)
@Setter
@Column(name = "payload_source")
@Enumerated(EnumType.STRING)
@JsonProperty("payload_source")
private PAYLOAD_SOURCE source;

@Queryable(filterable = true)
@Setter
@Column(name = "payload_status")
@Enumerated(EnumType.STRING)
@JsonProperty("payload_status")
Expand Down Expand Up @@ -168,6 +166,14 @@ private String getCollectorType() {
return this.collector != null ? this.collector.getType() : null;
}

public void setStatus(String status) {
this.status = PAYLOAD_STATUS.valueOf(status.toUpperCase());
}

public void setSource(String source) {
this.source = PAYLOAD_SOURCE.valueOf(source.toUpperCase());
}

@Override
public int hashCode() {
return Objects.hash(id);
Expand Down

0 comments on commit 729a7ce

Please sign in to comment.