Skip to content

Commit f77e6b9

Browse files
authored
edit node description (#822)
* add/edit node description --------- Signed-off-by: SOUISSI Maissa (Externe) <[email protected]>
1 parent a534dd7 commit f77e6b9

File tree

6 files changed

+28
-20
lines changed

6 files changed

+28
-20
lines changed

src/main/java/org/gridsuite/study/server/networkmodificationtree/entities/AbstractNodeInfoEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public UUID getId() {
4242
@Column(columnDefinition = "CLOB")
4343
String name;
4444

45-
@Column
45+
@Column(columnDefinition = "CLOB")
4646
String description;
4747

4848
@Column

src/main/java/org/gridsuite/study/server/notification/NotificationService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public class NotificationService {
119119
public static final String NODE_DELETED = "nodeDeleted";
120120
public static final String NODE_CREATED = "nodeCreated";
121121
public static final String NODE_MOVED = "nodeMoved";
122-
public static final String NODE_RENAMED = "nodeRenamed";
122+
public static final String NODE_EDITED = "nodeEdited";
123123
public static final String NODE_BUILD_STATUS_UPDATED = "nodeBuildStatusUpdated";
124124
public static final String SUBTREE_MOVED = "subtreeMoved";
125125
public static final String NODES_COLUMN_POSITIONS_CHANGED = "nodesColumnPositionsChanged";
@@ -337,8 +337,8 @@ public void emitNodeBuildStatusUpdated(UUID studyUuid, List<UUID> nodes, UUID ro
337337
}
338338

339339
@PostCompletion
340-
public void emitNodeRenamed(UUID studyUuid, UUID nodeUuid) {
341-
sendStudyUpdateMessage(studyUuid, NODE_RENAMED, MessageBuilder.withPayload("")
340+
public void emitNodeEdited(UUID studyUuid, UUID nodeUuid) {
341+
sendStudyUpdateMessage(studyUuid, NODE_EDITED, MessageBuilder.withPayload("")
342342
.setHeader(HEADER_NODE, nodeUuid)
343343
);
344344
}

src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ public void updateNode(UUID studyUuid, NetworkModificationNode node, String user
519519
networkModificationNodeEntity.setDescription(node.getDescription());
520520
}
521521

522-
if (isRenameNode(node)) {
523-
notificationService.emitNodeRenamed(self.getStudyUuidForNodeId(node.getId()), node.getId());
522+
if (isEditedNode(node)) {
523+
notificationService.emitNodeEdited(self.getStudyUuidForNodeId(node.getId()), node.getId());
524524
} else {
525525
notificationService.emitNodesChanged(self.getStudyUuidForNodeId(node.getId()), Collections.singletonList(node.getId()));
526526
}
@@ -548,13 +548,14 @@ public void updateNodesColumnPositions(UUID studyUuid, UUID parentUuid, List<Net
548548
notificationService.emitElementUpdated(studyUuid, userId);
549549
}
550550

551-
private boolean isRenameNode(AbstractNode node) {
552-
NetworkModificationNode renameNode = NetworkModificationNode.builder()
553-
.id(node.getId())
554-
.name(node.getName())
555-
.type(node.getType())
556-
.build();
557-
return renameNode.equals(node);
551+
private boolean isEditedNode(AbstractNode node) {
552+
NetworkModificationNode editedNode = NetworkModificationNode.builder()
553+
.id(node.getId())
554+
.name(node.getName())
555+
.type(node.getType())
556+
.description(node.getDescription())
557+
.build();
558+
return editedNode.equals(node);
558559
}
559560

560561
private NodeEntity getNodeEntity(UUID nodeId) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
2+
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
3+
<changeSet author="souissimai (generated)" id="1754596868860">
4+
<modifyDataType tableName="network_modification_node_info" columnName="description" newDataType="CLOB"/>
5+
</changeSet>
6+
</databaseChangeLog>

src/main/resources/db/changelog/db.changelog-master.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,5 +330,8 @@ databaseChangeLog:
330330
file: changesets/changelog_20250719T002545Z.xml
331331
relativeToChangelogFile: true
332332
- include:
333-
file: changesets/changelog_20250723T152653Z.xml
333+
file: changesets/changelog_20250807T200045Z.xml
334334
relativeToChangelogFile: true
335+
- include:
336+
file: changesets/changelog_20250723T152653Z.xml
337+
relativeToChangelogFile: true

src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
@ContextConfigurationWithTestChannel
9696
class NetworkModificationTreeTest {
9797
private static final Logger LOGGER = LoggerFactory.getLogger(NetworkModificationTreeTest.class);
98-
private static final String NODE_UPDATED = "nodeUpdated";
98+
private static final String NODE_EDITED = "nodeEdited";
9999
private static final long TIMEOUT = 1000;
100100

101101
@Autowired
@@ -1127,7 +1127,7 @@ void testNodeUpdate() throws Exception {
11271127
.content(objectWriter.writeValueAsString(justANameUpdate))
11281128
.header(USER_ID_HEADER, "userId"))
11291129
.andExpect(status().isOk());
1130-
assertEquals(NODE_RENAMED, output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION).getHeaders().get(HEADER_UPDATE_TYPE));
1130+
assertEquals(NODE_EDITED, output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION).getHeaders().get(HEADER_UPDATE_TYPE));
11311131
checkElementUpdatedMessageSent(root.getStudyId(), userId);
11321132

11331133
var newNode = getNode(root.getStudyId(), node1.getId(), firstRootNetworkUuid);
@@ -1174,9 +1174,7 @@ void testUpdateNodesColumnPositions() throws Exception {
11741174
checkElementUpdatedMessageSent(root.getStudyId(), userId);
11751175
}
11761176

1177-
// This test is for a part of the code that is not used yet
1178-
// We update a node description (this is not used in the front) and we assume that it will emit a nodeUpdated notif
1179-
// If it's not the case or if this test causes problems feel free to update it / remove it as needed
1177+
// We edit a node description and assume that it will emit a nodeEdited notif
11801178
@Test
11811179
void testNodeDescriptionUpdate() throws Exception {
11821180
String userId = "userId";
@@ -1194,7 +1192,7 @@ void testNodeDescriptionUpdate() throws Exception {
11941192
.content(objectWriter.writeValueAsString(nodeDescriptionUpdate))
11951193
.header(USER_ID_HEADER, "userId"))
11961194
.andExpect(status().isOk());
1197-
assertEquals(NODE_UPDATED, output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION).getHeaders().get(HEADER_UPDATE_TYPE));
1195+
assertEquals(NODE_EDITED, output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION).getHeaders().get(HEADER_UPDATE_TYPE));
11981196
checkElementUpdatedMessageSent(root.getStudyId(), userId);
11991197
}
12001198

0 commit comments

Comments
 (0)