primary ports moved to model, repository ports introduced to model
This commit is contained in:
@@ -3,6 +3,6 @@ package pl.com.bottega.factory.shortages.prediction;
|
||||
/**
|
||||
* Created by michal on 02.02.2017.
|
||||
*/
|
||||
public interface Configuration {
|
||||
public interface ConfigurationParams {
|
||||
int shortagePredictionDaysAhead();
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package pl.com.bottega.factory.shortages.prediction.monitoring;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import pl.com.bottega.factory.product.management.RefNoId;
|
||||
import pl.com.bottega.factory.shortages.prediction.Configuration;
|
||||
import pl.com.bottega.factory.shortages.prediction.ConfigurationParams;
|
||||
import pl.com.bottega.factory.shortages.prediction.Shortage;
|
||||
import pl.com.bottega.factory.shortages.prediction.calculation.ShortageForecast;
|
||||
import pl.com.bottega.factory.shortages.prediction.calculation.ShortageForecasts;
|
||||
@@ -21,7 +21,7 @@ class ShortagePredictionProcess {
|
||||
|
||||
private final ShortageDiffPolicy diffPolicy;
|
||||
private final ShortageForecasts forecasts;
|
||||
private final Configuration configuration;
|
||||
private final ConfigurationParams configuration;
|
||||
private final ShortageEvents events;
|
||||
|
||||
void onDemandChanged() {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package pl.com.bottega.factory.shortages.prediction.monitoring;
|
||||
|
||||
import pl.com.bottega.factory.product.management.RefNoId;
|
||||
|
||||
interface ShortagePredictionProcessRepository {
|
||||
ShortagePredictionProcess get(RefNoId refNo);
|
||||
|
||||
void save(ShortagePredictionProcess model);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package pl.com.bottega.factory.shortages.prediction.monitoring;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import pl.com.bottega.factory.demand.forecasting.DemandedLevelsChanged;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class ShortagePredictionService {
|
||||
|
||||
private final ShortagePredictionProcessRepository repository;
|
||||
|
||||
public void predictShortages(DemandedLevelsChanged event) {
|
||||
ShortagePredictionProcess model = repository.get(event.getRefNo());
|
||||
model.onDemandChanged();
|
||||
repository.save(model);
|
||||
}
|
||||
|
||||
//public void predictShortages(ProductionChanged event) { service.onPlanChanged(event.getId().getRefNo()); }
|
||||
|
||||
//public void predictShortages(StockChanged event) { service.onStockChanged(event.getId().getRefNo()); }
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import pl.com.bottega.factory.shortages.prediction.Shortage;
|
||||
/**
|
||||
* Created by michal on 02.02.2017.
|
||||
*/
|
||||
public interface Notifications {
|
||||
interface Notifications {
|
||||
void alertPlanner(Shortage shortage);
|
||||
|
||||
void softNotifyPlanner(Shortage shortage);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package pl.com.bottega.factory.shortages.prediction.monitoring
|
||||
|
||||
import pl.com.bottega.factory.shortages.prediction.Configuration
|
||||
import pl.com.bottega.factory.shortages.prediction.ConfigurationParams
|
||||
|
||||
class InMemoryConfiguration implements Configuration {
|
||||
class InMemoryConfigurationParams implements ConfigurationParams {
|
||||
int daysAhead;
|
||||
|
||||
@Override
|
||||
@@ -1,7 +1,7 @@
|
||||
package pl.com.bottega.factory.shortages.prediction.monitoring
|
||||
|
||||
import pl.com.bottega.factory.product.management.RefNoId
|
||||
import pl.com.bottega.factory.shortages.prediction.Configuration
|
||||
import pl.com.bottega.factory.shortages.prediction.ConfigurationParams
|
||||
import pl.com.bottega.factory.shortages.prediction.Shortage
|
||||
import pl.com.bottega.factory.shortages.prediction.calculation.ShortageForecasts
|
||||
import pl.com.bottega.factory.shortages.prediction.calculation.ShortagesCalculationAssembler
|
||||
@@ -166,8 +166,8 @@ class ShortagePredictionProcessSpec extends Specification {
|
||||
)
|
||||
}
|
||||
|
||||
Configuration defaultConfig() {
|
||||
new InMemoryConfiguration(daysAhead: 14)
|
||||
ConfigurationParams defaultConfig() {
|
||||
new InMemoryConfigurationParams(daysAhead: 14)
|
||||
}
|
||||
|
||||
NewShortage newShortage(After after, Map<LocalDateTime, Long> missing) {
|
||||
|
||||
Reference in New Issue
Block a user