Skip to content

Commit e70a389

Browse files
Provide ExperimentId To batch registration email (#954)
1 parent f02489f commit e70a389

File tree

10 files changed

+40
-19
lines changed

10 files changed

+40
-19
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ public interface AppContextProvider {
2222
* Returns a resolvable URL to the target project's sample page resource in the application.
2323
*
2424
* @param projectId the project id
25+
* @param experimentId the experiment id
2526
* @return a fully resolvable URL
2627
* @since 1.0.0
2728
*/
28-
String urlToSamplePage(String projectId);
29+
String urlToSamplePage(String projectId, String experimentId);
2930
}

project-management/src/main/java/life/qbic/projectmanagement/application/batch/BatchRegistrationService.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import life.qbic.projectmanagement.application.sample.SampleRegistrationService;
1616
import life.qbic.projectmanagement.domain.model.batch.Batch;
1717
import life.qbic.projectmanagement.domain.model.batch.BatchId;
18+
import life.qbic.projectmanagement.domain.model.experiment.ExperimentId;
1819
import life.qbic.projectmanagement.domain.model.project.ProjectId;
1920
import life.qbic.projectmanagement.domain.model.sample.Sample;
2021
import life.qbic.projectmanagement.domain.model.sample.SampleId;
@@ -70,21 +71,23 @@ public BatchRegistrationService(BatchRepository batchRepository,
7071
* are usually followed by a complete batch that represents the measurements of
7172
* the complete experiment.
7273
* @param projectId id of the project this batch is added to
74+
* @param experimentId id of the experiment this batch is added to
7375
* @return a result object with the response. If the registration failed, a response code will be
7476
* provided.
7577
* @since 1.0.0
7678
*/
7779
@PreAuthorize("hasPermission(#projectId, 'life.qbic.projectmanagement.domain.model.project.Project', 'WRITE')")
7880
public Result<BatchId, ResponseCode> registerBatch(String label, boolean isPilot,
79-
ProjectId projectId) {
81+
ProjectId projectId, ExperimentId experimentId) {
8082
var project = projectInformationService.find(projectId);
8183
if (project.isEmpty()) {
8284
log.error(
8385
"Batch registration aborted. Reason: project with id:" + projectId + " was not found");
8486
return Result.fromError(ResponseCode.BATCH_CREATION_FAILED);
8587
}
8688
String projectTitle = project.get().getProjectIntent().projectTitle().title();
87-
var result = batchDomainService.register(label, isPilot, projectTitle, projectId);
89+
var result = batchDomainService.register(label, isPilot, projectTitle, projectId,
90+
experimentId);
8891
if (result.isError()) {
8992
return Result.fromError(ResponseCode.BATCH_REGISTRATION_FAILED);
9093
}

project-management/src/main/java/life/qbic/projectmanagement/application/policy/directive/InformUsersAboutBatchRegistration.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public Class<? extends DomainEvent> subscribedToEventType() {
6060
@PreAuthorize("hasPermission(#projectId, 'life.qbic.projectmanagement.domain.model.project.Project', 'WRITE')")
6161
public void handleEvent(BatchRegistered event) {
6262
List<RecipientDTO> recipients = getRecipients(event.projectId());
63-
String sampleUri = appContextProvider.urlToSamplePage(event.projectId().value());
63+
String sampleUri = appContextProvider.urlToSamplePage(event.projectId().value(),
64+
event.experimentId().value());
6465
notifyAllRecipients(recipients, event.projectTitle(), event.name(), sampleUri);
6566
}
6667

project-management/src/main/java/life/qbic/projectmanagement/application/sample/SampleRegistrationServiceV2.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ public SampleRegistrationServiceV2(BatchRegistrationService batchRegistrationSer
5858
@PreAuthorize("hasPermission(#projectId, 'life.qbic.projectmanagement.domain.model.project.Project', 'WRITE')")
5959
@Async
6060
public CompletableFuture<Void> registerSamples(Collection<SampleMetadata> sampleMetadata,
61-
ProjectId projectId, String batchLabel, boolean batchIsPilot)
61+
ProjectId projectId, String batchLabel, boolean batchIsPilot, ExperimentId experimentId)
6262
throws RegistrationException {
63-
var result = batchRegistrationService.registerBatch(batchLabel, batchIsPilot, projectId);
63+
var result = batchRegistrationService.registerBatch(batchLabel, batchIsPilot, projectId,
64+
experimentId);
6465
if (result.isError()) {
6566
throw new RegistrationException("Batch registration failed");
6667
}

project-management/src/main/java/life/qbic/projectmanagement/domain/model/sample/event/BatchRegistered.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.Objects;
66
import life.qbic.domain.concepts.DomainEvent;
77
import life.qbic.projectmanagement.domain.model.batch.BatchId;
8+
import life.qbic.projectmanagement.domain.model.experiment.ExperimentId;
89
import life.qbic.projectmanagement.domain.model.project.ProjectId;
910

1011
/**
@@ -17,23 +18,27 @@
1718
public class BatchRegistered extends DomainEvent {
1819

1920
@Serial
20-
private static final long serialVersionUID = 580378782496926484L;
21+
private static final long serialVersionUID = 1439070961084871049L;
2122

2223
private final BatchId batchId;
2324
private final String projectTitle;
2425
private final String batchName;
2526
private final ProjectId projectId;
27+
private final ExperimentId experimentId;
2628

27-
private BatchRegistered(BatchId batchId, String batchName, String projectTitle, ProjectId projectId) {
29+
private BatchRegistered(BatchId batchId, String batchName, String projectTitle,
30+
ProjectId projectId,
31+
ExperimentId experimentId) {
2832
this.batchId = Objects.requireNonNull(batchId);
2933
this.projectTitle = Objects.requireNonNull(projectTitle);
3034
this.batchName = Objects.requireNonNull(batchName);
3135
this.projectId = Objects.requireNonNull(projectId);
36+
this.experimentId = Objects.requireNonNull(experimentId);
3237
}
3338

3439
public static BatchRegistered create(String batchName, BatchId id, String projectTitle,
35-
ProjectId projectId) {
36-
return new BatchRegistered(id, batchName, projectTitle, projectId);
40+
ProjectId projectId, ExperimentId experimentId) {
41+
return new BatchRegistered(id, batchName, projectTitle, projectId, experimentId);
3742
}
3843

3944
@JsonGetter("batchId")
@@ -50,4 +55,8 @@ public BatchId batchId() {
5055
@JsonGetter("projectId")
5156
public ProjectId projectId() { return projectId; }
5257

58+
@JsonGetter("experimentId")
59+
public ExperimentId experimentId() {
60+
return experimentId;
61+
}
5362
}

project-management/src/main/java/life/qbic/projectmanagement/domain/service/BatchDomainService.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import life.qbic.domain.concepts.DomainEventDispatcher;
66
import life.qbic.projectmanagement.domain.model.batch.Batch;
77
import life.qbic.projectmanagement.domain.model.batch.BatchId;
8+
import life.qbic.projectmanagement.domain.model.experiment.ExperimentId;
89
import life.qbic.projectmanagement.domain.model.project.ProjectId;
910
import life.qbic.projectmanagement.domain.model.project.event.ProjectChanged;
1011
import life.qbic.projectmanagement.domain.model.sample.event.BatchDeleted;
@@ -42,25 +43,28 @@ public BatchDomainService(BatchRepository batchRepository) {
4243
* measurements of the complete experiment.
4344
* @param projectName the title of the project the batch is added to
4445
* @param projectId id of the project this batch is added to
46+
* @param experimentId id of the experiment this batch is added to
4547
* @return a result object with the response. If the registration failed, a response code will be
4648
* provided.
4749
* @since 1.0.0
4850
*/
4951
public Result<BatchId, ResponseCode> register(String label, boolean isPilot, String projectName,
50-
ProjectId projectId) {
52+
ProjectId projectId, ExperimentId experimentId) {
5153
Batch batch = Batch.create(label, isPilot);
5254
var result = batchRepository.add(batch);
5355
if (result.isError()) {
5456
return Result.fromError(ResponseCode.BATCH_REGISTRATION_FAILED);
5557
} else {
56-
dispatchRegistration(label, batch.batchId(), projectName, projectId);
58+
dispatchRegistration(label, batch.batchId(), projectName, projectId,
59+
experimentId);
5760
}
5861
return Result.fromValue(result.getValue().batchId());
5962
}
6063

6164
private void dispatchRegistration(String name, BatchId id, String projectName,
62-
ProjectId projectId) {
63-
BatchRegistered batchRegistered = BatchRegistered.create(name, id, projectName, projectId);
65+
ProjectId projectId, ExperimentId experimentId) {
66+
BatchRegistered batchRegistered = BatchRegistered.create(name, id, projectName, projectId,
67+
experimentId);
6468
DomainEventDispatcher.instance().dispatch(batchRegistered);
6569
}
6670

project-management/src/test/groovy/life/qbic/projectmanagement/domain/service/BatchDomainServiceSpec.groovy

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import life.qbic.domain.concepts.DomainEventDispatcher
66
import life.qbic.domain.concepts.DomainEventSubscriber
77
import life.qbic.projectmanagement.domain.model.batch.Batch
88
import life.qbic.projectmanagement.domain.model.batch.BatchId
9+
import life.qbic.projectmanagement.domain.model.experiment.ExperimentId
910
import life.qbic.projectmanagement.domain.model.project.*
1011
import life.qbic.projectmanagement.domain.model.sample.event.BatchDeleted
1112
import life.qbic.projectmanagement.domain.model.sample.event.BatchRegistered
@@ -49,7 +50,7 @@ class BatchDomainServiceSpec extends Specification {
4950
DomainEventDispatcher.instance().subscribe(batchRegistered)
5051

5152
when:
52-
domainService.register("test", false, project.projectIntent.projectTitle().title(), project.getId())
53+
domainService.register("test", false, project.projectIntent.projectTitle().title(), project.getId(), ExperimentId.create())
5354

5455
then:
5556
batchRegistered.eventReceived

user-interface/src/main/java/life/qbic/datamanager/DataManagerContextProvider.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ public String urlToProject(String projectId) {
5151
}
5252

5353
@Override
54-
public String urlToSamplePage(String projectId) {
54+
public String urlToSamplePage(String projectId, String experimentId) {
5555
try {
5656
return new URL(baseUrlApplication,
57-
Paths.get(baseUrlApplication.getPath(), samplesEndpoint.formatted(projectId))
57+
Paths.get(baseUrlApplication.getPath(),
58+
samplesEndpoint.formatted(projectId, experimentId))
5859
.toString()).toExternalForm();
5960
} catch (MalformedURLException e) {
6061
throw new ApplicationException("Data Manager context creation failed.", e);

user-interface/src/main/java/life/qbic/datamanager/views/projects/project/samples/SampleInformationMain.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ private void onRegisterBatchClicked() {
232232
UI ui = event.getSource().getUI().orElseThrow();
233233
CompletableFuture<Void> registrationTask = sampleRegistrationServiceV2.registerSamples(
234234
event.validatedSampleMetadata(),
235-
projectId, event.batchName(), false)
235+
projectId, event.batchName(), false, experimentId)
236236
.orTimeout(5, TimeUnit.MINUTES);
237237
try {
238238
registrationTask

user-interface/src/main/resources/application.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ routing.password-reset.reset-parameter=${PASSWORD_RESET_PARAMETER:user-id}
9393
# route to project resource
9494
routing.projects.endpoint=/projects
9595
routing.projects.info.endpoint=/projects/%s/info
96-
routing.projects.samples.enpoint=/projects/%s/samples
96+
routing.projects.samples.enpoint=/projects/%s/experiments/%s/samples
9797
routing.registration.oidc.orcid.endpoint=/register/oidc
9898
routing.registration.error.pending-email-verification=/register/pending-email-confirmation
9999
################## oauth provider ###########################

0 commit comments

Comments
 (0)