88
99import lombok .*;
1010import org .gridsuite .modification .server .elasticsearch .ESConfig ;
11- import org .gridsuite .modification .server .modifications .ImpactedEquipmentsInfos ;
12- import org .gridsuite .modification .server .modifications .IndexedImpactedEquipmentInfos ;
1311import org .springframework .data .annotation .AccessType ;
1412import org .springframework .data .annotation .Id ;
15- import org .springframework .data .annotation .Transient ;
1613import org .springframework .data .annotation .TypeAlias ;
1714import org .springframework .data .elasticsearch .annotations .*;
1815
16+ import java .util .HashSet ;
1917import java .util .Set ;
2018import 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}
0 commit comments