Skip to content

Commit

Permalink
remove filterUuid in Rule DTO
Browse files Browse the repository at this point in the history
  • Loading branch information
thangqp committed Jul 10, 2024
1 parent 52d108c commit cd797b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/main/java/org/gridsuite/mapping/server/dto/Rule.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
package org.gridsuite.mapping.server.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
Expand Down Expand Up @@ -45,9 +44,6 @@ public class Rule {
@Schema(description = "Filter")
private ExpertFilter filter;

@JsonIgnore
private UUID filterUuid;

@Schema(description = "Filter is dirty or not")
private boolean filterDirty;

Expand Down Expand Up @@ -82,7 +78,7 @@ public Rule(RuleEntity ruleEntity) {
mappedModel = ruleEntity.getMappedModel();
setGroup = ruleEntity.getSetGroup();
groupType = ruleEntity.getGroupType();
filterUuid = ruleEntity.getFilterUuid();
filter = ruleEntity.getFilterUuid() != null ? ExpertFilter.builder().id(ruleEntity.getFilterUuid()).build() : null;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ private void enrichFiltersForMappings(List<InputMapping> mappings) {
// collect filterIds to a set (avoid duplication)
Set<UUID> filterIds = mappings.stream()
.flatMap(mapping -> mapping.getRules().stream())
.map(Rule::getFilterUuid)
.map(Rule::getFilter)
.filter(Objects::nonNull)
.map(ExpertFilter::getId)
.collect(Collectors.toSet());

if (CollectionUtils.isNotEmpty(filterIds)) {
Expand All @@ -82,8 +83,8 @@ private void enrichFiltersForMappings(List<InputMapping> mappings) {
// enrich filter for each rule
mappings.stream()
.flatMap(mapping -> mapping.getRules().stream()
.filter(rule -> rule.getFilterUuid() != null))
.forEach(rule -> rule.setFilter(filterIdFilterMap.get(rule.getFilterUuid())));
.filter(rule -> rule.getFilter() != null))
.forEach(rule -> rule.setFilter(filterIdFilterMap.get(rule.getFilter().getId())));
}
}

Expand Down

0 comments on commit cd797b3

Please sign in to comment.