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 @@ -29,6 +29,7 @@

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -101,41 +102,51 @@ public static String getCollectionName(String collectionID) {
return name;
}

public static IntegrityServiceSettings getIntegrityServiceSettings() {
return settings.getReferenceSettings().getIntegrityServiceSettings();
}

/**
* Grab all PillarDetails from the ReferenceSettings if any are defined and return them as a list.
* Return an empty list if not defined.
* @return List of all PillarDetails defined in the ReferenceSettings
*/
public static List<PillarIntegrityDetails.PillarDetails> getPillarIntegrityDetails() {
PillarIntegrityDetails pillarIntegrityDetails = getIntegrityServiceSettings().getPillarIntegrityDetails();
if (pillarIntegrityDetails != null) {
Comment thread
Bohlski marked this conversation as resolved.
List<PillarIntegrityDetails.PillarDetails> pillarDetails = pillarIntegrityDetails.getPillarDetails();
if (pillarDetails != null) {
return Collections.unmodifiableList(pillarDetails);
}
}
return List.of();
}

/**
* Get the human-readable pillar name for the given pillarID from the ReferenceSettings.
*
* @param pillarID The pillarID for which the pillar name is wanted.
* @return Returns the pillar name for the given pillar ID.
*/
public static String getPillarName(String pillarID) {
PillarIntegrityDetails details = settings.getReferenceSettings().getIntegrityServiceSettings().getPillarIntegrityDetails();
if (details != null) {
for (PillarIntegrityDetails.PillarDetails d : details.getPillarDetails()) {
if (d.getPillarID().equals(pillarID)) {
return d.getPillarName();
}
for (PillarIntegrityDetails.PillarDetails d : getPillarIntegrityDetails()) {
if (d.getPillarID().equals(pillarID)) {
return d.getPillarName();
}
}
return null;
}

public static IntegrityServiceSettings getIntegrityServiceSettings() {
return settings.getReferenceSettings().getIntegrityServiceSettings();
}

/**
* Get the {@link PillarType} for the given Pillar ID.
*
* @param pillarID The pillar ID for which the {@link PillarType} is wanted.
* @return Returns the {@link PillarType} for the given pillar ID.
*/
public static PillarType getPillarType(String pillarID) {
PillarIntegrityDetails details = settings.getReferenceSettings().getIntegrityServiceSettings().getPillarIntegrityDetails();
if (details != null) {
for (PillarIntegrityDetails.PillarDetails d : details.getPillarDetails()) {
if (d.getPillarID().equals(pillarID)) {
return d.getPillarType();
}
for (PillarIntegrityDetails.PillarDetails d : getPillarIntegrityDetails()) {
if (d.getPillarID().equals(pillarID)) {
return d.getPillarType();
}
}
return null;
Expand Down Expand Up @@ -212,5 +223,4 @@ public static Set<String> getStatusContributorsForCollection() {
contributors.addAll(SettingsUtils.getAllPillarIDs());
return contributors;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@
<PillarID>Pillar1</PillarID>
<PillarName>Alpha</PillarName>
<PillarType>FILE</PillarType>
<PillarDeleteFileApprover>Anon Anonymoose anon@kb.dk</PillarDeleteFileApprover>
</PillarDetails>
</PillarIntegrityDetails>
</IntegrityServiceSettings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,19 @@
<PillarID>checksum-pillar</PillarID>
<PillarName>Alpha</PillarName>
<PillarType>CHECKSUM</PillarType>
<PillarDeleteFileApprover>Anon Anonymoose anon@kb.dk</PillarDeleteFileApprover>
</PillarDetails>
<PillarDetails>
<PillarID>file1-pillar</PillarID>
<PillarName>Beta</PillarName>
<PillarType>FILE</PillarType>
<PillarDeleteFileApprover>Anon Anonymoose anon@kb.dk</PillarDeleteFileApprover>
</PillarDetails>
<PillarDetails>
<PillarID>file2-pillar</PillarID>
<PillarName>Gamma</PillarName>
<PillarType>FILE</PillarType>
<PillarDeleteFileApprover>Anon Anonymoose anon@kb.dk</PillarDeleteFileApprover>
</PillarDetails>
</PillarIntegrityDetails>
</IntegrityServiceSettings>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.bitrepository.integrityservice.web;

import java.io.Serializable;

public class PillarDetailsDto implements Serializable {
private static final long serialVersionUID = 1L;

private String pillarID;
private String pillarName;
private String pillarType;
private String pillarDeleteFileApprover;

public PillarDetailsDto() {}

public PillarDetailsDto(String pillarID, String pillarName, String pillarType, String pillarDeleteFileApprover) {
this.pillarID = pillarID;
this.pillarName = pillarName;
this.pillarType = pillarType;
this.pillarDeleteFileApprover = pillarDeleteFileApprover;
}

public String getPillarID() {
return pillarID;
}

public void setPillarID(String pillarID) {
this.pillarID = pillarID;
}

public String getPillarName() {
return pillarName;
}

public void setPillarName(String pillarName) {
this.pillarName = pillarName;
}

public String getPillarType() {
return pillarType;
}

public void setPillarType(String pillarType) {
this.pillarType = pillarType;
}

public String getPillarDeleteFileApprover() {
return pillarDeleteFileApprover;
}

public void setPillarDeleteFileApprover(String pillarDeleteFileApprover) {
this.pillarDeleteFileApprover = pillarDeleteFileApprover;
}

@Override
public String toString() {
return "PillarDetailsDTO{" +
"pillarID='" + pillarID + '\'' +
", pillarName='" + pillarName + '\'' +
", pillarType=" + pillarType +
", pillarDeleteFileApprover='" + pillarDeleteFileApprover + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.bitrepository.service.workflow.Workflow;
import org.bitrepository.service.workflow.WorkflowManager;
import org.bitrepository.service.workflow.WorkflowStatistic;
import org.bitrepository.settings.referencesettings.PillarIntegrityDetails;
import org.bitrepository.settings.referencesettings.PillarType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -261,6 +262,20 @@ public String getIntegrityStatus(@QueryParam("collectionID") String collectionID
return writer.toString();
}

@GET
@Path("/getPillarDetails")
@Produces(MediaType.APPLICATION_JSON)
public List<PillarDetailsDto> getPillarDetails() {
List<PillarIntegrityDetails.PillarDetails> pillarDetails = SettingsUtils.getPillarIntegrityDetails();
List<PillarDetailsDto> result = new ArrayList<>(pillarDetails.size());
for (PillarIntegrityDetails.PillarDetails details : pillarDetails) {
PillarDetailsDto detailsDTO = new PillarDetailsDto(details.getPillarID(), details.getPillarName(),
details.getPillarType().value(), details.getPillarDeleteFileApprover());
result.add(detailsDTO);
}
return result;
}

/***
* Get the current workflow’s setup as a JSON array
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.bitrepository.integrityservice.web;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.testng.annotations.Test;

import java.io.IOException;

import static org.testng.Assert.*;

public class PillarDetailsDtoTest {
private final ObjectMapper objectMapper = new ObjectMapper(); // Use ObjectMapper for JSON

@Test
void testSerialization() throws IOException {
PillarDetailsDto dto = new PillarDetailsDto("id", "pillar", "TYPE", "admin");

String jsonOutput = objectMapper.writeValueAsString(dto);

assertTrue(jsonOutput.contains("\"pillarID\":\"id\""));
assertTrue(jsonOutput.contains("\"pillarName\":\"pillar\""));
assertTrue(jsonOutput.contains("\"pillarType\":\"TYPE\""));
assertTrue(jsonOutput.contains("\"pillarDeleteFileApprover\":\"admin\""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,14 @@
</xs:annotation>
</xs:element>
<xs:element ref="PillarType"/>
<xs:element name="PillarDeleteFileApprover" type="xs:string">
<xs:annotation>
<xs:documentation>
Free text field for name/email/contact-info of the person responsible for approving any deletions
on this pillar prior to running an actual DeleteFile-operation.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Expand Down
16 changes: 15 additions & 1 deletion bitrepository-webclient/src/main/webapp/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h2 id="pageHeader">Overview</h2>
<table class="table table-hover table-condensed">
<thead>
<tr>
<th class="collectionName">Collection name</th>
<th>Collection name</th>
<th>Number of files</th>
<th>Latest Ingest</th>
<th>Collection size</th>
Expand All @@ -52,6 +52,19 @@ <h2 id="pageHeader">Overview</h2>
<tbody id="collectionStatusBody"></tbody>
</table>
</div>
<div class="pillarDetails">
<table class="table table-hover table-condensed">
<thead>
<tr>
<th>Pillar ID</th>
<th>Pillar name</th>
<th>Pillar type</th>
<th>Deletion approver</th>
</tr>
</thead>
<tbody id="pillarDetailsBody"></tbody>
</table>
</div>
<div id="dataSizeGraphContainer" class="dataSizeGraph">
<form class="dashboardForm">
<div style="float:left;">
Expand Down Expand Up @@ -106,6 +119,7 @@ <h3>Data distributed on pillars</h3>
<script src="static/js/dashboard_components/ColorMapper.js"></script>
<script src="static/js/CollectionNameMapper.js"></script>
<script src="static/js/dashboard_components/collectionStatus.js"></script>
<script src="static/js/dashboard_components/pillar-details.js"></script>
<script src="static/js/dashboard_components/legsSizePie.js"></script>
<script src="static/js/dashboard_components/collectionSizePie.js"></script>
<script src="static/js/dashboard_components/DataSizeGraph.js"></script>
Expand Down
12 changes: 2 additions & 10 deletions bitrepository-webclient/src/main/webapp/static/css/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
margin-top: 0.9em;
}

.collectionStatus, .dataSizeGraph, .collectionPieBox, .legPieBox {
.collectionStatus, .pillarDetails, .dataSizeGraph, .collectionPieBox, .legPieBox {
border: 1px solid #cccccc;
float: left;
margin: 0 0 2em;
Expand All @@ -15,18 +15,10 @@
box-sizing: border-box;
}

.collectionStatus, .collectionPieBox, .legPieBox {
.collectionStatus, .pillarDetails, .collectionPieBox, .legPieBox {
background-color: #F9FCFF;
}

.collectionStatus td, .collectionStatus th {
text-align: right;
}

td.collectionName, th.collectionName {
text-align: left;
}

td.error {
background-color: #CC0000;
color: white;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ function makeCollectionRow(collection) {
let id = collection.collectionID;
let html = "";
html += "<tr id=\"" + id + "-row\">";
html += "<td id=\""+ id + "-name\" class=\"collectionName\">" + id + "</div></td>";
html += "<td id=\""+ id + "-numFiles\"></td>";
html += "<td id=\""+ id + "-latestIngest\"></td>";
html += "<td id=\""+ id + "-collectionSize\"></td>";
html += "<td id=\""+ id + "-pillars\"></td>";
html += "<td id=\""+ id + "-latestCheck\"></td>";
html += "<td> <span id=\""+ id + "-numChecksumErrors\"></span></td>";
html += "<td> <span id=\""+ id + "-numMissingFiles\"></span></td>";
html += "<td id=\""+ id + "-nextCheck\"></td></tr>";
html += "<td id=\"" + id + "-name\">" + id + "</div></td>";
html += "<td id=\"" + id + "-numFiles\"></td>";
html += "<td id=\"" + id + "-latestIngest\"></td>";
html += "<td id=\"" + id + "-collectionSize\"></td>";
html += "<td id=\"" + id + "-pillars\"></td>";
html += "<td id=\"" + id + "-latestCheck\"></td>";
html += "<td><span id=\"" + id + "-numChecksumErrors\"></span></td>";
html += "<td><span id=\"" + id + "-numMissingFiles\"></span></td>";
html += "<td id=\"" + id + "-nextCheck\"></td></tr>";
return html;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Appends the information from the pillar details JSON as rows to a table with the given ID.
* @param pillarDetails JSON containing the pillar details to build the rows from
* @param tableBodyId ID of the table to append the rows to
*/
function fillInPillarDetailsTable(pillarDetails, tableBodyId) {
pillarDetails.forEach((detail) => {
$(tableBodyId).append(makePillarDetailsRow(detail));
});
}

/**
* Make a row in the pillar details table given the pillar details JSON.
* @param details Pillar details from ReferenceSettings-file as JSON
* @returns {string} HTML table row containing the pillar details
*/
function makePillarDetailsRow(details) {
let html = "";
html += "<tr>";
html += "<td>" + details.pillarID + "</td>";
html += "<td>" + details.pillarName + "</td>";
html += "<td>" + details.pillarType + "</td>";
html += "<td>" + details.pillarDeleteFileApprover + "</td>";
html += "</tr>";
return html;
}

Loading