From 5261c14b6bae8ac8df2df88cc05ce13b510025ec Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Sat, 9 Sep 2023 07:27:17 +0100 Subject: [PATCH] fix: Fix Kudos Sending outside of activities - MEED-2476 - Meeds-io/meeds#1090 (#346) Prior to this change, when sending a kudos outside of an activity, the Parent Entity Identifier is null while it was set as mandatory in Hibernate Entity Mapping. This change will ensure to use the exact same constraint as the ones made in database for this field, which is nullable. --- .../src/main/java/org/exoplatform/kudos/entity/KudosEntity.java | 2 +- .../main/java/org/exoplatform/kudos/service/utils/Utils.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/kudos-services/src/main/java/org/exoplatform/kudos/entity/KudosEntity.java b/kudos-services/src/main/java/org/exoplatform/kudos/entity/KudosEntity.java index 2c8df8194..5e6770522 100644 --- a/kudos-services/src/main/java/org/exoplatform/kudos/entity/KudosEntity.java +++ b/kudos-services/src/main/java/org/exoplatform/kudos/entity/KudosEntity.java @@ -76,7 +76,7 @@ public class KudosEntity implements Serializable { @Column(name = "IS_RECEIVER_USER", nullable = false) public boolean isReceiverUser; - @Column(name = "PARENT_ENTITY_ID", nullable = false) + @Column(name = "PARENT_ENTITY_ID", nullable = true) public Long parentEntityId; @Column(name = "ENTITY_ID", nullable = false) diff --git a/kudos-services/src/main/java/org/exoplatform/kudos/service/utils/Utils.java b/kudos-services/src/main/java/org/exoplatform/kudos/service/utils/Utils.java index 8310fa3b2..6f7d6fa2d 100644 --- a/kudos-services/src/main/java/org/exoplatform/kudos/service/utils/Utils.java +++ b/kudos-services/src/main/java/org/exoplatform/kudos/service/utils/Utils.java @@ -202,6 +202,8 @@ public static KudosEntity toEntity(Kudos kudos) { kudosEntity.setActivityId(kudos.getActivityId()); if (StringUtils.isNoneBlank(kudos.getParentEntityId())) { kudosEntity.setParentEntityId(Long.parseLong(kudos.getParentEntityId())); + } else { + kudosEntity.setParentEntityId(0l); } kudosEntity.setEntityType(KudosEntityType.valueOf(kudos.getEntityType()).ordinal()); kudosEntity.setSenderId(Long.parseLong(kudos.getSenderIdentityId()));