some renames
This commit is contained in:
@@ -4,8 +4,8 @@ import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import pl.com.bottega.factory.delivery.planning.projection.DeliveryForecastProjection;
|
||||
import pl.com.bottega.factory.demand.forecasting.command.DemandReviewDao;
|
||||
import pl.com.bottega.factory.demand.forecasting.command.DemandReviewEntity;
|
||||
import pl.com.bottega.factory.demand.forecasting.command.RequiredReviewDao;
|
||||
import pl.com.bottega.factory.demand.forecasting.command.RequiredReviewEntity;
|
||||
import pl.com.bottega.factory.demand.forecasting.projection.CurrentDemandProjection;
|
||||
import pl.com.bottega.factory.shortages.prediction.monitoring.ShortagePredictionService;
|
||||
|
||||
@@ -21,7 +21,7 @@ class DemandEventsMapping implements DemandEvents {
|
||||
private final CurrentDemandProjection demandProjection;
|
||||
private final DeliveryForecastProjection deliveryProjection;
|
||||
private final ShortagePredictionService shortagePrediction;
|
||||
private final DemandReviewDao demandReviews;
|
||||
private final RequiredReviewDao demandReviews;
|
||||
private final Clock clock;
|
||||
|
||||
@Override
|
||||
@@ -35,7 +35,7 @@ class DemandEventsMapping implements DemandEvents {
|
||||
public void emit(ReviewRequired event) {
|
||||
Instant timestamp = Instant.now(clock);
|
||||
demandReviews.save(event.getReviews().stream()
|
||||
.map(r -> new DemandReviewEntity(timestamp, r))
|
||||
.map(r -> new RequiredReviewEntity(timestamp, r))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,3 +44,6 @@ CREATE TABLE demand_forecasting.demand_review (
|
||||
decision character varying(64),
|
||||
clean_after timestamp without time zone
|
||||
);
|
||||
|
||||
--changeset michaluk.michal:2.rename.review.table
|
||||
ALTER TABLE demand_forecasting.demand_review RENAME TO required_review;
|
||||
|
||||
@@ -14,3 +14,6 @@ CREATE TABLE shortages_prediction.shortage (
|
||||
CREATE TABLE shortages_prediction.stock_forecast (
|
||||
ref_no character varying(64) NOT NULL PRIMARY KEY
|
||||
);
|
||||
|
||||
--changeset michaluk.michal:2.rename.shortages.column
|
||||
ALTER TABLE shortages_prediction.shortage RENAME shortages TO shortage;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Handler {
|
||||
|
||||
private final DemandService service;
|
||||
private final DemandAdjustmentDao adjustments;
|
||||
private final DemandReviewDao reviews;
|
||||
private final RequiredReviewDao reviews;
|
||||
private final Clock clock;
|
||||
|
||||
@HandleBeforeCreate
|
||||
@@ -35,7 +35,7 @@ public class Handler {
|
||||
}
|
||||
|
||||
@HandleBeforeSave
|
||||
public void review(DemandReviewEntity review) {
|
||||
public void review(RequiredReviewEntity review) {
|
||||
if (review.decisionTaken()) {
|
||||
review.setCleanAfter(LocalDate.now(clock).plusDays(7));
|
||||
service.review(review.getReview(), review.getDecision());
|
||||
|
||||
@@ -10,12 +10,12 @@ import java.util.List;
|
||||
|
||||
@Repository
|
||||
@RepositoryRestResource(
|
||||
path = "demand-reviews",
|
||||
collectionResourceRel = "demand-reviews",
|
||||
itemResourceRel = "demand-review")
|
||||
public interface DemandReviewDao extends CommandRepository<DemandReviewEntity, Long> {
|
||||
path = "required-reviews",
|
||||
collectionResourceRel = "required-reviews",
|
||||
itemResourceRel = "required-review")
|
||||
public interface RequiredReviewDao extends CommandRepository<RequiredReviewEntity, Long> {
|
||||
@RestResource(path = "refNos", rel = "refNos")
|
||||
List<DemandReviewEntity> findByRefNoAndDecisionIsNull(String refNo);
|
||||
List<RequiredReviewEntity> findByRefNoAndDecisionIsNull(String refNo);
|
||||
|
||||
@RestResource(exported = false)
|
||||
void deleteByCleanAfterGreaterThanEqual(LocalDate date);
|
||||
@@ -12,11 +12,11 @@ import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Entity(name = "DemandReview")
|
||||
@Entity(name = "RequiredReview")
|
||||
@Table(schema = "demand_forecasting")
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public class DemandReviewEntity implements Serializable {
|
||||
public class RequiredReviewEntity implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@@ -32,7 +32,7 @@ public class DemandReviewEntity implements Serializable {
|
||||
@Setter
|
||||
private LocalDate cleanAfter;
|
||||
|
||||
public DemandReviewEntity(Instant timestamp, ToReview review) {
|
||||
public RequiredReviewEntity(Instant timestamp, ToReview review) {
|
||||
this.timestamp = timestamp;
|
||||
this.refNo = review.getId().getRefNo();
|
||||
this.date = review.getId().getDate();
|
||||
@@ -26,7 +26,7 @@ class ShortagePredictionProcessORMRepository {
|
||||
return new ShortagePredictionProcess(
|
||||
entity.map(ShortagesEntity::createId)
|
||||
.orElseGet(() -> ShortagesEntity.createId(refNo)),
|
||||
entity.map(ShortagesEntity::getShortages).orElse(null),
|
||||
entity.map(ShortagesEntity::getShortage).orElse(null),
|
||||
policy, forecasts, configuration, new EventsHandler()
|
||||
);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class ShortagePredictionProcessORMRepository {
|
||||
ShortagesEntity entity = TechnicalId.findOrDefault(
|
||||
refNo, dao::findOne,
|
||||
() -> dao.save(new ShortagesEntity(refNo.getRefNo())));
|
||||
entity.setShortages(event.getShortage());
|
||||
entity.setShortage(event.getShortage());
|
||||
events.emit(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ public class ShortagesEntity implements Serializable {
|
||||
private Long version;
|
||||
private String refNo;
|
||||
@Setter
|
||||
@Convert(converter = ShortagesAsJson.class)
|
||||
private Shortage shortages;
|
||||
@Convert(converter = ShortageAsJson.class)
|
||||
private Shortage shortage;
|
||||
|
||||
public ShortagesEntity(String refNo) {
|
||||
this.refNo = refNo;
|
||||
@@ -39,8 +39,8 @@ public class ShortagesEntity implements Serializable {
|
||||
return id instanceof ShortagesEntityId ? id : new ShortagesEntityId(id.getRefNo());
|
||||
}
|
||||
|
||||
public static class ShortagesAsJson extends JsonConverter<Shortage> {
|
||||
public ShortagesAsJson() {
|
||||
public static class ShortageAsJson extends JsonConverter<Shortage> {
|
||||
public ShortageAsJson() {
|
||||
super(Shortage.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,12 +90,12 @@ class ShortagePredictionProcessORMRepositoryTest extends Specification {
|
||||
|
||||
def persistedShortage(Shortage shortages) {
|
||||
def entity = new ShortagesEntity(refNo)
|
||||
entity.setShortages(shortages)
|
||||
entity.setShortage(shortages)
|
||||
dao.save(entity)
|
||||
}
|
||||
|
||||
Shortage shortagesCurrentlyPersisted() {
|
||||
dao.findByRefNo(refNo).get().shortages
|
||||
dao.findByRefNo(refNo).get().shortage
|
||||
}
|
||||
|
||||
void noShortagesPersisted() {
|
||||
|
||||
Reference in New Issue
Block a user