Author: [log in to unmask]
Date: Tue Sep 29 13:14:36 2015
New Revision: 3739
Log:
Update run webapp from changes to hps-java.
Modified:
webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/AbstractRunServlet.java
webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/DatabaseUtilities.java
webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/EpicsDataServlet.java
webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunMainServlet.java
webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunsServlet.java
webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/ScalerDataServlet.java
webapps/trunk/run-webapp/src/main/webapp/WEB-INF/web.xml
webapps/trunk/run-webapp/src/main/webapp/runMain.jsp
webapps/trunk/run-webapp/src/main/webapp/runSummary.jsp
Modified: webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/AbstractRunServlet.java
=============================================================================
--- webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/AbstractRunServlet.java (original)
+++ webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/AbstractRunServlet.java Tue Sep 29 13:14:36 2015
@@ -62,11 +62,10 @@
* @param run the run number
* @return the run summary
*/
- RunSummary getRunSummary(final Integer run) {
- final RunManager runManager = new RunManager();
+ RunSummary getRunSummary(final Integer run) {
RunSummary runSummary = null;
try (Connection connection = this.dataSource.getConnection()) {
- runManager.setConnection(connection);
+ final RunManager runManager = new RunManager(connection);
runManager.setRun(run);
runSummary = runManager.getRunSummary();
} catch (final Exception e) {
Modified: webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/DatabaseUtilities.java
=============================================================================
--- webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/DatabaseUtilities.java (original)
+++ webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/DatabaseUtilities.java Tue Sep 29 13:14:36 2015
@@ -6,9 +6,9 @@
public final class DatabaseUtilities {
- private static String DATASOURCE_CONTEXT = "java:comp/env/jdbc/hps_run_db";
+ private static String DATASOURCE_CONTEXT = "java:comp/env/jdbc/hps_run_db_dev";
- public static DataSource getDataSource() {
+ static DataSource getDataSource() {
DataSource dataSource = null;
try {
dataSource = (DataSource) new InitialContext().lookup(DATASOURCE_CONTEXT);
Modified: webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/EpicsDataServlet.java
=============================================================================
--- webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/EpicsDataServlet.java (original)
+++ webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/EpicsDataServlet.java Tue Sep 29 13:14:36 2015
@@ -13,11 +13,8 @@
import javax.sql.DataSource;
import org.hps.record.epics.EpicsData;
-import org.hps.run.database.EpicsDataDao;
import org.hps.run.database.EpicsType;
import org.hps.run.database.EpicsVariable;
-import org.hps.run.database.EpicsVariableDao;
-import org.hps.run.database.RunDatabaseDaoFactory;
import org.hps.run.database.RunManager;
/**
@@ -41,7 +38,6 @@
throw new RuntimeException("Missing required run parameter.");
}
final Integer run = Integer.parseInt(request.getParameterValues("run")[0]);
- EpicsDataDao epicsDataDao = null;
Connection connection = null;
List<EpicsData> epicsDataList = null;
@@ -55,13 +51,10 @@
try {
connection = dataSource.getConnection();
- final RunDatabaseDaoFactory dbFactory = new RunManager(connection).createDaoFactory();
-
- epicsDataDao = dbFactory.createEpicsDataDao();
- epicsDataList = epicsDataDao.getEpicsData(epicsType, run);
-
- final EpicsVariableDao epicsVariableDao = dbFactory.createEpicsVariableDao();
- epicsVariables = epicsVariableDao.getEpicsVariables(epicsType);
+ RunManager runManager = new RunManager(connection);
+ runManager.setRun(run);
+ epicsDataList = runManager.getEpicsData(epicsType);
+ epicsVariables = runManager.getEpicsVariables(epicsType);
} catch (final SQLException e) {
throw new IllegalStateException("Failed to setup data source connection.", e);
Modified: webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunMainServlet.java
=============================================================================
--- webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunMainServlet.java (original)
+++ webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunMainServlet.java Tue Sep 29 13:14:36 2015
@@ -3,6 +3,7 @@
import java.io.IOException;
import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -13,17 +14,38 @@
* @author Jeremy McCormick, SLAC
*/
public class RunMainServlet extends AbstractRunServlet {
+
+ /**
+ * The URL to the data catalog.
+ */
+ private String datacat = "";
+
+ /**
+ * The URL to the data quality plots server.
+ */
+ private String dataquality = "";
+
+ /**
+ * Initialize the servlet.
+ *
+ * @param config the servlet config
+ */
+ public void init(ServletConfig config) throws ServletException {
+ super.init(config);
+ datacat = getServletContext().getInitParameter("datacat");
+ dataquality = getServletContext().getInitParameter("dataquality");
+ }
/**
* Setup servlet state by loading the run summaries and then forward to the JSP page for display.
*/
@Override
public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException,
- IOException {
-
+ IOException {
this.setRunAttribute(request);
-
final RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/runMain.jsp");
+ request.getSession().setAttribute("datacat", datacat);
+ request.getSession().setAttribute("dataquality", dataquality);
dispatcher.forward(request, response);
}
}
Modified: webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunsServlet.java
=============================================================================
--- webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunsServlet.java (original)
+++ webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunsServlet.java Tue Sep 29 13:14:36 2015
@@ -15,7 +15,6 @@
import org.hps.run.database.RunManager;
import org.hps.run.database.RunSummary;
-import org.hps.run.database.RunSummaryDao;
/**
* Loads the list of {@link org.hps.run.database.RunSummary} objects to setup state for the <code>runTable.jsp</code> page.
@@ -72,10 +71,7 @@
Connection connection = null;
try {
connection = this.dataSource.getConnection();
- final RunSummaryDao runSummaryDao = new RunManager(connection).createDaoFactory().createRunSummaryDao();
-
- // This does a shallow read of all run summaries but does not load their complex state.
- runSummaries = runSummaryDao.getRunSummaries();
+ runSummaries = new RunManager(connection).getRunSummaries();
} catch (final SQLException e) {
throw new RuntimeException(e);
} finally {
Modified: webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/ScalerDataServlet.java
=============================================================================
--- webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/ScalerDataServlet.java (original)
+++ webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/ScalerDataServlet.java Tue Sep 29 13:14:36 2015
@@ -13,7 +13,6 @@
import org.hps.record.scalers.ScalerData;
import org.hps.run.database.RunManager;
-import org.hps.run.database.ScalerDataDao;
/**
* Setup session state for JSP that shows a run's scaler data.
@@ -59,8 +58,9 @@
final Integer run = Integer.parseInt(request.getParameterValues("run")[0]);
List<ScalerData> scalerDataList = null;
try (Connection connection = this.dataSource.getConnection()) {
- final ScalerDataDao scalarDataDao = new RunManager(connection).createDaoFactory().createScalerDataDao();
- scalerDataList = scalarDataDao.getScalerData(run);
+ RunManager runManager = new RunManager(connection);
+ runManager.setRun(run);
+ scalerDataList = runManager.getScalerData();
} catch (final Exception e) {
throw new RuntimeException(e);
}
Modified: webapps/trunk/run-webapp/src/main/webapp/WEB-INF/web.xml
=============================================================================
--- webapps/trunk/run-webapp/src/main/webapp/WEB-INF/web.xml (original)
+++ webapps/trunk/run-webapp/src/main/webapp/WEB-INF/web.xml Tue Sep 29 13:14:36 2015
@@ -18,6 +18,16 @@
<res-auth>Container</res-auth>
</resource-ref>
+ <context-param>
+ <param-name>datacat</param-name>
+ <param-value>http://ppa-jeremym-l.slac.stanford.edu:8080/datacat-v0.4-SNAPSHOT</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>dataquality</param-name>
+ <param-value>http://ppa-jeremym-l.slac.stanford.edu:8080/data-quality</param-value>
+ </context-param>
+
<!-- Display full run table. -->
<servlet>
@@ -30,8 +40,8 @@
<url-pattern>/runs</url-pattern>
</servlet-mapping>
- <!-- Display the run page. -->
-
+ <!-- Display the main run page. -->
+
<servlet>
<servlet-name>RunMainServlet</servlet-name>
<servlet-class>org.hps.webapps.run.RunMainServlet</servlet-class>
Modified: webapps/trunk/run-webapp/src/main/webapp/runMain.jsp
=============================================================================
--- webapps/trunk/run-webapp/src/main/webapp/runMain.jsp (original)
+++ webapps/trunk/run-webapp/src/main/webapp/runMain.jsp Tue Sep 29 13:14:36 2015
@@ -1,6 +1,4 @@
-<%@page contentType="text/html" import="org.freehep.graphicsio.raw.RawImageWriteParam"%>
-<%@page pageEncoding="UTF-8"%>
-
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
@@ -9,10 +7,10 @@
<html>
<head>
-<title>HPS Run Web - Run <%=run%></title>
+<title>HPS Run Web - Run <%= run %></title>
</head>
<body>
- <h1>Run <%=run%></h1>
+ <h1>Run <%= run %></h1>
<iframe src="runSummary?run=<%= request.getAttribute("run") %>" name="runSummaryFrame" height="100%" width="30%"></iframe>
<iframe src="" name="dataFrame" height="100%" width="68%"></iframe>
</body>
Modified: webapps/trunk/run-webapp/src/main/webapp/runSummary.jsp
=============================================================================
--- webapps/trunk/run-webapp/src/main/webapp/runSummary.jsp (original)
+++ webapps/trunk/run-webapp/src/main/webapp/runSummary.jsp Tue Sep 29 13:14:36 2015
@@ -1,4 +1,5 @@
-<%@ page contentType="text/html" import="java.util.*,org.hps.run.database.*,java.text.SimpleDateFormat,org.hps.datacat.client.*" %>
+<%@ page contentType="text/html" import="java.util.*,org.hps.run.database.*,java.text.SimpleDateFormat,org.hps.datacat.client.*,java.io.File" %>
+<%@page language="java" session="true" %>
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" />
@@ -12,7 +13,7 @@
throw new RuntimeException("Run summary was not set in request.");
}
%>
- <h3>Run Summary</h3>
+ <h3>Summary</h3>
<div>
<table class="run-summary">
<tr>
@@ -65,29 +66,30 @@
<a target="dataFrame" href="scalers?run=<%= runSummary.getRun() %>">Scaler Data</a>
</p>
</div>
-
-
- <!--
- example search URL
- http://localhost:8080/datacat-v0.4-SNAPSHOT/display/datasets/HPS/data/raw?offset=0&max=999999&sort=dataType&filter=dataType%20eq%20%27RAW%27%20and%20runMin%20eq%205772
- -->
-
+
<h3>Files</h3>
<div>
- <% String datacatRootUrl = "http://localhost:8080/datacat-v0.4-SNAPSHOT/display/datasets/"; %>
+ <% String datacat = (String) request.getSession().getAttribute("datacat"); %>
<p>
- <a target="dataFrame" href="<%= datacatRootUrl + "HPS/data/raw?offset=0&max=999999&sort=name&filter=dataType eq 'RAW' and runMin eq " + run %>">EVIO / RAW</a>
+ <a target="dataFrame" href="<%= datacat + "/display/datasets/HPS/data/raw?offset=0&max=999999&sort=name&filter=dataType eq 'RAW' and runMin eq " + run %>">EVIO / RAW</a>
</p>
</div>
-
- <h3>Data Quality Plots</h3>
+ <h3>Data Quality Management</h3>
<div>
- <%
- String plotsUrl = "http://localhost:8080/data-quality/";
- DatacatClient datacatClient = new DatacatClientFactory().createClient();
- List<Dataset> dqmDatasets = datacatClient.findDatasets("dqm", "dataType == 'DQM' and runMin == " + run, new HashSet<String>());
+ <%
+ String dataquality = (String) request.getSession().getAttribute("dataquality");
+ DatacatClient datacatClient = new DatacatClientFactory().createClient();
+ List<Dataset> datasets = datacatClient.findDatasets("dqm", "dataType == 'DQM' and runMin == " + run, new HashSet<String>());
%>
- <p>found <%= dqmDatasets.size() %> DQM datasets</p>
- </div>
+ <p>Found <%= datasets.size() %> DQM file(s) in data catalog</p>
+ <table>
+ <% for (Dataset dataset : datasets) { %>
+ <% String resource = dataset.getLocations().get(0).getResource(); %>
+ <tr>
+ <td><a href="<%= dataquality %>/show_plots?rootDataURI=<%= resource %>" target="_blank"><%= new File(resource).getName() %></a></td>
+ </tr>
+ <% } %>
+ </table>
+ </div>
</body>
</html>
|