diff --git a/pom.xml b/pom.xml
index 42e3046..d6ac809 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
newway
- 1.0.2-SNAPSHOT
+ 1.0.4-SNAPSHOT
jar
newway
diff --git a/src/main/java/com/rbkmoney/newway/config/EventStockConfig.java b/src/main/java/com/rbkmoney/newway/config/EventStockConfig.java
index 549f008..2364fbf 100644
--- a/src/main/java/com/rbkmoney/newway/config/EventStockConfig.java
+++ b/src/main/java/com/rbkmoney/newway/config/EventStockConfig.java
@@ -2,8 +2,9 @@ package com.rbkmoney.newway.config;
import com.rbkmoney.eventstock.client.EventPublisher;
import com.rbkmoney.eventstock.client.poll.PollingEventPublisherBuilder;
+import com.rbkmoney.newway.poller.handler.InvoicingEventStockHandler;
import com.rbkmoney.newway.poller.handler.PayoutEventStockHandler;
-import com.rbkmoney.newway.poller.handler.ProcessingEventStockHandler;
+import com.rbkmoney.newway.poller.handler.PartyManagementEventStockHandler;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -15,8 +16,8 @@ import java.io.IOException;
public class EventStockConfig {
@Bean
- public EventPublisher processingEventPublisher(
- ProcessingEventStockHandler processingEventStockHandler,
+ public EventPublisher partyManagementEventPublisher(
+ PartyManagementEventStockHandler partyManagementEventStockHandler,
@Value("${bm.processing.url}") Resource resource,
@Value("${bm.processing.polling.delay}") int pollDelay,
@Value("${bm.processing.polling.retryDelay}") int retryDelay,
@@ -24,7 +25,24 @@ public class EventStockConfig {
) throws IOException {
return new PollingEventPublisherBuilder()
.withURI(resource.getURI())
- .withEventHandler(processingEventStockHandler)
+ .withEventHandler(partyManagementEventStockHandler)
+ .withMaxPoolSize(maxPoolSize)
+ .withEventRetryDelay(retryDelay)
+ .withPollDelay(pollDelay)
+ .build();
+ }
+
+ @Bean
+ public EventPublisher invoicingEventPublisher(
+ InvoicingEventStockHandler invoicingEventStockHandler,
+ @Value("${bm.processing.url}") Resource resource,
+ @Value("${bm.processing.polling.delay}") int pollDelay,
+ @Value("${bm.processing.polling.retryDelay}") int retryDelay,
+ @Value("${bm.processing.polling.maxPoolSize}") int maxPoolSize
+ ) throws IOException {
+ return new PollingEventPublisherBuilder()
+ .withURI(resource.getURI())
+ .withEventHandler(invoicingEventStockHandler)
.withMaxPoolSize(maxPoolSize)
.withEventRetryDelay(retryDelay)
.withPollDelay(pollDelay)
diff --git a/src/main/java/com/rbkmoney/newway/dao/party/iface/ContractDao.java b/src/main/java/com/rbkmoney/newway/dao/party/iface/ContractDao.java
index de47bd1..3649851 100644
--- a/src/main/java/com/rbkmoney/newway/dao/party/iface/ContractDao.java
+++ b/src/main/java/com/rbkmoney/newway/dao/party/iface/ContractDao.java
@@ -6,6 +6,6 @@ import com.rbkmoney.newway.exception.DaoException;
public interface ContractDao extends GenericDao {
Long save(Contract contract) throws DaoException;
- Contract get(String contractId) throws DaoException;
- void updateNotCurrent(String contractId) throws DaoException;
+ Contract get(String partyId, String contractId) throws DaoException;
+ void updateNotCurrent(String partyId, String contractId) throws DaoException;
}
diff --git a/src/main/java/com/rbkmoney/newway/dao/party/iface/ContractorDao.java b/src/main/java/com/rbkmoney/newway/dao/party/iface/ContractorDao.java
index 4275285..7814f40 100644
--- a/src/main/java/com/rbkmoney/newway/dao/party/iface/ContractorDao.java
+++ b/src/main/java/com/rbkmoney/newway/dao/party/iface/ContractorDao.java
@@ -6,6 +6,6 @@ import com.rbkmoney.newway.exception.DaoException;
public interface ContractorDao extends GenericDao {
Long save(Contractor contractor) throws DaoException;
- Contractor get(String contractorId) throws DaoException;
- void updateNotCurrent(String contractorId) throws DaoException;
+ Contractor get(String partyId, String contractorId) throws DaoException;
+ void updateNotCurrent(String partyId, String contractorId) throws DaoException;
}
diff --git a/src/main/java/com/rbkmoney/newway/dao/party/iface/ShopDao.java b/src/main/java/com/rbkmoney/newway/dao/party/iface/ShopDao.java
index 46a39ce..caf9110 100644
--- a/src/main/java/com/rbkmoney/newway/dao/party/iface/ShopDao.java
+++ b/src/main/java/com/rbkmoney/newway/dao/party/iface/ShopDao.java
@@ -6,6 +6,6 @@ import com.rbkmoney.newway.exception.DaoException;
public interface ShopDao extends GenericDao {
Long save(Shop shop) throws DaoException;
- Shop get(String shopId) throws DaoException;
- void updateNotCurrent(String shopId) throws DaoException;
+ Shop get(String partyId, String shopId) throws DaoException;
+ void updateNotCurrent(String partyId, String shopId) throws DaoException;
}
diff --git a/src/main/java/com/rbkmoney/newway/dao/party/impl/ContractDaoImpl.java b/src/main/java/com/rbkmoney/newway/dao/party/impl/ContractDaoImpl.java
index be9e592..65195d5 100644
--- a/src/main/java/com/rbkmoney/newway/dao/party/impl/ContractDaoImpl.java
+++ b/src/main/java/com/rbkmoney/newway/dao/party/impl/ContractDaoImpl.java
@@ -35,17 +35,17 @@ public class ContractDaoImpl extends AbstractGenericDao implements ContractDao {
}
@Override
- public Contract get(String contractId) throws DaoException {
+ public Contract get(String partyId, String contractId) throws DaoException {
Query query = getDslContext().selectFrom(CONTRACT)
- .where(CONTRACT.CONTRACT_ID.eq(contractId).and(CONTRACT.CURRENT));
+ .where(CONTRACT.PARTY_ID.eq(partyId).and(CONTRACT.CONTRACT_ID.eq(contractId)).and(CONTRACT.CURRENT));
return fetchOne(query, contractRowMapper);
}
@Override
- public void updateNotCurrent(String contractId) throws DaoException {
+ public void updateNotCurrent(String partyId, String contractId) throws DaoException {
Query query = getDslContext().update(CONTRACT).set(CONTRACT.CURRENT, false)
- .where(CONTRACT.CONTRACT_ID.eq(contractId).and(CONTRACT.CURRENT));
+ .where(CONTRACT.PARTY_ID.eq(partyId).and(CONTRACT.CONTRACT_ID.eq(contractId)).and(CONTRACT.CURRENT));
executeOne(query);
}
}
diff --git a/src/main/java/com/rbkmoney/newway/dao/party/impl/ContractorDaoImpl.java b/src/main/java/com/rbkmoney/newway/dao/party/impl/ContractorDaoImpl.java
index 87eeb17..aadb218 100644
--- a/src/main/java/com/rbkmoney/newway/dao/party/impl/ContractorDaoImpl.java
+++ b/src/main/java/com/rbkmoney/newway/dao/party/impl/ContractorDaoImpl.java
@@ -35,17 +35,17 @@ public class ContractorDaoImpl extends AbstractGenericDao implements ContractorD
}
@Override
- public Contractor get(String contractorId) throws DaoException {
+ public Contractor get(String partyId, String contractorId) throws DaoException {
Query query = getDslContext().selectFrom(CONTRACTOR)
- .where(CONTRACTOR.CONTRACTOR_ID.eq(contractorId).and(CONTRACTOR.CURRENT));
+ .where(CONTRACTOR.PARTY_ID.eq(partyId).and(CONTRACTOR.CONTRACTOR_ID.eq(contractorId)).and(CONTRACTOR.CURRENT));
return fetchOne(query, contractorRowMapper);
}
@Override
- public void updateNotCurrent(String contractId) throws DaoException {
+ public void updateNotCurrent(String partyId, String contractId) throws DaoException {
Query query = getDslContext().update(CONTRACTOR).set(CONTRACTOR.CURRENT, false)
- .where(CONTRACTOR.CONTRACTOR_ID.eq(contractId).and(CONTRACTOR.CURRENT));
+ .where(CONTRACTOR.PARTY_ID.eq(partyId).and(CONTRACTOR.CONTRACTOR_ID.eq(contractId)).and(CONTRACTOR.CURRENT));
executeOne(query);
}
}
diff --git a/src/main/java/com/rbkmoney/newway/dao/party/impl/ShopDaoImpl.java b/src/main/java/com/rbkmoney/newway/dao/party/impl/ShopDaoImpl.java
index fd3dd15..7b87ff6 100644
--- a/src/main/java/com/rbkmoney/newway/dao/party/impl/ShopDaoImpl.java
+++ b/src/main/java/com/rbkmoney/newway/dao/party/impl/ShopDaoImpl.java
@@ -35,17 +35,17 @@ public class ShopDaoImpl extends AbstractGenericDao implements ShopDao {
}
@Override
- public Shop get(String shopId) throws DaoException {
+ public Shop get(String partyId, String shopId) throws DaoException {
Query query = getDslContext().selectFrom(SHOP)
- .where(SHOP.SHOP_ID.eq(shopId).and(SHOP.CURRENT));
+ .where(SHOP.PARTY_ID.eq(partyId).and(SHOP.SHOP_ID.eq(shopId)).and(SHOP.CURRENT));
return fetchOne(query, shopRowMapper);
}
@Override
- public void updateNotCurrent(String shopId) throws DaoException {
+ public void updateNotCurrent(String partyId, String shopId) throws DaoException {
Query query = getDslContext().update(SHOP).set(SHOP.CURRENT, false)
- .where(SHOP.SHOP_ID.eq(shopId).and(SHOP.CURRENT));
+ .where(SHOP.PARTY_ID.eq(partyId).and(SHOP.SHOP_ID.eq(shopId)).and(SHOP.CURRENT));
executeOne(query);
}
}
diff --git a/src/main/java/com/rbkmoney/newway/listener/OnStart.java b/src/main/java/com/rbkmoney/newway/listener/OnStart.java
index 2a04019..7478c91 100644
--- a/src/main/java/com/rbkmoney/newway/listener/OnStart.java
+++ b/src/main/java/com/rbkmoney/newway/listener/OnStart.java
@@ -5,8 +5,9 @@ import com.rbkmoney.eventstock.client.EventConstraint;
import com.rbkmoney.eventstock.client.EventPublisher;
import com.rbkmoney.eventstock.client.SubscriberConfig;
import com.rbkmoney.eventstock.client.poll.EventFlowFilter;
+import com.rbkmoney.newway.service.InvoicingService;
import com.rbkmoney.newway.service.PayoutService;
-import com.rbkmoney.newway.service.ProcessingService;
+import com.rbkmoney.newway.service.PartyManagementService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
@@ -16,30 +17,37 @@ import java.util.Optional;
@Component
public class OnStart implements ApplicationListener {
- private final EventPublisher processingEventPublisher;
+ private final EventPublisher partyManagementEventPublisher;
+ private final EventPublisher invoicingEventPublisher;
private final EventPublisher payoutEventPublisher;
- private final ProcessingService processingService;
+ private final PartyManagementService partyManagementService;
+ private final InvoicingService invoicingService;
private final PayoutService payoutService;
@Value("${bm.pollingEnabled}")
private boolean pollingEnabled;
- public OnStart(EventPublisher processingEventPublisher,
+ public OnStart(EventPublisher partyManagementEventPublisher,
+ EventPublisher invoicingEventPublisher,
EventPublisher payoutEventPublisher,
- ProcessingService processingService,
+ PartyManagementService partyManagementService,
+ InvoicingService invoicingService,
PayoutService payoutService) {
- this.processingEventPublisher = processingEventPublisher;
+ this.partyManagementEventPublisher = partyManagementEventPublisher;
+ this.invoicingEventPublisher = invoicingEventPublisher;
this.payoutEventPublisher = payoutEventPublisher;
- this.processingService = processingService;
+ this.partyManagementService = partyManagementService;
+ this.invoicingService = invoicingService;
this.payoutService = payoutService;
}
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
if (pollingEnabled) {
- processingEventPublisher.subscribe(buildSubscriberConfig(processingService.getLastEventId()));
+ partyManagementEventPublisher.subscribe(buildSubscriberConfig(partyManagementService.getLastEventId()));
+ invoicingEventPublisher.subscribe(buildSubscriberConfig(invoicingService.getLastEventId()));
payoutEventPublisher.subscribe(buildSubscriberConfig(payoutService.getLastEventId()));
}
}
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/InvoicingEventStockHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/InvoicingEventStockHandler.java
new file mode 100644
index 0000000..25d90bc
--- /dev/null
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/InvoicingEventStockHandler.java
@@ -0,0 +1,53 @@
+package com.rbkmoney.newway.poller.handler;
+
+import com.rbkmoney.damsel.event_stock.StockEvent;
+import com.rbkmoney.damsel.payment_processing.Event;
+import com.rbkmoney.damsel.payment_processing.EventPayload;
+import com.rbkmoney.eventstock.client.EventAction;
+import com.rbkmoney.eventstock.client.EventHandler;
+import com.rbkmoney.newway.poller.handler.impl.invoicing.AbstractInvoicingHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+@Component
+public class InvoicingEventStockHandler implements EventHandler {
+
+ private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+ private final List invoicingHandlers;
+
+ public InvoicingEventStockHandler(List invoicingHandlers) {
+ this.invoicingHandlers = invoicingHandlers;
+ }
+
+ @Override
+ public EventAction handle(StockEvent stockEvent, String subsKey) {
+ Event processingEvent = stockEvent.getSourceEvent().getProcessingEvent();
+ EventPayload payload = processingEvent.getPayload();
+
+ try {
+ handleEvents(processingEvent, payload);
+ } catch (RuntimeException e) {
+ log.error("Error when polling invoicing event with id={}", processingEvent.getId(), e);
+ return EventAction.DELAYED_RETRY;
+ }
+ return EventAction.CONTINUE;
+ }
+
+ @Transactional(propagation = Propagation.REQUIRED)
+ public void handleEvents(Event processingEvent, EventPayload payload) {
+ if (payload.isSetInvoiceChanges()) {
+ payload.getInvoiceChanges().forEach(cc -> invoicingHandlers.forEach(ph -> {
+ if (ph.accept(cc)) {
+ ph.handle(cc, processingEvent);
+ }
+ }));
+ }
+ }
+
+}
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/ProcessingEventStockHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/PartyManagementEventStockHandler.java
similarity index 65%
rename from src/main/java/com/rbkmoney/newway/poller/handler/ProcessingEventStockHandler.java
rename to src/main/java/com/rbkmoney/newway/poller/handler/PartyManagementEventStockHandler.java
index 1d5ec58..7d491e2 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/ProcessingEventStockHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/PartyManagementEventStockHandler.java
@@ -5,7 +5,6 @@ import com.rbkmoney.damsel.payment_processing.Event;
import com.rbkmoney.damsel.payment_processing.EventPayload;
import com.rbkmoney.eventstock.client.EventAction;
import com.rbkmoney.eventstock.client.EventHandler;
-import com.rbkmoney.newway.poller.handler.impl.invoicing.AbstractInvoicingHandler;
import com.rbkmoney.newway.poller.handler.impl.party_mngmnt.AbstractPartyManagementHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -16,15 +15,13 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Component
-public class ProcessingEventStockHandler implements EventHandler {
+public class PartyManagementEventStockHandler implements EventHandler {
private final Logger log = LoggerFactory.getLogger(this.getClass());
- private final List invoicingHandlers;
private final List partyManagementHandlers;
- public ProcessingEventStockHandler(List invoicingHandlers, List partyManagementHandlers) {
- this.invoicingHandlers = invoicingHandlers;
+ public PartyManagementEventStockHandler(List partyManagementHandlers) {
this.partyManagementHandlers = partyManagementHandlers;
}
@@ -36,7 +33,7 @@ public class ProcessingEventStockHandler implements EventHandler {
try {
handleEvents(processingEvent, payload);
} catch (RuntimeException e) {
- log.error("Error when polling processing event with id={}", processingEvent.getId(), e);
+ log.error("Error when polling party management event with id={}", processingEvent.getId(), e);
return EventAction.DELAYED_RETRY;
}
return EventAction.CONTINUE;
@@ -44,15 +41,7 @@ public class ProcessingEventStockHandler implements EventHandler {
@Transactional(propagation = Propagation.REQUIRED)
public void handleEvents(Event processingEvent, EventPayload payload) {
- if (payload.isSetInvoiceChanges()) {
- payload.getInvoiceChanges().forEach(cc -> {
- invoicingHandlers.forEach(ih -> {
- if (ih.accept(cc)) {
- ih.handle(cc, processingEvent);
- }
- });
- });
- } else if (payload.isSetPartyChanges()) {
+ if (payload.isSetPartyChanges()) {
payload.getPartyChanges().forEach(cc -> partyManagementHandlers.forEach(ph -> {
if (ph.accept(cc)) {
ph.handle(cc, processingEvent);
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractAdjustmentCreatedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractAdjustmentCreatedHandler.java
index 235cac6..9cdf895 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractAdjustmentCreatedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractAdjustmentCreatedHandler.java
@@ -48,7 +48,7 @@ public class ContractAdjustmentCreatedHandler extends AbstractClaimChangedHandle
String contractId = contractEffectUnit.getContractId();
String partyId = event.getSource().getPartyId();
log.info("Start contract adjustment created handling, eventId={}, partyId={}, contractId={}", eventId, partyId, contractId);
- Contract contractSource = contractDao.get(contractId);
+ Contract contractSource = contractDao.get(partyId, contractId);
if (contractSource == null) {
throw new NotFoundException(String.format("Contract not found, contractId='%s'", contractId));
}
@@ -57,7 +57,7 @@ public class ContractAdjustmentCreatedHandler extends AbstractClaimChangedHandle
contractSource.setWtime(null);
contractSource.setEventId(eventId);
contractSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
- contractDao.updateNotCurrent(contractId);
+ contractDao.updateNotCurrent(partyId, contractId);
long cntrctId = contractDao.save(contractSource);
List adjustments = new ArrayList<>(contractAdjustmentDao.getByCntrctId(contractSourceId));
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractContractorIDChangedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractContractorIDChangedHandler.java
index 8bcecdd..fe86570 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractContractorIDChangedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractContractorIDChangedHandler.java
@@ -46,7 +46,7 @@ public class ContractContractorIDChangedHandler extends AbstractClaimChangedHand
String contractId = contractEffectUnit.getContractId();
String partyId = event.getSource().getPartyId();
log.info("Start contract contractorChanged changed handling, eventId={}, partyId={}, contractId={}", eventId, partyId, contractId);
- Contract contractSource = contractDao.get(contractId);
+ Contract contractSource = contractDao.get(partyId, contractId);
if (contractSource == null) {
throw new NotFoundException(String.format("Contract not found, contractId='%s'", contractId));
}
@@ -56,7 +56,7 @@ public class ContractContractorIDChangedHandler extends AbstractClaimChangedHand
contractSource.setEventId(eventId);
contractSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
contractSource.setContractorId(contractorChanged);
- contractDao.updateNotCurrent(contractId);
+ contractDao.updateNotCurrent(partyId, contractId);
long cntrctId = contractDao.save(contractSource);
List adjustments = contractAdjustmentDao.getByCntrctId(contractSourceId);
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractLegalAgreementBoundHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractLegalAgreementBoundHandler.java
index f375f29..869c830 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractLegalAgreementBoundHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractLegalAgreementBoundHandler.java
@@ -48,7 +48,7 @@ public class ContractLegalAgreementBoundHandler extends AbstractClaimChangedHand
String contractId = contractEffectUnit.getContractId();
String partyId = event.getSource().getPartyId();
log.info("Start contract legal agreement bound handling, eventId={}, partyId={}, contractId={}", eventId, partyId, contractId);
- Contract contractSource = contractDao.get(contractId);
+ Contract contractSource = contractDao.get(partyId, contractId);
if (contractSource == null) {
throw new NotFoundException(String.format("Contract not found, contractId='%s'", contractId));
}
@@ -58,7 +58,7 @@ public class ContractLegalAgreementBoundHandler extends AbstractClaimChangedHand
contractSource.setEventId(eventId);
contractSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
ContractUtil.fillContractLegalAgreementFields(contractSource, legalAgreementBound);
- contractDao.updateNotCurrent(contractId);
+ contractDao.updateNotCurrent(partyId, contractId);
long cntrctId = contractDao.save(contractSource);
List adjustments = contractAdjustmentDao.getByCntrctId(contractSourceId);
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractPayoutToolCreatedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractPayoutToolCreatedHandler.java
index b097260..b9ca122 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractPayoutToolCreatedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractPayoutToolCreatedHandler.java
@@ -48,7 +48,7 @@ public class ContractPayoutToolCreatedHandler extends AbstractClaimChangedHandle
String contractId = contractEffectUnit.getContractId();
String partyId = event.getSource().getPartyId();
log.info("Start contract payouttool created handling, eventId={}, partyId={}, contractId={}", eventId, partyId, contractId);
- Contract contractSource = contractDao.get(contractId);
+ Contract contractSource = contractDao.get(partyId, contractId);
if (contractSource == null) {
throw new NotFoundException(String.format("Contract not found, contractId='%s'", contractId));
}
@@ -57,7 +57,7 @@ public class ContractPayoutToolCreatedHandler extends AbstractClaimChangedHandle
contractSource.setWtime(null);
contractSource.setEventId(eventId);
contractSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
- contractDao.updateNotCurrent(contractId);
+ contractDao.updateNotCurrent(partyId, contractId);
long cntrctId = contractDao.save(contractSource);
List adjustments = contractAdjustmentDao.getByCntrctId(contractSourceId);
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractReportPreferencesChangedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractReportPreferencesChangedHandler.java
index 5d89d73..fa27a58 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractReportPreferencesChangedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractReportPreferencesChangedHandler.java
@@ -48,7 +48,7 @@ public class ContractReportPreferencesChangedHandler extends AbstractClaimChange
String contractId = contractEffectUnit.getContractId();
String partyId = event.getSource().getPartyId();
log.info("Start contract report preferences changed handling, eventId={}, partyId={}, contractId={}", eventId, partyId, contractId);
- Contract contractSource = contractDao.get(contractId);
+ Contract contractSource = contractDao.get(partyId, contractId);
if (contractSource == null) {
throw new NotFoundException(String.format("Contract not found, contractId='%s'", contractId));
}
@@ -58,7 +58,7 @@ public class ContractReportPreferencesChangedHandler extends AbstractClaimChange
contractSource.setEventId(eventId);
contractSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
ContractUtil.fillReportPreferences(contractSource, reportPreferencesChanged.getServiceAcceptanceActPreferences());
- contractDao.updateNotCurrent(contractId);
+ contractDao.updateNotCurrent(partyId, contractId);
long cntrctId = contractDao.save(contractSource);
List adjustments = contractAdjustmentDao.getByCntrctId(contractSourceId);
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractStatusChangedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractStatusChangedHandler.java
index 0d35086..fa137ed 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractStatusChangedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contract/ContractStatusChangedHandler.java
@@ -47,7 +47,7 @@ public class ContractStatusChangedHandler extends AbstractClaimChangedHandler {
String contractId = contractEffectUnit.getContractId();
String partyId = event.getSource().getPartyId();
log.info("Start contractSource status changed handling, eventId={}, partyId={}, contractId={}", eventId, partyId, contractId);
- Contract contractSource = contractDao.get(contractId);
+ Contract contractSource = contractDao.get(partyId, contractId);
if (contractSource == null) {
throw new NotFoundException(String.format("Contract not found, contractId='%s'", contractId));
}
@@ -64,7 +64,7 @@ public class ContractStatusChangedHandler extends AbstractClaimChangedHandler {
if (statusChanged.isSetTerminated()) {
contractSource.setStatusTerminatedAt(TypeUtil.stringToLocalDateTime(statusChanged.getTerminated().getTerminatedAt()));
}
- contractDao.updateNotCurrent(contractId);
+ contractDao.updateNotCurrent(partyId, contractId);
long cntrctId = contractDao.save(contractSource);
List adjustments = contractAdjustmentDao.getByCntrctId(contractSourceId);
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contractor/ContractorIdentificationalLevelChangedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contractor/ContractorIdentificationalLevelChangedHandler.java
index c15e5ed..49c7331 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contractor/ContractorIdentificationalLevelChangedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/contractor/ContractorIdentificationalLevelChangedHandler.java
@@ -37,7 +37,7 @@ public class ContractorIdentificationalLevelChangedHandler extends AbstractClaim
String contractorId = contractorEffect.getId();
String partyId = event.getSource().getPartyId();
log.info("Start identificational level changed handling, eventId={}, partyId={}, contractorId={}", eventId, partyId, contractorId);
- Contractor contractorSource = contractorDao.get(contractorId);
+ Contractor contractorSource = contractorDao.get(partyId, contractorId);
if (contractorSource == null) {
throw new NotFoundException(String.format("Contractor not found, contractorId='%s'", contractorId));
}
@@ -46,7 +46,7 @@ public class ContractorIdentificationalLevelChangedHandler extends AbstractClaim
contractorSource.setEventId(eventId);
contractorSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
contractorSource.setIdentificationalLevel(identificationLevelChanged.name());
- contractorDao.updateNotCurrent(contractorId);
+ contractorDao.updateNotCurrent(partyId, contractorId);
contractorDao.save(contractorSource);
log.info("Contract identificational level has been saved, eventId={}, contractorId={}", eventId, contractorId);
});
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopAccountCreatedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopAccountCreatedHandler.java
index abec29e..b423e0d 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopAccountCreatedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopAccountCreatedHandler.java
@@ -39,7 +39,7 @@ public class ShopAccountCreatedHandler extends AbstractClaimChangedHandler {
String shopId = shopEffect.getShopId();
String partyId = event.getSource().getPartyId();
log.info("Start shop accountCreated handling, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
- Shop shopSource = shopDao.get(shopId);
+ Shop shopSource = shopDao.get(partyId, shopId);
if (shopSource == null) {
throw new NotFoundException(String.format("Shop not found, shopId='%s'", shopId));
}
@@ -49,7 +49,7 @@ public class ShopAccountCreatedHandler extends AbstractClaimChangedHandler {
shopSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
ShopUtil.fillShopAccount(shopSource, accountCreated);
- shopDao.updateNotCurrent(shopId);
+ shopDao.updateNotCurrent(partyId, shopId);
shopDao.save(shopSource);
log.info("Shop accountCreated has been saved, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
});
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopBlockingHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopBlockingHandler.java
index b0e30a3..46eea18 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopBlockingHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopBlockingHandler.java
@@ -42,7 +42,7 @@ public class ShopBlockingHandler extends AbstractPartyManagementHandler {
String shopId = change.getShopBlocking().getShopId();
String partyId = event.getSource().getPartyId();
log.info("Start shop blocking handling, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
- Shop shopSource = shopDao.get(shopId);
+ Shop shopSource = shopDao.get(partyId, shopId);
if (shopSource == null) {
throw new NotFoundException(String.format("Shop not found, shopId='%s'", shopId));
}
@@ -66,7 +66,7 @@ public class ShopBlockingHandler extends AbstractPartyManagementHandler {
shopSource.setBlockingBlockedReason(blocking.getBlocked().getReason());
shopSource.setBlockingBlockedSince(TypeUtil.stringToLocalDateTime(blocking.getBlocked().getSince()));
}
- shopDao.updateNotCurrent(shopId);
+ shopDao.updateNotCurrent(partyId, shopId);
shopDao.save(shopSource);
log.info("Shop blocking has been saved, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
}
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopCategoryChangedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopCategoryChangedHandler.java
index 64fe523..7525f9f 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopCategoryChangedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopCategoryChangedHandler.java
@@ -36,7 +36,7 @@ public class ShopCategoryChangedHandler extends AbstractClaimChangedHandler {
String shopId = shopEffect.getShopId();
String partyId = event.getSource().getPartyId();
log.info("Start shop categoryId changed handling, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
- Shop shopSource = shopDao.get(shopId);
+ Shop shopSource = shopDao.get(partyId, shopId);
if (shopSource == null) {
throw new NotFoundException(String.format("Shop not found, shopId='%s'", shopId));
}
@@ -45,7 +45,7 @@ public class ShopCategoryChangedHandler extends AbstractClaimChangedHandler {
shopSource.setEventId(eventId);
shopSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
shopSource.setCategoryId(categoryId);
- shopDao.updateNotCurrent(shopId);
+ shopDao.updateNotCurrent(partyId, shopId);
shopDao.save(shopSource);
log.info("Shop categoryId has been saved, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
});
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopContractChangedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopContractChangedHandler.java
index b9e8f6f..d29e6d5 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopContractChangedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopContractChangedHandler.java
@@ -38,7 +38,7 @@ public class ShopContractChangedHandler extends AbstractClaimChangedHandler {
String shopId = shopEffect.getShopId();
String partyId = event.getSource().getPartyId();
log.info("Start shop contractChanged handling, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
- Shop shopSource = shopDao.get(shopId);
+ Shop shopSource = shopDao.get(partyId, shopId);
if (shopSource == null) {
throw new NotFoundException(String.format("Shop not found, shopId='%s'", shopId));
}
@@ -48,7 +48,7 @@ public class ShopContractChangedHandler extends AbstractClaimChangedHandler {
shopSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
shopSource.setContractId(contractChanged.getContractId());
shopSource.setPayoutToolId(contractChanged.getPayoutToolId());
- shopDao.updateNotCurrent(shopId);
+ shopDao.updateNotCurrent(partyId, shopId);
shopDao.save(shopSource);
log.info("Shop contractChanged has been saved, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
});
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopDetailsChangedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopDetailsChangedHandler.java
index 08f332b..2341797 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopDetailsChangedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopDetailsChangedHandler.java
@@ -38,7 +38,7 @@ public class ShopDetailsChangedHandler extends AbstractClaimChangedHandler {
String shopId = shopEffect.getShopId();
String partyId = event.getSource().getPartyId();
log.info("Start shop detailsChanged handling, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
- Shop shopSource = shopDao.get(shopId);
+ Shop shopSource = shopDao.get(partyId, shopId);
if (shopSource == null) {
throw new NotFoundException(String.format("Shop not found, shopId='%s'", shopId));
}
@@ -48,7 +48,7 @@ public class ShopDetailsChangedHandler extends AbstractClaimChangedHandler {
shopSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
shopSource.setDetailsName(detailsChanged.getName());
shopSource.setDetailsDescription(detailsChanged.getDescription());
- shopDao.updateNotCurrent(shopId);
+ shopDao.updateNotCurrent(partyId, shopId);
shopDao.save(shopSource);
log.info("Shop detailsChanged has been saved, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
});
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopLocationChangedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopLocationChangedHandler.java
index ca1f73d..eaa6f72 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopLocationChangedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopLocationChangedHandler.java
@@ -38,7 +38,7 @@ public class ShopLocationChangedHandler extends AbstractClaimChangedHandler {
String shopId = shopEffect.getShopId();
String partyId = event.getSource().getPartyId();
log.info("Start shop locationChanged handling, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
- Shop shopSource = shopDao.get(shopId);
+ Shop shopSource = shopDao.get(partyId, shopId);
if (shopSource == null) {
throw new NotFoundException(String.format("Shop not found, shopId='%s'", shopId));
}
@@ -51,7 +51,7 @@ public class ShopLocationChangedHandler extends AbstractClaimChangedHandler {
} else {
throw new IllegalArgumentException("Illegal shop location " + locationChanged);
}
- shopDao.updateNotCurrent(shopId);
+ shopDao.updateNotCurrent(partyId, shopId);
shopDao.save(shopSource);
log.info("Shop locationChanged has been saved, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
});
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopPayoutScheduleChangedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopPayoutScheduleChangedHandler.java
index 1a45d14..7bd87b2 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopPayoutScheduleChangedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopPayoutScheduleChangedHandler.java
@@ -37,7 +37,7 @@ public class ShopPayoutScheduleChangedHandler extends AbstractClaimChangedHandle
String shopId = shopEffect.getShopId();
String partyId = event.getSource().getPartyId();
log.info("Start shop payoutScheduleChanged handling, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
- Shop shopSource = shopDao.get(shopId);
+ Shop shopSource = shopDao.get(partyId, shopId);
if (shopSource == null) {
throw new NotFoundException(String.format("Shop not found, shopId='%s'", shopId));
}
@@ -50,7 +50,7 @@ public class ShopPayoutScheduleChangedHandler extends AbstractClaimChangedHandle
} else {
shopSource.setPayoutScheduleId(null);
}
- shopDao.updateNotCurrent(shopId);
+ shopDao.updateNotCurrent(partyId, shopId);
shopDao.save(shopSource);
log.info("Shop payoutScheduleChanged has been saved, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
});
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopPayoutToolChangedHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopPayoutToolChangedHandler.java
index d9bccb2..91845c0 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopPayoutToolChangedHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopPayoutToolChangedHandler.java
@@ -37,7 +37,7 @@ public class ShopPayoutToolChangedHandler extends AbstractClaimChangedHandler {
String shopId = shopEffect.getShopId();
String partyId = event.getSource().getPartyId();
log.info("Start shop payoutToolChanged handling, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
- Shop shopSource = shopDao.get(shopId);
+ Shop shopSource = shopDao.get(partyId, shopId);
if (shopSource == null) {
throw new NotFoundException(String.format("Shop not found, shopId='%s'", shopId));
}
@@ -46,7 +46,7 @@ public class ShopPayoutToolChangedHandler extends AbstractClaimChangedHandler {
shopSource.setEventId(eventId);
shopSource.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
shopSource.setPayoutToolId(payoutToolChanged);
- shopDao.updateNotCurrent(shopId);
+ shopDao.updateNotCurrent(partyId, shopId);
shopDao.save(shopSource);
log.info("Shop payoutToolChanged has been saved, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
});
diff --git a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopSuspensionHandler.java b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopSuspensionHandler.java
index 2c71d16..8ce6d61 100644
--- a/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopSuspensionHandler.java
+++ b/src/main/java/com/rbkmoney/newway/poller/handler/impl/party_mngmnt/shop/ShopSuspensionHandler.java
@@ -41,7 +41,7 @@ public class ShopSuspensionHandler extends AbstractPartyManagementHandler {
String shopId = change.getShopSuspension().getShopId();
String partyId = event.getSource().getPartyId();
log.info("Start shop suspension handling, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
- Shop shopSource = shopDao.get(shopId);
+ Shop shopSource = shopDao.get(partyId, shopId);
if (shopSource == null) {
throw new NotFoundException(String.format("Shop not found, shopId='%s'", shopId));
}
@@ -61,7 +61,7 @@ public class ShopSuspensionHandler extends AbstractPartyManagementHandler {
shopSource.setSuspensionActiveSince(null);
shopSource.setSuspensionSuspendedSince(TypeUtil.stringToLocalDateTime(suspension.getSuspended().getSince()));
}
- shopDao.updateNotCurrent(shopId);
+ shopDao.updateNotCurrent(partyId, shopId);
shopDao.save(shopSource);
log.info("Shop suspension has been saved, eventId={}, partyId={}, shopId={}", eventId, partyId, shopId);
}
diff --git a/src/main/java/com/rbkmoney/newway/service/InvoicingService.java b/src/main/java/com/rbkmoney/newway/service/InvoicingService.java
new file mode 100644
index 0000000..df921f3
--- /dev/null
+++ b/src/main/java/com/rbkmoney/newway/service/InvoicingService.java
@@ -0,0 +1,28 @@
+package com.rbkmoney.newway.service;
+
+import com.rbkmoney.newway.dao.invoicing.iface.InvoiceDao;
+import com.rbkmoney.newway.dao.party.iface.PartyDao;
+import com.rbkmoney.newway.exception.DaoException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.util.Optional;
+
+@Service
+public class InvoicingService {
+
+ private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+ private final InvoiceDao invoiceDao;
+
+ public InvoicingService(InvoiceDao invoiceDao) {
+ this.invoiceDao = invoiceDao;
+ }
+
+ public Optional getLastEventId() throws DaoException {
+ Optional lastEventId = Optional.ofNullable(invoiceDao.getLastEventId());
+ log.info("Last invoicing eventId={}", lastEventId);
+ return lastEventId;
+ }
+}
diff --git a/src/main/java/com/rbkmoney/newway/service/PartyManagementService.java b/src/main/java/com/rbkmoney/newway/service/PartyManagementService.java
new file mode 100644
index 0000000..e7e1166
--- /dev/null
+++ b/src/main/java/com/rbkmoney/newway/service/PartyManagementService.java
@@ -0,0 +1,27 @@
+package com.rbkmoney.newway.service;
+
+import com.rbkmoney.newway.dao.party.iface.PartyDao;
+import com.rbkmoney.newway.exception.DaoException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.util.Optional;
+
+@Service
+public class PartyManagementService {
+
+ private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+ private final PartyDao partyDao;
+
+ public PartyManagementService(PartyDao partyDao) {
+ this.partyDao = partyDao;
+ }
+
+ public Optional getLastEventId() throws DaoException {
+ Optional lastEventId = Optional.ofNullable(partyDao.getLastEventId());
+ log.info("Last party management eventId={}", lastEventId);
+ return lastEventId;
+ }
+}
diff --git a/src/main/java/com/rbkmoney/newway/service/ProcessingService.java b/src/main/java/com/rbkmoney/newway/service/ProcessingService.java
deleted file mode 100644
index 9bdcce8..0000000
--- a/src/main/java/com/rbkmoney/newway/service/ProcessingService.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.rbkmoney.newway.service;
-
-import com.rbkmoney.newway.dao.invoicing.iface.InvoiceDao;
-import com.rbkmoney.newway.dao.party.iface.PartyDao;
-import com.rbkmoney.newway.exception.DaoException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-import java.util.Optional;
-
-@Service
-public class ProcessingService {
-
- private final Logger log = LoggerFactory.getLogger(this.getClass());
-
- private final PartyDao partyDao;
- private final InvoiceDao invoiceDao;
-
- public ProcessingService(PartyDao partyDao, InvoiceDao invoiceDao) {
- this.partyDao = partyDao;
- this.invoiceDao = invoiceDao;
- }
-
- public Optional getLastEventId() throws DaoException {
- Long partyLastEventId = partyDao.getLastEventId();
- Long invLastEventId = invoiceDao.getLastEventId();
- Long max = partyLastEventId;
- if (partyLastEventId == null) {
- max = invLastEventId;
- } else if (invLastEventId != null) {
- max = Math.max(partyLastEventId, invLastEventId);
- }
- Optional lastEventId = Optional.ofNullable(max);
- log.info("Last processing eventId={}", lastEventId);
- return lastEventId;
- }
-}
diff --git a/src/test/java/com/rbkmoney/newway/dao/party/impl/ContractDaoImplTest.java b/src/test/java/com/rbkmoney/newway/dao/party/impl/ContractDaoImplTest.java
index ab7dec4..6e36877 100644
--- a/src/test/java/com/rbkmoney/newway/dao/party/impl/ContractDaoImplTest.java
+++ b/src/test/java/com/rbkmoney/newway/dao/party/impl/ContractDaoImplTest.java
@@ -19,9 +19,9 @@ public class ContractDaoImplTest extends AbstractIntegrationTest {
Contract contract = random(Contract.class);
contract.setCurrent(true);
contractDao.save(contract);
- Contract contractGet = contractDao.get(contract.getContractId());
+ Contract contractGet = contractDao.get(contract.getPartyId(), contract.getContractId());
assertEquals(contract, contractGet);
- contractDao.updateNotCurrent(contract.getContractId());
- assertNull(contractDao.get(contract.getContractId()));
+ contractDao.updateNotCurrent(contract.getPartyId(), contract.getContractId());
+ assertNull(contractDao.get(contract.getPartyId(), contract.getContractId()));
}
}
\ No newline at end of file
diff --git a/src/test/java/com/rbkmoney/newway/dao/party/impl/ContractorDaoImplTest.java b/src/test/java/com/rbkmoney/newway/dao/party/impl/ContractorDaoImplTest.java
index 254789f..ff1cfe3 100644
--- a/src/test/java/com/rbkmoney/newway/dao/party/impl/ContractorDaoImplTest.java
+++ b/src/test/java/com/rbkmoney/newway/dao/party/impl/ContractorDaoImplTest.java
@@ -19,9 +19,9 @@ public class ContractorDaoImplTest extends AbstractIntegrationTest {
Contractor contractor = random(Contractor.class);
contractor.setCurrent(true);
contractorDao.save(contractor);
- Contractor contractorGet = contractorDao.get(contractor.getContractorId());
+ Contractor contractorGet = contractorDao.get(contractor.getPartyId(), contractor.getContractorId());
assertEquals(contractor, contractorGet);
- contractorDao.updateNotCurrent(contractor.getContractorId());
- assertNull(contractorDao.get(contractor.getContractorId()));
+ contractorDao.updateNotCurrent(contractor.getPartyId(), contractor.getContractorId());
+ assertNull(contractorDao.get(contractor.getPartyId(), contractor.getContractorId()));
}
}
\ No newline at end of file
diff --git a/src/test/java/com/rbkmoney/newway/dao/party/impl/ShopDaoImplTest.java b/src/test/java/com/rbkmoney/newway/dao/party/impl/ShopDaoImplTest.java
index fa5bd3e..ed3ed96 100644
--- a/src/test/java/com/rbkmoney/newway/dao/party/impl/ShopDaoImplTest.java
+++ b/src/test/java/com/rbkmoney/newway/dao/party/impl/ShopDaoImplTest.java
@@ -19,9 +19,9 @@ public class ShopDaoImplTest extends AbstractIntegrationTest {
Shop shop = random(Shop.class);
shop.setCurrent(true);
shopDao.save(shop);
- Shop shopGet = shopDao.get(shop.getShopId());
+ Shop shopGet = shopDao.get(shop.getPartyId(), shop.getShopId());
assertEquals(shop, shopGet);
- shopDao.updateNotCurrent(shop.getShopId());
- assertNull(shopDao.get(shop.getShopId()));
+ shopDao.updateNotCurrent(shop.getPartyId(), shop.getShopId());
+ assertNull(shopDao.get(shop.getPartyId(), shop.getShopId()));
}
}
\ No newline at end of file