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.RepositoryEventHandler;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import pl.com.bottega.factory.delivery.planning.projection.DeliveryForecastProjection;
@Component
@Transactional
@AllArgsConstructor
@RepositoryEventHandler
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.RepositoryEventHandler;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
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.StockForecastEntity;
@Component
@Transactional
@AllArgsConstructor
@RepositoryEventHandler
public class ProductDescriptionEventsPropagation {

View File

@@ -1,28 +1,27 @@
curl http://localhost:8080
# define new product
curl -X POST -H "Content-Type: application/json" \
-d @app-monolith/src/test/resources/examples/product-descriptions.json \
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" \
-d @app-monolith/src/test/resources/examples/delivery-definitions.json \
http://localhost:8080/delivery-definitions
# define customer demands for our product
curl -X POST -H "Content-Type: application/json" \
-d @app-monolith/src/test/resources/examples/demand-adjustments.json \
http://localhost:8080/demand-adjustments
# check demands
curl http://localhost:8080/demand-forecasts
# check approximated deliveries
curl http://localhost:8080/delivery-forecasts
# check stock levels prediction
curl http://localhost:8080/stock-forecasts
# check potential shortages on delivery times
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": {
"definitions": {
"AtDayStart": {

View File

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

View File

@@ -1,5 +1,5 @@
{
"refNo": "3009001",
"refNo": "3009002",
"description": {
"matNum": "461952398959",
"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.Configuration;
import javax.transaction.Transactional;
@Configuration
class DemandForecastingConfiguration {
@@ -13,7 +11,6 @@ class DemandForecastingConfiguration {
private ProductDemandRepository repository;
@Bean
@Transactional
DemandService demandService() {
return new DemandService(repository);
}

View File

@@ -15,6 +15,7 @@ import java.time.Clock;
import java.time.LocalDate;
@Component
@Transactional
@AllArgsConstructor
@RepositoryEventHandler
public class CommandsHandler {
@@ -44,7 +45,6 @@ public class CommandsHandler {
@Scheduled(cron = "0 0 12 * * ?")
@EventListener(ApplicationReadyEvent.class)
@Transactional
public void clean() {
adjustments.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 pl.com.bottega.factory.shortages.prediction.ConfigurationParams;
import javax.transaction.Transactional;
@Configuration
class MonitoringConfiguration {
@@ -14,7 +12,6 @@ class MonitoringConfiguration {
private ShortagePredictionProcessRepository repository;
@Bean
@Transactional
ShortagePredictionService shortagePredictionService() {
return new ShortagePredictionService(repository);
}