diff --git a/src/main/java/nl/han/aim/asd/veilveilig/core/application/adapters/AgentManagerAdapter.java b/src/main/java/nl/han/aim/asd/veilveilig/core/application/adapters/AgentManagerAdapter.java index f00593fa19dbd2a1ea55d6a528df3a230d9acac8..b22cbc8bde7f68649204998dc87cc804c9a23ffb 100644 --- a/src/main/java/nl/han/aim/asd/veilveilig/core/application/adapters/AgentManagerAdapter.java +++ b/src/main/java/nl/han/aim/asd/veilveilig/core/application/adapters/AgentManagerAdapter.java @@ -14,6 +14,7 @@ import nl.han.aim.asd.veilveilig.modules.infrastructure.networkmodule.IPeer; * * @author Marco Noppen * @author Tobias Leijs + * @author Nathan Wijnberg * @since 26-4-2023 */ public class AgentManagerAdapter implements IAgentManagerPort { @@ -21,7 +22,6 @@ public class AgentManagerAdapter implements IAgentManagerPort { @Inject IAgentManager agentManager; - @Override public void setupCoordinator(AuctionDTO auctionDTO) { agentManager.setupCoordinator(auctionDTO); @@ -31,4 +31,34 @@ public class AgentManagerAdapter implements IAgentManagerPort { public void addSubscriber(IPeer subscriber, LotDTO lotDTO) { agentManager.addSubscriber(subscriber, lotDTO); } + + /** + * The adapter method for the port to shut an auction down. + * + * @param auctionId the unique id of the auction the peer is trying to shut down. + */ + @Override + public void shutdownAuction(String auctionId) { + agentManager.shutdownAuction(auctionId); + } + + /** + * The adapter method for the port to pause an auction. + * + * @param auctionId the unique id of the auction the peer is trying to pause. + */ + @Override + public void pauseAuction(String auctionId) { + agentManager.pauseAuction(auctionId); + } + + /** + * The adapter method for the port to execute an auction. + * + * @param auctionId the unique id of the auction the peer is trying to execute. + */ + @Override + public void executeAuction(String auctionId) { + agentManager.executeAuction(auctionId); + } } diff --git a/src/main/java/nl/han/aim/asd/veilveilig/core/application/dependencies/IAgentManager.java b/src/main/java/nl/han/aim/asd/veilveilig/core/application/dependencies/IAgentManager.java index e1757e9c598add1b0072fd8003f18edf00bc8c44..bb3447e5461d73a3c60f294cb2ad4cae1c0b0543 100644 --- a/src/main/java/nl/han/aim/asd/veilveilig/core/application/dependencies/IAgentManager.java +++ b/src/main/java/nl/han/aim/asd/veilveilig/core/application/dependencies/IAgentManager.java @@ -7,5 +7,26 @@ import nl.han.aim.asd.veilveilig.modules.infrastructure.networkmodule.IPeer; public interface IAgentManager { void setupCoordinator(AuctionDTO auctionDTO); void addSubscriber(IPeer subscriber, LotDTO lotDTO); + + /** + * The method for the adapter to shut an auction down. + * + * @param auctionId the unique id of the auction the peer is trying to shut down. + */ + void shutdownAuction(String auctionId); + + /** + * The method for the adapter to execute an auction. + * + * @param auctionId the unique id of the auction the peer is trying to execute. + */ + void executeAuction(String auctionId); + + /** + * The method for the adapter to pause an auction. + * + * @param auctionId the unique id of the auction the peer is trying to pause. + */ + void pauseAuction(String auctionId); } diff --git a/src/main/java/nl/han/aim/asd/veilveilig/core/application/ports/IAgentManagerPort.java b/src/main/java/nl/han/aim/asd/veilveilig/core/application/ports/IAgentManagerPort.java index 51058a1e622a8709d3203fb85fc6de1923ac235f..81f71705fa1da7841b7f813357bf991add71a633 100644 --- a/src/main/java/nl/han/aim/asd/veilveilig/core/application/ports/IAgentManagerPort.java +++ b/src/main/java/nl/han/aim/asd/veilveilig/core/application/ports/IAgentManagerPort.java @@ -8,5 +8,26 @@ import nl.han.aim.asd.veilveilig.modules.infrastructure.networkmodule.IPeer; public interface IAgentManagerPort { void setupCoordinator(AuctionDTO auctionDTO); void addSubscriber(IPeer subscriber, LotDTO lotDTO); + + /** + * The port method for the service to shut an auction down. + * + * @param auctionId the unique id of the auction the peer is trying to shut down. + */ + void shutdownAuction(String auctionId); + + /** + * The port method for the service to pause an auction. + * + * @param auctionId the unique id of the auction the peer is trying to pause. + */ + void pauseAuction(String auctionId); + + /** + * The port method for the service to execute an auction. + * + * @param auctionId the unique id of the auction the peer is trying to execute. + */ + void executeAuction(String auctionId); } diff --git a/src/main/java/nl/han/aim/asd/veilveilig/core/application/usecases/AuctionService.java b/src/main/java/nl/han/aim/asd/veilveilig/core/application/usecases/AuctionService.java index 854d721a529a4bee8968d361b12c39189f389d17..9cd795ae10be0ad5f6457ba73c9b872c398d9ab7 100644 --- a/src/main/java/nl/han/aim/asd/veilveilig/core/application/usecases/AuctionService.java +++ b/src/main/java/nl/han/aim/asd/veilveilig/core/application/usecases/AuctionService.java @@ -3,6 +3,7 @@ package nl.han.aim.asd.veilveilig.core.application.usecases; import com.google.inject.Inject; import nl.han.aim.asd.veilveilig.core.application.adapters.NetworkAdapter; import nl.han.aim.asd.veilveilig.core.application.adapters.StorageAdapter; +import nl.han.aim.asd.veilveilig.core.application.ports.IAgentManagerPort; import nl.han.aim.asd.veilveilig.core.application.ports.INetworkPort; import nl.han.aim.asd.veilveilig.core.application.ports.IStoragePort; import nl.han.aim.asd.veilveilig.models.AuctionDTO; @@ -11,12 +12,23 @@ import nl.han.aim.asd.veilveilig.modules.infrastructure.networkmodule.Peer; import java.util.List; +/** + * The {@link AuctionService} interface is a port for the {@link IAgentManagerPort}. + * <p> + * This interface can be called by the frontend/UI to manage the Auction (coordinator) functionalities. + * + * @author Nathan Wijnberg + * @author Tobias Leijs + * @since 16-5-2023 + */ public class AuctionService implements IAuctionService { @Inject INetworkPort networkPort; @Inject IStoragePort storagePort; + @Inject + IAgentManagerPort agentManagementPort; @Override @@ -27,4 +39,35 @@ public class AuctionService implements IAuctionService { // maybe create a new coordinator or something //TODO } + + /** + * The service method for the frontend to shut an auction down. + * + * @param auctionId the unique id of the auction the peer is trying to shut down. + */ + @Override + public void shutdownAuction(String auctionId) { + agentManagementPort.shutdownAuction(auctionId); + } + + /** + * The service method for the frontend to pause an auction. + * + * @param auctionId the unique id of the auction the peer is trying to pause. + */ + @Override + public void pauseAuction(String auctionId) { + agentManagementPort.pauseAuction(auctionId); + } + + /** + * The service method for the frontend to execute a auction. + * + * @param auctionId the unique id of the auction the peer is trying to execute. + */ + @Override + public void executeAuction(String auctionId) { + agentManagementPort.executeAuction(auctionId); + } + } diff --git a/src/main/java/nl/han/aim/asd/veilveilig/core/application/usecases/IAuctionService.java b/src/main/java/nl/han/aim/asd/veilveilig/core/application/usecases/IAuctionService.java index 075365750049196dbc46e57ed5687383a7b086e3..4e015727792187e6fdad035a44dc9436b9aeb155 100644 --- a/src/main/java/nl/han/aim/asd/veilveilig/core/application/usecases/IAuctionService.java +++ b/src/main/java/nl/han/aim/asd/veilveilig/core/application/usecases/IAuctionService.java @@ -8,4 +8,10 @@ import java.util.List; public interface IAuctionService { void createAuction(AuctionDTO auctionDTO, List<LotDTO> lotDTOList); + + void shutdownAuction(String auctionId); + + void executeAuction(String auctionId); + + void pauseAuction(String auctionId); }