fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-office] 04/05: added branches and employees to external references check
Date Mon, 22 Jan 2018 15:54:02 GMT
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-office.git

commit 6984777ab5bf9330cdbd28fa4a7aa6abeaa3e54d
Author: mgeiss <mgeiss@mifos.org>
AuthorDate: Tue Sep 19 07:16:13 2017 +0200

    added branches and employees to external references check
---
 component-test/src/main/java/io/mifos/office/TestOffice.java |  6 ++++++
 .../java/io/mifos/office/internal/service/OfficeService.java | 12 ++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/component-test/src/main/java/io/mifos/office/TestOffice.java b/component-test/src/main/java/io/mifos/office/TestOffice.java
index 8e8ad1d..fba3101 100644
--- a/component-test/src/main/java/io/mifos/office/TestOffice.java
+++ b/component-test/src/main/java/io/mifos/office/TestOffice.java
@@ -329,6 +329,9 @@ public class TestOffice {
     this.organizationManager.addBranch(parent.getIdentifier(), branch);
     this.eventRecorder.wait(EventConstants.OPERATION_POST_OFFICE, branch.getIdentifier());
 
+    final Office fetchedParent = this.organizationManager.findOfficeByIdentifier(parent.getIdentifier());
+    Assert.assertTrue(fetchedParent.getExternalReferences());
+
     this.organizationManager.deleteOffice(parent.getIdentifier());
   }
 
@@ -343,6 +346,9 @@ public class TestOffice {
     this.organizationManager.createEmployee(employee);
     this.eventRecorder.wait(EventConstants.OPERATION_POST_EMPLOYEE, employee.getIdentifier());
 
+    final Office fetchedOffice = this.organizationManager.findOfficeByIdentifier(office.getIdentifier());
+    Assert.assertTrue(fetchedOffice.getExternalReferences());
+
     this.organizationManager.deleteOffice(office.getIdentifier());
   }
 
diff --git a/service/src/main/java/io/mifos/office/internal/service/OfficeService.java b/service/src/main/java/io/mifos/office/internal/service/OfficeService.java
index aa36d15..4db1ae9 100644
--- a/service/src/main/java/io/mifos/office/internal/service/OfficeService.java
+++ b/service/src/main/java/io/mifos/office/internal/service/OfficeService.java
@@ -112,7 +112,11 @@ public class OfficeService {
         final Optional<AddressEntity> addressEntityOptional = this.addressRepository.findByOffice(officeEntityOptional.get());
         addressEntityOptional.ifPresent(addressEntity -> office.setAddress(AddressMapper.map(addressEntity)));
 
-        office.setExternalReferences(this.hasExternalReferences(office.getIdentifier()));
+        office.setExternalReferences(
+            this.branchExists(office.getIdentifier())
+                || this.hasEmployees(office.getIdentifier())
+                || this.hasExternalReferences(office.getIdentifier())
+        );
       });
 
       return officeOptional;
@@ -158,7 +162,11 @@ public class OfficeService {
       final Optional<AddressEntity> addressEntityOptional = this.addressRepository.findByOffice(officeEntity);
       addressEntityOptional.ifPresent(addressEntity -> office.setAddress(AddressMapper.map(addressEntity)));
 
-      office.setExternalReferences(this.hasExternalReferences(office.getIdentifier()));
+      office.setExternalReferences(
+          this.branchExists(office.getIdentifier())
+              || this.hasEmployees(office.getIdentifier())
+              || this.hasExternalReferences(office.getIdentifier())
+      );
     });
     return offices;
   }

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

Mime
View raw message