From commits-return-1644-archive-asf-public=cust-asf.ponee.io@fineract.apache.org Mon Jan 22 16:47:07 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 5D2721807A1 for ; Mon, 22 Jan 2018 16:47:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 4B4F2160C55; Mon, 22 Jan 2018 15:47:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 63FAE160C56 for ; Mon, 22 Jan 2018 16:47:05 +0100 (CET) Received: (qmail 89213 invoked by uid 500); 22 Jan 2018 15:47:04 -0000 Mailing-List: contact commits-help@fineract.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@fineract.apache.org Delivered-To: mailing list commits@fineract.apache.org Received: (qmail 89121 invoked by uid 99); 22 Jan 2018 15:47:04 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Jan 2018 15:47:04 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 97E1B82074; Mon, 22 Jan 2018 15:47:01 +0000 (UTC) Date: Mon, 22 Jan 2018 15:47:16 +0000 To: "commits@fineract.apache.org" Subject: [fineract-cn-customer] 15/46: added filtering for task based on command MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: myrle@apache.org In-Reply-To: <151663602123.6058.1093369368936783770@gitbox.apache.org> References: <151663602123.6058.1093369368936783770@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: fineract-cn-customer X-Git-Refname: refs/heads/develop X-Git-Reftype: branch X-Git-Rev: f078702d45124811a6e8dbf280de8305224adcc5 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20180122154701.97E1B82074@gitbox.apache.org> 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 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 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 myrle@apache.org.