Skip to content

Commit

Permalink
Adding Group service to demo-server
Browse files Browse the repository at this point in the history
  • Loading branch information
kengneruphine authored and myrle-krantz committed Apr 9, 2018
1 parent 9de98f2 commit bbbdfbc
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 19 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -122,4 +124,4 @@ license {
yml = 'SCRIPT_STYLE'
yaml = 'SCRIPT_STYLE'
}
}
}
47 changes: 29 additions & 18 deletions src/main/java/io/mifos/dev/ServiceRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -109,6 +110,7 @@ public class ServiceRunner {
private static Microservice<ReportManager> reportManager;
private static Microservice<ChequeManager> chequeManager;
private static Microservice<PayrollManager> payrollManager;
private static Microservice<GroupManager> groupManager;


private static DB embeddedMariaDb;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -331,26 +338,28 @@ private void provisionAppsViaSeshat() throws InterruptedException, IOException {
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()),
ApplicationBuilder.create(ServiceRunner.rhythmManager.name(), ServiceRunner.rhythmManager.uri()),
ApplicationBuilder.create(ServiceRunner.organizationManager.name(), ServiceRunner.organizationManager.uri()),
ApplicationBuilder.create(ServiceRunner.customerManager.name(), ServiceRunner.customerManager.uri()),
ApplicationBuilder.create(ServiceRunner.ledgerManager.name(), ServiceRunner.ledgerManager.uri()),
ApplicationBuilder.create(ServiceRunner.portfolioManager.name(), ServiceRunner.portfolioManager.uri()),
ApplicationBuilder.create(ServiceRunner.depositAccountManager.name(), ServiceRunner.depositAccountManager.uri()),
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.identityManager.name(), ServiceRunner.identityManager.uri()),
ApplicationBuilder.create(ServiceRunner.rhythmManager.name(), ServiceRunner.rhythmManager.uri()),
ApplicationBuilder.create(ServiceRunner.organizationManager.name(), ServiceRunner.organizationManager.uri()),
ApplicationBuilder.create(ServiceRunner.customerManager.name(), ServiceRunner.customerManager.uri()),
ApplicationBuilder.create(ServiceRunner.ledgerManager.name(), ServiceRunner.ledgerManager.uri()),
ApplicationBuilder.create(ServiceRunner.portfolioManager.name(), ServiceRunner.portfolioManager.uri()),
ApplicationBuilder.create(ServiceRunner.depositAccountManager.name(), ServiceRunner.depositAccountManager.uri()),
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.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())) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
}
}
}
51 changes: 51 additions & 0 deletions src/main/java/io/mifos/dev/listener/GroupListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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);
}
}

0 comments on commit bbbdfbc

Please sign in to comment.