-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
chutney/server/src/main/java/com/chutneytesting/execution/infra/aop/IndexingAspect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2017-2024 Enedis | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package com.chutneytesting.execution.infra.aop; | ||
|
||
import com.chutneytesting.execution.infra.storage.jpa.ScenarioExecutionReportEntity; | ||
import com.chutneytesting.index.infra.ScenarioExecutionReportIndexRepository; | ||
import java.util.List; | ||
import java.util.Set; | ||
import org.aspectj.lang.annotation.After; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Aspect | ||
@Component | ||
public class IndexingAspect { | ||
private final ScenarioExecutionReportIndexRepository indexRepository; | ||
|
||
public IndexingAspect(ScenarioExecutionReportIndexRepository indexRepository) { | ||
this.indexRepository = indexRepository; | ||
} | ||
|
||
@After("execution(* com.chutneytesting.execution.infra.storage.ScenarioExecutionReportJpaRepository.save(..)) && args(reportEntity)") | ||
public void index(ScenarioExecutionReportEntity reportEntity) { | ||
indexRepository.save(reportEntity); | ||
} | ||
|
||
@After("execution(* com.chutneytesting.execution.infra.storage.ScenarioExecutionReportJpaRepository.saveAll(..)) && args(reportEntities)") | ||
public void indexAll(List<ScenarioExecutionReportEntity> reportEntities) { | ||
indexRepository.saveAll(reportEntities); | ||
} | ||
|
||
@After("execution(* com.chutneytesting.execution.infra.storage.ScenarioExecutionReportJpaRepository.delete(..)) && args(reportEntity)") | ||
public void delete(ScenarioExecutionReportEntity reportEntity) { | ||
indexRepository.delete(reportEntity.scenarioExecutionId()); | ||
} | ||
|
||
@After("execution(* com.chutneytesting.execution.infra.storage.ScenarioExecutionReportJpaRepository.deleteAllById(..)) && args(scenarioExecutionIds)") | ||
public void deleteAllById(Set<Long> scenarioExecutionIds) { | ||
indexRepository.deleteAllById(scenarioExecutionIds); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters