This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-customer.git

commit f078702d45124811a6e8dbf280de8305224adcc5
Author: mgeiss <[email protected]>
AuthorDate: Wed Sep 6 13:53:09 2017 +0200

    added filtering for task based on command
---
 .../service/internal/command/handler/CustomerAggregate.java         | 6 +++---
 .../customer/service/internal/command/handler/TaskAggregate.java    | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git 
a/service/src/main/java/io/mifos/customer/service/internal/command/handler/CustomerAggregate.java
 
b/service/src/main/java/io/mifos/customer/service/internal/command/handler/CustomerAggregate.java
index 917b364..b41ddfb 100644
--- 
a/service/src/main/java/io/mifos/customer/service/internal/command/handler/CustomerAggregate.java
+++ 
b/service/src/main/java/io/mifos/customer/service/internal/command/handler/CustomerAggregate.java
@@ -231,7 +231,7 @@ public class CustomerAggregate {
   public String activateCustomer(final ActivateCustomerCommand 
activateCustomerCommand) {
     final CustomerEntity customerEntity = 
this.customerRepository.findByIdentifier(activateCustomerCommand.identifier());
 
-    if (this.taskAggregate.openTasksForCustomerExist(customerEntity)) {
+    if (this.taskAggregate.openTasksForCustomerExist(customerEntity, 
Command.Action.ACTIVATE.name())) {
       throw ServiceException.conflict("Open Tasks for customer {0} exists.", 
activateCustomerCommand.identifier());
     }
 
@@ -274,7 +274,7 @@ public class CustomerAggregate {
   public String unlockCustomer(final UnlockCustomerCommand 
unlockCustomerCommand) {
     final CustomerEntity customerEntity = 
this.customerRepository.findByIdentifier(unlockCustomerCommand.identifier());
 
-    if (this.taskAggregate.openTasksForCustomerExist(customerEntity)) {
+    if (this.taskAggregate.openTasksForCustomerExist(customerEntity, 
Command.Action.UNLOCK.name())) {
       throw ServiceException.conflict("Open Tasks for customer {0} exists.", 
unlockCustomerCommand.identifier());
     }
 
@@ -317,7 +317,7 @@ public class CustomerAggregate {
   public String reopenCustomer(final ReopenCustomerCommand 
reopenCustomerCommand) {
     final CustomerEntity customerEntity = 
this.customerRepository.findByIdentifier(reopenCustomerCommand.identifier());
 
-    if (this.taskAggregate.openTasksForCustomerExist(customerEntity)) {
+    if (this.taskAggregate.openTasksForCustomerExist(customerEntity, 
Command.Action.REOPEN.name())) {
       throw ServiceException.conflict("Open Tasks for customer {0} exists.", 
reopenCustomerCommand.identifier());
     }
 
diff --git 
a/service/src/main/java/io/mifos/customer/service/internal/command/handler/TaskAggregate.java
 
b/service/src/main/java/io/mifos/customer/service/internal/command/handler/TaskAggregate.java
index 9a0417c..65a03d5 100644
--- 
a/service/src/main/java/io/mifos/customer/service/internal/command/handler/TaskAggregate.java
+++ 
b/service/src/main/java/io/mifos/customer/service/internal/command/handler/TaskAggregate.java
@@ -145,13 +145,14 @@ public class TaskAggregate {
   }
 
   @Transactional
-  public Boolean openTasksForCustomerExist(final CustomerEntity 
customerEntity) {
+  public Boolean openTasksForCustomerExist(final CustomerEntity 
customerEntity, final String command) {
     final List<TaskInstanceEntity> taskInstanceEntities = 
this.taskInstanceRepository.findByCustomer(customerEntity);
 
     //noinspection SimplifiableIfStatement
     if (taskInstanceEntities != null) {
       return taskInstanceEntities
           .stream()
+              .filter(taskInstanceEntity -> 
taskInstanceEntity.getTaskDefinition().getAssignedCommands().contains(command))
               .filter(taskInstanceEntity -> 
taskInstanceEntity.getTaskDefinition().isMandatory())
               .anyMatch(taskInstanceEntity -> 
taskInstanceEntity.getExecutedBy() == null);
     } else {

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to