refactor: add lombok to notification module
This commit is contained in:
committed by
Arnold Gálovics
parent
5b935eb1ff
commit
0f2850fff5
+6
-16
@@ -21,10 +21,16 @@ package org.apache.fineract.notification.data;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class NotificationData implements Serializable {
|
public class NotificationData implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private String objectType;
|
private String objectType;
|
||||||
private Long objectId;
|
private Long objectId;
|
||||||
@@ -37,20 +43,4 @@ public class NotificationData implements Serializable {
|
|||||||
private String createdAt;
|
private String createdAt;
|
||||||
private Long officeId;
|
private Long officeId;
|
||||||
private Set<Long> userIds;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-50
@@ -18,6 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.notification.data;
|
package org.apache.fineract.notification.data;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class NotificationMapperData {
|
public class NotificationMapperData {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
@@ -25,54 +32,4 @@ public class NotificationMapperData {
|
|||||||
private Long userId;
|
private Long userId;
|
||||||
private boolean isRead;
|
private boolean isRead;
|
||||||
private String createdAt;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-68
@@ -22,10 +22,18 @@ import java.time.LocalDateTime;
|
|||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
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.infrastructure.core.domain.AbstractPersistableCustom;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "notification_generator")
|
@Table(name = "notification_generator")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class Notification extends AbstractPersistableCustom {
|
public class Notification extends AbstractPersistableCustom {
|
||||||
|
|
||||||
@Column(name = "object_type")
|
@Column(name = "object_type")
|
||||||
@@ -48,72 +56,4 @@ public class Notification extends AbstractPersistableCustom {
|
|||||||
|
|
||||||
@Column(name = "created_at")
|
@Column(name = "created_at")
|
||||||
private LocalDateTime createdAt;
|
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() + "]";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-39
@@ -24,11 +24,19 @@ import javax.persistence.Entity;
|
|||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
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.infrastructure.core.domain.AbstractPersistableCustom;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "notification_mapper")
|
@Table(name = "notification_mapper")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class NotificationMapper extends AbstractPersistableCustom {
|
public class NotificationMapper extends AbstractPersistableCustom {
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@@ -44,43 +52,4 @@ public class NotificationMapper extends AbstractPersistableCustom {
|
|||||||
|
|
||||||
@Column(name = "created_at")
|
@Column(name = "created_at")
|
||||||
private LocalDateTime createdAt;
|
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() + "]";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -329,8 +329,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
|
|||||||
|
|
||||||
String tenantIdentifier = ThreadLocalContextUtil.getTenant().getTenantIdentifier();
|
String tenantIdentifier = ThreadLocalContextUtil.getTenant().getTenantIdentifier();
|
||||||
Set<Long> userIds = getNotifiableUserIds(officeId, permission);
|
Set<Long> userIds = getNotifiableUserIds(officeId, permission);
|
||||||
NotificationData notificationData = new NotificationData(objectType, objectIdentifier, eventType, appUserId, notificationContent,
|
NotificationData notificationData = new NotificationData().setObjectType(objectType).setObjectId(objectIdentifier)
|
||||||
false, false, tenantIdentifier, officeId, userIds);
|
.setAction(eventType).setActorId(appUserId).setContent(notificationContent).setRead(false).setSystemGenerated(false)
|
||||||
|
.setTenantIdentifier(tenantIdentifier).setOfficeId(officeId).setUserIds(userIds);
|
||||||
try {
|
try {
|
||||||
notificationEventPublisher.broadcastNotification(notificationData);
|
notificationEventPublisher.broadcastNotification(notificationData);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
+9
-8
@@ -52,9 +52,9 @@ public class NotificationWritePlatformServiceImpl implements NotificationWritePl
|
|||||||
|
|
||||||
private Long insertIntoNotificationMapper(Long userId, Long generatedNotificationId) {
|
private Long insertIntoNotificationMapper(Long userId, Long generatedNotificationId) {
|
||||||
AppUser appUser = this.appUserRepository.findById(userId).orElse(null);
|
AppUser appUser = this.appUserRepository.findById(userId).orElse(null);
|
||||||
NotificationMapper notificationMapper = new NotificationMapper(
|
NotificationMapper notificationMapper = new NotificationMapper()
|
||||||
this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId), appUser, false,
|
.setNotification(this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId)).setUserId(appUser)
|
||||||
DateUtils.getLocalDateTimeOfSystem());
|
.setRead(false).setCreatedAt(DateUtils.getLocalDateTimeOfSystem());
|
||||||
|
|
||||||
this.notificationMapperWritePlatformService.create(notificationMapper);
|
this.notificationMapperWritePlatformService.create(notificationMapper);
|
||||||
return notificationMapper.getId();
|
return notificationMapper.getId();
|
||||||
@@ -63,8 +63,9 @@ public class NotificationWritePlatformServiceImpl implements NotificationWritePl
|
|||||||
private Long insertIntoNotificationGenerator(String objectType, Long objectIdentifier, String action, Long actorId,
|
private Long insertIntoNotificationGenerator(String objectType, Long objectIdentifier, String action, Long actorId,
|
||||||
String notificationContent, boolean isSystemGenerated) {
|
String notificationContent, boolean isSystemGenerated) {
|
||||||
|
|
||||||
Notification notification = new Notification(objectType, objectIdentifier, action, actorId, isSystemGenerated, notificationContent,
|
Notification notification = new Notification().setObjectType(objectType).setObjectIdentifier(objectIdentifier).setAction(action)
|
||||||
DateUtils.getLocalDateTimeOfSystem());
|
.setActorId(actorId).setSystemGenerated(isSystemGenerated).setNotificationContent(notificationContent)
|
||||||
|
.setCreatedAt(DateUtils.getLocalDateTimeOfSystem());
|
||||||
|
|
||||||
return this.notificationGeneratorWritePlatformService.create(notification);
|
return this.notificationGeneratorWritePlatformService.create(notification);
|
||||||
}
|
}
|
||||||
@@ -84,9 +85,9 @@ public class NotificationWritePlatformServiceImpl implements NotificationWritePl
|
|||||||
List<Long> mappedIds = new ArrayList<>();
|
List<Long> mappedIds = new ArrayList<>();
|
||||||
for (Long userId : userIds) {
|
for (Long userId : userIds) {
|
||||||
AppUser appUser = this.appUserRepository.findById(userId).orElseThrow();
|
AppUser appUser = this.appUserRepository.findById(userId).orElseThrow();
|
||||||
NotificationMapper notificationMapper = new NotificationMapper(
|
NotificationMapper notificationMapper = new NotificationMapper()
|
||||||
this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId), appUser, false,
|
.setNotification(this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId)).setUserId(appUser)
|
||||||
DateUtils.getLocalDateTimeOfSystem());
|
.setRead(false).setCreatedAt(DateUtils.getLocalDateTimeOfSystem());
|
||||||
this.notificationMapperWritePlatformService.create(notificationMapper);
|
this.notificationMapperWritePlatformService.create(notificationMapper);
|
||||||
mappedIds.add(notificationMapper.getId());
|
mappedIds.add(notificationMapper.getId());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user