Skip to content
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

Move shortcircuit parameters #569

Merged
merged 5 commits into from
Jun 21, 2024
Merged

Conversation

Tristan-WorkGH
Copy link
Contributor

@Tristan-WorkGH Tristan-WorkGH commented May 23, 2024

Move entity and related functions to shortcircuit-server and link to new endpoints.

cf gridsuite/shortcircuit-server#81

Sequences
sequenceDiagram
    box rgb(75,75,75) study-server
        participant Controller
        participant StudySrv
        participant StudyRepository
        participant SCService
    end
    participant SCServer
    #autonumber

    Note over Controller,StudySrv: PUT /studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/run
    Note right of Controller: runShortCircuit(studyUuid, nodeUuid, busId?, userId)
    Controller-->>StudySrv: studyService.assertIsNodeNotReadOnly
    activate Controller
    Controller-->>+StudySrv: runShortCircuit(studyUuid, nodeUuid, userId, busId?)
    StudySrv->>+StudyRepository: findById(studyUuid)
    StudyRepository-->>-StudySrv: optional<entity>
    alt old: entity repo
        StudySrv->>+SCService: fromEntity(studyEntity.shortCircuitParameters)
        SCService-->>-StudySrv: powsybl obj params
        StudySrv->>+SCService: runShortCircuit(studyUuid, nodeUuid, busId, objParameters, userId)
    else new: rest service
        StudySrv->>+SCService: runShortCircuit(studyUuid, nodeUuid, busId, parametersUuid, withFortescueResult, userId)
    end
    SCService->>+SCServer: /vX/networks/{networkUuid}/run-and-save
    SCServer-->>-SCService: uuid result
    SCService-->>-StudySrv: uuid result
    StudySrv->>StudySrv: updateComputationResultUuid(...)
    Note over StudySrv: notificationService.emitElementUpdated(studyUuid, userId)
    StudySrv-->>-Controller: uuid
    deactivate Controller
Loading
sequenceDiagram
    box rgb(75,75,75) study-server
        participant Controller
        participant StudySrv
        participant StudyRepository
        participant SCService
    end
    participant SCServer
    Note over Controller,StudySrv: POST /studies/{studyUuid}/short-circuit-analysis/parameters
    Note right of Controller: setShortCircuitParameters(studyUuid, shortCircuitParametersInfos, userId)
    activate Controller
    Controller-->>+StudySrv: setShortCircuitParameters(studyUuid, shortCircuitParametersInfos, userId)
    alt old: entity repo
        StudySrv->>+SCService: toEntity(dto.parameters, dto.predefinedParameters)
        SCService-->>-StudySrv: entity
        %%StudySrv->>+StudySrv: updateShortCircuitParameters(studyUuid, shortCircuitParametersEntity)
        StudySrv->>+StudyRepository: findById(studyUuid)
        StudyRepository-->>-StudySrv: optional<entity>
        StudySrv->>StudyRepository: entity.setShortCircuitParameters(scParametersEntity)
        %%deactivate StudySrv
    else new: rest service
        StudySrv->>+StudyRepository: findById(studyUuid)
        StudyRepository-->>-StudySrv: optional<entity>
        alt studyEntity.shortCircuitParametersUuid != null
            StudySrv->>SCService: updateParameters(paramsUuid, params)
            SCService->>SCServer: uuid <br/> + sc parameters
        else studyEntity.shortCircuitParametersUuid == null
            StudySrv->>+SCService: createParameters(shortCircuitParametersInfos)
            SCService->>+SCServer: sc parameters
            SCServer-->>-SCService: uuid
            SCService-->>-StudySrv: uuid
            StudySrv->>StudyRepository: entity.setShortCircuitParametersUuid(uuid)
        end
    end
    Note right of StudySrv: notificationService.emitElementUpdated(studyUuid, userId)
    StudySrv->>-Controller: dto
    deactivate Controller
Loading
sequenceDiagram
    box rgb(75,75,75) study-server
        participant Controller
        participant StudySrv
        participant StudyRepository
        participant SCService
    end
    participant SCServer
    Note over Controller,StudySrv: GET /studies/{studyUuid}/short-circuit-analysis/parameters
    Note right of Controller: getShortCircuitParameters(studyUuid)
    activate Controller
    Controller->>+StudySrv: getShortCircuitParametersInfo(studyUuid)
#activate StudySrv
    StudySrv->>+StudyRepository: findById(studyUuid)
    StudyRepository-->>-StudySrv: optional<entity>
    alt old: entity repo
        StudySrv->>+StudyRepository: entity.getShortCircuitParameters()
        StudyRepository-->>-StudySrv: ShortCircuitParametersEntity <br/> or new+saved default params
        StudySrv->>+SCService: toShortCircuitParametersInfo(scp_entity)
        SCService-->>-StudySrv: dto
    else new: rest service
    #create participant SCServer
        alt studyEntity.shortCircuitParametersUuid == null
            StudySrv->>+SCService: createParameters()
            SCService->>+SCServer: createParameters
            SCServer-->>-SCService: uuid
            SCService-->>-StudySrv: uuid
            StudySrv->>StudyRepository: entity.setShortCircuitParametersUuid(uuid)
        end
        StudySrv->>+SCService: getOrCreateParameters(entity.shortCircuitParametersUuid)
        SCService-)+SCServer: study uuid
        SCServer--)-SCService: dto
        SCService-->>-StudySrv: dto
    #destroy participant SCServer
    end
    StudySrv->>-Controller: dto
#deactivate StudySrv
    deactivate Controller
Loading
sequenceDiagram
    box rgb(75,75,75) study-server
        participant Controller
        participant StudySrv
        participant StudyRepository
        participant SCService
    end
    participant SCServer
    Note over Controller,StudySrv: /studies
    Note right of Controller: duplicateStudy(studyUuid)
    activate Controller
    
    Controller->>+StudySrv: duplicateStudy(...)
    StudySrv->>+StudyRepository: findById(studyUuid)
    StudyRepository-->>-StudySrv: optional<entity>
    StudySrv->>StudySrv: insertStudyCreationRequest(studyEntity)
    StudySrv->>StudySrv: toBasicStudyInfos(StudyCreationRequestEntity)
    StudySrv-->>-Controller: uuid
    StudySrv->>+StudySrv: duplicateStudyAsync(...)
    deactivate Controller
    StudySrv->>+StudySrv: insertDuplicatedStudy(...)
    StudySrv->>+StudyRepository: findById(studyUuid)
    StudyRepository-->>-StudySrv: optional<entity>
    StudySrv->>StudySrv: [...]
    alt old: entity repo
        StudySrv->>+SCService: fromEntity(sourceStudy.shortCircuitParameters)
        SCService-->>-StudySrv: dto
        StudySrv->>+SCService: toEntity(sourceStudy.shortCircuitParameters)
        SCService-->>-StudySrv: entity
        StudySrv->>StudyRepository: ...
    else new: rest service
        StudySrv->>+SCService: duplicateParameters(uuid)
        SCService->>+SCServer: parameters uuid
        SCServer-->>-SCService: new uuid
        SCService-->>-StudySrv: uuid
        StudySrv->>StudyRepository: ...
    end
    StudySrv->>StudySrv: reindexStudy(entity)
    deactivate StudySrv
    deactivate StudySrv
Loading
sequenceDiagram
    box rgb(75,75,75) study-server
        participant ConsumerSrv
        participant StudySrv
        participant StudyRepository
        participant SCService
    end
    participant SCServer
    Note right of ConsumerSrv: consumeCaseImportSucceeded()
    activate ConsumerSrv
    ConsumerSrv->>ConsumerSrv: [...]
    ConsumerSrv->>+StudyRepository: findById(studyUuid)
    StudyRepository-->>-ConsumerSrv: optional<entity>
    alt entity != null
        ConsumerSrv->>StudySrv: updateStudyNetwork(studyEntity, ...)
    else entity == null
        ConsumerSrv->>ConsumerSrv: [...]
        alt old: entity repo
            ConsumerSrv->>+SCService: getDefaultShortCircuitParameters()
            SCService-->>-ConsumerSrv: powsybl obj
            ConsumerSrv->>+SCService: toEntity(powsyblParams)
            SCService-->>-ConsumerSrv: entity
            ConsumerSrv->>+StudySrv: insertStudy(..., scEntity, ...)
        else new: rest service
            ConsumerSrv->>+SCService: createDefaultParameters()
            SCService-->>-ConsumerSrv: uuid
            ConsumerSrv->>+StudySrv: insertStudy(..., scParamsUuid, ...)
        end
        StudySrv->>StudyRepository: save(new entity)
        deactivate StudySrv
    end
Loading

@Tristan-WorkGH Tristan-WorkGH added the help wanted Extra attention is needed label May 23, 2024
@Tristan-WorkGH Tristan-WorkGH self-assigned this May 23, 2024
@Tristan-WorkGH Tristan-WorkGH requested a review from ayolab May 23, 2024 00:42
This was referenced May 27, 2024
@Tristan-WorkGH Tristan-WorkGH force-pushed the move_shortcircuit_parameters branch from c67a7da to aa038ff Compare June 3, 2024 08:56
@Tristan-WorkGH
Copy link
Contributor Author

@Tristan-WorkGH Tristan-WorkGH force-pushed the move_shortcircuit_parameters branch from 324f5d7 to 4c4e6f0 Compare June 11, 2024 14:59
@Tristan-WorkGH Tristan-WorkGH force-pushed the move_shortcircuit_parameters branch from 56f705f to 43b122d Compare June 14, 2024 15:10
@Tristan-WorkGH Tristan-WorkGH force-pushed the move_shortcircuit_parameters branch from de1cee5 to f4770e7 Compare June 19, 2024 14:57
@Tristan-WorkGH Tristan-WorkGH requested review from TheMaskedTurtle and removed request for TheMaskedTurtle June 19, 2024 14:57
Copy link

@Tristan-WorkGH Tristan-WorkGH merged commit c02ea74 into main Jun 21, 2024
3 checks passed
@Tristan-WorkGH Tristan-WorkGH deleted the move_shortcircuit_parameters branch June 21, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants