-
Notifications
You must be signed in to change notification settings - Fork 2
transmit CompositesToBeInserted to network modifications server #1004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b04a6a2
a861027
0aca8b6
00bb4ae
c9e2107
e97e24d
1bcd7a4
09e9813
e434747
896d551
25d10db
933f6f6
fe574d9
3cc7454
0bb437b
08c98bb
dfdf006
a955fe4
d6c4c83
8fc71cf
2369e75
5855806
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| This Source Code Form is subject to the terms of the Mozilla Public | ||
| License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
| package org.gridsuite.study.server.dto; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.Setter; | ||
| import lombok.experimental.SuperBuilder; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * @author Mathieu Deharbe <mathieu.deharbe at rte-france.com> | ||
| * attributes of the references to the shared composites stored in directory server | ||
| */ | ||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @SuperBuilder | ||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public class ReferenceAttributes { | ||
| public enum ReferenceType { | ||
| STUDY_NODE, | ||
| NETWORK_MODIFICATION, | ||
| DIRECTORY_ELEMENT | ||
| } | ||
|
|
||
| private UUID referenceId; | ||
| private ReferenceType referenceType; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| This Source Code Form is subject to the terms of the Mozilla Public | ||
| License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
| package org.gridsuite.study.server.dto.modification; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * @author Mathieu Deharbe <mathieu.deharbe at rte-france.com> | ||
| */ | ||
| public record CompositesToBeInserted(UUID id, String name, boolean isShared) { } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,9 +7,11 @@ | |
| package org.gridsuite.study.server.service; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.NonNull; | ||
| import lombok.Setter; | ||
| import org.gridsuite.study.server.RemoteServicesProperties; | ||
| import org.gridsuite.study.server.dto.ElementAttributes; | ||
| import org.gridsuite.study.server.dto.ReferenceAttributes; | ||
| import org.gridsuite.study.server.dto.networkexport.PermissionType; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.core.ParameterizedTypeReference; | ||
|
|
@@ -27,6 +29,7 @@ | |
| import java.util.*; | ||
|
|
||
| import static org.gridsuite.study.server.StudyConstants.*; | ||
| import static org.gridsuite.study.server.dto.ReferenceAttributes.ReferenceType.STUDY_NODE; | ||
|
|
||
| /** | ||
| * @author David Braquart <david.braquart at rte-france.com> | ||
|
|
@@ -99,13 +102,60 @@ public boolean elementExists(UUID directoryUuid, String elementName, String type | |
| return response.getStatusCode() == HttpStatus.OK; | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @param elementsUuids all the element uuids of the shared composites that need to be referenced in directory server | ||
| * @param userId id of the user who started the insertion | ||
| * @param targetNodeUuid where the new references will point | ||
| */ | ||
| public void addReferencesToSharedComposites(@NonNull List<UUID> elementsUuids, String userId, UUID targetNodeUuid) { | ||
|
Comment on lines
+107
to
+111
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Java doc and method name is not clear for me. What is the element UID of a shared composite ? What is an insertion ? The references will point to what ? We add or create a new reference ? |
||
| elementsUuids.forEach(elementUuid -> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fact that the method do several rest call is not intuitive |
||
| var path = UriComponentsBuilder.fromPath( | ||
| DELIMITER + DIRECTORY_API_VERSION + DELIMITER + "elements/{elementUuid}/references") | ||
| .buildAndExpand(elementUuid) | ||
| .toUriString(); | ||
|
|
||
| HttpHeaders headers = new HttpHeaders(); | ||
| headers.set(HEADER_USER_ID, userId); | ||
| headers.setContentType(MediaType.APPLICATION_JSON); | ||
|
|
||
| ReferenceAttributes referenceAttributes = new ReferenceAttributes(targetNodeUuid, STUDY_NODE); | ||
|
|
||
| HttpEntity<ReferenceAttributes> requestEntity = new HttpEntity<>(referenceAttributes, headers); | ||
| restTemplate.exchange(getDirectoryServerServerBaseUri() + path, HttpMethod.POST, requestEntity, ElementAttributes.class); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * remove references from the shared modification in directory server | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of or from ? What kind of references ? |
||
| * @param referenceUuid uuid of the composite or group where the 'Modification reference' is located | ||
| * @param userId id of the user who caused the unreferencing | ||
| * @param sharedElementUuid uuid of the referenced shared element in the directory-server | ||
| */ | ||
| public void removeReference(UUID referenceUuid, String userId, UUID sharedElementUuid) { | ||
| Objects.requireNonNull(referenceUuid); | ||
| Objects.requireNonNull(sharedElementUuid); | ||
|
|
||
| var path = UriComponentsBuilder.fromPath( | ||
| DELIMITER + DIRECTORY_API_VERSION + DELIMITER + "elements/{elementUuid}/references/{referenceUuid}") | ||
| .buildAndExpand(sharedElementUuid, referenceUuid) | ||
| .toUriString(); | ||
|
|
||
| HttpHeaders headers = new HttpHeaders(); | ||
| headers.set(HEADER_USER_ID, userId); | ||
| headers.setContentType(MediaType.APPLICATION_JSON); | ||
|
|
||
| HttpEntity<Object> requestEntity = new HttpEntity<>(headers); | ||
| restTemplate.exchange(getDirectoryServerServerBaseUri() + path, HttpMethod.DELETE, requestEntity, ElementAttributes.class); | ||
| } | ||
|
Mathieu-Deharbe marked this conversation as resolved.
|
||
|
|
||
| public void createElement(UUID directoryUuid, String description, UUID elementUuid, String elementName, String type, String userId) { | ||
| UriComponentsBuilder pathBuilder = UriComponentsBuilder.fromPath(DELIMITER + DIRECTORY_API_VERSION + "/directories/{directoryUuid}/elements"); | ||
| ElementAttributes elementAttributes = new ElementAttributes(elementUuid, elementName, type, userId, 0, description); | ||
| String path = pathBuilder.buildAndExpand(directoryUuid).toUriString(); | ||
|
|
||
| HttpHeaders headers = new HttpHeaders(); | ||
| headers.set("userId", userId); | ||
| headers.set(HEADER_USER_ID, userId); | ||
| headers.setContentType(MediaType.APPLICATION_JSON); | ||
|
|
||
| HttpEntity<ElementAttributes> requestEntity = new HttpEntity<>(elementAttributes, headers); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.