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
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,15 @@ public class WebAlarm {
private String alarmRaiser;
private String alarmText;
private String collectionID;

public WebAlarm() {}
private String fileID;

public WebAlarm(Alarm alarm) {
collectionID = alarm.getCollectionID() == null ? "" : alarm.getCollectionID();
fileID = alarm.getFileID() == null ? "" : alarm.getFileID();
origDateTime = TimeUtils.shortDate(CalendarUtils.convertFromXMLGregorianCalendar(alarm.getOrigDateTime()));
alarmRaiser = alarm.getAlarmRaiser();
alarmCode = alarm.getAlarmCode();
alarmText = alarm.getAlarmText();

}

@XmlElement(name = "origDateTime")
Expand Down Expand Up @@ -95,4 +94,13 @@ public String getCollectionID() {
public void setCollectionID(String collectionID) {
this.collectionID = collectionID;
}

@XmlElement(name = "fileID")
public String getFileID() {
return fileID;
}

public void setFileID(String fileID) {
this.fileID = fileID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class AlarmDatabaseTest extends ExtendedTestCase {
File dbDir = null;

@BeforeClass (alwaysRun = true)
public void setup() throws Exception {
public void setup() {
settings = TestSettingsProvider.reloadSettings("AlarmDatabaseUnderTest");

DerbyDatabaseDestroyer.deleteDatabase(
Expand All @@ -76,29 +76,29 @@ public void setup() throws Exception {
}

@AfterMethod (alwaysRun = true)
public void cleanupDatabase() throws Exception {
public void cleanupDatabase() {
// TODO
DBConnector connector = new DBConnector(settings.getReferenceSettings().getAlarmServiceSettings().getAlarmServiceDatabase());
DatabaseUtils.executeStatement(connector, "DELETE FROM " + ALARM_TABLE, new Object[0]);
DatabaseUtils.executeStatement(connector, "DELETE FROM " + COMPONENT_TABLE, new Object[0]);
DatabaseUtils.executeStatement(connector, "DELETE FROM " + ALARM_TABLE);
DatabaseUtils.executeStatement(connector, "DELETE FROM " + COMPONENT_TABLE);
}

@AfterClass (alwaysRun = true)
public void shutdown() throws Exception {
public void shutdown() {
addStep("Cleanup after test.", "Should remove directory with test material.");
if(dbDir != null) {
FileUtils.delete(dbDir);
}
}

@Test(groups = {"regressiontest", "databasetest"})
public void AlarmDatabaseExtractionTest() throws Exception {
public void AlarmDatabaseExtractionTest() {
addDescription("Testing the connection to the alarm service database especially with regards to "
+ "extracting the data from it.");
addStep("Setup the variables and constants.", "Should be ok.");
Date restrictionDate = new Date(123456789); // Sometime between epoch and now!

addStep("Adds the variables to the settings and instantaites the database cache", "Should be connected.");
addStep("Adds the variables to the settings and instantiates the database cache", "Should be connected.");
AlarmDAOFactory alarmDAOFactory = new AlarmDAOFactory();
AlarmServiceDAO database = alarmDAOFactory.getAlarmServiceDAOInstance(
settings.getReferenceSettings().getAlarmServiceSettings().getAlarmServiceDatabase());
Expand Down Expand Up @@ -184,7 +184,7 @@ public void AlarmDatabaseExtractionTest() throws Exception {
}

@Test(groups = {"regressiontest", "databasetest"})
public void AlarmDatabaseLargeIngestionTest() throws Exception {
public void AlarmDatabaseLargeIngestionTest() {
addDescription("Testing the ingestion of a large texts into the database");
addStep("Setup and create alarm", "");
AlarmDAOFactory alarmDAOFactory = new AlarmDAOFactory();
Expand Down
21 changes: 12 additions & 9 deletions bitrepository-webclient/src/main/webapp/alarm-service.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
<th>Date</th>
<th>Component</th>
<th>Collection</th>
<th>FileID</th>
<th>Alarm code</th>
<th>Description</th>
</tr>
Expand All @@ -122,9 +123,8 @@
<script src="CollectionNameMapper.js"></script>

<script>

var nameMapper;
var auto_getalarms;
var auto_get_alarms;
var alarmServiceUrl;

function clearElement(element) {
Expand Down Expand Up @@ -153,12 +153,15 @@
var htmlTableBody = "";
if(j != null) {
for (var i = 0; i < j.length; i++) {
htmlTableBody += "<tr><td>" + j[i].origDateTime +
"</td><td>" + j[i].alarmRaiser +
"</td><td>" + nameMapper.getName(j[i].collectionID) +
"</td> <td>" + j[i].alarmCode +
"</td> <td>" + nl2br(j[i].alarmText) +
"</td></tr>";
htmlTableBody +=
`<tr>
<td>${j[i].origDateTime}</td>
<td>${j[i].alarmRaiser}</td>
<td>${nameMapper.getName(j[i].collectionID)}</td>
<td>${j[i].fileID}</td>
<td>${j[i].alarmCode}</td>
<td>${nl2br(j[i].alarmText)}</td>
</tr>`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much nicer 👍

}
}
$("#alarms-table-body").html(htmlTableBody);
Expand All @@ -176,7 +179,7 @@
$("#collectionIDFilter").append('<option value="' + colls[i] + '">' + nameMapper.getName(colls[i]) + '</option>');
}
updateAlarms();
auto_getalarms = setInterval(function() {updateAlarms();}, 2500);
auto_get_alarms = setInterval(function() {updateAlarms();}, 2500);
});
});
}
Expand Down