refactor: add lombok to sms module
This commit is contained in:
committed by
Arnold Gálovics
parent
04e07890a4
commit
55b1baeacb
+18
-60
@@ -18,75 +18,33 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.sms.data;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
|
||||
/**
|
||||
* Immutable data object representing a SMS message.
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public final class SmsData {
|
||||
|
||||
private final Long id;
|
||||
private final Long groupId;
|
||||
private final Long clientId;
|
||||
private final Long staffId;
|
||||
private final EnumOptionData status;
|
||||
private final String mobileNo;
|
||||
private final String message;
|
||||
private final Long providerId;
|
||||
private final String campaignName;
|
||||
private Long id;
|
||||
private Long groupId;
|
||||
private Long clientId;
|
||||
private Long staffId;
|
||||
private EnumOptionData status;
|
||||
private String mobileNo;
|
||||
private String message;
|
||||
private Long providerId;
|
||||
private String campaignName;
|
||||
|
||||
public static SmsData instance(final Long id, final Long groupId, final Long clientId, final Long staffId, final EnumOptionData status,
|
||||
final String mobileNo, final String message, final Long providerId, final String camapignName) {
|
||||
return new SmsData(id, groupId, clientId, staffId, status, mobileNo, message, providerId, camapignName);
|
||||
return new SmsData().setId(id).setGroupId(groupId).setClientId(clientId).setStaffId(staffId).setStatus(status).setMobileNo(mobileNo)
|
||||
.setMessage(message).setProviderId(providerId).setCampaignName(camapignName);
|
||||
}
|
||||
|
||||
private SmsData(final Long id, final Long groupId, final Long clientId, final Long staffId, final EnumOptionData status,
|
||||
final String mobileNo, final String message, final Long providerId, final String camapignName) {
|
||||
this.id = id;
|
||||
this.groupId = groupId;
|
||||
this.clientId = clientId;
|
||||
this.staffId = staffId;
|
||||
this.status = status;
|
||||
this.mobileNo = mobileNo;
|
||||
this.message = message;
|
||||
this.providerId = providerId;
|
||||
this.campaignName = camapignName;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public Long getClientId() {
|
||||
return this.clientId;
|
||||
}
|
||||
|
||||
public Long getStaffId() {
|
||||
return this.staffId;
|
||||
}
|
||||
|
||||
public EnumOptionData getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public String getMobileNo() {
|
||||
return this.mobileNo;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public Long getProviderId() {
|
||||
return this.providerId;
|
||||
}
|
||||
|
||||
public String getCampaignName() {
|
||||
return this.campaignName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-70
@@ -20,10 +20,16 @@ package org.apache.fineract.infrastructure.sms.data;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import java.util.Collection;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* Immutable data object representing the API request body sent in the POST request to the "/queue" resource
|
||||
**/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SmsMessageApiQueueResourceData {
|
||||
|
||||
private Long internalId;
|
||||
@@ -34,82 +40,15 @@ public class SmsMessageApiQueueResourceData {
|
||||
private String message;
|
||||
private Long providerId;
|
||||
|
||||
/**
|
||||
* SmsMessageApiQueueResourceData constructor
|
||||
**/
|
||||
private SmsMessageApiQueueResourceData(Long internalId, String mifosTenantIdentifier, String createdOnDate, String sourceAddress,
|
||||
String mobileNumber, String message, Long providerId) {
|
||||
this.internalId = internalId;
|
||||
this.tenantId = mifosTenantIdentifier;
|
||||
this.createdOnDate = createdOnDate;
|
||||
this.sourceAddress = sourceAddress;
|
||||
this.mobileNumber = mobileNumber;
|
||||
this.message = message;
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* SmsMessageApiQueueResourceData constructor
|
||||
**/
|
||||
protected SmsMessageApiQueueResourceData() {}
|
||||
|
||||
/**
|
||||
* @return a new instance of the SmsMessageApiQueueResourceData class
|
||||
**/
|
||||
public static final SmsMessageApiQueueResourceData instance(Long internalId, String mifosTenantIdentifier, String createdOnDate,
|
||||
String sourceAddress, String mobileNumber, String message, Long providerId) {
|
||||
|
||||
return new SmsMessageApiQueueResourceData(internalId, mifosTenantIdentifier, createdOnDate, sourceAddress, mobileNumber, message,
|
||||
providerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the internalId
|
||||
*/
|
||||
public Long getInternalId() {
|
||||
return internalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mifosTenantIdentifier
|
||||
*/
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the createdOnDate
|
||||
*/
|
||||
public String getCreatedOnDate() {
|
||||
return createdOnDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sourceAddress
|
||||
*/
|
||||
public String getSourceAddress() {
|
||||
return sourceAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mobileNumber
|
||||
*/
|
||||
public String getMobileNumber() {
|
||||
return mobileNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the providerId
|
||||
*/
|
||||
public Long getproviderId() {
|
||||
return providerId;
|
||||
return new SmsMessageApiQueueResourceData().setInternalId(internalId).setTenantId(mifosTenantIdentifier)
|
||||
.setCreatedOnDate(createdOnDate).setSourceAddress(sourceAddress).setMobileNumber(mobileNumber).setMessage(message)
|
||||
.setProviderId(providerId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+7
-28
@@ -20,47 +20,26 @@ package org.apache.fineract.infrastructure.sms.data;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* Immutable data object representing the API request body sent in the POST request to the "/report" resource
|
||||
**/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SmsMessageApiReportResourceData {
|
||||
|
||||
private List<Long> externalIds;
|
||||
private String mifosTenantIdentifier;
|
||||
|
||||
/**
|
||||
* SmsMessageApiReportResourceData constructor
|
||||
**/
|
||||
private SmsMessageApiReportResourceData(List<Long> externalIds, String mifosTenantIdentifier) {
|
||||
this.externalIds = externalIds;
|
||||
this.mifosTenantIdentifier = mifosTenantIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* SmsMessageApiReportResourceData constructor
|
||||
**/
|
||||
protected SmsMessageApiReportResourceData() {}
|
||||
|
||||
/**
|
||||
* @return new instance of the SmsMessageApiReportResourceData class
|
||||
**/
|
||||
public static final SmsMessageApiReportResourceData instance(List<Long> externalIds, String mifosTenantIdentifier) {
|
||||
return new SmsMessageApiReportResourceData(externalIds, mifosTenantIdentifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the externalIds
|
||||
*/
|
||||
public List<Long> getExternalIds() {
|
||||
return externalIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mifosTenantIdentifier
|
||||
*/
|
||||
public String getMifosTenantIdentifier() {
|
||||
return mifosTenantIdentifier;
|
||||
return new SmsMessageApiReportResourceData().setExternalIds(externalIds).setMifosTenantIdentifier(mifosTenantIdentifier);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+7
-32
@@ -19,50 +19,25 @@
|
||||
package org.apache.fineract.infrastructure.sms.data;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* Immutable data object representing an outbound SMS message API response data
|
||||
**/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SmsMessageApiResponseData {
|
||||
|
||||
private Integer httpStatusCode;
|
||||
private List<SmsMessageDeliveryReportData> data;
|
||||
|
||||
/**
|
||||
* SmsMessageApiResponseData constructor
|
||||
*
|
||||
*
|
||||
**/
|
||||
private SmsMessageApiResponseData(Integer httpStatusCode, List<SmsMessageDeliveryReportData> data) {
|
||||
this.httpStatusCode = httpStatusCode;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default SmsMessageApiResponseData constructor
|
||||
*
|
||||
*
|
||||
**/
|
||||
protected SmsMessageApiResponseData() {}
|
||||
|
||||
/**
|
||||
* @return an instance of the SmsMessageApiResponseData class
|
||||
**/
|
||||
public static SmsMessageApiResponseData getInstance(Integer httpStatusCode, List<SmsMessageDeliveryReportData> data) {
|
||||
return new SmsMessageApiResponseData(httpStatusCode, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the httpStatusCode
|
||||
*/
|
||||
public Integer getHttpStatusCode() {
|
||||
return httpStatusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the data
|
||||
*/
|
||||
public List<SmsMessageDeliveryReportData> getData() {
|
||||
return data;
|
||||
return new SmsMessageApiResponseData().setHttpStatusCode(httpStatusCode).setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-73
@@ -18,9 +18,16 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.sms.data;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* Immutable data object representing an outbound SMS message delivery report data
|
||||
**/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SmsMessageDeliveryReportData {
|
||||
|
||||
private Long id;
|
||||
@@ -31,84 +38,13 @@ public class SmsMessageDeliveryReportData {
|
||||
private Boolean hasError;
|
||||
private String errorMessage;
|
||||
|
||||
/**
|
||||
* SmsMessageDeliveryReportData constructor
|
||||
*
|
||||
*
|
||||
**/
|
||||
private SmsMessageDeliveryReportData(Long id, String externalId, String addedOnDate, String deliveredOnDate, Integer deliveryStatus,
|
||||
Boolean hasError, String errorMessage) {
|
||||
this.id = id;
|
||||
this.externalId = externalId;
|
||||
this.addedOnDate = addedOnDate;
|
||||
this.deliveredOnDate = deliveredOnDate;
|
||||
this.deliveryStatus = deliveryStatus;
|
||||
this.hasError = hasError;
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default SmsMessageDeliveryReportData constructor
|
||||
*
|
||||
*
|
||||
**/
|
||||
protected SmsMessageDeliveryReportData() {}
|
||||
|
||||
/**
|
||||
* @return an instance of the SmsMessageDeliveryReportData class
|
||||
**/
|
||||
public static SmsMessageDeliveryReportData getInstance(Long id, String externalId, String addedOnDate, String deliveredOnDate,
|
||||
Integer deliveryStatus, Boolean hasError, String errorMessage) {
|
||||
|
||||
return new SmsMessageDeliveryReportData(id, externalId, addedOnDate, deliveredOnDate, deliveryStatus, hasError, errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the externalId
|
||||
*/
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the addedOnDate
|
||||
*/
|
||||
public String getAddedOnDate() {
|
||||
return addedOnDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the deliveredOnDate
|
||||
*/
|
||||
public String getDeliveredOnDate() {
|
||||
return deliveredOnDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the deliveryStatus
|
||||
*/
|
||||
public Integer getDeliveryStatus() {
|
||||
return deliveryStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hasError
|
||||
*/
|
||||
public Boolean getHasError() {
|
||||
return hasError;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the errorMessage
|
||||
*/
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
return new SmsMessageDeliveryReportData().setId(id).setExternalId(externalId).setAddedOnDate(addedOnDate)
|
||||
.setDeliveredOnDate(deliveredOnDate).setDeliveryStatus(deliveryStatus).setHasError(hasError).setErrorMessage(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
+17
-82
@@ -27,6 +27,10 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaign;
|
||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||
@@ -39,6 +43,10 @@ import org.apache.fineract.portfolio.group.domain.Group;
|
||||
|
||||
@Entity
|
||||
@Table(name = "sms_messages_outbound")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SmsMessage extends AbstractPersistableCustom {
|
||||
|
||||
@Column(name = "external_id", nullable = true)
|
||||
@@ -86,39 +94,26 @@ public class SmsMessage extends AbstractPersistableCustom {
|
||||
|
||||
public static SmsMessage pendingSms(final String externalId, final Group group, final Client client, final Staff staff,
|
||||
final String message, final String mobileNo, final SmsCampaign smsCampaign, final boolean isNotification) {
|
||||
return new SmsMessage(externalId, group, client, staff, SmsMessageStatusType.PENDING, message, mobileNo, smsCampaign,
|
||||
isNotification);
|
||||
return new SmsMessage().setExternalId(externalId).setGroup(group).setClient(client).setStaff(staff)
|
||||
.setStatusType(SmsMessageStatusType.PENDING.getValue()).setMessage(message).setMobileNo(mobileNo)
|
||||
.setSmsCampaign(smsCampaign).setNotification(isNotification).setSubmittedOnDate(DateUtils.getBusinessLocalDate());
|
||||
}
|
||||
|
||||
public static SmsMessage sentSms(final String externalId, final Group group, final Client client, final Staff staff,
|
||||
final String message, final String mobileNo, final SmsCampaign smsCampaign, final boolean isNotification) {
|
||||
return new SmsMessage(externalId, group, client, staff, SmsMessageStatusType.WAITING_FOR_DELIVERY_REPORT, message, mobileNo,
|
||||
smsCampaign, isNotification);
|
||||
return new SmsMessage().setExternalId(externalId).setGroup(group).setClient(client).setStaff(staff)
|
||||
.setStatusType(SmsMessageStatusType.WAITING_FOR_DELIVERY_REPORT.getValue()).setMessage(message).setMobileNo(mobileNo)
|
||||
.setSmsCampaign(smsCampaign).setNotification(isNotification).setSubmittedOnDate(DateUtils.getBusinessLocalDate());
|
||||
}
|
||||
|
||||
public static SmsMessage instance(String externalId, final Group group, final Client client, final Staff staff,
|
||||
final SmsMessageStatusType statusType, final String message, final String mobileNo, final SmsCampaign smsCampaign,
|
||||
final boolean isNotification) {
|
||||
|
||||
return new SmsMessage(externalId, group, client, staff, statusType, message, mobileNo, smsCampaign, isNotification);
|
||||
}
|
||||
return new SmsMessage().setExternalId(externalId).setGroup(group).setClient(client).setStaff(staff)
|
||||
.setStatusType(statusType.getValue()).setMessage(message).setMobileNo(mobileNo).setSmsCampaign(smsCampaign)
|
||||
.setNotification(isNotification).setSubmittedOnDate(DateUtils.getBusinessLocalDate());
|
||||
|
||||
protected SmsMessage() {
|
||||
//
|
||||
}
|
||||
|
||||
private SmsMessage(String externalId, final Group group, final Client client, final Staff staff, final SmsMessageStatusType statusType,
|
||||
final String message, final String mobileNo, final SmsCampaign smsCampaign, final boolean isNotification) {
|
||||
this.externalId = externalId;
|
||||
this.group = group;
|
||||
this.client = client;
|
||||
this.staff = staff;
|
||||
this.statusType = statusType.getValue();
|
||||
this.mobileNo = mobileNo;
|
||||
this.message = message;
|
||||
this.smsCampaign = smsCampaign;
|
||||
this.submittedOnDate = DateUtils.getBusinessLocalDate();
|
||||
this.isNotification = isNotification;
|
||||
}
|
||||
|
||||
public Map<String, Object> update(final JsonCommand command) {
|
||||
@@ -134,64 +129,4 @@ public class SmsMessage extends AbstractPersistableCustom {
|
||||
return actualChanges;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return this.externalId;
|
||||
}
|
||||
|
||||
public SmsCampaign getSmsCampaign() {
|
||||
return this.smsCampaign;
|
||||
}
|
||||
|
||||
public Group getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public Client getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
public Staff getStaff() {
|
||||
return staff;
|
||||
}
|
||||
|
||||
public Integer getStatusType() {
|
||||
return statusType;
|
||||
}
|
||||
|
||||
public String getMobileNo() {
|
||||
return mobileNo;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setExternalId(final String externalId) {
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
public void setStatusType(final Integer statusType) {
|
||||
this.statusType = statusType;
|
||||
}
|
||||
|
||||
public LocalDate getSubmittedOnDate() {
|
||||
return this.submittedOnDate;
|
||||
}
|
||||
|
||||
public LocalDateTime getDeliveredOnDate() {
|
||||
return this.deliveredOnDate;
|
||||
}
|
||||
|
||||
public void setDeliveredOnDate(final LocalDateTime deliveredOnDate) {
|
||||
this.deliveredOnDate = deliveredOnDate;
|
||||
}
|
||||
|
||||
public boolean isNotification() {
|
||||
return this.isNotification;
|
||||
}
|
||||
|
||||
public void setNotification(boolean isNotification) {
|
||||
this.isNotification = isNotification;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-3
@@ -22,9 +22,7 @@ import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
|
||||
public final class SmsMessageEnumerations {
|
||||
|
||||
private SmsMessageEnumerations() {
|
||||
|
||||
}
|
||||
private SmsMessageEnumerations() {}
|
||||
|
||||
public static EnumOptionData status(final Integer statusId) {
|
||||
return status(SmsMessageStatusType.fromInt(statusId));
|
||||
|
||||
Reference in New Issue
Block a user