From 8e36fa01ea42d282eacdc78d6749daf9ae1ede9c Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Tue, 9 Jul 2019 11:13:35 +0200 Subject: Refactor: Merge BinaryRepository into DeliveryRepository - Reason: Components, which rely on one of those, usually also rely on the other, so merging them reduces amount of dependencies. - Frame operations in DeliveryRepository API as "store" and "retrieve" operations. - Rename: Convert *Id in local variable names to upper case. --- src/main/java/at/gv/egiz/moazs/service/MsgService.java | 2 +- src/main/java/at/gv/egiz/moazs/service/MzsService.java | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'src/main/java/at/gv/egiz/moazs/service') diff --git a/src/main/java/at/gv/egiz/moazs/service/MsgService.java b/src/main/java/at/gv/egiz/moazs/service/MsgService.java index 93f1ed5..87644a0 100644 --- a/src/main/java/at/gv/egiz/moazs/service/MsgService.java +++ b/src/main/java/at/gv/egiz/moazs/service/MsgService.java @@ -58,7 +58,7 @@ public class MsgService implements Zuse2AppPort { } private void sendToWork(MsgResponse response) { - runAsync(() -> repository.add(response)) + runAsync(() -> repository.store(response)) .thenRunAsync(() -> handler.handle(response.getResponseID())); } diff --git a/src/main/java/at/gv/egiz/moazs/service/MzsService.java b/src/main/java/at/gv/egiz/moazs/service/MzsService.java index c41740f..2755a37 100644 --- a/src/main/java/at/gv/egiz/moazs/service/MzsService.java +++ b/src/main/java/at/gv/egiz/moazs/service/MzsService.java @@ -2,7 +2,6 @@ package at.gv.egiz.moazs.service; import at.gv.egiz.moazs.preprocess.DeliveryRequestAugmenter; import at.gv.egiz.moazs.process.DeliveryPipeline; -import at.gv.egiz.moazs.repository.BinaryRepository; import at.gv.egiz.moazs.repository.DeliveryRepository; import at.gv.egiz.moazs.scheme.Msg2MzsConverter; import at.gv.egiz.moazs.client.MzsClient; @@ -41,17 +40,15 @@ public class MzsService implements App2MzsPortType { private final MzsClient appClient; private final DeliveryRequestAugmenter augmenter; private final Msg2MzsConverter converter; - private final BinaryRepository binaryStatusRepository; @Autowired public MzsService(DeliveryRepository repository, DeliveryPipeline pipeline, MzsClient appClient, - DeliveryRequestAugmenter augmenter, Msg2MzsConverter converter, BinaryRepository binaryStatusRepository) { + DeliveryRequestAugmenter augmenter, Msg2MzsConverter converter) { this.repository = repository; this.pipeline = pipeline; this.appClient = appClient; this.augmenter = augmenter; this.converter = converter; - this.binaryStatusRepository = binaryStatusRepository; } @Override @@ -65,7 +62,7 @@ public class MzsService implements App2MzsPortType { var future = supplyAsync(() -> augmenter.augment(deliveryRequest)) .thenApply(this::process) - .thenApply(status -> converter.convert(status, binaryStatusRepository.get(responseID))); + .thenApply(status -> converter.convert(status, repository.retrieveBinaryResponse(responseID))); try { return future.get(TIMEOUT_FOR_ANWSER, TimeUnit.SECONDS); @@ -89,11 +86,11 @@ public class MzsService implements App2MzsPortType { var appDeliveryID = deliveryRequest.getMetaData().getAppDeliveryID(); logger.info("Receive request with appDeliveryID = {}.", appDeliveryID); - repository.add(deliveryRequest); + repository.store(deliveryRequest); pipeline.processRequest(appDeliveryID); var statusId = RequestStatusResponse.getResponseID(appDeliveryID); - var response = repository.getResponse(statusId) + var response = repository.retrieveResponse(statusId) .orElseThrow(() -> moaZSException("Could not get a response for AppDeliveryID=%s.", appDeliveryID)); return (DeliveryRequestStatusType) response.getResponse(); } -- cgit v1.2.3