Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions elibrary-core/source/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,11 @@ settingsPanel.treeMenuMonitor =
systemMonitorPanel.btnCheckHealth = Check
systemMonitorPanel.lblApiServicesVersion = Version:
systemMonitorPanelEvent.checkingElementsHealthStatus = Health of selected elements checked successfully.
systemMonitorPanel.chckbxDbConnection = DB connection
systemMonitorPanel.dbConnectionDetailsPanelTitle = Details
systemMonitorPanel.lblDbConnectionName = DB name:
systemMonitorPanel.lblDbConnectionHost = Host:
common.dbConnectivitySuccessStatus = OK, DB engine and version: {0}, {1}.



Expand Down
5 changes: 5 additions & 0 deletions elibrary-core/source/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -576,4 +576,9 @@ settingsPanel.treeMenuMonitor =
systemMonitorPanel.btnCheckHealth = Check
systemMonitorPanel.lblApiServicesVersion = Version:
systemMonitorPanelEvent.checkingElementsHealthStatus = Health of selected elements checked successfully.
systemMonitorPanel.dbConnectionDetailsPanelTitle = Details
systemMonitorPanel.chckbxDbConnection = DB connection
systemMonitorPanel.lblDbConnectionHost = Host:
systemMonitorPanel.lblDbConnectionName = DB name:
common.dbConnectivitySuccessStatus = OK, DB engine and version: {0}, {1}.

5 changes: 5 additions & 0 deletions elibrary-core/source/resources/messages_pl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -577,4 +577,9 @@ settingsPanel.treeMenuMonitor =
systemMonitorPanel.btnCheckHealth = Sprawd\u017A
systemMonitorPanel.lblApiServicesVersion = Wersja:
systemMonitorPanelEvent.checkingElementsHealthStatus = Sprawdzenie statusu wybranych element\u00F3w zako\u0144czy\u0142o si\u0119 pomy\u015Blnie.
systemMonitorPanel.dbConnectionDetailsPanelTitle = Szczeg\u00F3\u0142y
systemMonitorPanel.chckbxDbConnection = Po\u0142\u0105czenie z baz\u0105 danych
systemMonitorPanel.lblDbConnectionHost = Host:
systemMonitorPanel.lblDbConnectionName = Nazwa BD:
common.dbConnectivitySuccessStatus = OK, nazwa i wersja silnika BD: {0}, {1}.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ private void reloadDetails() {
.setText(SystemProperties.getInstance().getConfigProperties().getProperty("app.api.port"));
settingsForm.getSettingsPanel().getSystemMonitorPanel().getLblApiServicesVersionValue()
.setText(SystemProperties.getInstance().getConfigProperties().getProperty("app.api.version"));
settingsForm.getSettingsPanel().getSystemMonitorPanel().getLblDbConnectionHostValue()
.setText(SystemProperties.getInstance().getConfigProperties().getProperty("db.ip"));
settingsForm.getSettingsPanel().getSystemMonitorPanel().getLblDbConnectionNameValue()
.setText(SystemProperties.getInstance().getConfigProperties().getProperty("db.name"));
}

private void onClickBtnCheckHealth() {
Expand All @@ -68,16 +72,27 @@ private void reloadAllLblsForCheckedElements() {
elibraryApiStatus.getFirst(),
elibraryApiStatus.getSecond());
}
if (settingsForm.getSettingsPanel().getSystemMonitorPanel().getChckbxDbConnection().isSelected()) {
Pair<Boolean, String> elibraryDbStatus = Common.checkELibraryDbConnectivityAndGetHealthStatus();
reloadLblsWitchImageIconAndStatus(
settingsForm.getSettingsPanel().getSystemMonitorPanel().getLblDbConnectionHealth(),
settingsForm.getSettingsPanel().getSystemMonitorPanel().getLblDbConnectionStatus(),
elibraryDbStatus.getFirst(),
elibraryDbStatus.getSecond());
}
}

private void resetAllLblsForUncheckedElements() {
if (!settingsForm.getSettingsPanel().getSystemMonitorPanel().getChckbxApiServices().isSelected())
reloadLblsWitchImageIconAndStatus(settingsForm.getSettingsPanel().getSystemMonitorPanel().getLblApiServicesHealth(),
settingsForm.getSettingsPanel().getSystemMonitorPanel().getLblApiServicesStatus(),
null, null);
if (!settingsForm.getSettingsPanel().getSystemMonitorPanel().getChckbxDbConnection().isSelected())
reloadLblsWitchImageIconAndStatus(settingsForm.getSettingsPanel().getSystemMonitorPanel().getLblDbConnectionHealth(),
settingsForm.getSettingsPanel().getSystemMonitorPanel().getLblDbConnectionStatus(),
null, null);
}


private void reloadLblsWitchImageIconAndStatus(JLabel labelHealth, JLabel labelStatus, Boolean isPositive, String status) {
labelHealth.setIcon(isPositive != null ? (isPositive ? new ImageIcon(new ImageIcon(RegistrationPanel.class.getResource("/images/sign-check-ico.png"))
.getImage().getScaledInstance(18, 18, Image.SCALE_SMOOTH)) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.text.MessageFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
Expand Down Expand Up @@ -327,6 +330,27 @@ public static Pair<Boolean, String> checkELibraryApiConnectivityAndGetHealthStat
return new Pair<>(connectivity, response.toString());
}

public static Pair<Boolean, String> checkELibraryDbConnectivityAndGetHealthStatus() {
StringBuilder status = new StringBuilder();
Boolean connectivity = false;
String dbUrl = SystemProperties.getInstance().getConfigProperties().getProperty("db.url")
+ "?user=" + SystemProperties.getInstance().getConfigProperties().getProperty("db.username")
+ "&password=" + SystemProperties.getInstance().getConfigProperties().getProperty("db.password");
try {
Class.forName("org.postgresql.Driver");
Connection connection = DriverManager.getConnection(dbUrl);

connectivity = connection.getMetaData().getDatabaseProductName() != null;
status.append(MessageFormat.format(
SystemProperties.getInstance().getResourceBundle().getString("common.dbConnectivitySuccessStatus"),
connection.getMetaData().getDatabaseProductName(),
connection.getMetaData().getDatabaseProductVersion()));
} catch (Exception e) {
status.append(e.getMessage());
}
return new Pair<>(connectivity, status.toString());
}

public static String checkEmailServerConnectivity() {
String result = null;
MailSender mailSender = new MailSender();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ public class SystemMonitorPanel extends BasePanel {
private JLabel lblApiServicesHostValue;
private JLabel lblApiServicesPortValue;
private JButton btnCheckHealth;
private JLabel lblApiServicesVersion;
private JLabel lblApiServicesVersionValue;

private JCheckBox chckbxDbConnection;
private JLabel lblDbConnectionHostValue;
private JLabel lblDbConnectionNameValue;
private JLabel lblDbConnectionHealth;
private JLabel lblDbConnectionStatus;

public SystemMonitorPanel() {
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[]{260, 72, 400, 0};
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
gridBagLayout.columnWidths = new int[]{91, 68, 420, 0};
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
gridBagLayout.columnWeights = new double[]{1.0, 0.0, 0.0, Double.MIN_VALUE};
gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
setLayout(gridBagLayout);

chckbxApiServices = new CustomJCheckBox(
Expand All @@ -56,7 +60,7 @@ public SystemMonitorPanel() {

lblApiServicesStatus = new CustomJLabel();
GridBagConstraints gbc_lblApiServicesStatus = new GridBagConstraints();
gbc_lblApiServicesStatus.anchor = GridBagConstraints.EAST;
gbc_lblApiServicesStatus.anchor = GridBagConstraints.WEST;
gbc_lblApiServicesStatus.insets = new Insets(0, 0, 5, 0);
gbc_lblApiServicesStatus.gridx = 2;
gbc_lblApiServicesStatus.gridy = 0;
Expand All @@ -74,9 +78,9 @@ public SystemMonitorPanel() {
gbc_apiServicesDetailsPanel.gridy = 1;
add(apiServicesDetailsPanel, gbc_apiServicesDetailsPanel);
GridBagLayout gbl_apiServicesDetailsPanel = new GridBagLayout();
gbl_apiServicesDetailsPanel.columnWidths = new int[]{0, 0, 0, 0};
gbl_apiServicesDetailsPanel.columnWidths = new int[]{0, 0, 0};
gbl_apiServicesDetailsPanel.rowHeights = new int[]{0, 0, 0, 0};
gbl_apiServicesDetailsPanel.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
gbl_apiServicesDetailsPanel.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
gbl_apiServicesDetailsPanel.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
apiServicesDetailsPanel.setLayout(gbl_apiServicesDetailsPanel);

Expand All @@ -92,7 +96,6 @@ public SystemMonitorPanel() {
lblApiServicesHostValue = new CustomJLabel();
GridBagConstraints gbc_lblApiServicesHostValue = new GridBagConstraints();
gbc_lblApiServicesHostValue.fill = GridBagConstraints.HORIZONTAL;
gbc_lblApiServicesHostValue.gridwidth = 2;
gbc_lblApiServicesHostValue.insets = new Insets(0, 0, 5, 0);
gbc_lblApiServicesHostValue.gridx = 1;
gbc_lblApiServicesHostValue.gridy = 0;
Expand All @@ -111,12 +114,11 @@ public SystemMonitorPanel() {
GridBagConstraints gbc_lblApiServicesPortValue = new GridBagConstraints();
gbc_lblApiServicesPortValue.insets = new Insets(0, 0, 5, 0);
gbc_lblApiServicesPortValue.fill = GridBagConstraints.HORIZONTAL;
gbc_lblApiServicesPortValue.gridwidth = 2;
gbc_lblApiServicesPortValue.gridx = 1;
gbc_lblApiServicesPortValue.gridy = 1;
apiServicesDetailsPanel.add(lblApiServicesPortValue, gbc_lblApiServicesPortValue);

lblApiServicesVersion = new CustomJLabel(
JLabel lblApiServicesVersion = new CustomJLabel(
SystemProperties.getInstance().getResourceBundle().getString("systemMonitorPanel.lblApiServicesVersion"));
GridBagConstraints gbc_lblApiServicesVersion = new GridBagConstraints();
gbc_lblApiServicesVersion.insets = new Insets(0, 0, 0, 5);
Expand All @@ -127,19 +129,92 @@ public SystemMonitorPanel() {
lblApiServicesVersionValue = new CustomJLabel();
GridBagConstraints gbc_lblApiServicesVersionValue = new GridBagConstraints();
gbc_lblApiServicesVersionValue.fill = GridBagConstraints.HORIZONTAL;
gbc_lblApiServicesVersionValue.gridwidth = 2;
gbc_lblApiServicesVersionValue.gridx = 1;
gbc_lblApiServicesVersionValue.gridy = 2;
apiServicesDetailsPanel.add(lblApiServicesVersionValue, gbc_lblApiServicesVersionValue);

chckbxDbConnection = new CustomJCheckBox(SystemProperties.getInstance().getResourceBundle().getString("systemMonitorPanel.chckbxDbConnection"));
GridBagConstraints gbc_chckbxDbConnection = new GridBagConstraints();
gbc_chckbxDbConnection.anchor = GridBagConstraints.WEST;
gbc_chckbxDbConnection.insets = new Insets(0, 0, 5, 5);
gbc_chckbxDbConnection.gridx = 0;
gbc_chckbxDbConnection.gridy = 2;
add(chckbxDbConnection, gbc_chckbxDbConnection);

lblDbConnectionHealth = new CustomJLabel();
GridBagConstraints gbc_lblDbConnectionHealth = new GridBagConstraints();
gbc_lblDbConnectionHealth.fill = GridBagConstraints.HORIZONTAL;
gbc_lblDbConnectionHealth.insets = new Insets(0, 0, 5, 5);
gbc_lblDbConnectionHealth.gridx = 1;
gbc_lblDbConnectionHealth.gridy = 2;
add(lblDbConnectionHealth, gbc_lblDbConnectionHealth);

lblDbConnectionStatus = new CustomJLabel();
GridBagConstraints gbc_lblDbConnectionStatus = new GridBagConstraints();
gbc_lblDbConnectionStatus.anchor = GridBagConstraints.WEST;
gbc_lblDbConnectionStatus.insets = new Insets(0, 0, 5, 0);
gbc_lblDbConnectionStatus.gridx = 2;
gbc_lblDbConnectionStatus.gridy = 2;
add(lblDbConnectionStatus, gbc_lblDbConnectionStatus);

JPanel dbConnectionDetailsPanel = new BasePanel();
dbConnectionDetailsPanel.setBorder(new TitledBorder(null,
SystemProperties.getInstance().getResourceBundle().getString("systemMonitorPanel.dbConnectionDetailsPanelTitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null));
GridBagConstraints gbc_dbConnectionDetailsPanel = new GridBagConstraints();
gbc_dbConnectionDetailsPanel.fill = GridBagConstraints.BOTH;
gbc_dbConnectionDetailsPanel.gridwidth = 3;
gbc_dbConnectionDetailsPanel.insets = new Insets(0, 0, 5, 0);
gbc_dbConnectionDetailsPanel.gridx = 0;
gbc_dbConnectionDetailsPanel.gridy = 3;
add(dbConnectionDetailsPanel, gbc_dbConnectionDetailsPanel);
GridBagLayout gbl_dbConnectionDetailsPanel = new GridBagLayout();
gbl_dbConnectionDetailsPanel.columnWidths = new int[]{0, 0, 0};
gbl_dbConnectionDetailsPanel.rowHeights = new int[]{0, 0, 0};
gbl_dbConnectionDetailsPanel.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
gbl_dbConnectionDetailsPanel.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
dbConnectionDetailsPanel.setLayout(gbl_dbConnectionDetailsPanel);

JLabel lblDbConnectionHost = new CustomJLabel(
SystemProperties.getInstance().getResourceBundle().getString("systemMonitorPanel.lblDbConnectionHost"));
GridBagConstraints gbc_lblDbConnectionHost = new GridBagConstraints();
gbc_lblDbConnectionHost.anchor = GridBagConstraints.WEST;
gbc_lblDbConnectionHost.insets = new Insets(0, 0, 5, 5);
gbc_lblDbConnectionHost.gridx = 0;
gbc_lblDbConnectionHost.gridy = 0;
dbConnectionDetailsPanel.add(lblDbConnectionHost, gbc_lblDbConnectionHost);

lblDbConnectionHostValue = new CustomJLabel();
GridBagConstraints gbc_lblDbConnectionHostValue = new GridBagConstraints();
gbc_lblDbConnectionHostValue.fill = GridBagConstraints.HORIZONTAL;
gbc_lblDbConnectionHostValue.insets = new Insets(0, 0, 5, 0);
gbc_lblDbConnectionHostValue.gridx = 1;
gbc_lblDbConnectionHostValue.gridy = 0;
dbConnectionDetailsPanel.add(lblDbConnectionHostValue, gbc_lblDbConnectionHostValue);

JLabel lblDbConnectionName = new CustomJLabel(
SystemProperties.getInstance().getResourceBundle().getString("systemMonitorPanel.lblDbConnectionName"));
GridBagConstraints gbc_lblDbConnectionName = new GridBagConstraints();
gbc_lblDbConnectionName.anchor = GridBagConstraints.WEST;
gbc_lblDbConnectionName.insets = new Insets(0, 0, 0, 5);
gbc_lblDbConnectionName.gridx = 0;
gbc_lblDbConnectionName.gridy = 1;
dbConnectionDetailsPanel.add(lblDbConnectionName, gbc_lblDbConnectionName);

lblDbConnectionNameValue = new CustomJLabel();
GridBagConstraints gbc_lblDbConnectionNameValue = new GridBagConstraints();
gbc_lblDbConnectionNameValue.fill = GridBagConstraints.HORIZONTAL;
gbc_lblDbConnectionNameValue.gridx = 1;
gbc_lblDbConnectionNameValue.gridy = 1;
dbConnectionDetailsPanel.add(lblDbConnectionNameValue, gbc_lblDbConnectionNameValue);

btnCheckHealth = new CustomJButton(new ImageIcon(new ImageIcon(RegistrationPanel.class.getResource("/images/btnCheckHealth-ico.png"))
.getImage().getScaledInstance(18, 18, Image.SCALE_SMOOTH)),
SystemProperties.getInstance().getResourceBundle().getString("systemMonitorPanel.btnCheckHealth"));
GridBagConstraints gbc_btnCheckHealth = new GridBagConstraints();
gbc_btnCheckHealth.fill = GridBagConstraints.HORIZONTAL;
gbc_btnCheckHealth.insets = new Insets(0, 0, 0, 5);
gbc_btnCheckHealth.gridx = 1;
gbc_btnCheckHealth.gridy = 2;
gbc_btnCheckHealth.gridy = 4;
add(btnCheckHealth, gbc_btnCheckHealth);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Database Config
db.url = ${db.url}
db.ip = ${db.ip}
db.username = ${db.username}
db.password = ${db.password}
db.name = ${db.name}
Expand Down
5 changes: 3 additions & 2 deletions elibrary-hibernate/src/main/resources/db-changelog-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
<!--<include file="src/main/resources/db/changelog/db-changelog-20200629152316UTC.xml" relativeToChangelogFile="false"/>-->
<!--<include file="src/main/resources/db/changelog/db-changelog-20200629152317UTC.xml" relativeToChangelogFile="false"/>-->
<!--<include file="src/main/resources/db/changelog/db-changelog-20200629152318UTC.xml" relativeToChangelogFile="false"/>-->
<include file="src/main/resources/db/changelog/db-changelog-20200703213344UTC.xml" relativeToChangelogFile="false"/>
<include file="src/main/resources/db/changelog/db-changelog-ddl-20200703213345UTC.xml" relativeToChangelogFile="false"/>
<!--<include file="src/main/resources/db/changelog/db-changelog-20200703213344UTC.xml" relativeToChangelogFile="false"/>-->
<!--<include file="src/main/resources/db/changelog/db-changelog-ddl-20200703213345UTC.xml" relativeToChangelogFile="false"/>-->
<include file="src/main/resources/db/changelog/db-changelog-20200722123232UTC.xml" relativeToChangelogFile="false"/>

<!-- Notes -->
<!-- it is possible to run DML on local: -->
Expand Down
Loading