Skip to content

Commit

Permalink
Still not working
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Jun 27, 2024
1 parent bdb6d1c commit 264b484
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@
<@emailMacros.msg "email.digest.hasupdated_1" />
<br>
${(digestEmail.notificationsBySourceId[sourceId].source.sourceName.content)!sourceId}<@emailMacros.space /><@emailMacros.msg "email.digest.hasupdated_2" /><@emailMacros.space />${amendedSection?lower_case}<@emailMacros.space /><@emailMacros.msg "email.digest.hasupdated_3" /><@emailMacros.space /><#if notification.createdDate??>(${notification.createdDate.year?c}-<#if notification.createdDate.month?string?length == 1>0${notification.createdDate.month?c}<#else>${notification.createdDate.month?c}</#if>-<#if notification.createdDate.day?string?length == 1>0${notification.createdDate.day?c}<#else>${notification.createdDate.day?c}</#if>)</#if>






<#elseif notificationType == 'INSTITUTIONAL_CONNECTION'>
<@emailMacros.msg 'email.institutional_connection.1' /><@emailMacros.space />${(notification.idpName)!}<@emailMacros.space /><@emailMacros.msg 'email.institutional_connection.2' /><@emailMacros.msg 'email.institutional_connection.here' /><@emailMacros.msg 'email.institutional_connection.3' /><@emailMacros.space />${(notification.source.sourceName.content)!sourceId}<@emailMacros.space /><@emailMacros.msg 'email.institutional_connection.4' /><@emailMacros.space />${baseUri}/inbox/encrypted/${notification.encryptedPutCode}/action <#if notification.createdDate??>(${notification.createdDate.year?c}-<#if notification.createdDate.month?string?length == 1>0${notification.createdDate.month?c}<#else>${notification.createdDate.month?c}</#if>-<#if notification.createdDate.day?string?length == 1>0${notification.createdDate.day?c}<#else>${notification.createdDate.day?c}</#if>)</#if>
<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import org.orcid.jaxb.model.v3.release.notification.custom.NotificationAdministrative;
import org.orcid.jaxb.model.v3.release.notification.permission.Item;
import org.orcid.jaxb.model.v3.release.notification.permission.NotificationPermission;
import org.orcid.jaxb.model.v3.release.record.ExternalID;
import org.orcid.jaxb.model.v3.release.record.ExternalIDs;
import org.orcid.model.v3.release.notification.institutional_sign_in.NotificationInstitutionalConnection;
import org.orcid.persistence.dao.EmailDao;
import org.orcid.persistence.dao.GenericDao;
Expand Down Expand Up @@ -186,8 +188,6 @@ public EmailMessage createDigest(String orcid, Collection<Notification> notifica
String bodyHtmlDelegate = null;
String bodyHtmlDelegateRecipient = null;
String bodyHtmlAdminDelegate = null;

Set<String> memberIds = new HashSet<>();
DigestEmail digestEmail = new DigestEmail();

Map<String, ClientUpdates> updatesByClient = new HashMap<String, ClientUpdates>();
Expand All @@ -207,11 +207,6 @@ public EmailMessage createDigest(String orcid, Collection<Notification> notifica
digestEmail.addNotification(notification);
if (notification.getSource() == null) {
orcidMessageCount++;
} else {
SourceClientId clientId = notification.getSource().getSourceClientId();
if (clientId != null) {
memberIds.add(clientId.getPath());
}
}
if (notification instanceof NotificationPermission) {
NotificationPermission permissionNotification = (NotificationPermission) notification;
Expand Down Expand Up @@ -322,6 +317,11 @@ public void sendEmailMessages() {
if (!notifications.isEmpty()) {
LOGGER.info("Found {} messages to send for orcid: {}", notifications.size(), orcid);
EmailMessage digestMessage = createDigest(orcid, notifications);
System.out.println("---------------------------------------------------");
System.out.println(digestMessage.getBodyHtml());
System.out.println("---------------------------------------------------");
System.out.println(digestMessage.getBodyText());

digestMessage.setFrom(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG);
digestMessage.setTo(primaryEmail.getEmail());
boolean successfullySent = mailGunManager.sendEmail(digestMessage.getFrom(), digestMessage.getTo(), digestMessage.getSubject(),
Expand Down Expand Up @@ -550,6 +550,10 @@ public void addElement(XMLGregorianCalendar createdDate, Item item) {
break;
}

// Set the external identifiers list
String externalIdentifiersList = generateExternalIdentifiersList(item);
value += externalIdentifiersList;

Set<String> elements;
if (item.getActionType() != null) {
elements = updates.get(item.getItemType().name()).get(item.getActionType().name());
Expand All @@ -575,6 +579,50 @@ private void init(String itemType, String actionType) {
updates.get(itemType).put(actionType, new TreeSet<String>());
}
}

private String generateExternalIdentifiersList(Item item) {
String extIdsHtmlList = null;
if (item.getAdditionalInfo() != null) {
if(item.getAdditionalInfo().containsKey("external_identifiers")) {
Map extIds = (Map) item.getAdditionalInfo().get("external_identifiers");
if(extIds != null && extIds.containsKey("externalIdentifier")) {
List extIdsList = (List) extIds.get("externalIdentifier");
//TODO
if(extIdsList != null) {




extIdsHtmlList = "<ul>";
for(ExternalID extId : ) {
extIdsHtmlList += "<li>" + extId.getType() + ": ";
if(extId.getNormalizedUrl() != null) {
extIdsHtmlList += "<a style=\"text-decoration: underline;color: #085c77;\" target=\"_blank\" href=\"" + extId.getNormalizedUrl() + "\">" + extId.getNormalizedUrl() + "</a>";
} else if (extId.getUrl() != null) {
extIdsHtmlList += "<a style=\"text-decoration: underline;color: #085c77;\" target=\"_blank\" href=\"" + extId.getUrl() + "\">" + extId.getUrl() + "</a>";
} if(extId.getNormalized() != null) {
extIdsHtmlList += extId.getNormalized();
} else {
extIdsHtmlList += extId.getValue();
}
extIdsHtmlList += "</li>";
}
extIdsHtmlList = "</ul>";









}
}
}
}
return extIdsHtmlList;
}
}

private String getHtmlBody(NotificationAdministrative notificationAdministrative) {
Expand Down

0 comments on commit 264b484

Please sign in to comment.