Addressing SMS Review Comments

This commit is contained in:
Nazeer Hussain Shaik
2016-11-14 17:50:37 +05:30
parent 911cab85b0
commit 2d1f6ab391
12 changed files with 326 additions and 574 deletions
+151 -5
View File
@@ -21159,12 +21159,15 @@ Request Body:
<a id="smscampaigns_retrieve" name="smscampaigns_retrieve" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h4>Retrieve a Share Product</h4>
<h4>Retrieve a SMS Campaign</h4>
<p>Example Requests: </p>
<div class=apiClick>smscampaigns/1</div>
<br><br>
<div class=apiClick>smscampaigns/1?template=true</div>
<br><br>
<div class=apiClick>smscampaigns/template</div>
</div>
<div class="method-example">
<code class="method-declaration">GET https://Domain Name/api/v1/smscampaigns/1</code>
<code class="method-response">
@@ -21197,7 +21200,150 @@ Request Body:
"recurrenceStartDate":"22 Jan 2016",
"recurrence": "YEARLY"
}
</code>
<B>smscampaigns/1?template=true</B>
{
"id": 1,
"campaignName": "Savings Deposit Campaign"
"campaignType": "SMS",
"triggerType": 3,
"providerId": 2,
"runReportId": 180,
"reportName" : "Savings Deposit",
"paramValue": "{"officeId":1,"loanOfficerId":-1,"transactionId":1,"reportName":"Savings Deposit"}",
"message": "Hello {fullName} your account is credited with {depositAmount} on {transactionDate}",
"status" : { "id":"","code":"","value":""}
"smsProviderOptions": [{
"id": 1,
"tenantId": "1",
"phoneNo": "+XXXXXXXXXX",
"providerName": "Twilio SMS Provider",
"providerDescription": "Twilio, just for testing"
}],
"businessRulesOptions": [
{
"reportId": 166,
"reportName": "Active Clients",
"reportType": "SMS",
"reportSubType": "NonTriggered",
"reportDescription": "All clients with the status ‘Active’",
"reportParamName": {
"Office": "OfficeIdSelectOne",
"Loan Officer": "loanOfficerIdSelectAll"
}
}
],
"triggerTypeOptions": [
{"id": 1,"code": "triggerType.direct", "value": "Direct"},
{"id": 2, "code": "triggerType.schedule","value": "Scheduled"},
{"id": 3,"code": "triggerType.triggered","value": "Triggered"}
],
"months": [
{ "id": 1, "code": "JANUARY", "value": "JANUARY" },
{ "id": 2, "code": "FEBRUARY", "value": "FEBRUARY" },
{ "id": 3, "code": "MARCH", "value": "MARCH" },
{ "id": 4, "code": "APRIL", "value": "APRIL" },
{ "id": 5, "code": "MAY", "value": "MAY" },
{ "id": 6, "code": "JUNE", "value": "JUNE" },
{ "id": 7, "code": "JULY", "value": "JULY" },
{ "id": 8, "code": "AUGUST", "value": "AUGUST" },
{ "id": 9, "code": "SEPTEMBER", "value": "SEPTEMBER"},
{ "id": 10, "code": "OCTOBER", "value": "OCTOBER"},
{ "id": 11, "code": "NOVEMBER", "value": "NOVEMBER" }
],
"weekDays": [
{ "id": 1, "code": "calendarWeekDaysType.monday", "value": "MO" },
{ "id": 2, "code": "calendarWeekDaysType.tuesday", "value": "TU" },
{ "id": 3, "code": "calendarWeekDaysType.wednesday", "value": "WE" },
{ "id": 4, "code": "calendarWeekDaysType.thursday", "value": "TH"},
{ "id": 5, "code": "calendarWeekDaysType.friday", "value": "FR" },
{ "id": 6, "code": "calendarWeekDaysType.saturday", "value": "SA" },
{ "id": 7, "code": "calendarWeekDaysType.sunday", "value": "SU" }
],
"frequencyTypeOptions": [
{ "id": 1, "code": "calendarFrequencyType.daily", "value": "DAILY" },
{ "id": 2, "code": "calendarFrequencyType.weekly", "value": "WEEKLY"},
{ "id": 3, "code": "calendarFrequencyType.monthly", "value": "MONTHLY"},
{ "id": 4, "code": "calendarFrequencyType.yearly", "value": "YEARLY" }
],
"periodFrequencyOptions": [
{ "id": 0, "code": "periodFrequencyType.days", "value": "DAYS" },
{ "id": 1, "code": "periodFrequencyType.weeks", "value": "WEEKS" },
{ "id": 2, "code": "periodFrequencyType.months", "value": "MONTHS" },
{ "id": 3, "code": "periodFrequencyType.years", "value": "YEARS" }
]
}
<B>smscampaigns/template</B>
{
"smsProviderOptions": [{
"id": 1,
"tenantId": "1",
"phoneNo": "+XXXXXXXXXX",
"providerName": "Twilio SMS Provider",
"providerDescription": "Twilio, just for testing"
}],
"businessRulesOptions": [
{
"reportId": 166,
"reportName": "Active Clients",
"reportType": "SMS",
"reportSubType": "NonTriggered",
"reportDescription": "All clients with the status ‘Active’",
"reportParamName": {
"Office": "OfficeIdSelectOne",
"Loan Officer": "loanOfficerIdSelectAll"
}
}
],
"triggerTypeOptions": [
{"id": 1,"code": "triggerType.direct", "value": "Direct"},
{"id": 2, "code": "triggerType.schedule","value": "Scheduled"},
{"id": 3,"code": "triggerType.triggered","value": "Triggered"}
],
"months": [
{ "id": 1, "code": "JANUARY", "value": "JANUARY" },
{ "id": 2, "code": "FEBRUARY", "value": "FEBRUARY" },
{ "id": 3, "code": "MARCH", "value": "MARCH" },
{ "id": 4, "code": "APRIL", "value": "APRIL" },
{ "id": 5, "code": "MAY", "value": "MAY" },
{ "id": 6, "code": "JUNE", "value": "JUNE" },
{ "id": 7, "code": "JULY", "value": "JULY" },
{ "id": 8, "code": "AUGUST", "value": "AUGUST" },
{ "id": 9, "code": "SEPTEMBER", "value": "SEPTEMBER"},
{ "id": 10, "code": "OCTOBER", "value": "OCTOBER"},
{ "id": 11, "code": "NOVEMBER", "value": "NOVEMBER" }
],
"weekDays": [
{ "id": 1, "code": "calendarWeekDaysType.monday", "value": "MO" },
{ "id": 2, "code": "calendarWeekDaysType.tuesday", "value": "TU" },
{ "id": 3, "code": "calendarWeekDaysType.wednesday", "value": "WE" },
{ "id": 4, "code": "calendarWeekDaysType.thursday", "value": "TH"},
{ "id": 5, "code": "calendarWeekDaysType.friday", "value": "FR" },
{ "id": 6, "code": "calendarWeekDaysType.saturday", "value": "SA" },
{ "id": 7, "code": "calendarWeekDaysType.sunday", "value": "SU" }
],
"frequencyTypeOptions": [
{ "id": 1, "code": "calendarFrequencyType.daily", "value": "DAILY" },
{ "id": 2, "code": "calendarFrequencyType.weekly", "value": "WEEKLY"},
{ "id": 3, "code": "calendarFrequencyType.monthly", "value": "MONTHLY"},
{ "id": 4, "code": "calendarFrequencyType.yearly", "value": "YEARLY" }
],
"periodFrequencyOptions": [
{ "id": 0, "code": "periodFrequencyType.days", "value": "DAYS" },
{ "id": 1, "code": "periodFrequencyType.weeks", "value": "WEEKS" },
{ "id": 2, "code": "periodFrequencyType.months", "value": "MONTHS" },
{ "id": 3, "code": "periodFrequencyType.years", "value": "YEARS" }
]
}
</code>
</div>
</div>
@@ -21279,7 +21425,7 @@ Request Body:
"status": {
"id": 300,
"code": "smsCampaignStatus.active",
"value": "Activated",
"value": "active",
},
"locale": "en",
"dateFormat": "dd MMMM yyyy",
@@ -21314,7 +21460,7 @@ Request Body:
"status": {
"id": 600,
"code": "smsCampaignStatus.closed",
"value": "Activated",
"value": "closed",
},
"locale": "en",
"dateFormat": "dd MMMM yyyy",
@@ -21350,7 +21496,7 @@ Request Body:
"status": {
"id": 300,
"code": "smsCampaignStatus.active",
"value": "Activated",
"value": "active",
},
"locale": "en",
"dateFormat": "dd MMMM yyyy",
@@ -2808,7 +2808,7 @@ public class CommandWrapperBuilder {
this.actionName = "CREATE";
this.entityName = "SMSCAMPAIGN";
this.entityId = null;
this.href = "/smscampaign";
this.href = "/smscampaigns";
return this;
}
@@ -2816,7 +2816,7 @@ public class CommandWrapperBuilder {
this.actionName = "UPDATE";
this.entityName = "SMSCAMPAIGN";
this.entityId = resourceId;
this.href = "/smscampaign/"+resourceId;
this.href = "/smscampaigns/"+resourceId;
return this;
}
@@ -2824,7 +2824,7 @@ public class CommandWrapperBuilder {
this.actionName = "ACTIVATE";
this.entityName = "SMSCAMPAIGN";
this.entityId = resourceId;
this.href = "/smscampaign/"+resourceId + "?command=activate";
this.href = "/smscampaigns/"+resourceId + "?command=activate";
return this;
}
@@ -2832,14 +2832,14 @@ public class CommandWrapperBuilder {
this.actionName = "CLOSE";
this.entityName = "SMSCAMPAIGN";
this.entityId = resourceId;
this.href = "/smscampaign/"+resourceId + "?command=close";
this.href = "/smscampaigns/"+resourceId + "?command=close";
return this;
}
public CommandWrapperBuilder reactivateSmsCampaign(final Long resourceId) {
this.actionName = "REACTIVATE";
this.entityName = "SMSCAMPAIGN";
this.entityId = resourceId;
this.href = "/smscampaign/"+resourceId + "?command=reactivate";
this.href = "/smscampaigns/"+resourceId + "?command=reactivate";
return this;
}
@@ -2847,7 +2847,7 @@ public class CommandWrapperBuilder {
this.actionName = "DELETE";
this.entityName = "SMSCAMPAIGN";
this.entityId = resourceId;
this.href = "/smscampaign/"+resourceId;
this.href = "/smscampaigns/"+resourceId;
return this;
}
}
@@ -20,8 +20,6 @@ package org.apache.fineract.infrastructure.campaigns.sms.constants;
public interface SmsCampaignConstants {
String SMS_CAMPAIGN_NAME = "sms";
String RESOURCE_NAME = "SMSCAMPAIGN";
String SMS_BRIDGE = "sms_bridge";
@@ -31,13 +29,4 @@ public interface SmsCampaignConstants {
String FINERACT_PLATFORM_TENANT_ID = "Fineract-Platform-TenantId";
String FINERACT_TENANT_APP_KEY = "Fineract-Tenant-App-Key";
//Supported Triggered Campaigns
String LOAN_REJECT = "Loan Rejected" ;
String LOAN_APPROVED = "Loan Approved" ;
String LOAN_REPAYMENT = "Loan Repayment" ;
}
@@ -73,7 +73,7 @@ public class SmsCampaignEnumerations {
public static List<EnumOptionData> calendarMonthType() {
final List<EnumOptionData> optionDatas = new ArrayList<>();
for (final Month monthType : Month.values()) {
if (Month.DECEMBER.compareTo(monthType) != 0) {
if (Month.DECEMBER.compareTo(monthType) != 0) { //We are removing December because we are adding yearly frequency
optionDatas.add(calendarMonthType(monthType));
}
}
@@ -83,9 +83,11 @@ public class SmsCampaignEnumerations {
public static List<EnumOptionData> calendarPeriodFrequencyTypes(final PeriodFrequencyType[] periodFrequencyTypes) {
final List<EnumOptionData> optionDatas = new ArrayList<>();
for (final PeriodFrequencyType periodFrequencyType : periodFrequencyTypes) {
final EnumOptionData optionData = new EnumOptionData(periodFrequencyType.getValue().longValue(), periodFrequencyType.getCode(),
periodFrequencyType.toString());
optionDatas.add(optionData);
if(!periodFrequencyType.getValue().equals(PeriodFrequencyType.INVALID.getValue())) {
final EnumOptionData optionData = new EnumOptionData(periodFrequencyType.getValue().longValue(), periodFrequencyType.getCode(),
periodFrequencyType.toString());
optionDatas.add(optionData);
}
}
return optionDatas;
}
@@ -1,298 +0,0 @@
/**
* 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 org.apache.fineract.infrastructure.campaigns.sms.data;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
public final class CampaignTriggerWithSubTypes {
public enum ActualCampaignTriggerType {
INVALID(0, "campaignTriggerType.invalid"), //
LOAN(1, "campaignTriggerType.loan"), //
SAVING(2, "campaignTriggerType.saving"), //
CLIENT(3, "campaignTriggerType.client");
private Integer value;
private String code;
private ActualCampaignTriggerType(Integer value, String code) {
this.value = value;
this.code = code;
}
public static ActualCampaignTriggerType fromInt(final Integer typeValue) {
ActualCampaignTriggerType type = ActualCampaignTriggerType.INVALID;
switch (typeValue) {
case 1:
type = LOAN;
break;
case 2:
type = SAVING;
break;
case 3:
type = CLIENT;
break;
}
return type;
}
public Integer getValue() {
return this.value;
}
public String getCode() {
return this.code;
}
public static EnumOptionData toEnumOptionData(final ActualCampaignTriggerType triggerType) {
final EnumOptionData optionData = new EnumOptionData(new Long(triggerType.getValue()), triggerType.getCode(), triggerType.name());
return optionData;
}
public static EnumOptionData toEnumOptionData(final Integer triggerTypeValue) {
ActualCampaignTriggerType actualCampaignTriggerType = ActualCampaignTriggerType.fromInt(triggerTypeValue);
final EnumOptionData optionData = new EnumOptionData(new Long(actualCampaignTriggerType.getValue()),
actualCampaignTriggerType.getCode(), actualCampaignTriggerType.name());
return optionData;
}
public boolean isInvalid() {
return this.value.equals(ActualCampaignTriggerType.INVALID.getValue());
}
}
public enum CampaignTriggerSubType {
INVALID(0, ActualCampaignTriggerType.INVALID, "campaignTriggerSubType.invalid"), //
DISBURSE(101, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.disburse"), //
REPAYMENT(102, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.repayment"), //
UNDO_DISBURSAL(103, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.undodisbursal"), //
WRITE_OFF(104, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.writeoff"), //
ADJUST(105, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.adjust"), //
UNDO_WRITE_OFF(106, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.undowriteoff"), //
FORECLOSURE(107, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.foreclosure"), //
APPROVED(108, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.approved"), //
WAIVE_INTEREST(109, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.waive.interest"), //
CLOSE(110, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.close"), //
CLOSE_AS_RESCHEDULE(111, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.close.as.rescheduled"), //
ADD_CHARGE(112, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.add.charge"), //
UPDATE_CHARGE(113, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.update.charge"), //
WAIVE_CHARGE(114, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.waive.charge"), //
DELETE_CHARGE(115, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.delete.charge"), //
CHARGE_PAYMENT(116, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.charge.payment"), //
INITIATE_TRANSFER(117, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.initiate.transfer"), //
ACCEPT_TRANSFER(118, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.accept.transfer"), //
WITHDRAW_TRANSFER(119, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.withdraw.transfer"), //
REJECT_TRANSFER(120, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.reject.transfer"), //
REASSIGN_OFFICER(121, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.reassign.officer"), //
REMOVE_OFFICER(122, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.reassign.officer"), //
APPLY_OVERDUE_CHARGE(123, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.reassign.officer"), //
INTEREST_RECALCULATION(124, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.reassign.officer"), //
REFUND(125, ActualCampaignTriggerType.LOAN, "campaignTriggerSubType.reassign.officer"), //
SAVINGS_DEPOSIT(201, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.deposit"), //
SAVINGS_WITHDRAWAL(202, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.withdrawal"), //
SAVINGS_ACTIVATE(203, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.savings.activate"), //
SAVINGS_ADJUST_TRANSACTION(204, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.savings.adjust"), //
SAVINGS_APPLY_ANNUAL_FEE(205, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.savings.apply.annual.fee"), //
SAVINGS_CALCULATE_INTEREST(206, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.savings.calclulate.interest"), //
SAVINGS_CLOSE(207, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.savings.close"), //
SAVINGS_POST_INTEREST(208, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.savings.post"), //
SAVINGS_REJECT(209, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.savings.reject"), //
SAVINGS_UNDO(210, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.savings.undo"), //
SAVINGS_ADD_CHARGE(211, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.savings.add.charge"), //
SAVINGS_WAIVE_CHARGE(212, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.savings.waive.charge"), //
SAVINGS_PAY_CHARGE(213, ActualCampaignTriggerType.SAVING, "campaignTriggerSubType.savings.pay.charge"), //
CLIENTS_ACTIVATE(301, ActualCampaignTriggerType.CLIENT, "campaignTriggerSubType.activate"), //
CLIENTS_CLOSE(302, ActualCampaignTriggerType.CLIENT, "campaignTriggerSubType.close"), //
CLIENTS_ACCEPT_TRANSFER(303, ActualCampaignTriggerType.CLIENT, "campaignTriggerSubType.accept.transfer"), //
CLIENTS_ASSIGN_STAFF(304, ActualCampaignTriggerType.CLIENT, "campaignTriggerSubType.assign.staff"), //
CLIENTS_CREATE(305, ActualCampaignTriggerType.CLIENT, "campaignTriggerSubType.create"), //
CLIENTS_DELETE(306, ActualCampaignTriggerType.CLIENT, "campaignTriggerSubType.delete"), //
CLIENTS_PROPOSE_TRANSFER(307, ActualCampaignTriggerType.CLIENT, "campaignTriggerSubType.propose.transfer"), //
CLIENTS_REACTIVATE(308, ActualCampaignTriggerType.CLIENT, "campaignTriggerSubType.reactivate"), //
CLIENTS_REJECT(309, ActualCampaignTriggerType.CLIENT, "campaignTriggerSubType.reject"), //
CLIENTS_REJECT_TRANSFER(310, ActualCampaignTriggerType.CLIENT, "campaignTriggerSubType.reject.transfer"), //
CLIENTS_WITHDRAW(311, ActualCampaignTriggerType.CLIENT, "campaignTriggerSubType.withdraw"), //
CLIENTS_WITHDRAW_TRANSFER(312, ActualCampaignTriggerType.CLIENT, "campaignTriggerSubType.withdraw.transfer");
private Integer id;
private ActualCampaignTriggerType type;
private String code;
private CampaignTriggerSubType(Integer id, ActualCampaignTriggerType type, String code) {
this.id = id;
this.type = type;
this.code = code;
}
public static CampaignTriggerSubType fromInt(final Integer subTypeValue) {
CampaignTriggerSubType subType = CampaignTriggerSubType.INVALID;
switch (subTypeValue) {
case 101:
subType = DISBURSE;
break;
case 102:
subType = REPAYMENT;
break;
case 103:
subType = ADJUST;
break;
case 104:
subType = UNDO_DISBURSAL;
break;
case 105:
subType = WRITE_OFF;
break;
case 106:
subType = UNDO_WRITE_OFF;
break;
case 201:
subType = SAVINGS_DEPOSIT;
break;
case 202:
subType = SAVINGS_WITHDRAWAL;
break;
case 203:
subType = SAVINGS_ACTIVATE;
break;
case 204:
subType = SAVINGS_ADJUST_TRANSACTION;
break;
case 205:
subType = SAVINGS_APPLY_ANNUAL_FEE;
break;
case 206:
subType = SAVINGS_CALCULATE_INTEREST;
break;
case 207:
subType = SAVINGS_CLOSE;
break;
case 208:
subType = SAVINGS_POST_INTEREST;
break;
case 209:
subType = SAVINGS_REJECT;
break;
case 210:
subType = SAVINGS_UNDO;
break;
case 211:
subType = SAVINGS_ADD_CHARGE;
break;
case 212:
subType = SAVINGS_WAIVE_CHARGE;
break;
case 213:
subType = SAVINGS_PAY_CHARGE;
break;
case 301:
subType = CLIENTS_ACTIVATE;
break;
case 302:
subType = CLIENTS_CLOSE;
break;
case 303:
subType = CLIENTS_ACCEPT_TRANSFER;
break;
case 304:
subType = CLIENTS_ASSIGN_STAFF;
break;
case 305:
subType = CLIENTS_CREATE;
break;
case 306:
subType = CLIENTS_DELETE;
break;
case 307:
subType = CLIENTS_PROPOSE_TRANSFER;
break;
case 308:
subType = CLIENTS_REACTIVATE;
break;
case 309:
subType = CLIENTS_REJECT;
break;
case 310:
subType = CLIENTS_REJECT_TRANSFER;
break;
case 311:
subType = CLIENTS_WITHDRAW;
break;
case 312:
subType = CLIENTS_WITHDRAW_TRANSFER;
break;
}
return subType;
}
public Integer getId() {
return this.id;
}
public ActualCampaignTriggerType getType() {
return this.type;
}
public String getCode() {
return this.code;
}
public static EnumOptionData toEnumOptionData(final Integer triggerSubType) {
CampaignTriggerSubType subTypeEnum = CampaignTriggerSubType.fromInt(triggerSubType);
final EnumOptionData optionData = new EnumOptionData(new Long(subTypeEnum.getId()), subTypeEnum.getCode(), subTypeEnum.name());
return optionData;
}
}
public static List<EnumOptionData> addTypeSubTypeMapping(ActualCampaignTriggerType type) {
List<EnumOptionData> subTypeList = new ArrayList<>();
EnumOptionData optionData = null;
for (CampaignTriggerSubType subType : CampaignTriggerSubType.values()) {
if (subType.getType().equals(type)) {
optionData = new EnumOptionData(subType.getId().longValue(), subType.getCode(), subType.name());
subTypeList.add(optionData);
}
}
return subTypeList;
}
public static Collection<TriggerTypeWithSubTypesData> getTriggerTypeAndSubTypes() {
final Collection<TriggerTypeWithSubTypesData> typesList = new ArrayList<>();
EnumOptionData actualTriggerType = null;
for (ActualCampaignTriggerType triggerType : ActualCampaignTriggerType.values()) {
if (triggerType.isInvalid()) {
continue;
}
List<EnumOptionData> subTypeList = addTypeSubTypeMapping(triggerType);
actualTriggerType = ActualCampaignTriggerType.toEnumOptionData(triggerType);
TriggerTypeWithSubTypesData triggerTypeWithSubTypesData = new TriggerTypeWithSubTypesData(actualTriggerType, subTypeList);
typesList.add(triggerTypeWithSubTypesData);
}
return typesList;
}
}
@@ -1,43 +0,0 @@
/**
* 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 org.apache.fineract.infrastructure.campaigns.sms.data;
import java.util.List;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
public class TriggerTypeWithSubTypesData {
private final EnumOptionData actualTriggerType;
private final List<EnumOptionData> triggerSubTypes;
public TriggerTypeWithSubTypesData(final EnumOptionData actualTriggerType, List<EnumOptionData> triggerSubTypes) {
this.actualTriggerType = actualTriggerType;
this.triggerSubTypes = triggerSubTypes;
}
public EnumOptionData getActualTriggerType() {
return this.actualTriggerType;
}
public List<EnumOptionData> getTriggerSubTypes() {
return this.triggerSubTypes;
}
}
@@ -23,6 +23,8 @@ import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
public interface SmsCampaignRepository extends JpaRepository<SmsCampaign, Long>, JpaSpecificationExecutor<SmsCampaign> {
@@ -32,4 +34,7 @@ public interface SmsCampaignRepository extends JpaRepository<SmsCampaign, Long>,
final Integer status);
Collection<SmsCampaign> findByTriggerType(final Integer triggerType) ;
@Query("SELECT campaign FROM SmsCampaign campaign WHERE campaign.paramValue LIKE :reportPattern AND campaign.triggerType=:triggerType AND campaign.status=300")
List<SmsCampaign> findActiveSmsCampaigns(@Param("reportPattern") final String reportPattern, @Param("triggerType") final Integer triggerType) ;
}
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -65,6 +66,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private static final Logger logger = LoggerFactory.getLogger(SmsCampaignDomainServiceImpl.class);
//private final static int POOL_SIZE = 5 ;
private final SmsCampaignRepository smsCampaignRepository;
private final SmsMessageRepository smsMessageRepository;
private final OfficeRepository officeRepository;
@@ -100,216 +103,192 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SAVINGS_REJECT, new SavingsAccountRejectedListener());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SAVINGS_DEPOSIT, new SavingsAccountTransactionListener(true));
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SAVINGS_WITHDRAWAL, new SavingsAccountTransactionListener(false));
}
private void notifyRejectedLoanOwner(Loan loan) {
ArrayList<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("loan rejected");
if(smsCampaigns.size()>0){
for (SmsCampaign campaign:smsCampaigns){
if(campaign.isActive()) {
this.smsCampaignWritePlatformCommandHandler.insertDirectCampaignIntoSmsOutboundTable(loan, campaign);
}
}
}
}
private void notifyRejectedLoanOwner(Loan loan) {
List<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("Loan Rejected");
if (smsCampaigns.size() > 0) {
for (SmsCampaign campaign : smsCampaigns) {
if (campaign.isActive()) {
SmsCampaignDomainServiceImpl.this.smsCampaignWritePlatformCommandHandler
.insertDirectCampaignIntoSmsOutboundTable(loan, campaign);
}
}
}
}
private void notifyAcceptedLoanOwner(Loan loan) {
ArrayList<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("loan approved");
List<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("Loan Approved");
if(smsCampaigns.size()>0){
for (SmsCampaign campaign:smsCampaigns){
if(campaign.isActive()) {
this.smsCampaignWritePlatformCommandHandler.insertDirectCampaignIntoSmsOutboundTable(loan, campaign);
}
this.smsCampaignWritePlatformCommandHandler.insertDirectCampaignIntoSmsOutboundTable(loan, campaign);
}
}
}
private void notifyClientActivated(final Client client) {
ArrayList<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("client activated");
List<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("Client Activated");
if(smsCampaigns.size()>0){
for (SmsCampaign campaign:smsCampaigns){
if(campaign.isActive()) {
this.smsCampaignWritePlatformCommandHandler.insertDirectCampaignIntoSmsOutboundTable(client, campaign);
}
this.smsCampaignWritePlatformCommandHandler.insertDirectCampaignIntoSmsOutboundTable(client, campaign);
}
}
}
private void notifyClientRejected(final Client client) {
ArrayList<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("client rejected");
List<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("Client Rejected");
if(smsCampaigns.size()>0){
for (SmsCampaign campaign:smsCampaigns){
if(campaign.isActive()) {
this.smsCampaignWritePlatformCommandHandler.insertDirectCampaignIntoSmsOutboundTable(client, campaign);
}
this.smsCampaignWritePlatformCommandHandler.insertDirectCampaignIntoSmsOutboundTable(client, campaign);
}
}
}
private void notifySavingsAccountActivated(final SavingsAccount savingsAccount) {
ArrayList<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("savings activated");
List<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("Savings Activated");
if (smsCampaigns.size() > 0) {
for (SmsCampaign campaign : smsCampaigns) {
if (campaign.isActive()) {
this.smsCampaignWritePlatformCommandHandler.insertDirectCampaignIntoSmsOutboundTable(savingsAccount,
this.smsCampaignWritePlatformCommandHandler.insertDirectCampaignIntoSmsOutboundTable(savingsAccount,
campaign);
}
}
}
}
private void notifySavingsAccountRejected(final SavingsAccount savingsAccount) {
ArrayList<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("savings rejected");
List<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("Savings Rejected");
if (smsCampaigns.size() > 0) {
for (SmsCampaign campaign : smsCampaigns) {
if (campaign.isActive()) {
this.smsCampaignWritePlatformCommandHandler.insertDirectCampaignIntoSmsOutboundTable(savingsAccount,
this.smsCampaignWritePlatformCommandHandler.insertDirectCampaignIntoSmsOutboundTable(savingsAccount,
campaign);
}
}
}
}
private void sendSmsForLoanRepayment(LoanTransaction loanTransaction) {
ArrayList<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("loan repayment");
List<SmsCampaign> smsCampaigns = retrieveSmsCampaigns("Loan Repayment");
if (smsCampaigns.size() > 0) {
for (SmsCampaign smsCampaign : smsCampaigns) {
if (smsCampaign.isActive()) {
try {
Loan loan = loanTransaction.getLoan();
final Set<Client> groupClients = new HashSet<>();
if (loan.hasInvalidLoanType()) {
throw new InvalidLoanTypeException("Loan Type cannot be Invalid for the Triggered Sms Campaign");
}
if (loan.isGroupLoan()) {
Group group = this.groupRepository.findOne(loan.getGroupId());
groupClients.addAll(group.getClientMembers());
} else {
groupClients.add(loan.client());
}
HashMap<String, String> campaignParams = new ObjectMapper()
.readValue(smsCampaign.getParamValue(), new TypeReference<HashMap<String, String>>() {
});
try {
Loan loan = loanTransaction.getLoan();
final Set<Client> groupClients = new HashSet<>();
if (loan.hasInvalidLoanType()) {
throw new InvalidLoanTypeException(
"Loan Type cannot be Invalid for the Triggered Sms Campaign");
}
if (loan.isGroupLoan()) {
Group group = this.groupRepository.findOne(loan.getGroupId());
groupClients.addAll(group.getClientMembers());
} else {
groupClients.add(loan.client());
}
HashMap<String, String> campaignParams = new ObjectMapper().readValue(smsCampaign.getParamValue(),
new TypeReference<HashMap<String, String>>() {
});
if (groupClients.size() > 0) {
for (Client client : groupClients) {
HashMap<String, Object> smsParams = processRepaymentDataForSms(loanTransaction, client);
for (String key : campaignParams.keySet()) {
String value = campaignParams.get(key);
String spvalue = null;
boolean spkeycheck = smsParams.containsKey(key);
if (spkeycheck) {
spvalue = smsParams.get(key).toString();
}
if (spkeycheck && !(value.equals("-1") || spvalue.equals(value))) {
if (key.equals("officeId")) {
Office campaignOffice = this.officeRepository.findOne(Long.valueOf(value));
if (campaignOffice
.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) {
throw new RuntimeException();
}
} else {
if (groupClients.size() > 0) {
for (Client client : groupClients) {
HashMap<String, Object> smsParams = processRepaymentDataForSms(loanTransaction, client);
for (String key : campaignParams.keySet()) {
String value = campaignParams.get(key);
String spvalue = null;
boolean spkeycheck = smsParams.containsKey(key);
if (spkeycheck) {
spvalue = smsParams.get(key).toString();
}
if (spkeycheck && !(value.equals("-1") || spvalue.equals(value))) {
if (key.equals("officeId")) {
Office campaignOffice = this.officeRepository.findOne(Long.valueOf(value));
if (campaignOffice
.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) {
throw new RuntimeException();
}
} else {
throw new RuntimeException();
}
}
String message = this.smsCampaignWritePlatformCommandHandler.compileSmsTemplate(
smsCampaign.getMessage(), smsCampaign.getCampaignName(), smsParams);
Object mobileNo = smsParams.get("mobileNo");
if (mobileNo != null) {
SmsMessage smsMessage = SmsMessage.pendingSms(null, null, client, null, message,
mobileNo.toString(), smsCampaign);
this.smsMessageRepository.save(smsMessage);
Collection<SmsMessage> messages = new ArrayList<>();
messages.add(smsMessage);
Map<SmsCampaign, Collection<SmsMessage>> smsDataMap = new HashMap<>();
smsDataMap.put(smsCampaign, messages);
this.smsMessageScheduledJobService.sendTriggeredMessages(smsDataMap);
}
}
String message = this.smsCampaignWritePlatformCommandHandler.compileSmsTemplate(
smsCampaign.getMessage(), smsCampaign.getCampaignName(), smsParams);
Object mobileNo = smsParams.get("mobileNo");
if (mobileNo != null) {
SmsMessage smsMessage = SmsMessage.pendingSms(null, null, client, null, message,
mobileNo.toString(), smsCampaign);
this.smsMessageRepository.save(smsMessage);
Collection<SmsMessage> messages = new ArrayList<>();
messages.add(smsMessage);
Map<SmsCampaign, Collection<SmsMessage>> smsDataMap = new HashMap<>();
smsDataMap.put(smsCampaign, messages);
this.smsMessageScheduledJobService.sendTriggeredMessages(smsDataMap);
}
}
} catch (final IOException e) {
logger.error("smsParams does not contain the key: " + e.getMessage());
} catch (final RuntimeException e) {
logger.debug("Client Office Id and SMS Campaign Office id doesn't match");
}
} catch (final IOException e) {
logger.error("smsParams does not contain the key: " + e.getMessage());
} catch (final RuntimeException e) {
logger.debug("Client Office Id and SMS Campaign Office id doesn't match");
}
}
}
}
private void sendSmsForSavingsTransaction(final SavingsAccountTransaction savingsTransaction, boolean isDeposit) {
String campaignName = isDeposit ? "savings deposit" : "savings withdrawal";
ArrayList<SmsCampaign> smsCampaigns = retrieveSmsCampaigns(campaignName);
String campaignName = isDeposit ? "Savings Deposit" : "Savings Withdrawal";
List<SmsCampaign> smsCampaigns = retrieveSmsCampaigns(campaignName);
if (smsCampaigns.size() > 0) {
for (SmsCampaign smsCampaign : smsCampaigns) {
if (smsCampaign.isActive()) {
try {
final SavingsAccount savingsAccount = savingsTransaction.getSavingsAccount();
final Client client = savingsAccount.getClient();
HashMap<String, String> campaignParams = new ObjectMapper()
.readValue(smsCampaign.getParamValue(), new TypeReference<HashMap<String, String>>() {
});
HashMap<String, Object> smsParams = processSavingsTransactionDataForSms(savingsTransaction,
client);
for (String key : campaignParams.keySet()) {
String value = campaignParams.get(key);
String spvalue = null;
boolean spkeycheck = smsParams.containsKey(key);
if (spkeycheck) {
spvalue = smsParams.get(key).toString();
}
if (spkeycheck && !(value.equals("-1") || spvalue.equals(value))) {
if (key.equals("officeId")) {
Office campaignOffice = this.officeRepository.findOne(Long.valueOf(value));
if (campaignOffice
.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) {
throw new RuntimeException();
}
} else {
try {
final SavingsAccount savingsAccount = savingsTransaction.getSavingsAccount();
final Client client = savingsAccount.getClient();
HashMap<String, String> campaignParams = new ObjectMapper().readValue(smsCampaign.getParamValue(),
new TypeReference<HashMap<String, String>>() {
});
HashMap<String, Object> smsParams = processSavingsTransactionDataForSms(savingsTransaction, client);
for (String key : campaignParams.keySet()) {
String value = campaignParams.get(key);
String spvalue = null;
boolean spkeycheck = smsParams.containsKey(key);
if (spkeycheck) {
spvalue = smsParams.get(key).toString();
}
if (spkeycheck && !(value.equals("-1") || spvalue.equals(value))) {
if (key.equals("officeId")) {
Office campaignOffice = this.officeRepository.findOne(Long.valueOf(value));
if (campaignOffice.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) {
throw new RuntimeException();
}
} else {
throw new RuntimeException();
}
}
String message = this.smsCampaignWritePlatformCommandHandler
.compileSmsTemplate(smsCampaign.getMessage(), smsCampaign.getCampaignName(), smsParams);
Object mobileNo = smsParams.get("mobileNo");
if (mobileNo != null) {
SmsMessage smsMessage = SmsMessage.pendingSms(null, null, client, null, message,
mobileNo.toString(), smsCampaign);
this.smsMessageRepository.save(smsMessage);
Collection<SmsMessage> messages = new ArrayList<>();
messages.add(smsMessage);
Map<SmsCampaign, Collection<SmsMessage>> smsDataMap = new HashMap<>();
smsDataMap.put(smsCampaign, messages);
this.smsMessageScheduledJobService.sendTriggeredMessages(smsDataMap);
}
} catch (final IOException e) {
logger.error("smsParams does not contain the key: " + e.getMessage());
} catch (final RuntimeException e) {
logger.debug("Client Office Id and SMS Campaign Office id doesn't match");
}
String message = this.smsCampaignWritePlatformCommandHandler
.compileSmsTemplate(smsCampaign.getMessage(), smsCampaign.getCampaignName(), smsParams);
Object mobileNo = smsParams.get("mobileNo");
if (mobileNo != null) {
SmsMessage smsMessage = SmsMessage.pendingSms(null, null, client, null, message,
mobileNo.toString(), smsCampaign);
this.smsMessageRepository.save(smsMessage);
Collection<SmsMessage> messages = new ArrayList<>();
messages.add(smsMessage);
Map<SmsCampaign, Collection<SmsMessage>> smsDataMap = new HashMap<>();
smsDataMap.put(smsCampaign, messages);
this.smsMessageScheduledJobService.sendTriggeredMessages(smsDataMap);
}
} catch (final IOException e) {
logger.error("smsParams does not contain the key: " + e.getMessage());
} catch (final RuntimeException e) {
logger.debug("Client Office Id and SMS Campaign Office id doesn't match");
}
}
}
}
private ArrayList<SmsCampaign> retrieveSmsCampaigns(String paramValue){
Collection<SmsCampaign> initialSmsCampaignList = smsCampaignRepository.findByTriggerType(SmsCampaignTriggerType.TRIGGERED.getValue());
ArrayList<SmsCampaign> smsCampaigns = new ArrayList<>();
for(SmsCampaign campaign : initialSmsCampaignList){
if(campaign.getParamValue().toLowerCase().contains(paramValue)){
smsCampaigns.add(campaign);
}
}
private List<SmsCampaign> retrieveSmsCampaigns(String paramValue){
List<SmsCampaign> smsCampaigns = smsCampaignRepository.findActiveSmsCampaigns("%"+paramValue+"%", SmsCampaignTriggerType.TRIGGERED.getValue());
return smsCampaigns;
}
@@ -396,12 +375,15 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
return smsParams;
}
private class SendSmsOnLoanApproved implements BusinessEventListner{
private abstract class SmsBusinessEventAdapter implements BusinessEventListner {
@Override
public void businessEventToBeExecuted(Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> businessEventEntity) {
}
@Override
public void businessEventToBeExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) {
//Nothing to do
}
}
private class SendSmsOnLoanApproved extends SmsBusinessEventAdapter{
@Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> businessEventEntity) {
@@ -413,12 +395,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
}
}
private class SendSmsOnLoanRejected implements BusinessEventListner{
@Override
public void businessEventToBeExecuted(Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> businessEventEntity) {
}
private class SendSmsOnLoanRejected extends SmsBusinessEventAdapter{
@Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> businessEventEntity) {
@@ -430,12 +407,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
}
}
private class SendSmsOnLoanRepayment implements BusinessEventListner{
@Override
public void businessEventToBeExecuted(Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> businessEventEntity) {
}
private class SendSmsOnLoanRepayment extends SmsBusinessEventAdapter{
@Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> businessEventEntity) {
@@ -447,12 +419,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
}
}
private class ClientActivatedListener implements BusinessEventListner {
@Override
public void businessEventToBeExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) {
}
private class ClientActivatedListener extends SmsBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) {
@@ -463,12 +430,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
}
}
private class ClientRejectedListener implements BusinessEventListner {
@Override
public void businessEventToBeExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) {
}
private class ClientRejectedListener extends SmsBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) {
@@ -480,12 +442,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
}
}
private class SavingsAccountActivatedListener implements BusinessEventListner {
@Override
public void businessEventToBeExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) {
}
private class SavingsAccountActivatedListener extends SmsBusinessEventAdapter{
@Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) {
@@ -497,12 +454,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
}
}
private class SavingsAccountRejectedListener implements BusinessEventListner {
@Override
public void businessEventToBeExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) {
}
private class SavingsAccountRejectedListener extends SmsBusinessEventAdapter {
@Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) {
@@ -513,18 +465,13 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
}
}
private class SavingsAccountTransactionListener implements BusinessEventListner {
private class SavingsAccountTransactionListener extends SmsBusinessEventAdapter {
final boolean isDeposit ;
public SavingsAccountTransactionListener(final boolean isDeposit) {
this.isDeposit = isDeposit ;
}
@Override
public void businessEventToBeExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) {
// TODO Auto-generated method stub
}
@Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) {
@@ -534,4 +481,19 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
}
}
}
/*private abstract class Task implements Runnable {
protected final FineractPlatformTenant tenant;
protected final String reportName ;
private final Object entity ;
public Task(final FineractPlatformTenant tenant, final String reportName, final Object entity) {
this.tenant = tenant;
this.reportName = reportName ;
this.entity = entity ;
}
}*/
}
@@ -21,7 +21,6 @@ package org.apache.fineract.infrastructure.campaigns.sms.service;
import java.util.Collection;
import org.apache.fineract.infrastructure.campaigns.sms.data.SmsProviderData;
import org.apache.fineract.infrastructure.campaigns.sms.data.TriggerTypeWithSubTypesData;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
public interface SmsCampaignDropdownReadPlatformService {
@@ -38,6 +37,4 @@ public interface SmsCampaignDropdownReadPlatformService {
Collection<EnumOptionData> retrivePeriodFrequencyTypes();
Collection<TriggerTypeWithSubTypesData> getTriggerTypeAndSubTypes();
}
@@ -27,12 +27,9 @@ import java.util.Map;
import org.apache.fineract.infrastructure.campaigns.constants.CampaignType;
import org.apache.fineract.infrastructure.campaigns.helper.SmsConfigUtils;
import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignConstants;
import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignEnumerations;
import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignTriggerType;
import org.apache.fineract.infrastructure.campaigns.sms.data.CampaignTriggerWithSubTypes;
import org.apache.fineract.infrastructure.campaigns.sms.data.SmsProviderData;
import org.apache.fineract.infrastructure.campaigns.sms.data.TriggerTypeWithSubTypesData;
import org.apache.fineract.infrastructure.campaigns.sms.exception.ConnectionFailureException;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.portfolio.calendar.domain.CalendarWeekDaysType;
@@ -74,19 +71,20 @@ public class SmsCampaignDropdownReadPlatformServiceImpl implements SmsCampaignDr
@Override
public Collection<SmsProviderData> retrieveSmsProviders() {
Collection<SmsProviderData> smsProviderOptions = new ArrayList<>();
String hostName = "" ;
try {
Map<String, Object> hostConfig = this.smsConfigUtils.getMessageGateWayRequestURI("smsbridges", null);
URI uri = (URI) hostConfig.get("uri");
hostName = uri.getHost() ;
HttpEntity<?> entity = (HttpEntity<?>) hostConfig.get("entity");
ResponseEntity<Collection<SmsProviderData>> responseOne = restTemplate.exchange(uri, HttpMethod.GET, entity,
new ParameterizedTypeReference<Collection<SmsProviderData>>() {});
smsProviderOptions = responseOne.getBody();
if (!responseOne.getStatusCode().equals(HttpStatus.OK)) {
System.out.println(responseOne.getStatusCode().name());
throw new ConnectionFailureException(SmsCampaignConstants.SMS_BRIDGE);
throw new ConnectionFailureException(hostName);
}
} catch (Exception e) {
e.getStackTrace();
throw new ConnectionFailureException(hostName);
}
return smsProviderOptions;
}
@@ -117,9 +115,4 @@ public class SmsCampaignDropdownReadPlatformServiceImpl implements SmsCampaignDr
.calendarPeriodFrequencyTypes(PeriodFrequencyType.values());
return periodFrequencyTypes;
}
@Override
public Collection<TriggerTypeWithSubTypesData> getTriggerTypeAndSubTypes() {
return CampaignTriggerWithSubTypes.getTriggerTypeAndSubTypes();
}
}
@@ -234,8 +234,7 @@ public class SmsCampaignWritePlatformServiceJpaImpl implements SmsCampaignWriteP
}
}
} catch (final IOException e) {
// TODO throw something here
System.out.println(e.getMessage());
logger.error(e.getMessage());
}
}
@@ -291,9 +290,9 @@ public class SmsCampaignWritePlatformServiceJpaImpl implements SmsCampaignWriteP
}
}
} catch (final IOException e) {
System.out.println("IOException: " + e.getMessage());
logger.error(e.getMessage()) ;
} catch (final RuntimeException e) {
System.out.println("RuntimeException: " + e.getMessage());
logger.error(e.getMessage()) ;
}
}
@@ -332,9 +331,9 @@ public class SmsCampaignWritePlatformServiceJpaImpl implements SmsCampaignWriteP
}
}
} catch (final IOException e) {
System.out.println("IOException: " + e.getMessage());
logger.error(e.getMessage()) ;
} catch (final RuntimeException e) {
System.out.println("RuntimeException: " + e.getMessage());
logger.error(e.getMessage()) ;
}
}
@@ -372,9 +371,9 @@ public class SmsCampaignWritePlatformServiceJpaImpl implements SmsCampaignWriteP
}
}
} catch (final IOException e) {
System.out.println("IOException: " + e.getMessage());
logger.error(e.getMessage()) ;
} catch (final RuntimeException e) {
System.out.println("RuntimeException: " + e.getMessage());
logger.error(e.getMessage()) ;
}
}
@@ -173,7 +173,7 @@ public class SmsMessageScheduledJobServiceImpl implements SmsMessageScheduledJob
if (responseOne != null) {
// String smsResponse = responseOne.getBody();
if (!responseOne.getStatusCode().equals(HttpStatus.ACCEPTED)) {
System.out.println(responseOne.getStatusCode().name());
logger.debug(responseOne.getStatusCode().name());
throw new ConnectionFailureException(SmsCampaignConstants.SMS);
}
}