This is an automated email from the ASF dual-hosted git repository.
arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new 0f2850fff refactor: add lombok to notification module
0f2850fff is described below
commit 0f2850fff5e81396316f9277dcaac8a2828dd5fc
Author: Hemant Gupta <[email protected]>
AuthorDate: Thu Oct 13 04:54:41 2022 +0530
refactor: add lombok to notification module
---
.../notification/data/NotificationData.java | 22 ++-----
.../notification/data/NotificationMapperData.java | 57 ++--------------
.../fineract/notification/domain/Notification.java | 76 +++-------------------
.../notification/domain/NotificationMapper.java | 47 +++----------
.../service/NotificationDomainServiceImpl.java | 5 +-
.../NotificationWritePlatformServiceImpl.java | 17 ++---
6 files changed, 41 insertions(+), 183 deletions(-)
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/notification/data/NotificationData.java
b/fineract-provider/src/main/java/org/apache/fineract/notification/data/NotificationData.java
index f67cc81a7..44fa8cf09 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/notification/data/NotificationData.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/notification/data/NotificationData.java
@@ -21,10 +21,16 @@ package org.apache.fineract.notification.data;
import java.io.Serializable;
import java.util.Set;
import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
@Data
+@NoArgsConstructor
+@Accessors(chain = true)
public class NotificationData implements Serializable {
+ private static final long serialVersionUID = 1L;
+
private Long id;
private String objectType;
private Long objectId;
@@ -37,20 +43,4 @@ public class NotificationData implements Serializable {
private String createdAt;
private Long officeId;
private Set<Long> userIds;
-
- public NotificationData() {}
-
- public NotificationData(String objectType, Long objectId, String action,
Long actorId, String content, boolean isSystemGenerated,
- boolean isRead, String tenantIdentifier, Long officeId, Set<Long>
userIds) {
- this.objectType = objectType;
- this.objectId = objectId;
- this.action = action;
- this.actorId = actorId;
- this.content = content;
- this.isRead = isRead;
- this.isSystemGenerated = isSystemGenerated;
- this.tenantIdentifier = tenantIdentifier;
- this.officeId = officeId;
- this.userIds = userIds;
- }
}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/notification/data/NotificationMapperData.java
b/fineract-provider/src/main/java/org/apache/fineract/notification/data/NotificationMapperData.java
index 659fb5f57..c85155f21 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/notification/data/NotificationMapperData.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/notification/data/NotificationMapperData.java
@@ -18,6 +18,13 @@
*/
package org.apache.fineract.notification.data;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
public class NotificationMapperData {
private Long id;
@@ -25,54 +32,4 @@ public class NotificationMapperData {
private Long userId;
private boolean isRead;
private String createdAt;
-
- public NotificationMapperData(Long id, Long notificationId, Long userId,
boolean isRead, String createdAt) {
- this.id = id;
- this.notificationId = notificationId;
- this.userId = userId;
- this.isRead = isRead;
- this.createdAt = createdAt;
- }
-
- public NotificationMapperData() {}
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public Long getNotificationId() {
- return notificationId;
- }
-
- public void setNotificationId(Long notificationId) {
- this.notificationId = notificationId;
- }
-
- public Long getUserId() {
- return userId;
- }
-
- public void setUserId(Long userId) {
- this.userId = userId;
- }
-
- public boolean isRead() {
- return isRead;
- }
-
- public void setRead(boolean read) {
- isRead = read;
- }
-
- public String getCreatedAt() {
- return createdAt;
- }
-
- public void setCreatedAt(String createdAt) {
- this.createdAt = createdAt;
- }
}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/notification/domain/Notification.java
b/fineract-provider/src/main/java/org/apache/fineract/notification/domain/Notification.java
index a7fa46ef2..de411d020 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/notification/domain/Notification.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/notification/domain/Notification.java
@@ -22,10 +22,18 @@ import java.time.LocalDateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.Accessors;
import
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@Entity
@Table(name = "notification_generator")
+@Getter
+@Setter
+@NoArgsConstructor
+@Accessors(chain = true)
public class Notification extends AbstractPersistableCustom {
@Column(name = "object_type")
@@ -48,72 +56,4 @@ public class Notification extends AbstractPersistableCustom {
@Column(name = "created_at")
private LocalDateTime createdAt;
-
- public Notification() {}
-
- public Notification(String objectType, Long objectIdentifier, String
action, Long actorId, boolean isSystemGenerated,
- String notificationContent, LocalDateTime createdAt) {
- this.objectType = objectType;
- this.objectIdentifier = objectIdentifier;
- this.action = action;
- this.actorId = actorId;
- this.isSystemGenerated = isSystemGenerated;
- this.notificationContent = notificationContent;
- this.createdAt = createdAt;
- }
-
- public String getObjectType() {
- return objectType;
- }
-
- public void setObjectType(String objectType) {
- this.objectType = objectType;
- }
-
- public Long getObjectIdentifier() {
- return objectIdentifier;
- }
-
- public void setObjectIdentifier(Long objectIdentifier) {
- this.objectIdentifier = objectIdentifier;
- }
-
- public String getAction() {
- return action;
- }
-
- public void setAction(String action) {
- this.action = action;
- }
-
- public Long getActor() {
- return actorId;
- }
-
- public void setActor(Long actorId) {
- this.actorId = actorId;
- }
-
- public boolean isSystemGenerated() {
- return isSystemGenerated;
- }
-
- public void setSystemGenerated(boolean systemGenerated) {
- isSystemGenerated = systemGenerated;
- }
-
- public String getNotificationContent() {
- return notificationContent;
- }
-
- public void setNotificationContent(String notificationContent) {
- this.notificationContent = notificationContent;
- }
-
- @Override
- public String toString() {
- return "Notification [objectType=" + this.objectType + ",
objectIdentifier=" + this.objectIdentifier + ", action=" + this.action
- + ", actorId=" + this.actorId + ", isSystemGenerated=" +
this.isSystemGenerated + ", notificationContent="
- + this.notificationContent + ", createdAt=" + this.createdAt +
", getId()=" + this.getId() + "]";
- }
}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/notification/domain/NotificationMapper.java
b/fineract-provider/src/main/java/org/apache/fineract/notification/domain/NotificationMapper.java
index 4ed11829c..f4b1fa3c6 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/notification/domain/NotificationMapper.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/notification/domain/NotificationMapper.java
@@ -24,11 +24,19 @@ 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.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.useradministration.domain.AppUser;
@Entity
@Table(name = "notification_mapper")
+@Getter
+@Setter
+@NoArgsConstructor
+@Accessors(chain = true)
public class NotificationMapper extends AbstractPersistableCustom {
@ManyToOne
@@ -44,43 +52,4 @@ public class NotificationMapper extends
AbstractPersistableCustom {
@Column(name = "created_at")
private LocalDateTime createdAt;
-
- public NotificationMapper() {}
-
- public NotificationMapper(Notification notification, AppUser userId,
boolean isRead, LocalDateTime createdAt) {
- this.notification = notification;
- this.userId = userId;
- this.isRead = isRead;
- this.createdAt = createdAt;
- }
-
- public Notification getNotification() {
- return notification;
- }
-
- public void setNotification(Notification notification) {
- this.notification = notification;
- }
-
- public AppUser getUserId() {
- return userId;
- }
-
- public void setUserId(AppUser userId) {
- this.userId = userId;
- }
-
- public boolean isRead() {
- return isRead;
- }
-
- public void setRead(boolean read) {
- isRead = read;
- }
-
- @Override
- public String toString() {
- return "NotificationMapper [notification=" + this.notification + ",
userId=" + this.userId + ", isRead=" + this.isRead
- + ", createdAt=" + this.createdAt + ", getId()=" +
this.getId() + "]";
- }
}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationDomainServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationDomainServiceImpl.java
index 9e607f73e..1fcb893a7 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationDomainServiceImpl.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationDomainServiceImpl.java
@@ -329,8 +329,9 @@ public class NotificationDomainServiceImpl implements
NotificationDomainService
String tenantIdentifier =
ThreadLocalContextUtil.getTenant().getTenantIdentifier();
Set<Long> userIds = getNotifiableUserIds(officeId, permission);
- NotificationData notificationData = new NotificationData(objectType,
objectIdentifier, eventType, appUserId, notificationContent,
- false, false, tenantIdentifier, officeId, userIds);
+ NotificationData notificationData = new
NotificationData().setObjectType(objectType).setObjectId(objectIdentifier)
+
.setAction(eventType).setActorId(appUserId).setContent(notificationContent).setRead(false).setSystemGenerated(false)
+
.setTenantIdentifier(tenantIdentifier).setOfficeId(officeId).setUserIds(userIds);
try {
notificationEventPublisher.broadcastNotification(notificationData);
} catch (Exception e) {
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationWritePlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationWritePlatformServiceImpl.java
index 92297c37f..42105d9cc 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationWritePlatformServiceImpl.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationWritePlatformServiceImpl.java
@@ -52,9 +52,9 @@ public class NotificationWritePlatformServiceImpl implements
NotificationWritePl
private Long insertIntoNotificationMapper(Long userId, Long
generatedNotificationId) {
AppUser appUser = this.appUserRepository.findById(userId).orElse(null);
- NotificationMapper notificationMapper = new NotificationMapper(
-
this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId),
appUser, false,
- DateUtils.getLocalDateTimeOfSystem());
+ NotificationMapper notificationMapper = new NotificationMapper()
+
.setNotification(this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId)).setUserId(appUser)
+
.setRead(false).setCreatedAt(DateUtils.getLocalDateTimeOfSystem());
this.notificationMapperWritePlatformService.create(notificationMapper);
return notificationMapper.getId();
@@ -63,8 +63,9 @@ public class NotificationWritePlatformServiceImpl implements
NotificationWritePl
private Long insertIntoNotificationGenerator(String objectType, Long
objectIdentifier, String action, Long actorId,
String notificationContent, boolean isSystemGenerated) {
- Notification notification = new Notification(objectType,
objectIdentifier, action, actorId, isSystemGenerated, notificationContent,
- DateUtils.getLocalDateTimeOfSystem());
+ Notification notification = new
Notification().setObjectType(objectType).setObjectIdentifier(objectIdentifier).setAction(action)
+
.setActorId(actorId).setSystemGenerated(isSystemGenerated).setNotificationContent(notificationContent)
+ .setCreatedAt(DateUtils.getLocalDateTimeOfSystem());
return
this.notificationGeneratorWritePlatformService.create(notification);
}
@@ -84,9 +85,9 @@ public class NotificationWritePlatformServiceImpl implements
NotificationWritePl
List<Long> mappedIds = new ArrayList<>();
for (Long userId : userIds) {
AppUser appUser =
this.appUserRepository.findById(userId).orElseThrow();
- NotificationMapper notificationMapper = new NotificationMapper(
-
this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId),
appUser, false,
- DateUtils.getLocalDateTimeOfSystem());
+ NotificationMapper notificationMapper = new NotificationMapper()
+
.setNotification(this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId)).setUserId(appUser)
+
.setRead(false).setCreatedAt(DateUtils.getLocalDateTimeOfSystem());
this.notificationMapperWritePlatformService.create(notificationMapper);
mappedIds.add(notificationMapper.getId());
}