transactional configuration move to command handlers

This commit is contained in:
Michał Michaluk
2018-02-22 22:33:47 +01:00
parent f1132df0a3
commit 93a7732854
9 changed files with 20 additions and 23 deletions

View File

@@ -5,9 +5,11 @@ import org.springframework.data.rest.core.annotation.HandleAfterCreate;
import org.springframework.data.rest.core.annotation.HandleAfterSave; import org.springframework.data.rest.core.annotation.HandleAfterSave;
import org.springframework.data.rest.core.annotation.RepositoryEventHandler; import org.springframework.data.rest.core.annotation.RepositoryEventHandler;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import pl.com.bottega.factory.delivery.planning.projection.DeliveryForecastProjection; import pl.com.bottega.factory.delivery.planning.projection.DeliveryForecastProjection;
@Component @Component
@Transactional
@AllArgsConstructor @AllArgsConstructor
@RepositoryEventHandler @RepositoryEventHandler
public class DeliveryPlannerDefinitionEventsPropagation { public class DeliveryPlannerDefinitionEventsPropagation {

View File

@@ -5,11 +5,13 @@ import org.springframework.data.rest.core.annotation.HandleAfterCreate;
import org.springframework.data.rest.core.annotation.HandleAfterDelete; import org.springframework.data.rest.core.annotation.HandleAfterDelete;
import org.springframework.data.rest.core.annotation.RepositoryEventHandler; import org.springframework.data.rest.core.annotation.RepositoryEventHandler;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import pl.com.bottega.factory.demand.forecasting.DemandService; import pl.com.bottega.factory.demand.forecasting.DemandService;
import pl.com.bottega.factory.stock.forecast.ressource.StockForecastDao; import pl.com.bottega.factory.stock.forecast.ressource.StockForecastDao;
import pl.com.bottega.factory.stock.forecast.ressource.StockForecastEntity; import pl.com.bottega.factory.stock.forecast.ressource.StockForecastEntity;
@Component @Component
@Transactional
@AllArgsConstructor @AllArgsConstructor
@RepositoryEventHandler @RepositoryEventHandler
public class ProductDescriptionEventsPropagation { public class ProductDescriptionEventsPropagation {

View File

@@ -1,28 +1,27 @@
curl http://localhost:8080 curl http://localhost:8080
# define new product
curl -X POST -H "Content-Type: application/json" \ curl -X POST -H "Content-Type: application/json" \
-d @app-monolith/src/test/resources/examples/product-descriptions.json \ -d @app-monolith/src/test/resources/examples/product-descriptions.json \
http://localhost:8080/product-descriptions http://localhost:8080/product-descriptions
curl http://localhost:8080/stock-forecasts # define non dummy preferred delivery hours
curl -X POST -H "Content-Type: application/json" \ curl -X POST -H "Content-Type: application/json" \
-d @app-monolith/src/test/resources/examples/delivery-definitions.json \ -d @app-monolith/src/test/resources/examples/delivery-definitions.json \
http://localhost:8080/delivery-definitions http://localhost:8080/delivery-definitions
# define customer demands for our product
curl -X POST -H "Content-Type: application/json" \ curl -X POST -H "Content-Type: application/json" \
-d @app-monolith/src/test/resources/examples/demand-adjustments.json \ -d @app-monolith/src/test/resources/examples/demand-adjustments.json \
http://localhost:8080/demand-adjustments http://localhost:8080/demand-adjustments
# check demands
curl http://localhost:8080/demand-forecasts curl http://localhost:8080/demand-forecasts
# check approximated deliveries
curl http://localhost:8080/delivery-forecasts curl http://localhost:8080/delivery-forecasts
# check stock levels prediction
curl http://localhost:8080/stock-forecasts curl http://localhost:8080/stock-forecasts
# check potential shortages on delivery times
curl http://localhost:8080/shortages curl http://localhost:8080/shortages
curl http://localhost:8080/demand-reviews
curl http://localhost:8080/production-outputs
curl http://localhost:8080/production-outputs-daily

View File

@@ -1,5 +1,5 @@
{ {
"refNo": "3009001", "refNo": "3009002",
"definition": { "definition": {
"definitions": { "definitions": {
"AtDayStart": { "AtDayStart": {

View File

@@ -1,19 +1,19 @@
{ {
"note": "Bo demo robie", "note": "Bo demo robie",
"customerRepresentative": "Kolega z logistyki", "customerRepresentative": "Kolega z logistyki od klienta",
"adjustment": { "adjustment": {
"refNo": "3009001", "refNo": "3009002",
"adjustments": { "adjustments": {
"2018-02-13": { "2018-03-10": {
"demand": { "demand": {
"level": 1000, "level": 2000,
"schema": "AtDayStart" "schema": "AtDayStart"
}, },
"strong": true "strong": true
}, },
"2018-02-14": { "2018-03-11": {
"demand": { "demand": {
"level": 1500, "level": 2500,
"schema": "TillDayEnd" "schema": "TillDayEnd"
}, },
"strong": false "strong": false

View File

@@ -1,5 +1,5 @@
{ {
"refNo": "3009001", "refNo": "3009002",
"description": { "description": {
"matNum": "461952398959", "matNum": "461952398959",
"names": [ "names": [

View File

@@ -4,8 +4,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import javax.transaction.Transactional;
@Configuration @Configuration
class DemandForecastingConfiguration { class DemandForecastingConfiguration {
@@ -13,7 +11,6 @@ class DemandForecastingConfiguration {
private ProductDemandRepository repository; private ProductDemandRepository repository;
@Bean @Bean
@Transactional
DemandService demandService() { DemandService demandService() {
return new DemandService(repository); return new DemandService(repository);
} }

View File

@@ -15,6 +15,7 @@ import java.time.Clock;
import java.time.LocalDate; import java.time.LocalDate;
@Component @Component
@Transactional
@AllArgsConstructor @AllArgsConstructor
@RepositoryEventHandler @RepositoryEventHandler
public class CommandsHandler { public class CommandsHandler {
@@ -44,7 +45,6 @@ public class CommandsHandler {
@Scheduled(cron = "0 0 12 * * ?") @Scheduled(cron = "0 0 12 * * ?")
@EventListener(ApplicationReadyEvent.class) @EventListener(ApplicationReadyEvent.class)
@Transactional
public void clean() { public void clean() {
adjustments.deleteByCleanAfterGreaterThanEqual(LocalDate.now(clock)); adjustments.deleteByCleanAfterGreaterThanEqual(LocalDate.now(clock));
reviews.deleteByCleanAfterGreaterThanEqual(LocalDate.now(clock)); reviews.deleteByCleanAfterGreaterThanEqual(LocalDate.now(clock));

View File

@@ -5,8 +5,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import pl.com.bottega.factory.shortages.prediction.ConfigurationParams; import pl.com.bottega.factory.shortages.prediction.ConfigurationParams;
import javax.transaction.Transactional;
@Configuration @Configuration
class MonitoringConfiguration { class MonitoringConfiguration {
@@ -14,7 +12,6 @@ class MonitoringConfiguration {
private ShortagePredictionProcessRepository repository; private ShortagePredictionProcessRepository repository;
@Bean @Bean
@Transactional
ShortagePredictionService shortagePredictionService() { ShortagePredictionService shortagePredictionService() {
return new ShortagePredictionService(repository); return new ShortagePredictionService(repository);
} }