fix read all inapp notifications query
This commit is contained in:
parent
b2e2fc593f
commit
cb7d5b342f
|
@ -124,7 +124,7 @@ public class InAppNotificationController {
|
||||||
|
|
||||||
@PostMapping("read-all")
|
@PostMapping("read-all")
|
||||||
@Transactional
|
@Transactional
|
||||||
public Boolean MarkAsReadAllUserInAppNotification() throws InvalidApplicationException, NoSuchFieldException {
|
public Boolean MarkAsReadAllUserInAppNotification() throws InvalidApplicationException {
|
||||||
logger.debug(new MapLogEntry("marking as read all"));
|
logger.debug(new MapLogEntry("marking as read all"));
|
||||||
|
|
||||||
UUID userId = this.userScope.getUserId();
|
UUID userId = this.userScope.getUserId();
|
||||||
|
|
|
@ -335,6 +335,163 @@ notification:
|
||||||
'[{recipient}]': null
|
'[{recipient}]': null
|
||||||
priority-key: null
|
priority-key: null
|
||||||
cipher-fields: [ ]
|
cipher-fields: [ ]
|
||||||
|
- #dmpModified
|
||||||
|
key: 4542262A-22F8-4BAA-9DB6-1C8E70AC1DBB
|
||||||
|
subject-path: classpath:notification_templates/dmpmodified/inapp/subject.{language}.txt
|
||||||
|
subject-field-options:
|
||||||
|
mandatory: [ ]
|
||||||
|
optional: [ ]
|
||||||
|
body-path: classpath:notification_templates/dmpmodified/inapp/body.{language}.html
|
||||||
|
body-field-options:
|
||||||
|
mandatory: [ "{reasonName}", "{name}", "{installation-url}", "{id}" ]
|
||||||
|
optional:
|
||||||
|
- key: "{recipient}"
|
||||||
|
value:
|
||||||
|
formatting:
|
||||||
|
'[{reasonName}]': null
|
||||||
|
'[{name}]': null
|
||||||
|
'[{installation-url}]': null
|
||||||
|
'[{id}]': null
|
||||||
|
'[{recipient}]': null
|
||||||
|
priority-key: null
|
||||||
|
cipher-fields: [ ]
|
||||||
|
- #dmpFinalised
|
||||||
|
key: 90DB0B46-42DE-BD89-AEBF-6F27EFEB256E
|
||||||
|
subject-path: classpath:notification_templates/dmpfinalised/inapp/subject.{language}.txt
|
||||||
|
subject-field-options:
|
||||||
|
mandatory: [ ]
|
||||||
|
optional: [ ]
|
||||||
|
body-path: classpath:notification_templates/dmpfinalised/inapp/body.{language}.html
|
||||||
|
body-field-options:
|
||||||
|
mandatory: [ "{reasonName}", "{name}", "{installation-url}", "{id}" ]
|
||||||
|
optional:
|
||||||
|
- key: "{recipient}"
|
||||||
|
value:
|
||||||
|
formatting:
|
||||||
|
'[{reasonName}]': null
|
||||||
|
'[{name}]': null
|
||||||
|
'[{installation-url}]': null
|
||||||
|
'[{id}]': null
|
||||||
|
'[{recipient}]': null
|
||||||
|
priority-key: null
|
||||||
|
cipher-fields: [ ]
|
||||||
|
- #desriptionModified
|
||||||
|
key: 4FDBFA80-7A71-4A69-B854-67CBB70648F1
|
||||||
|
subject-path: classpath:notification_templates/descriptionmodified/inapp/subject.{language}.txt
|
||||||
|
subject-field-options:
|
||||||
|
mandatory: [ ]
|
||||||
|
optional: [ ]
|
||||||
|
body-path: classpath:notification_templates/descriptionmodified/inapp/body.{language}.html
|
||||||
|
body-field-options:
|
||||||
|
mandatory: [ "{reasonName}", "{name}", "{installation-url}", "{id}" ]
|
||||||
|
optional:
|
||||||
|
- key: "{recipient}"
|
||||||
|
value:
|
||||||
|
formatting:
|
||||||
|
'[{reasonName}]': null
|
||||||
|
'[{name}]': null
|
||||||
|
'[{installation-url}]': null
|
||||||
|
'[{id}]': null
|
||||||
|
'[{recipient}]': null
|
||||||
|
priority-key: null
|
||||||
|
cipher-fields: [ ]
|
||||||
|
- #descriptionFinalised
|
||||||
|
key: 33790bad-94d4-488a-8ee2-7f6295ca18ea
|
||||||
|
subject-path: classpath:notification_templates/descriptionfinalised/inapp/subject.{language}.txt
|
||||||
|
subject-field-options:
|
||||||
|
mandatory: [ ]
|
||||||
|
optional: [ ]
|
||||||
|
body-path: classpath:notification_templates/descriptionfinalised/inapp/body.{language}.html
|
||||||
|
body-field-options:
|
||||||
|
mandatory: [ "{reasonName}", "{name}", "{installation-url}", "{id}" ]
|
||||||
|
optional:
|
||||||
|
- key: "{recipient}"
|
||||||
|
value:
|
||||||
|
formatting:
|
||||||
|
'[{reasonName}]': null
|
||||||
|
'[{name}]': null
|
||||||
|
'[{installation-url}]': null
|
||||||
|
'[{id}]': null
|
||||||
|
'[{recipient}]': null
|
||||||
|
priority-key: null
|
||||||
|
cipher-fields: [ ]
|
||||||
|
- #mergeAccountConfirmation
|
||||||
|
key: BFE68845-CB05-4C5A-A03D-29161A7C9660
|
||||||
|
subject-path: classpath:notification_templates/mergeacountconfirmation/inapp/subject.{language}.txt
|
||||||
|
subject-field-options:
|
||||||
|
mandatory: [ ]
|
||||||
|
optional: [ ]
|
||||||
|
body-path: classpath:notification_templates/mergeacountconfirmation/inapp/body.{language}.html
|
||||||
|
body-field-options:
|
||||||
|
mandatory: [ "{userName}", "{installation-url}", "{confirmationToken}" ]
|
||||||
|
optional:
|
||||||
|
- key: "{expiration_time}"
|
||||||
|
value: ---
|
||||||
|
formatting:
|
||||||
|
'[{userName}]': null
|
||||||
|
'[{installation-url}]': null
|
||||||
|
'[{confirmationToken}]': null
|
||||||
|
'[{expiration_time}]': null
|
||||||
|
priority-key: null
|
||||||
|
cipher-fields: [ ]
|
||||||
|
- #removeCredentialConfirmation
|
||||||
|
key: C9BC3F16-057E-4BBA-8A5F-36BD835E5604
|
||||||
|
subject-path: classpath:notification_templates/removecredentialconfirmation/inapp/subject.{language}.txt
|
||||||
|
subject-field-options:
|
||||||
|
mandatory: [ "{installation-url}", "{confirmationToken}" ]
|
||||||
|
optional: [ ]
|
||||||
|
body-path: classpath:notification_templates/removecredentialconfirmation/inapp/body.{language}.html
|
||||||
|
body-field-options:
|
||||||
|
mandatory: [ ]
|
||||||
|
optional:
|
||||||
|
- key: "{email}"
|
||||||
|
value: email
|
||||||
|
- key: "{expiration_time}"
|
||||||
|
value: --
|
||||||
|
formatting:
|
||||||
|
'[{email}]': null
|
||||||
|
'[{expiration_time}]': null
|
||||||
|
priority-key: null
|
||||||
|
cipher-fields: [ ]
|
||||||
|
- #dmpDeposit
|
||||||
|
key: 55736F7A-83AB-4190-AF43-9D031A6F9612
|
||||||
|
subject-path: classpath:notification_templates/dmpdeposit/inapp/subject.{language}.txt
|
||||||
|
subject-field-options:
|
||||||
|
mandatory: [ ]
|
||||||
|
optional: [ ]
|
||||||
|
body-path: classpath:notification_templates/dmpdeposit/inapp/body.{language}.html
|
||||||
|
body-field-options:
|
||||||
|
mandatory: [ "{reasonName}", "{name}", "{installation-url}", "{id}" ]
|
||||||
|
optional:
|
||||||
|
- key: "{recipient}"
|
||||||
|
value:
|
||||||
|
formatting:
|
||||||
|
'[{reasonName}]': null
|
||||||
|
'[{name}]': null
|
||||||
|
'[{installation-url}]': null
|
||||||
|
'[{id}]': null
|
||||||
|
'[{recipient}]': null
|
||||||
|
priority-key: null
|
||||||
|
cipher-fields: [ ]
|
||||||
|
- #descriptionTemplateInvitation
|
||||||
|
key: 223BB607-EFA1-4CE7-99EC-4BEABFEF9A8B
|
||||||
|
subject-path: classpath:notification_templates/descriptiontemplateinvitation/inapp/subject.{language}.txt
|
||||||
|
subject-field-options:
|
||||||
|
mandatory: [ ]
|
||||||
|
optional: [ ]
|
||||||
|
body-path: classpath:notification_templates/descriptiontemplateinvitation/inapp/body.{language}.html
|
||||||
|
body-field-options:
|
||||||
|
mandatory: [ "{templateName}", "{installation-url}", "{templateID}" ]
|
||||||
|
optional:
|
||||||
|
- key: "{recipient}"
|
||||||
|
value:
|
||||||
|
formatting:
|
||||||
|
'[{templateName}]': null
|
||||||
|
'[{installation-url}]': null
|
||||||
|
'[{templateID}]': null
|
||||||
|
'[{recipient}]': null
|
||||||
|
priority-key: null
|
||||||
|
cipher-fields: [ ]
|
||||||
template-cache:
|
template-cache:
|
||||||
prefix: ${CACHE_DISAMBIGUATION:}
|
prefix: ${CACHE_DISAMBIGUATION:}
|
||||||
key-pattern: "{prefix}:Notification_Message_InApp_Template:{key}:v0"
|
key-pattern: "{prefix}:Notification_Message_InApp_Template:{key}:v0"
|
||||||
|
|
|
@ -9,5 +9,5 @@ public interface InAppNotificationService {
|
||||||
void markAsRead(List<UUID> ids);
|
void markAsRead(List<UUID> ids);
|
||||||
void markAsRead(UUID id);
|
void markAsRead(UUID id);
|
||||||
void deleteAndSave(UUID id) throws InvalidApplicationException;
|
void deleteAndSave(UUID id) throws InvalidApplicationException;
|
||||||
void markAsReadAllUserNotification(UUID userId) throws NoSuchFieldException;
|
void markAsReadAllUserNotification(UUID userId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,23 +68,18 @@ public class InAppNotificationServiceImpl implements InAppNotificationService{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markAsReadAllUserNotification(UUID userId) throws NoSuchFieldException {
|
public void markAsReadAllUserNotification(UUID userId) {
|
||||||
|
|
||||||
String entity = InAppNotificationEntity.class.getSimpleName();
|
String entity = InAppNotificationEntity.class.getSimpleName();
|
||||||
String trackingStateProperty = InAppNotificationEntity.class.getDeclaredField(InAppNotificationEntity.Field._trackingState).getAnnotation(Column.class).name().replace("\"", "");
|
|
||||||
String updateProperty = InAppNotificationEntity.class.getDeclaredField(InAppNotificationEntity.Field._updatedAt).getAnnotation(Column.class).name().replace("\"", "");
|
|
||||||
String readTimeProperty = InAppNotificationEntity.class.getDeclaredField(InAppNotificationEntity.Field._readTime).getAnnotation(Column.class).name().replace("\"", "");
|
|
||||||
String userProperty = InAppNotificationEntity.class.getDeclaredField(InAppNotificationEntity.Field._userId).getAnnotation(Column.class).name().replace("\"", "");
|
|
||||||
|
|
||||||
String sqlQuery = "UPDATE " + entity + " SET "+ trackingStateProperty +" = :trackingState, "+ updateProperty + "= :updatedAt, " + readTimeProperty + " = :readTime " +
|
String sqlQuery = "UPDATE " + entity + " as e SET "+ InAppNotificationEntity.Field._trackingState +" = :trackingState, "+ InAppNotificationEntity.Field._updatedAt + "= :updatedAt, " + InAppNotificationEntity.Field._readTime + " = :readTime " +
|
||||||
"WHERE " + trackingStateProperty + " = :trackingStateCondition";//TODO AND \"'user\" = :userId";
|
"WHERE e." + InAppNotificationEntity.Field._trackingState + " = :trackingStateCondition AND e."+ InAppNotificationEntity.Field._userId + " = :userId";
|
||||||
|
|
||||||
Query query = this.entityManager.createQuery(sqlQuery)
|
Query query = this.entityManager.createQuery(sqlQuery)
|
||||||
.setParameter("trackingState", NotificationInAppTracking.DELIVERED.getValue())
|
.setParameter("trackingState", NotificationInAppTracking.DELIVERED)
|
||||||
.setParameter("updatedAt", Instant.now())
|
.setParameter("updatedAt", Instant.now())
|
||||||
.setParameter("readTime", Instant.now())
|
.setParameter("readTime", Instant.now())
|
||||||
//.setParameter("userId", userId)
|
.setParameter("userId", userId)
|
||||||
.setParameter("trackingStateCondition", NotificationInAppTracking.STORED.getValue());
|
.setParameter("trackingStateCondition", NotificationInAppTracking.STORED);
|
||||||
|
|
||||||
int updateCount = query.executeUpdate();
|
int updateCount = query.executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue