Skip to content

Commit 1e279e7

Browse files
refactor: reduce complexity of indexation handling (#732)
Signed-off-by: Joris Mancini <[email protected]>
1 parent 4332f6c commit 1e279e7

File tree

4 files changed

+102
-242
lines changed

4 files changed

+102
-242
lines changed

src/main/java/org/gridsuite/modification/server/dto/elasticsearch/ModificationApplicationInfos.java

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88

99
import lombok.*;
1010
import org.gridsuite.modification.server.elasticsearch.ESConfig;
11-
import org.gridsuite.modification.server.modifications.ImpactedEquipmentsInfos;
12-
import org.gridsuite.modification.server.modifications.IndexedImpactedEquipmentInfos;
1311
import org.springframework.data.annotation.AccessType;
1412
import org.springframework.data.annotation.Id;
15-
import org.springframework.data.annotation.Transient;
1613
import org.springframework.data.annotation.TypeAlias;
1714
import org.springframework.data.elasticsearch.annotations.*;
1815

16+
import java.util.HashSet;
1917
import java.util.Set;
2018
import java.util.UUID;
21-
import java.util.stream.Collectors;
2219

2320
/**
2421
* @author Kevin Le Saulnier <kevin.lesaulnier at rte-france.com>
@@ -58,7 +55,8 @@ public void setUniqueId(String uniqueId) {
5855
@InnerField(suffix = "raw", type = FieldType.Keyword)
5956
}
6057
)
61-
private Set<String> createdEquipmentIds;
58+
@Builder.Default
59+
private Set<String> createdEquipmentIds = new HashSet<>();
6260

6361
@MultiField(
6462
mainField = @Field(type = FieldType.Text),
@@ -67,7 +65,8 @@ public void setUniqueId(String uniqueId) {
6765
@InnerField(suffix = "raw", type = FieldType.Keyword)
6866
}
6967
)
70-
private Set<String> modifiedEquipmentIds;
68+
@Builder.Default
69+
private Set<String> modifiedEquipmentIds = new HashSet<>();
7170

7271
@MultiField(
7372
mainField = @Field(type = FieldType.Text),
@@ -76,33 +75,10 @@ public void setUniqueId(String uniqueId) {
7675
@InnerField(suffix = "raw", type = FieldType.Keyword)
7776
}
7877
)
79-
private Set<String> deletedEquipmentIds;
80-
81-
@Transient
8278
@Builder.Default
83-
ImpactedEquipmentsInfos impactedEquipmentsInfos = new ImpactedEquipmentsInfos();
84-
85-
public ModificationApplicationInfos flushImpactedEquipments() {
86-
createdEquipmentIds = impactedEquipmentsInfos.getCreatedEquipments().stream()
87-
.filter(IndexedImpactedEquipmentInfos::shouldIndexInModification)
88-
.map(IndexedImpactedEquipmentInfos::impactedEquipmentInfos)
89-
.map(BasicEquipmentInfos::getId)
90-
.collect(Collectors.toSet());
91-
modifiedEquipmentIds = impactedEquipmentsInfos.getModifiedEquipments().stream()
92-
.filter(IndexedImpactedEquipmentInfos::shouldIndexInModification)
93-
.map(IndexedImpactedEquipmentInfos::impactedEquipmentInfos)
94-
.map(BasicEquipmentInfos::getId)
95-
.collect(Collectors.toSet());
96-
deletedEquipmentIds = impactedEquipmentsInfos.getTombstonedEquipments().stream()
97-
.filter(IndexedImpactedEquipmentInfos::shouldIndexInModification)
98-
.map(IndexedImpactedEquipmentInfos::impactedEquipmentInfos)
99-
.map(BasicEquipmentInfos::getId)
100-
.collect(Collectors.toSet());
101-
impactedEquipmentsInfos = null;
102-
return this;
103-
}
79+
private Set<String> deletedEquipmentIds = new HashSet<>();
10480

105-
public boolean hasAnyImpactedEquipment() {
106-
return impactedEquipmentsInfos.hasAnyImpactedEquipmentToIndexInModification();
81+
public boolean isNotEmpty() {
82+
return !createdEquipmentIds.isEmpty() || !modifiedEquipmentIds.isEmpty() || !deletedEquipmentIds.isEmpty();
10783
}
10884
}

src/main/java/org/gridsuite/modification/server/modifications/ImpactedEquipmentsInfos.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/main/java/org/gridsuite/modification/server/modifications/IndexedImpactedEquipmentInfos.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)