Skip to content

Commit

Permalink
Refactor createStudy method to use CaseInfo object
Browse files Browse the repository at this point in the history
  • Loading branch information
jamal-khey committed Feb 6, 2024
1 parent 302d7af commit 36bc41f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public ResponseEntity<Void> createStudy(@PathVariable("studyName") String studyN
@RequestParam(QUERY_PARAM_PARENT_DIRECTORY_ID) UUID parentDirectoryUuid,
@RequestHeader("userId") String userId,
@RequestBody(required = false) Map<String, Object> importParams) {
exploreService.createStudy(studyName, caseUuid, description, userId, parentDirectoryUuid, caseFormat, importParams, duplicateCase);
ExploreService.CaseInfo caseInfo = new ExploreService.CaseInfo(caseUuid, caseFormat);
exploreService.createStudy(studyName, caseInfo, description, userId, parentDirectoryUuid, importParams, duplicateCase);
return ResponseEntity.ok().build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package org.gridsuite.explore.server.services;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.gridsuite.explore.server.ExploreException;
import org.gridsuite.explore.server.dto.*;
Expand Down Expand Up @@ -60,9 +62,16 @@ public ExploreService(
this.parametersService = parametersService;
}

public void createStudy(String studyName, UUID caseUuid, String description, String userId, UUID parentDirectoryUuid, String caseFormat, Map<String, Object> importParams, Boolean duplicateCase) {
@Data
@AllArgsConstructor
public static class CaseInfo {
private UUID caseUuid;
private String caseFormat;
}

public void createStudy(String studyName, CaseInfo caseInfo, String description, String userId, UUID parentDirectoryUuid, Map<String, Object> importParams, Boolean duplicateCase) {
ElementAttributes elementAttributes = new ElementAttributes(UUID.randomUUID(), studyName, STUDY, null, userId, 0L, description);
studyService.insertStudyWithExistingCaseFile(elementAttributes.getElementUuid(), userId, caseUuid, caseFormat, importParams, duplicateCase);
studyService.insertStudyWithExistingCaseFile(elementAttributes.getElementUuid(), userId, caseInfo.getCaseUuid(), caseInfo.getCaseFormat(), importParams, duplicateCase);
directoryService.createElement(elementAttributes, parentDirectoryUuid, userId);
}

Expand Down

0 comments on commit 36bc41f

Please sign in to comment.