Skip to content

Commit 4e038df

Browse files
rogintonygermano
authored andcommitted
add environmentName to the alert template variable list
Issue: nextgenhealthcare/connect#6261 Original-pr: nextgenhealthcare/connect#6262 Signed-off-by: Richard Ogin <rogin@users.noreply.github.com>
1 parent 9a36030 commit 4e038df

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

client/src/com/mirth/connect/client/ui/alert/DefaultAlertEditPanel.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
/*
2-
* Copyright (c) Mirth Corporation. All rights reserved.
3-
*
4-
* http://www.mirthcorp.com
5-
*
6-
* The software in this package is published under the terms of the MPL license a copy of which has
7-
* been included with this distribution in the LICENSE.txt file.
8-
*/
1+
// SPDX-License-Identifier: MPL-2.0
2+
// SPDX-FileCopyrightText: Mirth Corporation
3+
// SPDX-FileCopyrightText: 2025-2026 Open Integration Engine Contributors
94

105
package com.mirth.connect.client.ui.alert;
116

@@ -106,6 +101,7 @@ public void updateVariableList() {
106101
variables.add("alertName");
107102
variables.add("serverId");
108103
variables.add("serverName");
104+
variables.add("environmentName");
109105
variables.add("globalMapVariable");
110106
variables.add("date");
111107

server/src/com/mirth/connect/server/alert/Alert.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
/*
2-
* Copyright (c) Mirth Corporation. All rights reserved.
3-
*
4-
* http://www.mirthcorp.com
5-
*
6-
* The software in this package is published under the terms of the MPL license a copy of which has
7-
* been included with this distribution in the LICENSE.txt file.
8-
*/
1+
// SPDX-License-Identifier: MPL-2.0
2+
// SPDX-FileCopyrightText: Mirth Corporation
3+
// SPDX-FileCopyrightText: 2025-2026 Open Integration Engine Contributors
94

105
package com.mirth.connect.server.alert;
116

7+
import static java.util.Map.entry;
8+
129
import java.util.HashMap;
10+
import java.util.Objects;
1311
import java.util.Map;
1412
import java.util.concurrent.atomic.AtomicInteger;
1513

14+
import org.apache.logging.log4j.LogManager;
15+
import org.apache.logging.log4j.Logger;
1616
import org.apache.velocity.tools.generic.DateTool;
1717

18+
import com.mirth.connect.client.core.ControllerException;
19+
import com.mirth.connect.model.ServerSettings;
1820
import com.mirth.connect.model.alert.AlertModel;
1921
import com.mirth.connect.server.controllers.ConfigurationController;
2022

2123
public class Alert {
24+
private static final Logger logger = LogManager.getLogger(Alert.class);
2225

2326
private AlertModel model;
2427
private Long enabledDateTime;
@@ -56,12 +59,25 @@ public Map<String, Object> createContext() {
5659
context.put("alertId", model.getId());
5760
context.put("alertName", model.getName());
5861
context.put("serverId", ConfigurationController.getInstance().getServerId());
59-
context.put("serverName", ConfigurationController.getInstance().getServerName());
62+
context.putAll(getServerSettings());
6063
context.put("date", new DateTool());
6164

6265
return context;
6366
}
6467

68+
private Map<String, Object> getServerSettings() {
69+
try {
70+
ServerSettings settings = ConfigurationController.getInstance().getServerSettings();
71+
// ensure an empty string as Velocity won't replace when given a null value
72+
return Map.ofEntries(entry("serverName", Objects.toString(settings.getServerName(), "")),
73+
entry("environmentName", Objects.toString(settings.getEnvironmentName(), "")));
74+
} catch (ControllerException e) {
75+
logger.warn("Failed to retrieve server settings", e);
76+
}
77+
78+
return Map.of();
79+
}
80+
6581
public int getAlertedCount() {
6682
return alertedCount.get();
6783
}

0 commit comments

Comments
 (0)