Skip to content

Commit 0eb9ab2

Browse files
authored
Api methods for experiment creation (#1139)
* add api objects * Update documentation --------- Co-authored-by: KochTobi <[email protected]>
1 parent 4c38e8e commit 0eb9ab2

File tree

2 files changed

+91
-3
lines changed

2 files changed

+91
-3
lines changed

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

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ public interface AsyncProjectService {
6363
*/
6464
Mono<ExperimentalGroupCreationResponse> create(ExperimentalGroupCreationRequest request);
6565

66+
67+
/**
68+
* Requests the creation of an experiment and returns a reactive
69+
* {@link Mono<ExperimentCreationResponse>}.
70+
* <p>
71+
* <b>Exceptions</b>
72+
* <p>
73+
* Exceptions are wrapped as {@link Mono#error(Throwable)} and are one of the types described in
74+
* the throw section below.
75+
*
76+
* @param request the request containing information to create the experiment
77+
* @return a {@link Mono<ExperimentCreationResponse>} object publishing a
78+
* {@link ExperimentCreationResponse} on success.
79+
* @throws UnknownRequestException if an unknown request has been used in the service call
80+
* @throws RequestFailedException if the request was not successfully executed
81+
* @throws AccessDeniedException if the user has insufficient rights
82+
* @since 1.10.0
83+
*/
84+
Mono<ExperimentCreationResponse> create(ExperimentCreationRequest request);
85+
6686
/**
6787
* Submits an experimental group update request and returns a reactive
6888
* {@link Mono<ExperimentalGroupUpdateResponse>}.
@@ -571,9 +591,9 @@ sealed interface ValidationRequestBody permits MeasurementRegistrationInformatio
571591
*
572592
* @since 1.9.0
573593
*/
574-
sealed interface CacheableRequest permits ExperimentalGroupCreationRequest,
575-
ExperimentalGroupDeletionRequest, ExperimentalGroupUpdateRequest, ExperimentUpdateRequest,
576-
ProjectUpdateRequest, ValidationRequest {
594+
sealed interface CacheableRequest permits ExperimentCreationRequest, ExperimentUpdateRequest,
595+
ExperimentalGroupCreationRequest, ExperimentalGroupDeletionRequest,
596+
ExperimentalGroupUpdateRequest, ProjectUpdateRequest, ValidationRequest {
577597

578598
/**
579599
* Returns an ID that is unique to the request.
@@ -958,6 +978,69 @@ public String toString() {
958978
}
959979
}
960980

981+
/**
982+
* A service request to create an experiment
983+
*
984+
* @param projectId the project in which to create the experiment
985+
* @param experimentDescription the minimal required information for the experiment
986+
* @param requestId the unique id of this request. If none exists use
987+
* {@link ExperimentCreationRequest#ExperimentCreationRequest(String,
988+
* ExperimentDescription)} for construction.
989+
* @since 1.10.0
990+
*/
991+
record ExperimentCreationRequest(String projectId, ExperimentDescription experimentDescription,
992+
String requestId) implements CacheableRequest {
993+
994+
/**
995+
* A service request to create an experiment
996+
*
997+
* @param projectId the project in which to create the experiment
998+
* @param experimentDescription the minimal required information for the experiment
999+
* @param requestId the unique id of this request. If none exists use
1000+
* {@link
1001+
* ExperimentCreationRequest#ExperimentCreationRequest(String,
1002+
* ExperimentDescription)} for construction.
1003+
* @since 1.10.0
1004+
*/
1005+
public ExperimentCreationRequest {
1006+
requireNonNull(projectId);
1007+
requireNonNull(requestId);
1008+
}
1009+
1010+
/**
1011+
* A service request to create an experiment. Generates a request id and assinges it to this
1012+
* request.
1013+
*
1014+
* @param projectId the project in which to create the experiment
1015+
* @param experimentDescription the minimal required information for the experiment
1016+
* @since 1.10.0
1017+
*/
1018+
public ExperimentCreationRequest(String projectId,
1019+
ExperimentDescription experimentDescription) {
1020+
this(projectId, experimentDescription, UUID.randomUUID().toString());
1021+
}
1022+
}
1023+
1024+
/**
1025+
* A service response for experiment creation.
1026+
*
1027+
* @param projectId the project in which the experiment was created
1028+
* @param experimentId the identifier of the created experiment
1029+
* @param experimentDescription information about the experiment
1030+
* @param requestId the identifier of the original request
1031+
* @since 1.10.0
1032+
*/
1033+
record ExperimentCreationResponse(String projectId, String experimentId,
1034+
ExperimentDescription experimentDescription,
1035+
String requestId) {
1036+
1037+
public ExperimentCreationResponse {
1038+
requireNonNull(projectId);
1039+
requireNonNull(requestId);
1040+
}
1041+
}
1042+
1043+
9611044
/**
9621045
* A service request to update an experiment
9631046
*

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ private static OntologyTerm convertToApi(OntologyClass term) {
130130
}
131131

132132

133+
@Override
134+
public Mono<ExperimentCreationResponse> create(ExperimentCreationRequest request) {
135+
throw new RuntimeException("Not implemented");
136+
}
137+
133138
@Override
134139
public Mono<ExperimentalGroupCreationResponse> create(ExperimentalGroupCreationRequest request) {
135140
throw new RuntimeException("not implemented");

0 commit comments

Comments
 (0)