add description created notification type

This commit is contained in:
amentis 2024-06-12 12:06:40 +03:00
parent 3608a6297e
commit 89fe30df30
8 changed files with 401 additions and 20 deletions

View File

@ -11,6 +11,7 @@ public class NotificationProperties {
private UUID dmpInvitationExistingUserType; private UUID dmpInvitationExistingUserType;
private UUID dmpModifiedType; private UUID dmpModifiedType;
private UUID dmpFinalisedType; private UUID dmpFinalisedType;
private UUID descriptionCreatedType;
private UUID descriptionModifiedType; private UUID descriptionModifiedType;
private UUID descriptionFinalisedType; private UUID descriptionFinalisedType;
private UUID descriptionAnnotationCreated; private UUID descriptionAnnotationCreated;
@ -55,6 +56,14 @@ public class NotificationProperties {
this.dmpFinalisedType = dmpFinalisedType; this.dmpFinalisedType = dmpFinalisedType;
} }
public UUID getDescriptionCreatedType() {
return descriptionCreatedType;
}
public void setDescriptionCreatedType(UUID descriptionCreatedType) {
this.descriptionCreatedType = descriptionCreatedType;
}
public UUID getDescriptionModifiedType() { public UUID getDescriptionModifiedType() {
return this.descriptionModifiedType; return this.descriptionModifiedType;
} }

View File

@ -260,9 +260,7 @@ public class DescriptionServiceImpl implements DescriptionService {
this.persistTags(data.getId(), model.getTags()); this.persistTags(data.getId(), model.getTags());
if (isUpdate){ this.sendNotification(data, isUpdate);
this.sendNotification(data);
}
//this.deleteOldFilesAndAddNew(datasetWizardModel, userInfo); //TODO //this.deleteOldFilesAndAddNew(datasetWizardModel, userInfo); //TODO
this.eventBroker.emit(new DescriptionTouchedEvent(data.getId())); this.eventBroker.emit(new DescriptionTouchedEvent(data.getId()));
@ -313,7 +311,7 @@ public class DescriptionServiceImpl implements DescriptionService {
this.entityManager.flush(); this.entityManager.flush();
this.sendNotification(data); this.sendNotification(data, true);
this.eventBroker.emit(new DescriptionTouchedEvent(data.getId())); this.eventBroker.emit(new DescriptionTouchedEvent(data.getId()));
@ -322,7 +320,7 @@ public class DescriptionServiceImpl implements DescriptionService {
this.elasticService.persistDescription(data); this.elasticService.persistDescription(data);
} }
private void sendNotification(DescriptionEntity description) throws InvalidApplicationException { private void sendNotification(DescriptionEntity description, Boolean isUpdate) throws InvalidApplicationException {
List<DmpUserEntity> existingUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking() List<DmpUserEntity> existingUsers = this.queryFactory.query(DmpUserQuery.class).disableTracking()
.dmpIds(description.getDmpId()) .dmpIds(description.getDmpId())
.isActives(IsActive.Active) .isActives(IsActive.Active)
@ -335,7 +333,7 @@ public class DescriptionServiceImpl implements DescriptionService {
if (!dmpUser.getUserId().equals(this.userScope.getUserIdSafe())){ if (!dmpUser.getUserId().equals(this.userScope.getUserIdSafe())){
UserEntity user = this.queryFactory.query(UserQuery.class).disableTracking().ids(dmpUser.getUserId()).first(); UserEntity user = this.queryFactory.query(UserQuery.class).disableTracking().ids(dmpUser.getUserId()).first();
if (user == null || user.getIsActive().equals(IsActive.Inactive)) throw new MyValidationException(this.errors.getDmpInactiveUser().getCode(), this.errors.getDmpInactiveUser().getMessage()); if (user == null || user.getIsActive().equals(IsActive.Inactive)) throw new MyValidationException(this.errors.getDmpInactiveUser().getCode(), this.errors.getDmpInactiveUser().getMessage());
this.createDescriptionNotificationEvent(description, user); this.createDescriptionNotificationEvent(description, user, isUpdate);
} }
} }
} }
@ -384,11 +382,11 @@ public class DescriptionServiceImpl implements DescriptionService {
return cleanData; return cleanData;
} }
private void createDescriptionNotificationEvent(DescriptionEntity description, UserEntity user) throws InvalidApplicationException { private void createDescriptionNotificationEvent(DescriptionEntity description, UserEntity user, Boolean isUpdate) throws InvalidApplicationException {
NotifyIntegrationEvent event = new NotifyIntegrationEvent(); NotifyIntegrationEvent event = new NotifyIntegrationEvent();
event.setUserId(user.getId()); event.setUserId(user.getId());
this.applyNotificationType(description.getStatus(), event); this.applyNotificationType(description.getStatus(), event, isUpdate);
NotificationFieldData data = new NotificationFieldData(); NotificationFieldData data = new NotificationFieldData();
List<FieldInfo> fieldInfoList = new ArrayList<>(); List<FieldInfo> fieldInfoList = new ArrayList<>();
fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName())); fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName()));
@ -404,18 +402,20 @@ public class DescriptionServiceImpl implements DescriptionService {
this.eventHandler.handle(event); this.eventHandler.handle(event);
} }
private void applyNotificationType(DescriptionStatus status, NotifyIntegrationEvent event) { private void applyNotificationType(DescriptionStatus status, NotifyIntegrationEvent event, Boolean isUpdate) {
switch (status) { if (!isUpdate) event.setNotificationType(this.notificationProperties.getDescriptionCreatedType());
case Draft: else {
event.setNotificationType(this.notificationProperties.getDescriptionModifiedType()); switch (status) {
break; case Draft:
case Finalized: event.setNotificationType(this.notificationProperties.getDescriptionModifiedType());
event.setNotificationType(this.notificationProperties.getDescriptionFinalisedType()); break;
break; case Finalized:
default: event.setNotificationType(this.notificationProperties.getDescriptionFinalisedType());
throw new MyApplicationException("Unsupported Description Status."); break;
default:
throw new MyApplicationException("Unsupported Description Status.");
}
} }
return;
} }
@Override @Override
@ -446,7 +446,7 @@ public class DescriptionServiceImpl implements DescriptionService {
this.eventBroker.emit(new DescriptionTouchedEvent(data.getId())); this.eventBroker.emit(new DescriptionTouchedEvent(data.getId()));
this.annotationEntityTouchedIntegrationEventHandler.handleDescription(data.getId()); this.annotationEntityTouchedIntegrationEventHandler.handleDescription(data.getId());
if (data.getStatus().equals(DescriptionStatus.Finalized)) this.sendNotification(data); if (data.getStatus().equals(DescriptionStatus.Finalized)) this.sendNotification(data, true);
} }
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Description._id), data); return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Description._id), data);
} }

View File

@ -3,6 +3,7 @@ notification:
dmpInvitationExistingUserType: 4904dea2-5079-46d3-83be-3a19c9ab45dc dmpInvitationExistingUserType: 4904dea2-5079-46d3-83be-3a19c9ab45dc
dmpModifiedType: 4542262A-22F8-4BAA-9DB6-1C8E70AC1DBB dmpModifiedType: 4542262A-22F8-4BAA-9DB6-1C8E70AC1DBB
dmpFinalisedType: 90DB0B46-42DE-BD89-AEBF-6F27EFEB256E dmpFinalisedType: 90DB0B46-42DE-BD89-AEBF-6F27EFEB256E
descriptionCreatedType: 8965b1d5-99a6-4acf-9016-c0d0ce341364
descriptionModifiedType: 4FDBFA80-7A71-4A69-B854-67CBB70648F1 descriptionModifiedType: 4FDBFA80-7A71-4A69-B854-67CBB70648F1
descriptionFinalisedType: 33790bad-94d4-488a-8ee2-7f6295ca18ea descriptionFinalisedType: 33790bad-94d4-488a-8ee2-7f6295ca18ea
descriptionAnnotationCreated: db1e99d2-a240-4e75-9bb2-ef25b234c1f0 descriptionAnnotationCreated: db1e99d2-a240-4e75-9bb2-ef25b234c1f0

View File

@ -18,6 +18,9 @@ notification:
- #planFinalised - #planFinalised
type: 90DB0B46-42DE-BD89-AEBF-6F27EFEB256E type: 90DB0B46-42DE-BD89-AEBF-6F27EFEB256E
contacts: [ inapp, email ] contacts: [ inapp, email ]
- #descriptionCreated
type: 8965b1d5-99a6-4acf-9016-c0d0ce341364
contacts: [ inapp, email ]
- #descriptionModified - #descriptionModified
type: 4FDBFA80-7A71-4A69-B854-67CBB70648F1 type: 4FDBFA80-7A71-4A69-B854-67CBB70648F1
contacts: [ inapp, email ] contacts: [ inapp, email ]
@ -149,6 +152,31 @@ notification:
bcc-mode: 0 bcc-mode: 0
allow-attachments: false allow-attachments: false
cipher-fields: [ ] cipher-fields: [ ]
- #desriptionCreated
key: 8965b1d5-99a6-4acf-9016-c0d0ce341364
subject-path: classpath:notification_templates/descriptioncreated/email/subject.{language}.txt
subject-field-options:
mandatory: [ ]
optional: [ ]
body-path: classpath:notification_templates/descriptioncreated/email/body.{language}.html
body-field-options:
mandatory: [ "{reasonName}", "{name}", "{installation-url}", "{id}" ]
optional:
- key: "{recipient}"
value:
- key: "{tenant-url-path}"
value:
formatting:
'[{reasonName}]': null
'[{name}]': null
'[{recipient}]': null
'[{tenant-url-path}]': null
cc: [ ]
cc-mode: 0
bcc: [ ]
bcc-mode: 0
allow-attachments: false
cipher-fields: [ ]
- #desriptionModified - #desriptionModified
key: 4FDBFA80-7A71-4A69-B854-67CBB70648F1 key: 4FDBFA80-7A71-4A69-B854-67CBB70648F1
subject-path: classpath:notification_templates/descriptionmodified/email/subject.{language}.txt subject-path: classpath:notification_templates/descriptionmodified/email/subject.{language}.txt
@ -431,6 +459,31 @@ notification:
'[{tenant-url-path}]': null '[{tenant-url-path}]': null
priority-key: null priority-key: null
cipher-fields: [ ] cipher-fields: [ ]
- #desriptionCreated
key: 8965b1d5-99a6-4acf-9016-c0d0ce341364
subject-path: classpath:notification_templates/descriptioncreated/inapp/subject.{language}.txt
subject-field-options:
mandatory: [ ]
optional: [ ]
body-path: classpath:notification_templates/descriptioncreated/inapp/body.{language}.html
body-field-options:
mandatory: [ "{reasonName}", "{name}", "{installation-url}", "{id}" ]
optional:
- key: "{recipient}"
value:
- key: "{tenant-url-path}"
value:
formatting:
'[{reasonName}]': null
'[{name}]': null
'[{recipient}]': null
'[{tenant-url-path}]': null
cc: [ ]
cc-mode: 0
bcc: [ ]
bcc-mode: 0
allow-attachments: false
cipher-fields: [ ]
- #desriptionModified - #desriptionModified
key: 4FDBFA80-7A71-4A69-B854-67CBB70648F1 key: 4FDBFA80-7A71-4A69-B854-67CBB70648F1
subject-path: classpath:notification_templates/descriptionmodified/inapp/subject.{language}.txt subject-path: classpath:notification_templates/descriptionmodified/inapp/subject.{language}.txt

View File

@ -0,0 +1,304 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>OpenCDMP Notification</title>
<style>
/* -------------------------------------
GLOBAL RESETS
------------------------------------- */
img {
border: none;
-ms-interpolation-mode: bicubic;
max-width: 100%; }
body {
background-color: #f6f6f6;
font-family: sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 14px;
line-height: 1.4;
margin: 0;
padding: 0;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%; }
table {
border-collapse: separate;
mso-table-lspace: 0pt;
mso-table-rspace: 0pt;
width: 100%; }
table td {
font-family: sans-serif;
font-size: 14px;
vertical-align: top; }
/* -------------------------------------
BODY & CONTAINER
------------------------------------- */
.body {
background-color: #f6f6f6;
width: 100%; }
/* Set a max-width, and make it display as block so it will automatically stretch to that width, but will also shrink down on a phone or something */
.container {
display: block;
Margin: 0 auto !important;
/* makes it centered */
max-width: 580px;
padding: 10px;
width: 580px; }
/* This should also be a block element, so that it will fill 100% of the .container */
.content {
box-sizing: border-box;
display: block;
Margin: 0 auto;
max-width: 580px;
padding: 10px; }
/* -------------------------------------
HEADER, FOOTER, MAIN
------------------------------------- */
.main {
background: #ffffff;
border-radius: 3px;
width: 100%; }
.wrapper {
box-sizing: border-box;
padding: 20px; }
.content-block {
padding-bottom: 10px;
padding-top: 10px;
}
.footer {
clear: both;
Margin-top: 10px;
text-align: center;
width: 100%; }
.footer td,
.footer p,
.footer span,
.footer a {
color: #999999;
font-size: 12px;
text-align: center; }
/* -------------------------------------
TYPOGRAPHY
------------------------------------- */
h1,
h2,
h3,
h4 {
color: #000000;
font-family: sans-serif;
font-weight: 400;
line-height: 1.4;
margin: 0;
Margin-bottom: 30px; }
h1 {
font-size: 35px;
font-weight: 300;
text-align: center;
text-transform: capitalize; }
p,
ul,
ol {
font-family: sans-serif;
font-size: 14px;
font-weight: normal;
margin: 0;
Margin-bottom: 15px; }
p li,
ul li,
ol li {
list-style-position: inside;
margin-left: 5px; }
a {
color: #3498db;
text-decoration: underline; }
/* -------------------------------------
BUTTONS
------------------------------------- */
.btn {
box-sizing: border-box;
width: 100%; }
.btn > tbody > tr > td {
padding-bottom: 15px; }
.btn table {
width: auto; }
.btn table td {
background-color: #ffffff;
border-radius: 5px;
text-align: center; }
.btn a {
background-color: #ffffff;
border: solid 1px #3498db;
border-radius: 5px;
box-sizing: border-box;
color: #3498db;
cursor: pointer;
display: inline-block;
font-size: 14px;
font-weight: bold;
margin: 0;
padding: 12px 25px;
text-decoration: none;
text-transform: capitalize; }
.btn-primary table td {
background-color: #3498db; }
.btn-primary a {
background-color: #3498db;
border-color: #3498db;
color: #ffffff; }
/* -------------------------------------
OTHER STYLES THAT MIGHT BE USEFUL
------------------------------------- */
.last {
margin-bottom: 0; }
.first {
margin-top: 0; }
.align-center {
text-align: center; }
.align-right {
text-align: right; }
.align-left {
text-align: left; }
.clear {
clear: both; }
.mt0 {
margin-top: 0; }
.mb0 {
margin-bottom: 0; }
.preheader {
color: transparent;
display: none;
height: 0;
max-height: 0;
max-width: 0;
opacity: 0;
overflow: hidden;
mso-hide: all;
visibility: hidden;
width: 0; }
.powered-by a {
text-decoration: none; }
hr {
border: 0;
border-bottom: 1px solid #f6f6f6;
Margin: 20px 0; }
/* -------------------------------------
RESPONSIVE AND MOBILE FRIENDLY STYLES
------------------------------------- */
@media only screen and (max-width: 620px) {
table[class=body] h1 {
font-size: 28px !important;
margin-bottom: 10px !important; }
table[class=body] p,
table[class=body] ul,
table[class=body] ol,
table[class=body] td,
table[class=body] span,
table[class=body] a {
font-size: 16px !important; }
table[class=body] .wrapper,
table[class=body] .article {
padding: 10px !important; }
table[class=body] .content {
padding: 0 !important; }
table[class=body] .container {
padding: 0 !important;
width: 100% !important; }
table[class=body] .main {
border-left-width: 0 !important;
border-radius: 0 !important;
border-right-width: 0 !important; }
table[class=body] .btn table {
width: 100% !important; }
table[class=body] .btn a {
width: 100% !important; }
table[class=body] .img-responsive {
height: auto !important;
max-width: 100% !important;
width: auto !important; }}
/* -------------------------------------
PRESERVE THESE STYLES IN THE HEAD
------------------------------------- */
@media all {
.ExternalClass {
width: 100%; }
.ExternalClass,
.ExternalClass p,
.ExternalClass span,
.ExternalClass font,
.ExternalClass td,
.ExternalClass div {
line-height: 100%; }
.apple-link a {
color: inherit !important;
font-family: inherit !important;
font-size: inherit !important;
font-weight: inherit !important;
line-height: inherit !important;
text-decoration: none !important; }
.btn-primary table td:hover {
background-color: #34495e !important; }
.btn-primary a:hover {
background-color: #34495e !important;
border-color: #34495e !important; } }
</style>
</head>
<body class="">
<table border="0" cellpadding="0" cellspacing="0" class="body">
<tr>
<td>&nbsp;</td>
<td class="container">
<div class="content">
<!-- START CENTERED WHITE CONTAINER -->
<span class="preheader">This is preheader text. Some clients will show this text as a preview.</span>
<table class="main">
<!-- START MAIN CONTENT AREA -->
<tr>
<td class="wrapper">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<p>Dear {recipient},</p>
<p>{reasonName} created new Description with name {name}.</p>
<table border="0" cellpadding="0" cellspacing="0" class="btn btn-primary">
<tbody>
<tr>
<td align="left">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td> <a href="{installation-url}{tenant-url-path}/descriptions/overview/{id}" target="_blank">Click here to view it.</a> </td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- END MAIN CONTENT AREA -->
</table>
<!-- START FOOTER -->
<div class="footer">
</div>
<!-- END FOOTER -->
<!-- END CENTERED WHITE CONTAINER -->
</div>
</td>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>

View File

@ -0,0 +1,12 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body class="">
<p>Dear {recipient},</p>
<p>{reasonName} created new Description with name {name}.</p>
<a href="{installation-url}{tenant-url-path}/descriptions/overview/{id}" target="_blank">Click here to view it.</a>
</body>
</html>