1212 *******************************************************************************/
1313package org .eclipse .sirius .web .application .project .services ;
1414
15- import com .fasterxml .jackson .core .JsonProcessingException ;
16- import com .fasterxml .jackson .databind .ObjectMapper ;
17-
1815import java .util .ArrayList ;
1916import java .util .Collections ;
2017import java .util .HashMap ;
7572import org .eclipse .sirius .components .diagrams .events .appearance .label .LabelVisibilityAppearanceChange ;
7673import org .eclipse .sirius .components .diagrams .layoutdata .DiagramLayoutData ;
7774import org .eclipse .sirius .components .diagrams .layoutdata .EdgeLayoutData ;
75+ import org .eclipse .sirius .components .diagrams .layoutdata .HandleLayoutData ;
7876import org .eclipse .sirius .components .diagrams .layoutdata .LabelLayoutData ;
7977import org .eclipse .sirius .components .diagrams .layoutdata .NodeLayoutData ;
8078import org .eclipse .sirius .components .diagrams .renderer .LabelAppearanceHandler ;
8179import org .eclipse .sirius .components .events .ICause ;
8280import org .eclipse .sirius .web .application .UUIDParser ;
8381import org .eclipse .sirius .web .application .project .services .api .IDiagramImporterNodeStyleAppearanceChangeHandler ;
8482import org .eclipse .sirius .web .application .project .services .api .IRepresentationImporterUpdateService ;
85- import org .eclipse .sirius .web .domain .boundedcontexts .representationdata .RepresentationMetadata ;
86- import org .eclipse .sirius .web .domain .boundedcontexts .semanticdata .SemanticData ;
87- import org .slf4j .Logger ;
88- import org .slf4j .LoggerFactory ;
89- import org .springframework .data .jdbc .core .mapping .AggregateReference ;
9083import org .springframework .stereotype .Service ;
9184
9285/**
@@ -99,8 +92,6 @@ public class DiagramImporterUpdateService implements IRepresentationImporterUpda
9992
10093 private final IEditingContextSearchService editingContextSearchService ;
10194
102- private final ObjectMapper objectMapper ;
103-
10495 private final IRepresentationSearchService representationSearchService ;
10596
10697 private final IRepresentationDescriptionSearchService representationDescriptionSearchService ;
@@ -111,12 +102,9 @@ public class DiagramImporterUpdateService implements IRepresentationImporterUpda
111102
112103 private final IRepresentationPersistenceService representationPersistenceService ;
113104
114- private final Logger logger = LoggerFactory .getLogger (DiagramImporterUpdateService .class );
115-
116- public DiagramImporterUpdateService (IEditingContextSearchService editingContextSearchService , ObjectMapper objectMapper , IRepresentationSearchService representationSearchService , IRepresentationDescriptionSearchService representationDescriptionSearchService , DiagramCreationService diagramCreationService , List <IDiagramImporterNodeStyleAppearanceChangeHandler > diagramImporterNodeStyleAppearanceChangeHandlers ,
105+ public DiagramImporterUpdateService (IEditingContextSearchService editingContextSearchService , IRepresentationSearchService representationSearchService , IRepresentationDescriptionSearchService representationDescriptionSearchService , DiagramCreationService diagramCreationService , List <IDiagramImporterNodeStyleAppearanceChangeHandler > diagramImporterNodeStyleAppearanceChangeHandlers ,
117106 IRepresentationPersistenceService representationPersistenceService ) {
118107 this .editingContextSearchService = Objects .requireNonNull (editingContextSearchService );
119- this .objectMapper = Objects .requireNonNull (objectMapper );
120108 this .representationSearchService = Objects .requireNonNull (representationSearchService );
121109 this .representationDescriptionSearchService = Objects .requireNonNull (representationDescriptionSearchService );
122110 this .diagramCreationService = Objects .requireNonNull (diagramCreationService );
@@ -171,18 +159,11 @@ public void handle(Map<String, String> semanticElementsIdMappings, ICause cause,
171159 var optionalRepresentationMetadataId = new UUIDParser ().parse (newRepresentationId );
172160
173161 if (optionalSemanticDataId .isPresent () && optionalRepresentationMetadataId .isPresent () && updatedDiagram .isPresent ()) {
174- var semanticData = AggregateReference .<SemanticData , UUID >to (optionalSemanticDataId .get ());
175- var representationMetadata = AggregateReference .<RepresentationMetadata , UUID >to (optionalRepresentationMetadataId .get ());
176162
177163 var laidOutDiagram = Diagram .newDiagram (updatedDiagram .get ())
178164 .layoutData (newLayoutData )
179165 .build ();
180- try {
181- String json = this .objectMapper .writeValueAsString (laidOutDiagram );
182- this .representationPersistenceService .save (cause , editingContext .get (), laidOutDiagram );
183- } catch (JsonProcessingException exception ) {
184- this .logger .warn (exception .getMessage (), exception );
185- }
166+ this .representationPersistenceService .save (cause , editingContext .get (), laidOutDiagram );
186167 }
187168 }
188169 }
@@ -222,8 +203,10 @@ private void handleLayout(DiagramLayoutData newLayoutData, DiagramLayoutData old
222203 }
223204 if (newNodeLayoutId != null ) {
224205 var oldLayoutNodeData = oldNodeLayoutData .get (key );
206+ var newHandleLayoutData = oldLayoutNodeData .handleLayoutData ().stream ().map (handleLayoutData -> new HandleLayoutData (edgeElementOldNewIds .get (handleLayoutData .edgeId ()),
207+ handleLayoutData .position (), handleLayoutData .handlePosition (), handleLayoutData .type ())).toList ();
225208 var newNodeLayoutData = new NodeLayoutData (newNodeLayoutId , oldLayoutNodeData .position (), oldLayoutNodeData .size (), oldLayoutNodeData .resizedByUser (),
226- oldLayoutNodeData .movedByUser (), oldLayoutNodeData . handleLayoutData () , oldLayoutNodeData .minComputedSize ());
209+ oldLayoutNodeData .movedByUser (), newHandleLayoutData , oldLayoutNodeData .minComputedSize ());
227210 newLayoutData .nodeLayoutData ().put (newNodeLayoutId , newNodeLayoutData );
228211 }
229212 });
0 commit comments