Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit 2da95f9

Browse files
author
sowerstl
committed
Adjust sendApprovalNotification email message based on previous action; (DOECODE-629)
1 parent 14ba1d8 commit 2da95f9

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/main/java/gov/osti/services/Metadata.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,6 +2383,18 @@ private static void sendApprovalNotification(DOECodeMetadata md) {
23832383

23842384
Long codeId = md.getCodeId();
23852385

2386+
// lookup previous Snapshot status info for item
2387+
EntityManager em = DoeServletContextListener.createEntityManager();
2388+
TypedQuery<MetadataSnapshot> querySnapshot = em.createNamedQuery("MetadataSnapshot.findByCodeIdLastNotStatus", MetadataSnapshot.class)
2389+
.setParameter("status", DOECodeMetadata.Status.Approved)
2390+
.setParameter("codeId", codeId);
2391+
2392+
String lastApprovalFor = "submitted/announced";
2393+
List<MetadataSnapshot> results = querySnapshot.setMaxResults(1).getResultList();
2394+
for ( MetadataSnapshot ms : results ) {
2395+
lastApprovalFor = ms.getSnapshotKey().getSnapshotStatus().toString().toLowerCase();
2396+
}
2397+
23862398
String softwareTitle = md.getSoftwareTitle().replaceAll("^\\h+|\\h+$","");
23872399

23882400
email.setFrom(EMAIL_FROM);
@@ -2402,7 +2414,7 @@ private static void sendApprovalNotification(DOECodeMetadata md) {
24022414
.append(owner.getLastName())
24032415
.append(":");
24042416

2405-
msg.append("<P>Thank you -- your submitted project, DOE CODE ID: <a href=\"")
2417+
msg.append("<P>Thank you -- your ").append(lastApprovalFor).append(" project, DOE CODE ID: <a href=\"")
24062418
.append(SITE_URL)
24072419
.append("/biblio/")
24082420
.append(codeId)
@@ -2412,8 +2424,8 @@ private static void sendApprovalNotification(DOECodeMetadata md) {
24122424
.append(SITE_URL)
24132425
.append("\">searchable</a> in DOE CODE by, for example, title or CODE ID #.</P>");
24142426

2415-
// OMIT the following for BUSINESS TYPE software
2416-
if (!DOECodeMetadata.Type.B.equals(md.getSoftwareType())) {
2427+
// OMIT the following for BUSINESS TYPE software, or last ANNOUNCED software
2428+
if (!DOECodeMetadata.Type.B.equals(md.getSoftwareType()) && !lastApprovalFor.equalsIgnoreCase("announced")) {
24172429
msg.append("<P>You may need to continue editing your project to announce it to the Department of Energy ")
24182430
.append("to ensure announcement and dissemination in accordance with DOE statutory responsibilities. For more information please see ")
24192431
.append("<a href=\"")

0 commit comments

Comments
 (0)