Skip to content

Commit fac2368

Browse files
KochTobisven1103
andauthored
Implement adding and deletion.of experimental variables (#1123)
* Implement adding of experimental variables * Fix test * Remove log statement * remove unused code * Make UI use async service for variable creation * Make UI use async service for variable creation * Add overloaded constructor Co-authored-by: Sven F. <[email protected]> * Immutable record lists Co-authored-by: Sven F. <[email protected]> * extract predicate Co-authored-by: Sven F. <[email protected]> * use var Co-authored-by: Sven F. <[email protected]> * throw instead of empty body Co-authored-by: Sven F. <[email protected]> * use contextWrite instead of transform * Introduce ExperimentDeletionRequest and ExperimentDeletionResponse * Start implementing delete experimental variables * Implement variable deletion * Add back retry * Remove deletion from update * remove impossible case --------- Co-authored-by: KochTobi <[email protected]> Co-authored-by: Sven F. <[email protected]>
1 parent 5d4034c commit fac2368

File tree

9 files changed

+589
-128
lines changed

9 files changed

+589
-128
lines changed

project-management/src/main/java/life/qbic/projectmanagement/application/api/AsyncProjectService.java

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.util.Collection;
99
import java.util.List;
1010
import java.util.Map;
11-
import java.util.Objects;
1211
import java.util.Optional;
1312
import java.util.Set;
1413
import java.util.UUID;
@@ -123,6 +122,9 @@ public interface AsyncProjectService {
123122
*/
124123
Mono<ProjectDeletionResponse> delete(ProjectDeletionRequest request);
125124

125+
126+
Mono<ExperimentDeletionResponse> delete(ExperimentDeletionRequest request);
127+
126128
/**
127129
* Submits a project creation request and returns a {@link Mono<ProjectCreationResponse>}
128130
* immediately.
@@ -376,7 +378,7 @@ sealed interface ProjectUpdateResponseBody permits FundingInformation,
376378

377379
sealed interface ExperimentUpdateRequestBody permits ConfoundingVariableAdditions,
378380
ConfoundingVariableDeletions, ConfoundingVariableUpdates, ExperimentDescription,
379-
ExperimentalGroups, ExperimentalVariableAdditions, ExperimentalVariableDeletions {
381+
ExperimentalGroups, ExperimentalVariableAdditions {
380382

381383
}
382384

@@ -428,6 +430,15 @@ sealed interface ProjectDeletionRequestBody permits FundingDeletion,
428430

429431
}
430432

433+
sealed interface ExperimentDeletionRequestBody permits ExperimentalVariableDeletions {
434+
435+
}
436+
437+
438+
sealed interface ExperimentDeletionResponseBody permits ExperimentalVariables {
439+
440+
}
441+
431442
/**
432443
* Container for passing information in an {@link ProjectUpdateRequestBody} or
433444
* {@link ProjectUpdateResponseBody}.
@@ -500,7 +511,11 @@ record PrincipalInvestigator(ProjectContact contact) implements ProjectUpdateReq
500511
* @param unit the unit of the experimental variable. Can be null if no unit is set
501512
* @since 1.9.0
502513
*/
503-
record ExperimentalVariable(Long id, String name, Set<String> levels, @Nullable String unit) {
514+
record ExperimentalVariable(String name, Set<String> levels, @Nullable String unit) {
515+
516+
public ExperimentalVariable(String name, Set<String> levels) {
517+
this(name, levels, "");
518+
}
504519

505520
public ExperimentalVariable {
506521
levels = Set.copyOf(levels);
@@ -537,7 +552,7 @@ public List<ExperimentalVariable> experimentalVariables() {
537552
* @param experimentalVariables
538553
*/
539554
record ExperimentalVariableDeletions(List<ExperimentalVariable> experimentalVariables) implements
540-
ExperimentUpdateRequestBody {
555+
ExperimentDeletionRequestBody {
541556

542557
public ExperimentalVariableDeletions {
543558
experimentalVariables = List.copyOf(experimentalVariables);
@@ -556,7 +571,7 @@ public List<ExperimentalVariable> experimentalVariables() {
556571
* @since 1.9.0
557572
*/
558573
record ExperimentalVariables(List<ExperimentalVariable> experimentalVariables) implements
559-
ExperimentUpdateResponseBody {
574+
ExperimentUpdateResponseBody, ExperimentDeletionResponseBody {
560575

561576

562577
public ExperimentalVariables {
@@ -1068,7 +1083,6 @@ record ProjectResponsibleDeletion() implements ProjectDeletionRequestBody {
10681083
*/
10691084
record ProjectUpdateResponse(String projectId, ProjectUpdateResponseBody responseBody,
10701085
String requestId) {
1071-
10721086
public ProjectUpdateResponse {
10731087
if (projectId == null) {
10741088
throw new IllegalArgumentException("Project ID cannot be null");
@@ -1078,7 +1092,6 @@ record ProjectUpdateResponse(String projectId, ProjectUpdateResponseBody respons
10781092
}
10791093
if (requestId == null || requestId.isBlank()) {
10801094
requestId = UUID.randomUUID().toString();
1081-
;
10821095
}
10831096
}
10841097

@@ -1095,6 +1108,50 @@ public Optional<String> retrieveRequestId() {
10951108
boolean hasRequestId() {
10961109
return nonNull(requestId);
10971110
}
1111+
1112+
}
1113+
1114+
record ExperimentDeletionRequest(String projectId, String experimentId, String requestId,
1115+
ExperimentDeletionRequestBody body) {
1116+
1117+
public ExperimentDeletionRequest {
1118+
if (projectId == null) {
1119+
throw new IllegalArgumentException("Project ID cannot be null");
1120+
}
1121+
if (projectId.isBlank()) {
1122+
throw new IllegalArgumentException("Project ID cannot be blank");
1123+
}
1124+
if (experimentId == null || experimentId.isBlank()) {
1125+
throw new IllegalArgumentException("Experiment ID cannot be empty");
1126+
}
1127+
if (requestId == null || requestId.isBlank()) {
1128+
requestId = UUID.randomUUID().toString();
1129+
}
1130+
}
1131+
1132+
public ExperimentDeletionRequest(String projectId, String experimentId,
1133+
ExperimentDeletionRequestBody body) {
1134+
this(projectId, experimentId, null, body);
1135+
}
1136+
}
1137+
1138+
record ExperimentDeletionResponse(String projectId, String experimentId, String requestId,
1139+
ExperimentDeletionResponseBody body) {
1140+
1141+
public ExperimentDeletionResponse {
1142+
if (projectId == null) {
1143+
throw new IllegalArgumentException("Project ID cannot be null");
1144+
}
1145+
if (projectId.isBlank()) {
1146+
throw new IllegalArgumentException("Project ID cannot be blank");
1147+
}
1148+
if (experimentId == null || experimentId.isBlank()) {
1149+
throw new IllegalArgumentException("Experiment ID cannot be empty");
1150+
}
1151+
if (requestId == null || requestId.isBlank()) {
1152+
throw new IllegalArgumentException("Request information cannot be empty");
1153+
}
1154+
}
10981155
}
10991156

11001157
/**

0 commit comments

Comments
 (0)