-
Notifications
You must be signed in to change notification settings - Fork 45
/
SemanticDataInitializer.java
44 lines (38 loc) · 1.77 KB
/
SemanticDataInitializer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.web.application.semanticdata.listeners;
import java.util.Objects;
import org.eclipse.sirius.web.domain.boundedcontexts.project.events.ProjectCreatedEvent;
import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataCreationService;
import org.springframework.data.jdbc.core.mapping.AggregateReference;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.event.TransactionalEventListener;
/**
* Service used to create the semantic data of a project.
*
* @author sbegaudeau
*/
@Service
public class SemanticDataInitializer {
private final ISemanticDataCreationService semanticDataCreationService;
public SemanticDataInitializer(ISemanticDataCreationService semanticDataCreationService) {
this.semanticDataCreationService = Objects.requireNonNull(semanticDataCreationService);
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
@TransactionalEventListener
public void onProjectCreatedEvent(ProjectCreatedEvent event) {
this.semanticDataCreationService.initialize(AggregateReference.to(event.project().getId()));
}
}