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

Commit 44e50be

Browse files
author
sowerstl
committed
Move POC email to Approve step and update text; (DOECODE-526)
1 parent 0c0be6b commit 44e50be

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

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

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,6 @@ private Response doSubmit(String json, InputStream file, FormDataContentDisposit
15781578

15791579
// send NOTIFICATION if configured to do so
15801580
sendStatusNotification(md);
1581-
sendPOCNotification(md);
15821581

15831582
// we are done here
15841583
return Response
@@ -1774,7 +1773,6 @@ private Response doAnnounce(String json, InputStream file, FormDataContentDispos
17741773

17751774
// send NOTIFICATION if configured
17761775
sendStatusNotification(md);
1777-
sendPOCNotification(md);
17781776

17791777
// and we're happy
17801778
return Response
@@ -2064,6 +2062,7 @@ public Response approve(@PathParam("codeId") Long codeId) {
20642062

20652063
// send APPROVAL NOTIFICATION to OWNER
20662064
sendApprovalNotification(md);
2065+
sendPOCNotification(md);
20672066

20682067
// and we're happy
20692068
return Response
@@ -2454,9 +2453,8 @@ private static void sendPOCNotification(DOECodeMetadata md) {
24542453
if (StringUtils.isEmpty(siteCode))
24552454
return;
24562455

2457-
// only applicable to SUBMITTED or ANNOUNCED records
2458-
if (!Status.Announced.equals(workflowStatus) &&
2459-
!Status.Submitted.equals(workflowStatus))
2456+
// only applicable to APPROVED records
2457+
if (!Status.Approved.equals(workflowStatus))
24602458
return;
24612459

24622460
// get the SITE information
@@ -2466,6 +2464,18 @@ private static void sendPOCNotification(DOECodeMetadata md) {
24662464
return;
24672465
}
24682466

2467+
// lookup previous Snapshot status info for item
2468+
EntityManager em = DoeServletContextListener.createEntityManager();
2469+
TypedQuery<MetadataSnapshot> querySnapshot = em.createNamedQuery("MetadataSnapshot.findByCodeIdLastNotStatus", MetadataSnapshot.class)
2470+
.setParameter("status", DOECodeMetadata.Status.Approved)
2471+
.setParameter("codeId", codeId);
2472+
2473+
String lastApprovalFor = "submitted/announced";
2474+
List<MetadataSnapshot> results = querySnapshot.setMaxResults(1).getResultList();
2475+
for ( MetadataSnapshot ms : results ) {
2476+
lastApprovalFor = ms.getSnapshotKey().getSnapshotStatus().toString().toLowerCase();
2477+
}
2478+
24692479
List<String> emails = site.getPocEmails();
24702480

24712481
// if POC is setup
@@ -2493,22 +2503,24 @@ private static void sendPOCNotification(DOECodeMetadata md) {
24932503
msg.append("<html>");
24942504
msg.append("Dear Sir or Madam:");
24952505

2496-
msg.append("<P>As a Point of Contact for ").append(lab).append(", we wanted to inform you that a project was ")
2497-
.append(workflowStatus)
2498-
.append(" and assigned DOE CODE ID: <a href=\"")
2499-
.append(SITE_URL)
2500-
.append("/biblio/")
2501-
.append(codeId)
2502-
.append("\">")
2506+
String biblioLink = SITE_URL + "/biblio/" + codeId;
2507+
2508+
msg.append("<p>As a point of contact for ").append(lab).append(", we wanted to inform you that a software project, titled ")
2509+
.append(md.getSoftwareTitle())
2510+
.append(", associated with your organization was ").append(lastApprovalFor).append(" to DOE CODE and assigned DOE CODE ID: ")
25032511
.append(codeId)
2504-
.append("</a>. Once approved, it will be <a href=\"")
2512+
.append(". This project record is discoverable in <a href=\"")
25052513
.append(SITE_URL)
2506-
.append("\">searchable</a> in DOE CODE by, for example, title or CODE ID #.</P>");
2514+
.append("\">DOE CODE</a>, e.g. searching by the project title or DOE CODE ID #, and can be found here: <a href=\"")
2515+
.append(biblioLink)
2516+
.append("\">")
2517+
.append(biblioLink)
2518+
.append("</a></p>");
25072519

25082520

2509-
msg.append("<P>If you have any questions, please do not hesitate to <a href=\"mailto:[email protected]\">Contact Us</a>.</P>");
2510-
msg.append("<P>Sincerely,</P>");
2511-
msg.append("<P>"+PM_NAME+"<BR/>Product Manager for DOE CODE<BR/>USDOE/OSTI</P>");
2521+
msg.append("<p>If you have any questions, please do not hesitate to <a href=\"mailto:[email protected]\">Contact Us</a>.</p>");
2522+
msg.append("<p>Sincerely,</p>");
2523+
msg.append("<p>"+PM_NAME+"<br/>Product Manager for DOE CODE<br/>USDOE/OSTI</p>");
25122524

25132525
msg.append("</html>");
25142526

0 commit comments

Comments
 (0)