Skip to content

Commit a8414c2

Browse files
authored
API for requesting templates for sample registration and update (#1082)
Introduces a reactive API for requesting templates to register or update samples for a data manager experiment.
1 parent 37045be commit a8414c2

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

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

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
import java.util.Set;
1010
import java.util.UUID;
1111
import life.qbic.application.commons.SortOrder;
12+
import life.qbic.projectmanagement.application.api.fair.DigitalObject;
1213
import life.qbic.projectmanagement.application.ValidationResult;
1314
import life.qbic.projectmanagement.application.batch.SampleUpdateRequest.SampleInformation;
1415
import life.qbic.projectmanagement.application.confounding.ConfoundingVariableService.ConfoundingVariableInformation;
1516
import life.qbic.projectmanagement.application.sample.SamplePreview;
1617
import life.qbic.projectmanagement.domain.model.sample.Sample;
1718
import life.qbic.projectmanagement.domain.model.sample.SampleRegistrationRequest;
1819
import org.springframework.lang.Nullable;
20+
import org.springframework.util.MimeType;
1921
import reactor.core.publisher.Flux;
2022
import reactor.core.publisher.Mono;
2123

@@ -216,7 +218,7 @@ Flux<SamplePreview> getSamplePreviews(String projectId, String experimentId, int
216218
* @param projectId the project id to which the sample belongs to
217219
* @param sampleId the sample id of the sample to find
218220
* @return a reactive container of {@link Sample} for the sample matching the sample id. For no
219-
* matches a {@link Mono#empty()} is returned. Exceptions are * provided as
221+
* matches a {@link Mono#empty()} is returned. Exceptions are provided as
220222
* {@link Mono#error(Throwable)}.
221223
* @throws RequestFailedException in case the request cannot be executed
222224
* @since 1.10.0
@@ -236,6 +238,44 @@ Flux<SamplePreview> getSamplePreviews(String projectId, String experimentId, int
236238
*/
237239
Flux<ValidationResponse> validate(Flux<ValidationRequest> requests);
238240

241+
/**
242+
* Requests a sample registration template in a desired {@link MimeType}.
243+
* <p>
244+
* If the mime type is not supported, a {@link UnsupportedMimeTypeException} will be provided as
245+
* {@link Mono#error(Throwable)}.
246+
*
247+
* @param projectId the project ID of the project the template should be created for
248+
* @param experimentId the experiment ID of the experiment the template should be created for
249+
* @param mimeType the mime type the digital object should be
250+
* @return a {@link Mono} with a {@link DigitalObject} providing the requested template
251+
* @throws AccessDeniedException if the user has insufficient rights
252+
* @throws RequestFailedException if the request cannot be executed
253+
* @throws UnsupportedMimeTypeException if the service cannot provide the requested
254+
* {@link MimeType}
255+
* @since 1.10.0
256+
*/
257+
Mono<DigitalObject> sampleRegistrationTemplate(String projectId, String experimentId,
258+
MimeType mimeType);
259+
260+
/**
261+
* Requests a sample update template in a desired {@link MimeType}.
262+
* <p>
263+
* If the mime type is not supported, a {@link UnsupportedMimeTypeException} will be provided as
264+
* {@link Mono#error(Throwable)}.
265+
*
266+
* @param projectId the project ID of the project the template should be created for
267+
* @param experimentId the experiment ID of the experiment the template should be created for
268+
* @param mimeType the mime type the digital object should be
269+
* @return a {@link Mono} with a {@link DigitalObject} providing the requested template
270+
* @throws AccessDeniedException if the user has insufficient rights
271+
* @throws RequestFailedException if the request cannot be executed
272+
* @throws UnsupportedMimeTypeException if the service cannot provide the requested
273+
* {@link MimeType}
274+
* @since 1.10.0
275+
*/
276+
Mono<DigitalObject> sampleUpdateTemplate(String projectId, String experimentId,
277+
MimeType mimeType);
278+
239279
/**
240280
* Container of an update request for a service call and part of the
241281
* {@link ProjectUpdateRequest}.
@@ -883,4 +923,16 @@ public AccessDeniedException(String message, Throwable cause) {
883923
}
884924
}
885925

926+
/**
927+
* Exception to indicate that a service implementation cannot handle a certain mime type.
928+
*
929+
* @since 1.10.0
930+
*/
931+
class UnsupportedMimeTypeException extends RuntimeException {
932+
933+
public UnsupportedMimeTypeException(String message) {
934+
super(message);
935+
}
936+
}
937+
886938
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.springframework.security.core.context.SecurityContext;
3434
import org.springframework.security.core.context.SecurityContextHolder;
3535
import org.springframework.stereotype.Service;
36+
import org.springframework.util.MimeType;
3637
import reactor.core.publisher.Flux;
3738
import reactor.core.publisher.FluxSink;
3839
import reactor.core.publisher.FluxSink.OverflowStrategy;
@@ -235,6 +236,18 @@ public Mono<Sample> findSample(String projectId, String sampleId) {
235236
}).subscribeOn(scheduler);
236237
}
237238

239+
@Override
240+
public Mono<DigitalObject> sampleRegistrationTemplate(String projectId, String experimentId,
241+
MimeType mimeType) {
242+
throw new RuntimeException("not implemented");
243+
}
244+
245+
@Override
246+
public Mono<DigitalObject> sampleUpdateTemplate(String projectId, String experimentId,
247+
MimeType mimeType) {
248+
throw new RuntimeException("not implemented");
249+
}
250+
238251
@Override
239252
public Flux<ValidationResponse> validate(Flux<ValidationRequest> requests)
240253
throws RequestFailedException {

0 commit comments

Comments
 (0)