Author: [log in to unmask] Date: Tue Dec 8 20:51:03 2015 New Revision: 4032 Log: Current working version of run db webapp with many new features; compatible with hps-java dev branch. Added: webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/DatacatHelper.java webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/DatasetServlet.java webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/TriggerConfigServlet.java webapps/trunk/run-webapp/src/main/webapp/showDatasets.jsp webapps/trunk/run-webapp/src/main/webapp/showTriggerConfig.jsp Modified: webapps/trunk/run-webapp/pom.xml 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/RunSummaryServlet.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/context.xml webapps/trunk/run-webapp/src/main/webapp/WEB-INF/web.xml webapps/trunk/run-webapp/src/main/webapp/html/pager.html webapps/trunk/run-webapp/src/main/webapp/runEpics.jsp webapps/trunk/run-webapp/src/main/webapp/runMain.jsp webapps/trunk/run-webapp/src/main/webapp/runScalers.jsp webapps/trunk/run-webapp/src/main/webapp/runSummary.jsp webapps/trunk/run-webapp/src/main/webapp/runTable.jsp Modified: webapps/trunk/run-webapp/pom.xml ============================================================================= --- webapps/trunk/run-webapp/pom.xml (original) +++ webapps/trunk/run-webapp/pom.xml Tue Dec 8 20:51:03 2015 @@ -26,10 +26,10 @@ </releases> </repository> <repository> - <id>freehep-repo-public</id> + <id>srs-repo-public</id> <name>FreeHEP Maven Public</name> - <url>http://srs.slac.stanford.edu/nexus/content/groups/freehep-maven2-public/</url> - </repository> + <url>http://srs.slac.stanford.edu/nexus/content/groups/srs-maven2-public/</url> + </repository> <repository> <id>lcsim-repo-public</id> <name>LCSIM Public Maven Repository</name> @@ -40,13 +40,19 @@ <dependency> <groupId>org.hps</groupId> <artifactId>hps-run-database</artifactId> - <version>3.4.1-SNAPSHOT</version> + <version>3.4.2-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> - <artifactId>hps-datacat-client</artifactId> - <version>3.4.1-SNAPSHOT</version> + <artifactId>hps-detector-model</artifactId> + <version>3.4.2-SNAPSHOT</version> + <scope>runtime</scope> </dependency> + <dependency> + <groupId>srs</groupId> + <artifactId>org-srs-datacat-client</artifactId> + <version>0.5-SNAPSHOT</version> + </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> 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 Dec 8 20:51:03 2015 @@ -19,11 +19,11 @@ */ @SuppressWarnings("serial") public abstract class AbstractRunServlet extends HttpServlet { - + /** * The data source with the database connection. */ - private final DataSource dataSource; + protected final DataSource dataSource; /** * Create a new run servlet. @@ -39,22 +39,23 @@ * @param response the HTTP response */ @Override - abstract public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException; - + 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")) { + protected 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. @@ -62,10 +63,10 @@ * @param run the run number * @return the run summary */ - RunSummary getRunSummary(final Integer run) { + protected RunSummary getRunSummary(final Integer run) { RunSummary runSummary = null; try (Connection connection = this.dataSource.getConnection()) { - final RunManager runManager = new RunManager(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 Dec 8 20:51:03 2015 @@ -6,7 +6,7 @@ public final class DatabaseUtilities { - private static String DATASOURCE_CONTEXT = "java:comp/env/jdbc/hps_run_db_dev"; + private static String DATASOURCE_CONTEXT = "java:comp/env/jdbc/hps_run_db"; static DataSource getDataSource() { DataSource dataSource = null; Added: webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/DatacatHelper.java ============================================================================= --- webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/DatacatHelper.java (added) +++ webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/DatacatHelper.java Tue Dec 8 20:51:03 2015 @@ -0,0 +1,46 @@ +package org.hps.webapps.run; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import org.srs.datacat.client.Client; +import org.srs.datacat.model.DatasetModel; +import org.srs.datacat.model.DatasetResultSetModel; +import org.srs.datacat.model.dataset.DatasetWithViewModel; + +public class DatacatHelper { + + private Client client = null; + private String dir = "/HPS/**"; + + DatacatHelper(URI url) { + client = new Client(url); + } + + /** + * @return + */ + List<DatasetWithViewModel> executeQuery(String query) { + + List<DatasetWithViewModel> datasets = new ArrayList<DatasetWithViewModel>(); + + // searchForDatasets(String target, String versionId, String site, + // String query, String[] sort, String show, Integer offset, Integer max) + DatasetResultSetModel results = client.searchForDatasets( + dir, // target + "current", // versionId + "all", // site + query, // query + null, // sort + null, // show + null, // offset + null); // max + + for (DatasetModel dataset : results) { + datasets.add((DatasetWithViewModel) dataset); + } + + return datasets; + } +} Added: webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/DatasetServlet.java ============================================================================= --- webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/DatasetServlet.java (added) +++ webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/DatasetServlet.java Tue Dec 8 20:51:03 2015 @@ -0,0 +1,60 @@ +package org.hps.webapps.run; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.srs.datacat.model.dataset.DatasetWithViewModel; + +public class DatasetServlet extends HttpServlet { + + private static String JSP_TARGET = "/showDatasets.jsp"; + + public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, + IOException { + + String dataType = null; + if (request.getParameter("dataType") != null) { + dataType = request.getParameter("dataType"); + request.setAttribute("dataType", dataType); + } else { + throw new RuntimeException("Missing required dataType parameter"); + } + + String fileFormat = null; + if (request.getParameter("fileFormat") != null) { + fileFormat = request.getParameter("fileFormat"); + request.setAttribute("fileFormat", fileFormat); + } else { + throw new RuntimeException("Missing required fileFormat parameter"); + } + + Integer run = null; + if (request.getParameter("run") != null) { + run = Integer.parseInt(request.getParameter("run")); + request.setAttribute("run", run); + } else { + throw new RuntimeException("Missing required run parameter"); + } + + String query = "dataType eq '" + dataType + "' and fileFormat eq '" + fileFormat + "' and runMin eq " + run; + DatacatHelper helper = null; + try { + helper = new DatacatHelper(new URI(getServletContext().getInitParameter("datacat") + "/r")); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + List<DatasetWithViewModel> datasets = helper.executeQuery(query); + request.setAttribute("datasets", datasets); + + final RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher(JSP_TARGET); + dispatcher.forward(request, response); + } +} 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 Dec 8 20:51:03 2015 @@ -33,29 +33,30 @@ @Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, - IOException { + IOException { + if (!request.getParameterMap().containsKey("run")) { throw new RuntimeException("Missing required run parameter."); } final Integer run = Integer.parseInt(request.getParameterValues("run")[0]); + Connection connection = null; List<EpicsData> epicsDataList = null; + List<EpicsVariable> epicsVariables = null; - EpicsType epicsType = EpicsType.EPICS_1S; + // Get EPICS type to determine what variables to display. + EpicsType epicsType = EpicsType.EPICS_2S; if (request.getParameterMap().containsKey("epicsBankType")) { epicsType = EpicsType.valueOf(request.getParameter("epicsBankType")); } - List<EpicsVariable> epicsVariables = null; - + // Get EPICS data from run manager. try { connection = dataSource.getConnection(); - 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); } finally { @@ -67,6 +68,8 @@ } } } + + // Set session attributes and forward to JSP page. request.setAttribute("EpicsDataList", epicsDataList); request.setAttribute("EpicsType", epicsType); request.setAttribute("EpicsVariables", epicsVariables); 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 Dec 8 20:51:03 2015 @@ -15,37 +15,23 @@ */ 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. + /** + * Initialize the servlet. + * + * @param config the servlet config + */ + public void init(ServletConfig config) throws ServletException { + super.init(config); + } + + /** + * Forward to JSP. */ @Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, - IOException { - this.setRunAttribute(request); + 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/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 Tue Dec 8 20:51:03 2015 @@ -6,8 +6,6 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - -import org.hps.run.database.RunSummary; /** * Setup state for JSP that shows run summary. @@ -23,13 +21,10 @@ @Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { - - int run = this.setRunAttribute(request); - - final RunSummary runSummary = this.getRunSummary(run); - request.setAttribute("run_summary", runSummary); - + + this.setRunAttribute(request); + final RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/runSummary.jsp"); 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 Dec 8 20:51:03 2015 @@ -1,23 +1,15 @@ package org.hps.webapps.run; import java.io.IOException; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; 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; /** - * Loads the list of {@link org.hps.run.database.RunSummary} objects to setup state for the <code>runTable.jsp</code> page. + * Forwards to <code>runTable.jsp</code> JSP page. * * @author Jeremy McCormick, SLAC */ @@ -30,59 +22,20 @@ private static final String JSP_TARGET = "/runTable.jsp"; /** - * Attribute for list of run summaries that will set on the request object. - */ - private static final String RUN_SUMMARIES_ATTRIBUTE = "RunSummaries"; - - /** - * 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 RunsServlet() { - this.dataSource = DatabaseUtilities.getDataSource(); } /** - * Setup servlet state by loading the run summaries and then forward to the JSP page for display. + * Forward to the JSP page for display. */ @Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { - - final List<RunSummary> runSummaries = this.getRunSummaries(); - request.setAttribute(RUN_SUMMARIES_ATTRIBUTE, runSummaries); final RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher(JSP_TARGET); dispatcher.forward(request, response); } - - /** - * Read the full list of run summaries from the db. - * - * @return the list of run summaries - */ - private List<RunSummary> getRunSummaries() { - List<RunSummary> runSummaries = new ArrayList<RunSummary>(); - Connection connection = null; - try { - connection = this.dataSource.getConnection(); - runSummaries = new RunManager(connection).getRunSummaries(); - } catch (final SQLException e) { - throw new RuntimeException(e); - } finally { - if (connection != null) { - try { - connection.close(); - } catch (final Exception e) { - e.printStackTrace(); - } - } - } - return runSummaries; - } } 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 Dec 8 20:51:03 2015 @@ -51,16 +51,16 @@ */ @Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, - IOException { + IOException { if (!request.getParameterMap().containsKey("run")) { throw new RuntimeException("Missing required run parameter."); } final Integer run = Integer.parseInt(request.getParameterValues("run")[0]); List<ScalerData> scalerDataList = null; try (Connection connection = this.dataSource.getConnection()) { - RunManager runManager = new RunManager(connection); - runManager.setRun(run); - scalerDataList = runManager.getScalerData(); + RunManager runManager = new RunManager(connection); + runManager.setRun(run); + scalerDataList = runManager.getScalerData(); } catch (final Exception e) { throw new RuntimeException(e); } Added: webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/TriggerConfigServlet.java ============================================================================= --- webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/TriggerConfigServlet.java (added) +++ webapps/trunk/run-webapp/src/main/java/org/hps/webapps/run/TriggerConfigServlet.java Tue Dec 8 20:51:03 2015 @@ -0,0 +1,49 @@ +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.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.hps.conditions.database.DatabaseConditionsManager; +import org.hps.record.daqconfig.DAQConfig; +import org.hps.run.database.RunManager; +import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException; + +public class TriggerConfigServlet extends AbstractRunServlet { + + private static final String JSP_TARGET = "/showTriggerConfig.jsp"; + + /** + * 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); + + Integer run = (Integer) request.getAttribute("run"); + + // Set trigger config object on the request. + try { + DatabaseConditionsManager.getInstance().setDetector("HPS-EngRun2015-Nominal-v3", run); // eek! + } catch (ConditionsNotFoundException e) { + throw new RuntimeException(e); + } + try (Connection connection = this.dataSource.getConnection()) { + RunManager manager = new RunManager(connection); + manager.setRun((Integer) request.getAttribute("run")); + DAQConfig config = manager.getDAQConfig(); + request.setAttribute("daqconfig", config); + } catch (final Exception e) { + throw new RuntimeException(e); + } + + final RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher(JSP_TARGET); + dispatcher.forward(request, response); + } +} Modified: webapps/trunk/run-webapp/src/main/webapp/WEB-INF/context.xml ============================================================================= --- webapps/trunk/run-webapp/src/main/webapp/WEB-INF/context.xml (original) +++ webapps/trunk/run-webapp/src/main/webapp/WEB-INF/context.xml Tue Dec 8 20:51:03 2015 @@ -25,11 +25,16 @@ <!-- url: The JDBC connection url for connecting to your MySQL database. --> -<!-- +<!-- <Resource name="jdbc/hps_run_db" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="hpsuser" password="darkphoton" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://hpsdb.jlab.org/hps_run_db"/> ---> + --> + + <Resource name="jdbc/hps_run_db" auth="Container" type="javax.sql.DataSource" + maxActive="100" maxIdle="30" maxWait="10000" + username="root" password="derp" driverClassName="com.mysql.jdbc.Driver" + url="jdbc:mysql://localhost:3306/hps_run_db"/> </Context> 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 Dec 8 20:51:03 2015 @@ -8,9 +8,9 @@ <display-name>HPS Run Web Application</display-name> <description> - Application for showing information about runs of the HPS experiment. + Web interface to the HPS Run Database </description> - + <resource-ref> <description>Run Database Connection</description> <res-ref-name>jdbc/hps_run_db</res-ref-name> @@ -18,35 +18,45 @@ <res-auth>Container</res-auth> </resource-ref> + <!-- <context-param> <param-name>datacat</param-name> - <param-value>http://hpsweb.jlab.org/datacat</param-value> + <param-value>http://hpsweb.jlab.org/datacat/r</param-value> + </context-param> + --> + + <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://hpsweb.jlab.org/data-quality</param-value> </context-param> + --> + + <context-param> + <param-name>dqm</param-name> + <param-value>http://ppa-jeremym-l.slac.stanford.edu:8080/data-quality</param-value> + </context-param> - <!-- Display full run table. --> - + <!-- Display full run table. --> <servlet> <servlet-name>RunsServlet</servlet-name> <servlet-class>org.hps.webapps.run.RunsServlet</servlet-class> </servlet> - <servlet-mapping> <servlet-name>RunsServlet</servlet-name> <url-pattern>/runs</url-pattern> </servlet-mapping> - <!-- Display the main run page. --> - + <!-- Display the main 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> @@ -57,34 +67,49 @@ <servlet-name>RunSummaryServlet</servlet-name> <servlet-class>org.hps.webapps.run.RunSummaryServlet</servlet-class> </servlet> - <servlet-mapping> <servlet-name>RunSummaryServlet</servlet-name> - <url-pattern>/runSummary</url-pattern> + <url-pattern>/runSummary</url-pattern> </servlet-mapping> - <!-- Display EPICS data --> - + <!-- Display EPICS data --> <servlet> <servlet-name>EpicsDataServlet</servlet-name> <servlet-class>org.hps.webapps.run.EpicsDataServlet</servlet-class> </servlet> - <servlet-mapping> <servlet-name>EpicsDataServlet</servlet-name> <url-pattern>/epics</url-pattern> </servlet-mapping> - <!-- Display scaler data --> - + <!-- Display scaler data --> <servlet> <servlet-name>ScalerDataServlet</servlet-name> <servlet-class>org.hps.webapps.run.ScalerDataServlet</servlet-class> - </servlet> - + </servlet> <servlet-mapping> <servlet-name>ScalerDataServlet</servlet-name> <url-pattern>/scalers</url-pattern> + </servlet-mapping> + + <!-- Display dataset list --> + <servlet> + <servlet-name>DatasetServlet</servlet-name> + <servlet-class>org.hps.webapps.run.DatasetServlet</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>DatasetServlet</servlet-name> + <url-pattern>/datasets</url-pattern> + </servlet-mapping> + + <!-- Display trigger config --> + <servlet> + <servlet-name>TriggerConfigServlet</servlet-name> + <servlet-class>org.hps.webapps.run.TriggerConfigServlet</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>TriggerConfigServlet</servlet-name> + <url-pattern>/triggerconfig</url-pattern> </servlet-mapping> <welcome-file-list> Modified: webapps/trunk/run-webapp/src/main/webapp/html/pager.html ============================================================================= --- webapps/trunk/run-webapp/src/main/webapp/html/pager.html (original) +++ webapps/trunk/run-webapp/src/main/webapp/html/pager.html Tue Dec 8 20:51:03 2015 @@ -12,6 +12,9 @@ <option value="30">30</option> <option value="40">40</option> <option value="50">50</option> + <option value="100">100</option> + <option value="1000">1000</option> + <option value="10000">10000</option> </select> </form> </div> 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 Tue Dec 8 20:51:03 2015 @@ -1,4 +1,5 @@ -<%@ page contentType="text/html" import="java.util.*,java.text.SimpleDateFormat,org.hps.record.epics.*,org.hps.run.database.*" %> +<%@ page contentType="text/html" + import="java.util.*,java.text.SimpleDateFormat,org.hps.record.epics.*,org.hps.run.database.*"%> <!DOCTYPE html> <html> <link rel="stylesheet" href="css/style.css" /> @@ -21,12 +22,15 @@ <body> <% - int run = Integer.parseInt(request.getParameterValues("run")[0]); + int run = Integer.parseInt(request.getParameterValues("run")[0]); List<EpicsVariable> epicsVariables = (List<EpicsVariable>) request.getAttribute("EpicsVariables"); EpicsType epicsType = (EpicsType) request.getAttribute("EpicsType"); List<EpicsData> epicsDataList = (List<EpicsData>) request.getAttribute("EpicsDataList"); %> - <h1>EPICS <%= epicsType.getTypeCode() %>s Data</h1> + <h1> + EPICS + <%=epicsType.getTypeCode()%>s Data + </h1> <hr /> <!-- @@ -52,7 +56,7 @@ <% for (EpicsVariable epicsVariable : epicsVariables) { %> - <th><%= epicsVariable.getVariableName() %></th> + <th><%=epicsVariable.getVariableName()%></th> <% } %> 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 Dec 8 20:51:03 2015 @@ -1,17 +1,16 @@ -<%@page contentType="text/html" pageEncoding="UTF-8" %> +<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - -<% - Integer run = (Integer) request.getAttribute("run"); -%> +<%@page language="java" session="true"%> <html> <head> -<title>HPS Run Web - Run <%= run %></title> +<title>HPS Run Database - <c:out value="${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> + <h2> + Run <c:out value="${run}" /> + </h2> + <iframe frameBorder="0" src="runSummary?run=<c:out value="${run}"/>" name="runSummaryFrame" height="100%" width="30%"></iframe> + <iframe frameBorder="0" 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 Tue Dec 8 20:51:03 2015 @@ -45,22 +45,14 @@ </tr> </thead> <tbody> - <% - for (ScalerData scalerData : scalerDataList) { - %> + <% for (ScalerData scalerData : scalerDataList) { %> <tr> - <td><%= scalerData.getEventId() %> - <% - for (ScalerDataIndex index : ScalerDataIndex.values()) { - %> + <td><%= scalerData.getEventId() %></td> + <% for (ScalerDataIndex index : ScalerDataIndex.values()) { %> <td><%= scalerData.getValue(index.index()) %></td> - <% - } - %> + <% } %> </tr> - <% - } - %> + <% } %> <tbody> </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 Tue Dec 8 20:51:03 2015 @@ -1,95 +1,122 @@ -<%@ 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> +<%@page contentType="text/html"%> +<%@page import="java.util.*,java.io.File,java.text.SimpleDateFormat,org.hps.datacat.client.*,org.hps.run.database.*"%> +<%@page language="java" session="true"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> +<%@ page isELIgnored="false"%> + <html> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" /> <body> - <% - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); - dateFormat.setTimeZone(TimeZone.getTimeZone("America/New_York")); - RunSummary runSummary = (RunSummary) request.getAttribute("run_summary"); - int run = runSummary.getRun(); - if (runSummary == null) { - throw new RuntimeException("Run summary was not set in request."); - } - %> + + <sql:query dataSource="jdbc/hps_run_db" var="result"> + SELECT * FROM run_summaries WHERE run = ?; + <sql:param value="${run}" /> + </sql:query> + <h3>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> + <c:forEach var="row" items="${result.rows}"> + <tr> + <td class="label">Run</td> + <td><c:out value="${row.run}" /></td> + </tr> + <tr> + <td class="label">Events</td> + <td><c:out value="${row.nevents}" /></td> + </tr> + <tr> + <td class="label">Files</td> + <td><c:out value="${row.nfiles}" /></td> + </tr> + <tr> + <td class="label">Prestart Timestamp</td> + <td><c:out value="${row.prestart_timestamp}" /></td> + </tr> + <tr> + <td class="label">Go Timestamp</td> + <td><c:out value="${row.go_timestamp}" /></td> + </tr> + <tr> + <td class="label">End Timestamp</td> + <td><c:out value="${row.end_timestamp}" /></td> + </tr> + <tr> + <td class="label">Trigger Rate</td> + <td><c:out value="${row.trigger_rate}" /></td> + </tr> + <tr> + <td class="label">Trigger Config Name</td> + <td><c:out value="${row.trigger_config_name}" /></td> + </tr> + <tr> + <td class="label">TI Time Offset</td> + <td><c:out value="${row.ti_time_offset}" /></td> + </tr> + <tr> + <td class="label">Livetime Clock</td> + <td><c:out value="${row.livetime_clock}" /></td> + </tr> + <tr> + <td class="label">Livetime TDC</td> + <td><c:out value="${row.livetime_fcup_tdc}" /></td> + </tr> + <tr> + <td class="label">Livetime TRG</td> + <td><c:out value="${row.livetime_fcup_trg}" /></td> + </tr> + <tr> + <td class="label">Target</td> + <td><c:out value="${row.target}" /></td> + </tr> + <tr> + <td class="label">Notes</td> + <td><c:out value="${row.notes}" /></td> + </tr> + <tr> + <td class="label">Created</td> + <td><c:out value="${row.created}" /></td> + </tr> + <tr> + <td class="label">Created</td> + <td><c:out value="${row.updated}" /></td> + </tr> + </c:forEach> </table> </div> <h3>Data</h3> - <div> + <div> <p> - <a target="dataFrame" href="epics?run=<%= runSummary.getRun() %>&epicsBankType=<%= EpicsType.EPICS_1S %>">EPICS 1s Data</a> + <a target="dataFrame" href="epics?run=<c:out value="${run}"/>&epicsBankType=<%= EpicsType.EPICS_2S %>">EPICS 2s Data</a> </p> <p> - <a target="dataFrame" href="epics?run=<%= runSummary.getRun() %>&epicsBankType=<%= EpicsType.EPICS_10S %>">EPICS 10s Data</a> + <a target="dataFrame" href="epics?run=<c:out value="${run}"/>&epicsBankType=<%= EpicsType.EPICS_20S %>">EPICS 20s Data</a> </p> <p> - <a target="dataFrame" href="scalers?run=<%= runSummary.getRun() %>">Scaler Data</a> + <a target="dataFrame" href="scalers?run=<c:out value="${run}"/>">Scaler Data</a> </p> </div> - <h3>Files</h3> <div> - <% String datacat = (String) request.getSession().getAttribute("datacat"); %> <p> - <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> + <a target="dataFrame" href="<%= getServletContext().getInitParameter("datacat") %>/display/datasets/HPS/data/raw?offset=0&max=999999&sort=name&filter=dataType eq 'RAW' and runMin eq <c:out value="${run}"/>">EVIO</a> + </p> + <p> + <a target="dataFrame" href="datasets?run=<c:out value="${run}"/>&dataType=RECON&fileFormat=LCIO">LCIO RECON</a> + </p> + <p> + <a target="dataFrame" href="datasets?run=<c:out value="${run}"/>&dataType=DST&fileFormat=ROOT">ROOT DST</a> + </p> + <p> + <a target="dataFrame" href="datasets?run=<c:out value="${run}"/>&dataType=DQM&fileFormat=AIDA">AIDA DQM</a> </p> </div> - <h3>Data Quality Management</h3> + <h3>System Config</h3> <div> - <% - 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 <%= 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> + <p> + <a target="dataFrame" href="triggerconfig?run=<c:out value="${run}"/>">Trigger Config</a> + </p> + </div> </body> </html> Modified: webapps/trunk/run-webapp/src/main/webapp/runTable.jsp ============================================================================= --- webapps/trunk/run-webapp/src/main/webapp/runTable.jsp (original) +++ webapps/trunk/run-webapp/src/main/webapp/runTable.jsp Tue Dec 8 20:51:03 2015 @@ -1,69 +1,70 @@ -<%@ page contentType="text/html" import="java.util.*,org.hps.run.database.RunSummary,java.text.SimpleDateFormat"%> -<!DOCTYPE html> +<%@ page contentType="text/html"%> +<%@page import="java.util.*,org.hps.run.database.RunSummary,java.text.SimpleDateFormat"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> + <html> <!-- application stylesheet --> <link rel="stylesheet" href="css/style.css" /> <!-- include links and scripts for tablesorter jquery plugin --> -<%@include file="html/tablesorter.html" %> +<%@include file="html/tablesorter.html"%> <!-- sort the table after doc loads --> <!cript> - $(document).ready(function() - { - $("#run-table") - .tablesorter({widthFixed: true, widgets: ['zebra']}) - .tablesorterPager({container: $("#pager"), size: 20}); - } - ); + $(document).ready(function() { + $("#run-table").tablesorter({ + widthFixed : true, + widgets : [ 'zebra' ] + }).tablesorterPager({ + container : $("#pager"), + size : 20 + }); + }); </script> <body> - <h1>HPS Run Table</h1> - <hr/> - - <!-- full run table with tablesorter theme, sorting and pagination --> - <table id="run-table" class="tablesorter-blue"> - <thead> - <tr> - <th>Run</th> - <th>Start Date</th> - <th>End Date</th> - <th>Events</th> - <th>Files</th> - <th>End Okay</th> - <th>Run Okay</th> - <th>Updated</th> - <th>Created</th> - </tr> - </thead> - <tbody> - <!-- get the list of run summaries from the request and create a table row for each one --> - <% - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - List<RunSummary> runSummaries = (List<RunSummary>) request.getAttribute("RunSummaries"); - for (RunSummary runSummary : runSummaries) { - %> - <!-- table row links to its run summary page --> - <tr onclick="document.location.href='run?run=<%= runSummary.getRun() %>';"> - <td><%= runSummary.getRun() %></td> - <td><%= dateFormat.format(runSummary.getStartDate()) %></td> - <td><%= dateFormat.format(runSummary.getEndDate()) %></td> - <td><%= runSummary.getTotalEvents() %></td> - <td><%= runSummary.getTotalFiles() %></td> - <td><%= runSummary.getEndOkay() %></td> - <td><%= runSummary.getRunOkay() %></td> - <td><%= dateFormat.format(runSummary.getUpdated()) %></td> - <td><%= dateFormat.format(runSummary.getCreated()) %></td> - </tr> - <% } %> - <tbody> - </table> - - <!-- tablesorter paging container --> - <%@include file="html/pager.html" %> - + <h1>HPS Run Table</h1> + <hr /> + + <!-- full run table with tablesorter theme, sorting and pagination --> + <table id="run-table" class="tablesorter-blue"> + <thead> + <tr> + <th>Run</th> + <th>Events</th> + <th>Files</th> + <th>Prestart Timestamp</th> + <th>Go Timestamp</th> + <th>End Timestamp</th> + <th>Trigger Rate</th> + <th>Created</th> + <th>Updated</th> + </tr> + </thead> + <tbody> + <sql:query dataSource="jdbc/hps_run_db" var="result"> + SELECT * FROM run_summaries; + </sql:query> + <c:forEach var="row" items="${result.rows}"> + <tr onclick="document.location.href='run?run=<c:out value="${row.run}"/>';"> + <td><c:out value="${row.run}" /></td> + <td><c:out value="${row.nevents}" /></td> + <td><c:out value="${row.nfiles}" /></td> + <td><c:out value="${row.prestart_timestamp}" /></td> + <td><c:out value="${row.go_timestamp}" /></td> + <td><c:out value="${row.end_timestamp}" /></td> + <td><c:out value="${row.trigger_rate}" /></td> + <td><c:out value="${row.created}" /></td> + <td><c:out value="${row.updated}" /></td> + </tr> + </c:forEach> + <tbody> + </table> + + <!-- tablesorter paging container --> + <%@include file="html/pager.html"%> + </body> </html> Added: webapps/trunk/run-webapp/src/main/webapp/showDatasets.jsp ============================================================================= --- webapps/trunk/run-webapp/src/main/webapp/showDatasets.jsp (added) +++ webapps/trunk/run-webapp/src/main/webapp/showDatasets.jsp Tue Dec 8 20:51:03 2015 @@ -0,0 +1,62 @@ +<%@ page contentType="text/html"%> +<%@page import="java.util.*,org.hps.run.database.RunSummary,java.text.SimpleDateFormat"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + +<html> + +<link rel="stylesheet" href="css/style.css" /> + +<!-- include links and scripts for tablesorter jquery plugin --> +<%@include file="html/tablesorter.html"%> + +<!-- sort the table after doc loads --> +<!cript> + $(document).ready(function() { + $("#dataset-table").tablesorter({ + widthFixed : true, + widgets : [ 'zebra' ] + }).tablesorterPager({ + container : $("#pager"), + size : 50 + }); + }); +</script> + +<body> + <h3><c:out value="${fileFormat}"/> <c:out value="${dataType}"/> Datasets for Run <c:out value="${run}"/></h3> + <table id="dataset-table" class="tablesorter-blue"> + <thead> + <tr> + <th>Path</th> + <th>Type</th> + <th>Created</th> + </tr> + </thead> + <tbody> + <c:forEach var="dataset" items="${datasets}"> + <tr onclick="document.location.href='<%= getServletContext().getInitParameter("datacat") %>/display/datasets/<c:out value="${dataset.path}"/>';"> + <td> + <c:out value="${dataset.path}" /> + <c:if test="${dataType == 'DQM'}"> + <c:forEach var="location" items="${dataset.viewInfo.locations}" begin="0" end="0"> + <a target="_blank" style="font-size: 80%" + href="<%= getServletContext().getInitParameter("dqm") %>/show_plots?file=<c:out value="${location.resource}"/>">Show Plots</a> + </c:forEach> + </c:if> + </td> + <td> + <c:out value="${dataset.dataType}" /> + </td> + <td> + <c:out value="${dataset.dateCreated}" /> + </td> + </tr> + </c:forEach> + </tbody> + </table> + + <!-- tablesorter paging container --> + <%@include file="html/pager.html"%> + +</body> +</html> Added: webapps/trunk/run-webapp/src/main/webapp/showTriggerConfig.jsp ============================================================================= --- webapps/trunk/run-webapp/src/main/webapp/showTriggerConfig.jsp (added) +++ webapps/trunk/run-webapp/src/main/webapp/showTriggerConfig.jsp Tue Dec 8 20:51:03 2015 @@ -0,0 +1,13 @@ +<%@page contentType="text/html"%> +<%@page import="java.util.*"%> +<%@page language="java" session="true"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ page isELIgnored="false"%> + +<html> +<body> + <div> + <%= request.getAttribute("daqconfig").toString().replaceAll("\\r?\\n", "<br />") %> + </div> +</body> +</html>