You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2018/04/09 19:43:03 UTC

[GitHub] myrle-krantz closed pull request #10: Adding Group service to demo-server

myrle-krantz closed pull request #10: Adding Group service to demo-server
URL: https://github.com/apache/fineract-cn-demo-server/pull/10
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/build.gradle b/build.gradle
index d1db301..38d00e9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -34,6 +34,7 @@ ext.versions = [
         mifosreporting          : '0.1.0-BUILD-SNAPSHOT',
         kuelapcheques           : '0.1.0-BUILD-SNAPSHOT',
         mifospayroll            : '0.1.0-BUILD-SNAPSHOT',
+        mifosgroup              : '0.1.0-BUILD-SNAPSHOT',
         frameworkapi            : '0.1.0-BUILD-SNAPSHOT',
         frameworklang           : '0.1.0-BUILD-SNAPSHOT',
         frameworktest           : '0.1.0-BUILD-SNAPSHOT',
@@ -90,6 +91,7 @@ dependencies {
             [group: 'org.apache.fineract.cn.reporting', name: 'api', version: versions.mifosreporting],
             [group: 'org.apache.fineract.cn.cheques', name: 'api', version: versions.kuelapcheques],
             [group: 'org.apache.fineract.cn.payroll', name: 'api', version: versions.mifospayroll],
+            [group: 'org.apache.fineract.cn.group', name: 'api', version: versions.mifosgroup],
 
             [group: 'org.apache.fineract.cn.anubis', name: 'api', version: versions.frameworkanubis],
             [group: 'org.apache.fineract.cn.anubis', name: 'test', version: versions.frameworkanubis],
@@ -122,4 +124,4 @@ license {
         yml = 'SCRIPT_STYLE'
         yaml = 'SCRIPT_STYLE'
     }
-}
+}
\ No newline at end of file
diff --git a/src/main/java/io/mifos/dev/ServiceRunner.java b/src/main/java/io/mifos/dev/ServiceRunner.java
index 59863dd..b4a86d8 100644
--- a/src/main/java/io/mifos/dev/ServiceRunner.java
+++ b/src/main/java/io/mifos/dev/ServiceRunner.java
@@ -44,6 +44,7 @@
 import io.mifos.customer.api.v1.CustomerEventConstants;
 import io.mifos.customer.api.v1.client.CustomerManager;
 import io.mifos.deposit.api.v1.client.DepositAccountManager;
+import io.mifos.group.api.v1.client.GroupManager;
 import io.mifos.identity.api.v1.client.IdentityManager;
 import io.mifos.identity.api.v1.domain.*;
 import io.mifos.identity.api.v1.events.ApplicationPermissionEvent;
@@ -109,6 +110,7 @@
   private static Microservice<ReportManager> reportManager;
   private static Microservice<ChequeManager> chequeManager;
   private static Microservice<PayrollManager> payrollManager;
+  private static Microservice<GroupManager> groupManager;
 
 
   private static DB embeddedMariaDb;
@@ -174,9 +176,9 @@ public void before() throws Exception
       EmbeddedCassandraServerHelper.startEmbeddedCassandra(TimeUnit.SECONDS.toMillis(30L));
       // start embedded MariaDB
       ServiceRunner.embeddedMariaDb = DB.newEmbeddedDB(
-          DBConfigurationBuilder.newBuilder()
-              .setPort(3306)
-              .build()
+              DBConfigurationBuilder.newBuilder()
+                      .setPort(3306)
+                      .build()
       );
       ServiceRunner.embeddedMariaDb.start();
     }
@@ -234,10 +236,14 @@ public void before() throws Exception
 
     ServiceRunner.payrollManager = new Microservice<>(PayrollManager.class, "payroll", "0.1.0-BUILD-SNAPSHOT", ServiceRunner.INTEGRATION_TEST_ENVIRONMENT);
     startService(generalProperties, ServiceRunner.payrollManager);
+
+    ServiceRunner.groupManager = new Microservice<>(GroupManager.class, "group", "0.1.0-BUILD-SNAPSHOT", ServiceRunner.INTEGRATION_TEST_ENVIRONMENT);
+    startService(generalProperties, ServiceRunner.groupManager);
   }
 
   @After
   public void tearDown() throws Exception {
+    ServiceRunner.groupManager.kill();
     ServiceRunner.payrollManager.kill();
     ServiceRunner.chequeManager.kill();
     ServiceRunner.reportManager.kill();
@@ -279,6 +285,7 @@ public void startDevServer() throws InterruptedException, IOException, ArtifactR
     System.out.println("Reporting Service: " + ServiceRunner.reportManager.getProcessEnvironment().serverURI());
     System.out.println("Cheque Service: " + ServiceRunner.chequeManager.getProcessEnvironment().serverURI());
     System.out.println("Payroll Service: " + ServiceRunner.payrollManager.getProcessEnvironment().serverURI());
+    System.out.println("Group Service: " + ServiceRunner.groupManager.getProcessEnvironment().serverURI());
 
     boolean run = true;
 
@@ -304,7 +311,7 @@ private void startService(ExtraProperties properties, Microservice microservice)
 
   private void migrateServices() {
     final AuthenticationResponse authenticationResponse =
-        ServiceRunner.provisionerService.api().authenticate(ServiceRunner.CLIENT_ID, ApiConstants.SYSTEM_SU, "oS/0IiAME/2unkN1momDrhAdNKOhGykYFH/mJN20");
+            ServiceRunner.provisionerService.api().authenticate(ServiceRunner.CLIENT_ID, ApiConstants.SYSTEM_SU, "oS/0IiAME/2unkN1momDrhAdNKOhGykYFH/mJN20");
 
     try (final AutoSeshat ignored = new AutoSeshat(authenticationResponse.getToken())) {
       final List<Tenant> tenants = ServiceRunner.provisionerService.api().getTenants();
@@ -328,7 +335,7 @@ private void migrateServices() {
 
   private void provisionAppsViaSeshat() throws InterruptedException, IOException {
     final AuthenticationResponse authenticationResponse =
-        ServiceRunner.provisionerService.api().authenticate(ServiceRunner.CLIENT_ID, ApiConstants.SYSTEM_SU, "oS/0IiAME/2unkN1momDrhAdNKOhGykYFH/mJN20");
+            ServiceRunner.provisionerService.api().authenticate(ServiceRunner.CLIENT_ID, ApiConstants.SYSTEM_SU, "oS/0IiAME/2unkN1momDrhAdNKOhGykYFH/mJN20");
 
     final List<Application> applicationsToCreate = Arrays.asList(
             ApplicationBuilder.create(ServiceRunner.identityManager.name(), ServiceRunner.identityManager.uri()),
@@ -341,16 +348,18 @@ private void provisionAppsViaSeshat() throws InterruptedException, IOException {
             ApplicationBuilder.create(ServiceRunner.tellerManager.name(), ServiceRunner.tellerManager.uri()),
             ApplicationBuilder.create(ServiceRunner.reportManager.name(), ServiceRunner.reportManager.uri()),
             ApplicationBuilder.create(ServiceRunner.chequeManager.name(), ServiceRunner.chequeManager.uri()),
-            ApplicationBuilder.create(ServiceRunner.payrollManager.name(), ServiceRunner.payrollManager.uri())
+            ApplicationBuilder.create(ServiceRunner.payrollManager.name(), ServiceRunner.payrollManager.uri()),
+            ApplicationBuilder.create(ServiceRunner.groupManager.name(), ServiceRunner.groupManager.uri())
     );
 
+
     final List<Tenant> tenantsToCreate = Arrays.asList(
-        TenantBuilder.create(ServiceRunner.provisionerService.getProcessEnvironment(), "playground", "A place to mess around and have fun", "playground")
-        //TenantBuilder.create(ServiceRunner.provisionerService.getProcessEnvironment(), "demo-cccu", "Demo for CCCU", "demo_cccu"),
-        //TenantBuilder.create(ServiceRunner.provisionerService.getProcessEnvironment(), "SKCUKNS1", "St Kitts Cooperative Credit Union", "SKCUKNS1"),
-        //TenantBuilder.create(ServiceRunner.provisionerService.getProcessEnvironment(), "PCCUKNS1", "Police Cooperative Credit Union", "PCCUKNS1"),
-        //TenantBuilder.create(ServiceRunner.provisionerService.getProcessEnvironment(), "FCCUKNS1", "FND Cooperative Credit Union", "FCCUKNS1"),
-        //TenantBuilder.create(ServiceRunner.provisionerService.getProcessEnvironment(), "NCCUKNN1", "Nevis Cooperative Credit Union", "NCCUKNN1")
+            TenantBuilder.create(ServiceRunner.provisionerService.getProcessEnvironment(), "playground", "A place to mess around and have fun", "playground")
+            //TenantBuilder.create(ServiceRunner.provisionerService.getProcessEnvironment(), "demo-cccu", "Demo for CCCU", "demo_cccu"),
+            //TenantBuilder.create(ServiceRunner.provisionerService.getProcessEnvironment(), "SKCUKNS1", "St Kitts Cooperative Credit Union", "SKCUKNS1"),
+            //TenantBuilder.create(ServiceRunner.provisionerService.getProcessEnvironment(), "PCCUKNS1", "Police Cooperative Credit Union", "PCCUKNS1"),
+            //TenantBuilder.create(ServiceRunner.provisionerService.getProcessEnvironment(), "FCCUKNS1", "FND Cooperative Credit Union", "FCCUKNS1"),
+            //TenantBuilder.create(ServiceRunner.provisionerService.getProcessEnvironment(), "NCCUKNN1", "Nevis Cooperative Credit Union", "NCCUKNN1")
     );
 
     try (final AutoSeshat ignored = new AutoSeshat(authenticationResponse.getToken())) {
@@ -444,6 +453,8 @@ private String provisionAppsViaSeshatForTenant(final Tenant tenant) throws Inter
 
       provisionApp(tenant, ServiceRunner.payrollManager, io.mifos.payroll.api.v1.EventConstants.INITIALIZE);
 
+      provisionApp(tenant, ServiceRunner.groupManager, io.mifos.group.api.v1.EventConstants.INITIALIZE);
+
       final UserWithPassword orgAdminUserPassword = createOrgAdminRoleAndUser(tenantAdminPassword.getAdminPassword());
 
       createChartOfAccounts(orgAdminUserPassword);
@@ -591,15 +602,15 @@ private Role defineOrgAdministratorRole() {
     final Role role = new Role();
     role.setIdentifier("orgadmin");
     role.setPermissions(
-        Arrays.asList(
-            employeeAllPermission,
-            officeAllPermission,
-            userAllPermission,
-            roleAllPermission,
-            selfManagementPermission,
-            ledgerManagementPermission,
-            accountManagementPermission
-        )
+            Arrays.asList(
+                    employeeAllPermission,
+                    officeAllPermission,
+                    userAllPermission,
+                    roleAllPermission,
+                    selfManagementPermission,
+                    ledgerManagementPermission,
+                    accountManagementPermission
+            )
     );
 
     return role;
@@ -647,4 +658,4 @@ private void setAdditionalProperties(final ExtraProperties properties) {
       properties.setProperty(MariaDBConstants.MARIADB_PASSWORD_PROP, this.environment.getProperty(ServiceRunner.CUSTOM_PROP_PREFIX + MariaDBConstants.MARIADB_PASSWORD_PROP));
     }
   }
-}
+}
\ No newline at end of file
diff --git a/src/main/java/io/mifos/dev/listener/GroupListener.java b/src/main/java/io/mifos/dev/listener/GroupListener.java
new file mode 100644
index 0000000..9f7e136
--- /dev/null
+++ b/src/main/java/io/mifos/dev/listener/GroupListener.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package io.mifos.dev.listener;
+
+import io.mifos.group.api.v1.EventConstants;
+import io.mifos.core.lang.config.TenantHeaderFilter;
+import io.mifos.core.test.listener.EventRecorder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jms.annotation.JmsListener;
+import org.springframework.messaging.handler.annotation.Header;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Myrle Krantz
+ */
+@SuppressWarnings("unused")
+@Component
+public class GroupListener {
+
+    private final EventRecorder eventRecorder;
+
+    @Autowired
+    public GroupListener(final EventRecorder eventRecorder) {
+        this.eventRecorder = eventRecorder;
+    }
+
+    @JmsListener(
+            destination = EventConstants.DESTINATION,
+            selector = EventConstants.SELECTOR_INITIALIZE,
+            subscription = EventConstants.DESTINATION
+    )
+    public void onInitialization(@Header(TenantHeaderFilter.TENANT_HEADER) final String tenant,
+                                 final String payload) {
+        this.eventRecorder.event(tenant, EventConstants.INITIALIZE, payload, String.class);
+    }
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services