LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  September 2015

HPS-SVN September 2015

Subject:

r3675 - in /webapps/trunk/run-webapp: ./ src/main/java/org/hps/webapps/run/ src/main/webapp/ src/main/webapp/WEB-INF/ src/main/webapp/css/

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Wed, 23 Sep 2015 13:26:02 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (499 lines)

Author: [log in to unmask]
Date: Wed Sep 23 06:25:58 2015
New Revision: 3675

Log:
Current working version of run webapp; new main page with iframes.

Added:
    webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/AbstractRunServlet.java   (with props)
    webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunMainServlet.java   (with props)
    webapps/trunk/run-webapp/src/main/webapp/runMain.jsp   (with props)
Modified:
    webapps/trunk/run-webapp/pom.xml
    webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunSummaryServlet.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/css/style.css
    webapps/trunk/run-webapp/src/main/webapp/runEpics.jsp
    webapps/trunk/run-webapp/src/main/webapp/runScalers.jsp
    webapps/trunk/run-webapp/src/main/webapp/runSummary.jsp

Modified: webapps/trunk/run-webapp/pom.xml
 =============================================================================
--- webapps/trunk/run-webapp/pom.xml	(original)
+++ webapps/trunk/run-webapp/pom.xml	Wed Sep 23 06:25:58 2015
@@ -43,6 +43,11 @@
             <version>3.4.1-SNAPSHOT</version>
         </dependency>
         <dependency>
+            <groupId>org.hps</groupId>
+            <artifactId>hps-datacat-client</artifactId>
+            <version>3.4.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>
             <version>2.4</version>

Added: 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	(added)
+++ webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/AbstractRunServlet.java	Wed Sep 23 06:25:58 2015
@@ -0,0 +1,77 @@
+package org.hps.webapps.run;
+
+import java.io.IOException;
+import java.sql.Connection;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.sql.DataSource;
+
+import org.hps.run.database.RunManager;
+import org.hps.run.database.RunSummary;
+
+/**
+ * Setup state for JSP that shows run summary.
+ *
+ * @author Jeremy McCormick, SLAC
+ */
+@SuppressWarnings("serial")
+public abstract class AbstractRunServlet extends HttpServlet {
+   
+    /**
+     * The data source with the database connection.
+     */
+    private final DataSource dataSource;
+
+    /**
+     * Create a new run servlet.
+     */
+    public AbstractRunServlet() {
+        this.dataSource = DatabaseUtilities.getDataSource();
+    }
+
+    /**
+     * Child class implements specific behavior.
+     * 
+     * @param request the HTTP request
+     * @param response the HTTP response
+     */
+    @Override
+    abstract public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException;
+    	
+    /**
+     * Set the <i>run</i> and <i>run_summary</i> attributes on the request.
+     * 
+     * @param request the HTTP request
+     * @return the run number
+     */
+	int setRunAttribute(final HttpServletRequest request) {
+		if (!request.getParameterMap().containsKey("run")) {
+            throw new RuntimeException("Missing required run parameter.");
+        }
+        final Integer run = Integer.parseInt(request.getParameterValues("run")[0]);
+        request.setAttribute("run", run);
+        return run;
+	}
+
+    /**
+     * Get a run summary for the given run number.
+     *
+     * @param run the run number
+     * @return the run summary
+     */
+    RunSummary getRunSummary(final Integer run) {
+        final RunManager runManager = new RunManager();
+        RunSummary runSummary = null;
+        try (Connection connection = this.dataSource.getConnection()) {
+            runManager.setConnection(connection);
+            runManager.setRun(run);
+            runSummary = runManager.getRunSummary();
+        } catch (final Exception e) {
+            throw new RuntimeException(e);
+        }
+        return runSummary;
+    }
+}

Added: 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	(added)
+++ webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunMainServlet.java	Wed Sep 23 06:25:58 2015
@@ -0,0 +1,29 @@
+package org.hps.webapps.run;
+
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Servlet for main run page.
+ * 
+ * @author Jeremy McCormick, SLAC
+ */
+public class RunMainServlet extends AbstractRunServlet {
+	      
+	/**
+     * 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 {
+    	
+    	this.setRunAttribute(request);
+
+        final RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/runMain.jsp");
+        dispatcher.forward(request, response);
+    }           
+}

Modified: webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunSummaryServlet.java
 =============================================================================
--- webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunSummaryServlet.java	(original)
+++ webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/RunSummaryServlet.java	Wed Sep 23 06:25:58 2015
@@ -1,16 +1,12 @@
 package org.hps.webapps.run;
 
 import java.io.IOException;
-import java.sql.Connection;
 
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import javax.sql.DataSource;
 
-import org.hps.run.database.RunManager;
 import org.hps.run.database.RunSummary;
 
 /**
@@ -19,31 +15,7 @@
  * @author Jeremy McCormick, SLAC
  */
 @SuppressWarnings("serial")
-public class RunSummaryServlet extends HttpServlet {
-
-    /**
-     * JSP target page.
-     */
-    private static final String JSP_TARGET = "/runSummary.jsp";
-
-    /**
-     * Attribute in the request which will have the run summary object.
-     */
-    private static final String RUN_SUMMARY_ATTRIBUTE = "RunSummary";
-
-    /**
-     * The data source with the database connection.
-     */
-    private final DataSource dataSource;
-
-    /**
-     * Create a new runs servlet.
-     * <p>
-     * This will initialize the data source with the db connection.
-     */
-    public RunSummaryServlet() {
-        this.dataSource = DatabaseUtilities.getDataSource();
-    }
+public class RunSummaryServlet extends AbstractRunServlet {
 
     /**
      * Setup servlet state by loading the run summaries and then forward to the JSP page for display.
@@ -51,32 +23,13 @@
     @Override
     public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException,
             IOException {
-        if (!request.getParameterMap().containsKey("run")) {
-            throw new RuntimeException("Missing required run parameter.");
-        }
-        final Integer run = Integer.parseInt(request.getParameterValues("run")[0]);
+    	
+    	int run = this.setRunAttribute(request);
+    
         final RunSummary runSummary = this.getRunSummary(run);
-        request.setAttribute(RUN_SUMMARY_ATTRIBUTE, runSummary);
-        final RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher(JSP_TARGET);
+        request.setAttribute("run_summary", runSummary);
+        
+        final RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/runSummary.jsp");
         dispatcher.forward(request, response);
-    }
-
-    /**
-     * Get a run summary for the given run number.
-     *
-     * @param run the run number
-     * @return the run summary
-     */
-    private RunSummary getRunSummary(final Integer run) {
-        final RunManager runManager = new RunManager();
-        RunSummary runSummary = null;
-        try (Connection connection = this.dataSource.getConnection()) {
-            runManager.setConnection(connection);
-            runManager.setRun(run);
-            runSummary = runManager.getRunSummary();
-        } catch (final Exception e) {
-            throw new RuntimeException(e);
-        }
-        return runSummary;
-    }
+    }   
 }

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	Wed Sep 23 06:25:58 2015
@@ -12,7 +12,6 @@
 import javax.sql.DataSource;
 
 import org.hps.record.scalers.ScalerData;
-import org.hps.run.database.RunDatabaseDaoFactory;
 import org.hps.run.database.RunManager;
 import org.hps.run.database.ScalerDataDao;
 

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	Wed Sep 23 06:25:58 2015
@@ -30,8 +30,19 @@
         <url-pattern>/runs</url-pattern>
     </servlet-mapping>
         
-    <!-- Display a run summary. -->
+    <!-- Display the run page. -->
     
+    <servlet>
+        <servlet-name>RunMainServlet</servlet-name>
+        <servlet-class>org.hps.webapps.run.RunMainServlet</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>RunMainServlet</servlet-name>
+        <url-pattern>/run</url-pattern>
+    </servlet-mapping>
+    
+    <!-- Display run summary side bar. -->
     <servlet>
         <servlet-name>RunSummaryServlet</servlet-name>
         <servlet-class>org.hps.webapps.run.RunSummaryServlet</servlet-class>
@@ -39,7 +50,7 @@
 
     <servlet-mapping>
         <servlet-name>RunSummaryServlet</servlet-name>
-        <url-pattern>/run</url-pattern>
+        <url-pattern>/runSummary</url-pattern>
     </servlet-mapping>
     
     <!-- Display EPICS data -->

Modified: webapps/trunk/run-webapp/src/main/webapp/css/style.css
 =============================================================================
--- webapps/trunk/run-webapp/src/main/webapp/css/style.css	(original)
+++ webapps/trunk/run-webapp/src/main/webapp/css/style.css	Wed Sep 23 06:25:58 2015
@@ -6,3 +6,18 @@
     rgba(255, 255, 255, 0.3);
 }
 
+table.run-summary {
+	border: 1px gray solid;
+	border-collapse: collapse;
+}
+
+table.run-summary td.label {
+    font-weight: bold;
+}
+
+table.run-summary td {
+    border: 1px gray solid;
+    padding: 5px;
+    text-align: left;
+    vertical-align: middle;
+}

Modified: webapps/trunk/run-webapp/src/main/webapp/runEpics.jsp
 =============================================================================
--- webapps/trunk/run-webapp/src/main/webapp/runEpics.jsp	(original)
+++ webapps/trunk/run-webapp/src/main/webapp/runEpics.jsp	Wed Sep 23 06:25:58 2015
@@ -26,7 +26,7 @@
         EpicsType epicsType = (EpicsType) request.getAttribute("EpicsType");
         List<EpicsData> epicsDataList = (List<EpicsData>) request.getAttribute("EpicsDataList");
     %>
-    <h1>HPS Run <%= run %> - EPICS <%= epicsType.getTypeCode() %>s Data</h1>
+    <h1>EPICS <%= epicsType.getTypeCode() %>s Data</h1>
     <hr />
 
     <!--  

Added: webapps/trunk/run-webapp/src/main/webapp/runMain.jsp
 =============================================================================
--- webapps/trunk/run-webapp/src/main/webapp/runMain.jsp	(added)
+++ webapps/trunk/run-webapp/src/main/webapp/runMain.jsp	Wed Sep 23 06:25:58 2015
@@ -0,0 +1,19 @@
+<%@page contentType="text/html" import="org.freehep.graphicsio.raw.RawImageWriteParam"%>
+<%@page pageEncoding="UTF-8"%>
+
+<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
+
+<%
+    Integer run = (Integer) request.getAttribute("run");
+%>
+
+<html>
+<head>
+<title>HPS Run Web - Run <%=run%></title>
+</head>
+<body>
+    <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>
+</html>

Modified: webapps/trunk/run-webapp/src/main/webapp/runScalers.jsp
 =============================================================================
--- webapps/trunk/run-webapp/src/main/webapp/runScalers.jsp	(original)
+++ webapps/trunk/run-webapp/src/main/webapp/runScalers.jsp	Wed Sep 23 06:25:58 2015
@@ -27,7 +27,7 @@
         // Get the list of EPICS data for this run.
         List<ScalerData> scalerDataList = (List<ScalerData>) request.getAttribute("ScalerDataList");
     %>
-    <h1>HPS Run <%= run %> - Scaler Data</h1>
+    <h1>Scaler Data</h1>
     <hr />
 
     <!-- scaler data table -->

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	Wed Sep 23 06:25:58 2015
@@ -1,33 +1,93 @@
-<%@ page contentType="text/html" import="java.util.*,org.hps.run.database.*,java.text.SimpleDateFormat"%>
+<%@ page contentType="text/html" import="java.util.*,org.hps.run.database.*,java.text.SimpleDateFormat,org.hps.datacat.client.*" %>
 <!DOCTYPE html>
 <html>
-<link rel="stylesheet" href="css/style.css" />
+<link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" />
 <body>
-    <h1>HPS Run Summary</h1>
-    <hr />
     <%
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
         dateFormat.setTimeZone(TimeZone.getTimeZone("America/New_York"));
-        RunSummary runSummary = (RunSummary) request.getAttribute("RunSummary"); 
+        RunSummary runSummary = (RunSummary) request.getAttribute("run_summary");
+        int run = runSummary.getRun();
+        if (runSummary == null) {
+            throw new RuntimeException("Run summary was not set in request.");
+        }
     %>
-    <p><b>run:</b> <%= runSummary.getRun() %></p>
-    <p><b>start:</b> <%= dateFormat.format(runSummary.getStartDate()) %></p>
-    <p><b>end:</b> <%= dateFormat.format(runSummary.getEndDate()) %></p>
-    <p><b>events:</b> <%= runSummary.getTotalEvents() %></p>
-    <p><b>files:</b> <%= runSummary.getTotalFiles() %></p>
-    <p><b>end okay:</b> <%= runSummary.getEndOkay() %></p>
-    <p><b>run okay:</b> <%= runSummary.getRunOkay() %></p>
-    <p><b>updated:</b> <%= dateFormat.format(runSummary.getUpdated()) %></p>
-    <p><b>created:</b> <%= dateFormat.format(runSummary.getCreated()) %></p>
-    <hr/>	
-    <p>
-        <a href="epics?run=<%= runSummary.getRun() %>&epicsBankType=<%= EpicsType.EPICS_1S %>">EPICS 1s Data</a>        
-    </p>		
-    <p>
-        <a href="epics?run=<%= runSummary.getRun() %>&epicsBankType=<%= EpicsType.EPICS_10S %>">EPICS 10s Data</a>
-    </p>
-    <p>
-        <a href="scalers?run=<%= runSummary.getRun() %>">Scaler Data</a>
-    </p>
+    <h3>Run Summary</h3>
+    <div>
+        <table class="run-summary">
+            <tr>
+                <td class="label">Run</td>
+                <td><%= runSummary.getRun() %></td>
+            </tr>
+            <tr>
+                <td class="label">Started</td>
+                <td><%= dateFormat.format(runSummary.getStartDate()) %></td>
+            </tr>
+            <tr>
+                <td class="label">Ended</td>
+                <td><%= dateFormat.format(runSummary.getEndDate()) %></td>
+            <tr>
+            <tr>
+                <td class="label">Event Count</td>
+                <td><%= runSummary.getTotalEvents() %></td>
+            </tr>
+            <tr>
+                <td class="label">File Count</td>
+                <td><%= runSummary.getTotalFiles() %></td>
+            </tr>
+            <tr>
+                <td class="label">End Okay</td>
+                <td><%= runSummary.getEndOkay() %></td>
+            </tr>
+            <tr>
+                <td class="label">Run Okay</td>
+                <td><%= runSummary.getRunOkay() %></td>
+            </tr>
+            <tr>
+                <td class="label">Updated</td>
+                <td><%= dateFormat.format(runSummary.getUpdated()) %></td>
+            </tr>
+            <tr>
+                <td class="label">Created</td>
+                <td><%= dateFormat.format(runSummary.getCreated()) %></td>
+            </tr>                        
+        </table>
+    </div>
+    <h3>Data</h3>
+    <div>                 
+        <p>
+            <a target="dataFrame" href="epics?run=<%= runSummary.getRun() %>&epicsBankType=<%= EpicsType.EPICS_1S %>">EPICS 1s Data</a>
+        </p>
+        <p>
+            <a target="dataFrame" href="epics?run=<%= runSummary.getRun() %>&epicsBankType=<%= EpicsType.EPICS_10S %>">EPICS 10s Data</a>
+        </p>
+        <p>
+            <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/"; %>
+        <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>
+        </p>
+    </div>
+    
+    <h3>Data Quality Plots</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>());
+        %>
+        <p>found <%= dqmDatasets.size() %> DQM datasets</p>
+    </div>
 </body>
 </html>

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use