Skip to content

Commit 51d9331

Browse files
committed
Merge interfaces and fix security context handling
1 parent 3663902 commit 51d9331

File tree

5 files changed

+152
-150
lines changed

5 files changed

+152
-150
lines changed

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

-66
This file was deleted.

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

-42
This file was deleted.

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

+98-16
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
import static java.util.Objects.nonNull;
44

5+
import java.util.List;
56
import java.util.Optional;
7+
import java.util.Set;
68
import java.util.UUID;
9+
import life.qbic.projectmanagement.application.confounding.ConfoundingVariableService.ConfoundingVariableInformation;
710
import reactor.core.publisher.Mono;
811

912
/**
@@ -29,10 +32,10 @@ public interface AsyncProjectService {
2932
* The method is non-blocking.
3033
* <p>
3134
* The implementing class must ensure to be able to process all implementing classes of the
32-
* {@link UpdateRequestBody} interface contained in the request.
35+
* {@link ProjectUpdateRequestBody} interface contained in the request.
3336
* <p>
3437
* The implementing class must also ensure to only return responses with classes implementing the
35-
* {@link UpdateResponseBody} interface.
38+
* {@link ProjectUpdateResponseBody} interface.
3639
*
3740
* @param request the request to update a project
3841
* @return a {@link Mono<ProjectUpdateResponse>} object publishing an
@@ -47,6 +50,31 @@ Mono<ProjectUpdateResponse> update(
4750
throws UnknownRequestException, RequestFailedException, AccessDeniedException;
4851

4952

53+
/**
54+
* Submits an experiment update request and returns a reactive
55+
* {@link Mono< ExperimentUpdateResponse >} object immediately.
56+
* <p>
57+
* The method is non-blocking.
58+
* <p>
59+
* The implementing class must ensure to be able to process all implementing classes of the
60+
* {@link ProjectUpdateRequestBody} interface contained in the request.
61+
* <p>
62+
* The implementing class must also ensure to only return responses with classes implementing the
63+
* {@link ProjectUpdateResponseBody} interface.
64+
*
65+
* @param request the request to update a project
66+
* @return a {@link Mono<ProjectUpdateResponse>} object publishing an
67+
* {@link ProjectUpdateResponse} on success.
68+
* @throws UnknownRequestException if an unknown request has been used in the service call
69+
* @throws RequestFailedException if the request was not successfully executed
70+
* @throws AccessDeniedException if the user has insufficient rights
71+
* @since 1.9.0
72+
*/
73+
Mono<ExperimentUpdateResponse> update(ExperimentUpdateRequest request)
74+
throws RequestFailedException, AccessDeniedException;
75+
76+
77+
5078
Mono<ProjectCreationResponse> create(ProjectCreationRequest request)
5179
throws UnknownRequestException, RequestFailedException, AccessDeniedException;
5280

@@ -57,7 +85,8 @@ Mono<ProjectCreationResponse> create(ProjectCreationRequest request)
5785
*
5886
* @since 1.9.0
5987
*/
60-
sealed interface UpdateRequestBody permits FundingInformation, ProjectContacts, ProjectDesign {
88+
sealed interface ProjectUpdateRequestBody permits FundingInformation, ProjectContacts,
89+
ProjectDesign {
6190

6291
}
6392

@@ -67,17 +96,29 @@ sealed interface UpdateRequestBody permits FundingInformation, ProjectContacts,
6796
*
6897
* @since 1.9.0
6998
*/
70-
sealed interface UpdateResponseBody permits FundingInformation, ProjectContacts, ProjectDesign {
99+
sealed interface ProjectUpdateResponseBody permits FundingInformation, ProjectContacts,
100+
ProjectDesign {
101+
102+
}
103+
104+
sealed interface ExperimentUpdateRequestBody permits ConfoundingVariables, ExperimentDescription,
105+
ExperimentalVariables {
71106

72107
}
73108

109+
sealed interface ExperimentUpdateResponseBody permits ConfoundingVariables, ExperimentDescription,
110+
ExperimentalVariables {
111+
112+
}
113+
114+
74115
/**
75116
* Cacheable requests provide a unique identifier so cache implementations can unambiguously
76117
* manage the requests.
77118
*
78119
* @since 1.9.0
79120
*/
80-
sealed interface CacheableRequest permits ProjectUpdateRequest {
121+
sealed interface CacheableRequest permits ProjectUpdateRequest, ExperimentUpdateRequest {
81122

82123
/**
83124
* Returns an ID that is unique to the request.
@@ -90,15 +131,15 @@ sealed interface CacheableRequest permits ProjectUpdateRequest {
90131
}
91132

92133
/**
93-
* Container for passing information in an {@link UpdateRequestBody} or
94-
* {@link UpdateResponseBody}.
134+
* Container for passing information in an {@link ProjectUpdateRequestBody} or
135+
* {@link ProjectUpdateResponseBody}.
95136
*
96137
* @param title the title of the project
97138
* @param objective the objective of the project
98139
* @since 1.9.0
99140
*/
100-
record ProjectDesign(String title, String objective) implements UpdateRequestBody,
101-
UpdateResponseBody {
141+
record ProjectDesign(String title, String objective) implements ProjectUpdateRequestBody,
142+
ProjectUpdateResponseBody {
102143

103144
}
104145

@@ -111,8 +152,8 @@ record ProjectDesign(String title, String objective) implements UpdateRequestBod
111152
* @since 1.9.0
112153
*/
113154
record ProjectContacts(ProjectContact investigator, ProjectContact manager,
114-
ProjectContact responsible) implements UpdateRequestBody,
115-
UpdateResponseBody {
155+
ProjectContact responsible) implements ProjectUpdateRequestBody,
156+
ProjectUpdateResponseBody {
116157

117158
}
118159

@@ -134,8 +175,47 @@ record ProjectContact(String fullName, String email) {
134175
* @param grantId the grant ID
135176
* @since 1.9.0
136177
*/
137-
record FundingInformation(String grant, String grantId) implements UpdateRequestBody,
138-
UpdateResponseBody {
178+
record FundingInformation(String grant, String grantId) implements ProjectUpdateRequestBody,
179+
ProjectUpdateResponseBody {
180+
181+
}
182+
183+
184+
record ExperimentalVariable(String name, Set<String> levels, String unit) {
185+
186+
}
187+
188+
record ExperimentalVariables(
189+
List<ExperimentalVariable> experimentalVariables) implements
190+
ExperimentUpdateRequestBody,
191+
ExperimentUpdateResponseBody {
192+
193+
}
194+
195+
record ExperimentDescription(String experimentName, Set<String> species, Set<String> specimen,
196+
Set<String> analytes) implements ExperimentUpdateRequestBody,
197+
ExperimentUpdateResponseBody {
198+
199+
200+
}
201+
202+
record ConfoundingVariables(List<ConfoundingVariableInformation> confoundingVariables) implements
203+
ExperimentUpdateRequestBody, ExperimentUpdateResponseBody {
204+
205+
}
206+
207+
record ExperimentUpdateRequest(String projectId, String experimentId,
208+
ExperimentUpdateRequestBody body,
209+
String requestId) implements CacheableRequest {
210+
211+
public ExperimentUpdateRequest(String projectId, String experimentId,
212+
ExperimentUpdateRequestBody body) {
213+
this(projectId, experimentId, body, UUID.randomUUID().toString());
214+
}
215+
}
216+
217+
record ExperimentUpdateResponse(String experimentId, ExperimentUpdateResponseBody body,
218+
String requestId) {
139219

140220
}
141221

@@ -171,10 +251,11 @@ record ProjectCreationResponse(String projectId) {
171251
* @param requestBody the information to be updated.
172252
* @since 1.9.0
173253
*/
174-
record ProjectUpdateRequest(String projectId, UpdateRequestBody requestBody, String id) implements
254+
record ProjectUpdateRequest(String projectId, ProjectUpdateRequestBody requestBody,
255+
String id) implements
175256
CacheableRequest {
176257

177-
public ProjectUpdateRequest(String projectId, UpdateRequestBody requestBody) {
258+
public ProjectUpdateRequest(String projectId, ProjectUpdateRequestBody requestBody) {
178259
this(projectId, requestBody, UUID.randomUUID().toString());
179260
}
180261

@@ -191,7 +272,8 @@ public String requestId() {
191272
* @param responseBody the information that was updated.
192273
* @since 1.9.0
193274
*/
194-
record ProjectUpdateResponse(String projectId, UpdateResponseBody responseBody, String requestId) {
275+
record ProjectUpdateResponse(String projectId, ProjectUpdateResponseBody responseBody,
276+
String requestId) {
195277

196278
public ProjectUpdateResponse {
197279
if (projectId == null) {

0 commit comments

Comments
 (0)