-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
steliomo
committed
Nov 20, 2023
1 parent
fd24fc5
commit 8f3907d
Showing
17 changed files
with
303 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
grocery-core/src/main/java/mz/co/grocery/core/application/pos/out/SaleListner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* | ||
*/ | ||
package mz.co.grocery.core.application.pos.out; | ||
|
||
import mz.co.grocery.core.domain.sale.Sale; | ||
import mz.co.msaude.boot.frameworks.exception.BusinessException; | ||
import mz.co.msaude.boot.frameworks.model.UserContext; | ||
|
||
/** | ||
* @author Stélio Moiane | ||
* | ||
*/ | ||
public interface SaleListner { | ||
|
||
Sale send(UserContext context, Sale sale) throws BusinessException; | ||
} |
21 changes: 21 additions & 0 deletions
21
grocery-core/src/main/java/mz/co/grocery/core/application/pos/out/SaleNotifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* | ||
*/ | ||
package mz.co.grocery.core.application.pos.out; | ||
|
||
import mz.co.grocery.core.domain.sale.Sale; | ||
import mz.co.msaude.boot.frameworks.exception.BusinessException; | ||
import mz.co.msaude.boot.frameworks.model.UserContext; | ||
|
||
/** | ||
* @author Stélio Moiane | ||
* | ||
*/ | ||
public interface SaleNotifier { | ||
|
||
void registListner(SaleListner listner); | ||
|
||
void removeListner(SaleListner listner); | ||
|
||
Sale notify(UserContext context, Sale sale) throws BusinessException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...-persistence/src/main/java/mz/co/grocery/persistence/pos/adapter/SaleNotifierAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* | ||
*/ | ||
package mz.co.grocery.persistence.pos.adapter; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import mz.co.grocery.core.application.pos.out.SaleListner; | ||
import mz.co.grocery.core.application.pos.out.SaleNotifier; | ||
import mz.co.grocery.core.common.PersistenceAdapter; | ||
import mz.co.grocery.core.domain.sale.Sale; | ||
import mz.co.msaude.boot.frameworks.exception.BusinessException; | ||
import mz.co.msaude.boot.frameworks.model.UserContext; | ||
|
||
/** | ||
* @author Stélio Moiane | ||
* | ||
*/ | ||
|
||
@PersistenceAdapter | ||
public class SaleNotifierAdapter implements SaleNotifier { | ||
|
||
private Set<SaleListner> listners; | ||
|
||
public SaleNotifierAdapter() { | ||
this.listners = new HashSet<>(); | ||
} | ||
|
||
@Override | ||
public void registListner(final SaleListner listner) { | ||
this.listners.add(listner); | ||
} | ||
|
||
@Override | ||
public void removeListner(final SaleListner listner) { | ||
this.listners.remove(listner); | ||
} | ||
|
||
@Override | ||
public Sale notify(final UserContext context, Sale sale) throws BusinessException { | ||
if (this.listners.isEmpty()) { | ||
throw new BusinessException("regist.listners"); | ||
} | ||
|
||
for (final SaleListner listner : this.listners) { | ||
sale = listner.send(context, sale); | ||
} | ||
|
||
return sale; | ||
} | ||
} |
Oops, something went wrong.