You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2012/05/23 04:29:06 UTC
svn commit: r1341732 [3/3] - in
/incubator/airavata/sandbox/workflow-monitoring-util: ./ conf/ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/airavata/ src/main/java/org/apache/airavata/tools/
src/ma...
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/jsp/reportGenerator.jsp
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/jsp/reportGenerator.jsp?rev=1341732&view=auto
==============================================================================
--- incubator/airavata/sandbox/workflow-monitoring-util/web/jsp/reportGenerator.jsp (added)
+++ incubator/airavata/sandbox/workflow-monitoring-util/web/jsp/reportGenerator.jsp Wed May 23 02:29:03 2012
@@ -0,0 +1,196 @@
+<%@ page import="org.apache.airavata.tools.workflow.monitoring.QueryManager" %>
+<%@ page import="org.apache.airavata.tools.workflow.monitoring.WorkflowMonitoringException" %>
+<%@ page import="org.apache.airavata.tools.workflow.monitoring.bean.TemplateInfoBean" %>
+<%@ page import="org.apache.airavata.tools.workflow.monitoring.db.DBConstants" %>
+<%@ page import="java.sql.ResultSet" %>
+<%@ page import="java.sql.SQLException" %>
+<%@ page import="java.text.DecimalFormat" %>
+<%@ page import="java.text.ParseException" %>
+<%@ page import="java.text.SimpleDateFormat" %>
+<%@ page import="java.util.*" %>
+<%@ page import="org.apache.airavata.tools.workflow.monitoring.util.Util" %>
+
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head>
+ <title>:: Reports ::</title></head>
+<body>
+<h2 align="center">Lead Monitoring System Reports</h2>
+
+
+<%
+ try {
+
+ String startTimeString = request.getParameter("startTime");
+
+ long startDate = Util.getTime(startTimeString);
+
+ String endTimeString = request.getParameter("endTime");
+ long endDate = -1;
+ if (endTimeString != null && !"".equals(endTimeString)) {
+ endDate = Util.getTime(endTimeString);
+ }
+
+ // first get the summary report
+
+ // Here I need to get the total number of entries in this queries. I can do it either by executing another query
+ // or counting the number of entries in this query.
+ // I follow the second option and store the date in a temporary location (HashMap). Having claculated the total number
+ // I display the results
+ QueryManager queryManager = new QueryManager();
+ ResultSet summaryData = queryManager.getSummaryInformation(startDate, endDate);
+
+ HashMap<String, Integer> summaryInformation = new HashMap<String, Integer>();
+ long totalCount = 0;
+ int statusCount = 0;
+ while (summaryData.next()) {
+ statusCount = summaryData.getInt("total");
+ totalCount += statusCount;
+
+ summaryInformation.put(summaryData.getString(DBConstants.T_SUMMARY_STATUS), statusCount);
+ }
+
+ summaryData.close();
+
+ // ok now I am ready to output the summary details
+ if (totalCount > 0) {
+%>
+<table cellspacing="1" cellpadding="3" border="0" width="40%">
+ <tr>
+ <th bgcolor="#4682B4"><font color="#ffffff">Total WorkFlows</font></th>
+ <th colspan="2" align="center" bgcolor="#dbeaf5"><%=totalCount%>
+ </th>
+ <td/>
+ </tr>
+
+ <%
+ Iterator<String> summaryInfoIter = summaryInformation.keySet().iterator();
+ DecimalFormat format = new DecimalFormat("##.00");
+ while (summaryInfoIter.hasNext()) {
+ String statusName = summaryInfoIter.next();
+ int count = summaryInformation.get(statusName);
+ %>
+ <tr bgcolor="#dbeaf5">
+ <th align="left" width="22%"><%=statusName%>
+ </th>
+ <td align="right" width="10%"><%=count%>
+ </td>
+
+ <td align="right" width="5%"><%=format.format(count * 100.00 / totalCount)%>%</td>
+ </tr>
+ <%
+ }
+ %>
+
+</table>
+
+<%
+ // summary information are done now. Now it is the time to look at information grouped by template ID, if the user
+ // had asked for it.
+ String groupByParam = request.getParameter("groupByTemplateId");
+ if (groupByParam != null && !"".equals(groupByParam) && groupByParam.equalsIgnoreCase("yes")) {
+ ResultSet workflowData = queryManager.getSummaryInformationForTemplates(startDate, endDate);
+
+
+ ArrayList<TemplateInfoBean> templateBeans = new ArrayList<TemplateInfoBean>();
+ TemplateInfoBean bean = null;
+ String currentTemplateId = "";
+
+ // I'm gonna do a small trick here. Since the templates are coming in order, as the sql is grouped by template ID,
+ // I will keep a reference to TemplateInfoBean and template id created in the previous iteration. If the current
+ // template id is same as the earlier one, the the query is giving info about an existing bean. Else create
+ // a new bean.
+ while (workflowData.next()) {
+ String templateID = workflowData.getString(DBConstants.T_SUMMARY_TEMPLATE_ID);
+ if (!currentTemplateId.equals(templateID)) {
+ currentTemplateId = templateID;
+ bean = new TemplateInfoBean(templateID);
+ templateBeans.add(bean);
+ }
+
+ bean.addStatusInfo(workflowData.getString(DBConstants.T_SUMMARY_STATUS), workflowData.getInt("total"));
+ }
+ queryManager.close();
+
+ // now let's present the information we have
+
+
+%>
+
+<h3>Report on Workflow Templates</h3>
+<table cellspacing="1" cellpadding="3" border="0" width="80%">
+ <tr>
+ <th align="center" bgcolor="#4682B4"><font color="#ffffff">Template Id</font></th>
+ <td align="center" bgcolor="#4682B4"><font color="#ffffff">Status</font></td>
+ <td align="center" bgcolor="#4682B4"><font color="#ffffff">Count</font></td>
+ <td align="center" bgcolor="#4682B4"><font color="#ffffff">Percentage</font></td>
+ <td/>
+ </tr>
+
+ <%
+
+ for (int i = 0; i < templateBeans.size(); i++) {
+ TemplateInfoBean infoBean = templateBeans.get(i);
+
+ List<String> statsusNames = infoBean.getAllStatusNames();
+ List<Long> statusCounts = infoBean.getAllStatusCounts();
+
+ long totalStatusCount = infoBean.getTotalCount();
+ %>
+ <tr>
+ <th align="left" bgcolor="#dbeaf5" rowspan="<%=statsusNames.size()%>"><%=infoBean.getTemplateID()%>
+ </th>
+ <!--<td align="right" colspan="3">-->
+
+ <!--<table border="1" cellpadding="5">-->
+ <%
+ for (int j = 0; j < statsusNames.size(); j++) {
+ long count = statusCounts.get(j);
+ if (j > 0) {
+ %>
+ <tr bgcolor="#dbeaf5"><%
+ }
+ %>
+
+ <td align="center"><%=statsusNames.get(j)%>
+ </td>
+ <td align="right"><%=count%>
+ </td>
+ <td align="right"><%=format.format(count * 100.00 / totalStatusCount)%>%</td>
+ </tr>
+ <%
+ }
+ %>
+
+ </tr>
+ <%
+ }
+ %>
+
+</table>
+
+
+<%
+ }
+
+} else {
+%>
+<p>There are no information available at this time about the Wokflows</p>
+<%
+ }
+
+
+} catch (WorkflowMonitoringException e) {
+%>
+<h4>An error occurred while retreiving data. Please retry later.</h4>
+<%
+} catch (SQLException e) {
+%>
+<h4>An error occurred while retreiving data. Please retry later.</h4>
+<%
+ }
+
+%>
+
+</body>
+</html>
\ No newline at end of file
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/calendar.html
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/calendar.html?rev=1341732&view=auto
==============================================================================
--- incubator/airavata/sandbox/workflow-monitoring-util/web/resources/calendar.html (added)
+++ incubator/airavata/sandbox/workflow-monitoring-util/web/resources/calendar.html Wed May 23 02:29:03 2012
@@ -0,0 +1,168 @@
+<!--
+Title: Tigra Calendar
+URL: http://www.softcomplex.com/products/tigra_calendar/
+Version: 3.2
+Date: 05/18/2006
+Feedback: feedback@softcomplex.com (specify product title in the subject)
+Note: Permission given to use this script in ANY kind of applications if
+ header lines are left unchanged.
+Note: Script consists of two files: calendar?.js and calendar.html
+About us: Our company provides offshore IT consulting services.
+ Contact us at sales@softcomplex.com if you have any programming task you
+ want to be handled by professionals. Our typical hourly rate is $20.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+ <title>Select Date, Please.</title>
+ <style>
+ td {
+ font-family: Tahoma, Verdana, sans-serif;
+ font-size: 12px;
+ }
+ </style>
+ <script language="JavaScript">
+
+ // months as they appear in the calendar's title
+ var ARR_MONTHS = ["January", "February", "March", "April", "May", "June",
+ "July", "August", "September", "October", "November", "December"];
+ // week day titles as they appear on the calendar
+ var ARR_WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
+ // day week starts from (normally 0-Su or 1-Mo)
+ var NUM_WEEKSTART = 1;
+ // path to the directory where calendar images are stored. trailing slash req.
+ var STR_ICONPATH = 'img/';
+
+ var re_url = new RegExp('datetime=(\\-?\\d+)');
+ var dt_current = (re_url.exec(String(window.location))
+ ? new Date(new Number(RegExp.$1)) : new Date());
+ var re_id = new RegExp('id=(\\d+)');
+ var num_id = (re_id.exec(String(window.location))
+ ? new Number(RegExp.$1) : 0);
+ var obj_caller = (window.opener ? window.opener.calendars[num_id] : null);
+
+ if (obj_caller && obj_caller.year_scroll) {
+ // get same date in the previous year
+ var dt_prev_year = new Date(dt_current);
+ dt_prev_year.setFullYear(dt_prev_year.getFullYear() - 1);
+ if (dt_prev_year.getDate() != dt_current.getDate())
+ dt_prev_year.setDate(0);
+
+ // get same date in the next year
+ var dt_next_year = new Date(dt_current);
+ dt_next_year.setFullYear(dt_next_year.getFullYear() + 1);
+ if (dt_next_year.getDate() != dt_current.getDate())
+ dt_next_year.setDate(0);
+ }
+
+ // get same date in the previous month
+ var dt_prev_month = new Date(dt_current);
+ dt_prev_month.setMonth(dt_prev_month.getMonth() - 1);
+ if (dt_prev_month.getDate() != dt_current.getDate())
+ dt_prev_month.setDate(0);
+
+ // get same date in the next month
+ var dt_next_month = new Date(dt_current);
+ dt_next_month.setMonth(dt_next_month.getMonth() + 1);
+ if (dt_next_month.getDate() != dt_current.getDate())
+ dt_next_month.setDate(0);
+
+ // get first day to display in the grid for current month
+ var dt_firstday = new Date(dt_current);
+ dt_firstday.setDate(1);
+ dt_firstday.setDate(1 - (7 + dt_firstday.getDay() - NUM_WEEKSTART) % 7);
+
+ // function passing selected date to calling window
+ function set_datetime(n_datetime, b_close) {
+ if (!obj_caller) return;
+
+ var dt_datetime = obj_caller.prs_time(
+ (document.cal ? document.cal.time.value : ''),
+ new Date(n_datetime)
+ );
+
+ if (!dt_datetime) return;
+ if (b_close) {
+
+ obj_caller.target.value = (document.cal
+ ? obj_caller.gen_tsmp(dt_datetime)
+ : obj_caller.gen_date(dt_datetime)
+ );
+ window.close();
+ }
+ else obj_caller.popup(dt_datetime.valueOf());
+ }
+
+ </script>
+</head>
+<body bgcolor="#FFFFFF" marginheight="5" marginwidth="5" topmargin="5" leftmargin="5" rightmargin="5">
+<table class="clsOTable" cellspacing="0" border="0" width="100%">
+ <tr>
+ <td bgcolor="#4682B4">
+ <table cellspacing="1" cellpadding="3" border="0" width="100%">
+ <tr>
+ <td colspan="7">
+ <table cellspacing="0" cellpadding="0" border="0" width="100%">
+ <tr>
+ <script language="JavaScript">
+ document.write(
+ '<td>' + (obj_caller && obj_caller.year_scroll ? '<a href="javascript:set_datetime(' + dt_prev_year.valueOf() + ')"><img src="' + STR_ICONPATH + 'prev_year.gif" width="16" height="16" border="0" alt="previous year"></a> ' : '') + '<a href="javascript:set_datetime(' + dt_prev_month.valueOf() + ')"><img src="' + STR_ICONPATH + 'prev.gif" width="16" height="16" border="0" alt="previous month"></a></td>' +
+ '<td align="center" width="100%"><font color="#ffffff">' + ARR_MONTHS[dt_current.getMonth()] + ' ' + dt_current.getFullYear() + '</font></td>' +
+ '<td><a href="javascript:set_datetime(' + dt_next_month.valueOf() + ')"><img src="' + STR_ICONPATH + 'next.gif" width="16" height="16" border="0" alt="next month"></a>' + (obj_caller && obj_caller.year_scroll ? ' <a href="javascript:set_datetime(' + dt_next_year.valueOf() + ')"><img src="' + STR_ICONPATH + 'next_year.gif" width="16" height="16" border="0" alt="next year"></a>' : '') + '</td>'
+ );
+ </script>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <script language="JavaScript">
+
+ // print weekdays titles
+ for (var n = 0; n < 7; n++)
+ document.write('<td bgcolor="#87cefa" align="center"><font color="#ffffff">' + ARR_WEEKDAYS[(NUM_WEEKSTART + n) % 7] + '</font></td>');
+ document.write('</tr>');
+
+ // print calendar table
+ var dt_current_day = new Date(dt_firstday);
+ while (dt_current_day.getMonth() == dt_current.getMonth() ||
+ dt_current_day.getMonth() == dt_firstday.getMonth()) {
+ // print row heder
+ document.write('<tr>');
+ for (var n_current_wday = 0; n_current_wday < 7; n_current_wday++) {
+ if (dt_current_day.getDate() == dt_current.getDate() &&
+ dt_current_day.getMonth() == dt_current.getMonth())
+ // print current date
+ document.write('<td bgcolor="#ffb6c1" align="center" width="14%">');
+ else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
+ // weekend days
+ document.write('<td bgcolor="#dbeaf5" align="center" width="14%">');
+ else
+ // print working days of current month
+ document.write('<td bgcolor="#ffffff" align="center" width="14%">');
+
+ document.write('<a href="javascript:set_datetime(' + dt_current_day.valueOf() + ', true);">');
+
+ if (dt_current_day.getMonth() == this.dt_current.getMonth())
+ // print days of current month
+ document.write('<font color="#000000">');
+ else
+ // print days of other months
+ document.write('<font color="#606060">');
+
+ document.write(dt_current_day.getDate() + '</font></a></td>');
+ dt_current_day.setDate(dt_current_day.getDate() + 1);
+ }
+ // print row footer
+ document.write('</tr>');
+ }
+ if (obj_caller && obj_caller.time_comp)
+ document.write('<form onsubmit="javascript:set_datetime(' + dt_current.valueOf() + ', true)" name="cal"><tr><td colspan="7" bgcolor="#87CEFA"><font color="White" face="tahoma, verdana" size="2">Time: <input type="text" name="time" value="' + obj_caller.gen_time(this.dt_current) + '" size="8" maxlength="8"></font></td></tr></form>');
+ </script>
+ </table>
+ </tr>
+</td>
+</table>
+</body>
+</html>
+
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/cal.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/cal.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/cal.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_demo.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_demo.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_demo.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_docs.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_docs.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_docs.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_download.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_download.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_download.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_forum.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_forum.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_forum.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_home.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_home.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/icon_home.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/logo.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/logo.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/logo.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/next.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/next.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/next.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/next_year.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/next_year.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/next_year.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/pixel.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/pixel.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/pixel.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/prev.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/prev.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/prev.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/prev_year.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/prev_year.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/prev_year.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/tc.gif
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/tc.gif?rev=1341732&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/img/tc.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/index.html
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/index.html?rev=1341732&view=auto
==============================================================================
--- incubator/airavata/sandbox/workflow-monitoring-util/web/resources/index.html (added)
+++ incubator/airavata/sandbox/workflow-monitoring-util/web/resources/index.html Wed May 23 02:29:03 2012
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title> :: Wokflow Monitoring System :: </title>
+ <script language="JavaScript" src="js/calendar2.js"></script>
+ <script language="javascript" type='text/javascript'>
+
+ function showDiv(showDiv, hideDiv) {
+ if (document.getElementById) { // DOM3 = IE5, NS6
+ document.showLayer = eval('document.getElementById(showDiv)');
+ document.hideLayer = eval('document.getElementById(hideDiv)');
+
+ document.showLayer.style.display = "visible";
+ document.showLayer.style.display = "inline";
+ document.hideLayer.style.display = "hidden";
+ document.hideLayer.style.display = "none";
+ }
+ }
+ function load()
+ {
+ showDiv('findWorkFlowsByTime', 'findWorkFlowsbyUser');
+ }
+
+ function checkFindByUserForm(form)
+ {
+
+ // ** START **
+ if (form.username.value == "") {
+ alert("Please enter a non-empty username");
+ form.username.focus();
+ form.username.borderColor = "#0000FF #00FF00";
+ return false;
+ }
+ // ** END **
+ return true;
+ }
+
+
+ </script>
+</head>
+<body onload="load()">
+<h1>Wokflow Monitoring System</h1>
+
+<p>This will provide basic functionality to monitor the workflows running within LEAD system.</p>
+
+
+<h3>Find Failed Workflows By Id</h3>
+
+<p>This helps you to find information about failed workflows. Enter the workflow id of the failed workflow below.</p>
+
+
+<form action="./jsp/findWorkFlowById.jsp" method="post" name="form1">
+ <table>
+ <tr>
+ <td><label><b>Workflow Id : </b></label></td>
+ <td><input type="text" name="workflowId" id="workflowId"></td>
+ </tr>
+ <tr>
+ <td align="center"><input type="submit" value="Search"></td>
+ <td align="center"><input type="reset"></td>
+ </tr>
+ </table>
+</form>
+
+
+<h3> Find Workflows </h3>
+
+<ul>
+ <li><a href="#" onClick="javascript:showDiv('findWorkFlowsByTime','findWorkFlowsbyUser');">By Time Range</a></li>
+ <li><a href="#" onClick="javascript:showDiv('findWorkFlowsbyUser','findWorkFlowsByTime');">By Username</a></li>
+</ul>
+
+<div id="findWorkFlowsByTime" style="display: inline">
+ <p>This helps you to find information about all the Wokflows that started between a given time range. (If you want
+ to
+ search for workflows that are started since a given time, only select the start range leaving the end range
+ blank.)
+ <br/>
+ The report that will be generated will contain Wokflows which have different states and you can evaluate more
+ on
+ failed workflow by clicking on them.
+ </p>
+
+
+ <form action="./jsp/findWorkFlowByTimes.jsp" method="post" name="form2">
+ <table>
+ <tr>
+ <td><label><b>Start Range : </b></label></td>
+ <td><input type="text" name="startTime" id="startTime" readonly="true"><a
+ href="javascript:cal1.popup();"><img
+ src="img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a>
+ </td>
+ </tr>
+ <tr>
+ <td><label>End Range : </label></td>
+ <td><input type="text" name="endTime" id="endTime" readonly="true"><a
+ href="javascript:cal2.popup();"><img
+ src="img/cal.gif"
+ width="16"
+ height="16"
+ border="0"
+ alt="Click Here to Pick up the date"></a>
+ </td>
+ </tr>
+ <tr>
+ <td align="center"><input type="submit" value="Search"></td>
+ <td align="center"><input type="reset"></td>
+ </tr>
+ </table>
+ </form>
+
+</div>
+
+<div id="findWorkFlowsbyUser" style="display: inline">
+ <p>This helps you to find information about all the Wokflows started by a given user. <br/>
+ The report that will be generated will contain Wokflows which have different states and you can evaluate more
+ on failed workflow by clicking on them.</p>
+
+
+ <form action="./jsp/findWorkFlowByUser.jsp" method="post" name="form4" onsubmit="return checkFindByUserForm(this);">
+ <table>
+ <tr>
+ <td><label><b>Username : </b></label></td>
+ <td><input type="text" name="username" id="username"></td>
+ </tr>
+ <tr>
+ <td align="center"><input type="submit" value="Search"></td>
+ <td align="center"><input type="reset"></td>
+ </tr>
+ </table>
+ </form>
+
+</div>
+
+<h3>Reports</h3>
+
+<p>This will generate a summary report for all the Wokflows. </p>
+
+<form action="./jsp/reportGenerator.jsp" method="post" name="form3">
+ <table>
+ <tr>
+ <td><label><b>Start Time : </b></label></td>
+ <td><input type="text" name="startTime" id="startTime" readonly="true"><a
+ href="javascript:cal3.popup();"><img
+ src="img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a>
+ </tr>
+ <tr>
+ <td><label>End Time : </label></td>
+ <td><input type="text" name="endTime" id="endTime" readonly="true"><a href="javascript:cal4.popup();"><img
+ src="img/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a></td>
+ </tr>
+
+ <tr>
+ <td><label>Do you want to group by template id ? </label></td>
+ <td><input type="radio" name="groupByTemplateId" value="yes" checked="true">Yes</input>
+ <input type="radio" name="groupByTemplateId" value="no">No</input></td>
+ </tr>
+ <tr>
+ <td align="center"><input type="submit" value="Search"></td>
+ <td align="center"><input type="reset"></td>
+ </tr>
+ </table>
+</form>
+<script language="JavaScript">
+ var cal1 = new calendar2(document.forms['form2'].elements['startTime']);
+ cal1.year_scroll = true;
+ cal1.time_comp = true;
+ var cal2 = new calendar2(document.forms['form2'].elements['endTime']);
+ cal2.year_scroll = true;
+ cal2.time_comp = true;
+ var cal3 = new calendar2(document.forms['form3'].elements['startTime']);
+ cal3.year_scroll = true;
+ cal3.time_comp = true;
+ var cal4 = new calendar2(document.forms['form3'].elements['endTime']);
+ cal4.year_scroll = true;
+ cal4.time_comp = true;
+</script>
+</body>
+</html>
\ No newline at end of file
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/resources/js/calendar2.js
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/resources/js/calendar2.js?rev=1341732&view=auto
==============================================================================
--- incubator/airavata/sandbox/workflow-monitoring-util/web/resources/js/calendar2.js (added)
+++ incubator/airavata/sandbox/workflow-monitoring-util/web/resources/js/calendar2.js Wed May 23 02:29:03 2012
@@ -0,0 +1,161 @@
+// Title: Tigra Calendar
+// URL: http://www.softcomplex.com/products/tigra_calendar/
+// Version: 3.3 (American date format)
+// Date: 09/01/2005 (mm/dd/yyyy)
+// Note: Permission given to use this script in ANY kind of applications if
+// header lines are left unchanged.
+// Note: Script consists of two files: calendar?.js and calendar.html
+
+// if two digit year input dates after this year considered 20 century.
+var NUM_CENTYEAR = 30;
+// is time input control required by default
+var BUL_TIMECOMPONENT = false;
+// are year scrolling buttons required by default
+var BUL_YEARSCROLL = true;
+
+var calendars = [];
+var RE_NUM = /^\-?\d+$/;
+
+function calendar2(obj_target) {
+
+ // assigning methods
+ this.gen_date = cal_gen_date2;
+ this.gen_time = cal_gen_time2;
+ this.gen_tsmp = cal_gen_tsmp2;
+ this.prs_date = cal_prs_date2;
+ this.prs_time = cal_prs_time2;
+ this.prs_tsmp = cal_prs_tsmp2;
+ this.popup = cal_popup2;
+
+ // validate input parameters
+ if (!obj_target)
+ return cal_error("Error calling the calendar: no target control specified");
+ if (obj_target.value == null)
+ return cal_error("Error calling the calendar: parameter specified is not valid target control");
+ this.target = obj_target;
+ this.time_comp = BUL_TIMECOMPONENT;
+ this.year_scroll = BUL_YEARSCROLL;
+
+ // register in global collections
+ this.id = calendars.length;
+ calendars[this.id] = this;
+}
+
+function cal_popup2(str_datetime) {
+ if (str_datetime) {
+ this.dt_current = this.prs_tsmp(str_datetime);
+ }
+ else {
+ this.dt_current = this.prs_tsmp(this.target.value);
+ this.dt_selected = this.dt_current;
+ }
+ if (!this.dt_current) return;
+
+ var obj_calwindow = window.open(
+ 'calendar.html?datetime=' + this.dt_current.valueOf() + '&id=' + this.id,
+// 'Calendar', 'width=200,height=' + (this.time_comp ? 215 : 190) +
+ 'Calendar', 'width=200,height=300' +
+ ',status=no,resizable=no,top=200,left=200,dependent=yes,alwaysRaised=yes'
+ );
+ obj_calwindow.opener = window;
+ obj_calwindow.focus();
+}
+
+// timestamp generating function
+function cal_gen_tsmp2(dt_datetime) {
+ return(this.gen_date(dt_datetime) + ' ' + this.gen_time(dt_datetime));
+}
+
+// date generating function
+function cal_gen_date2(dt_datetime) {
+ return (
+ (dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1) + "/"
+ + (dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate() + "/"
+ + dt_datetime.getFullYear()
+ );
+}
+// time generating function
+function cal_gen_time2(dt_datetime) {
+ return (
+ (dt_datetime.getHours() < 10 ? '0' : '') + dt_datetime.getHours() + ":"
+ + (dt_datetime.getMinutes() < 10 ? '0' : '') + (dt_datetime.getMinutes()) + ":"
+ + (dt_datetime.getSeconds() < 10 ? '0' : '') + (dt_datetime.getSeconds())
+ );
+}
+
+// timestamp parsing function
+function cal_prs_tsmp2(str_datetime) {
+ // if no parameter specified return current timestamp
+ if (!str_datetime)
+ return (new Date());
+
+ // if positive integer treat as milliseconds from epoch
+ if (RE_NUM.exec(str_datetime))
+ return new Date(str_datetime);
+
+ // else treat as date in string format
+ var arr_datetime = str_datetime.split(' ');
+ return this.prs_time(arr_datetime[1], this.prs_date(arr_datetime[0]));
+}
+
+// date parsing function
+function cal_prs_date2(str_date) {
+
+ var arr_date = str_date.split('/');
+
+ if (arr_date.length != 3) return alert("Invalid date format: '" + str_date + "'.\nFormat accepted is dd-mm-yyyy.");
+ if (!arr_date[1]) return alert("Invalid date format: '" + str_date + "'.\nNo day of month value can be found.");
+ if (!RE_NUM.exec(arr_date[1])) return alert("Invalid day of month value: '" + arr_date[1] + "'.\nAllowed values are unsigned integers.");
+ if (!arr_date[0]) return alert("Invalid date format: '" + str_date + "'.\nNo month value can be found.");
+ if (!RE_NUM.exec(arr_date[0])) return alert("Invalid month value: '" + arr_date[0] + "'.\nAllowed values are unsigned integers.");
+ if (!arr_date[2]) return alert("Invalid date format: '" + str_date + "'.\nNo year value can be found.");
+ if (!RE_NUM.exec(arr_date[2])) return alert("Invalid year value: '" + arr_date[2] + "'.\nAllowed values are unsigned integers.");
+
+ var dt_date = new Date();
+ dt_date.setDate(1);
+
+ if (arr_date[0] < 1 || arr_date[0] > 12) return alert("Invalid month value: '" + arr_date[0] + "'.\nAllowed range is 01-12.");
+ dt_date.setMonth(arr_date[0] - 1);
+
+ if (arr_date[2] < 100) arr_date[2] = Number(arr_date[2]) + (arr_date[2] < NUM_CENTYEAR ? 2000 : 1900);
+ dt_date.setFullYear(arr_date[2]);
+
+ var dt_numdays = new Date(arr_date[2], arr_date[0], 0);
+ dt_date.setDate(arr_date[1]);
+ if (dt_date.getMonth() != (arr_date[0] - 1)) return alert("Invalid day of month value: '" + arr_date[1] + "'.\nAllowed range is 01-" + dt_numdays.getDate() + ".");
+
+ return (dt_date)
+}
+
+// time parsing function
+function cal_prs_time2(str_time, dt_date) {
+
+ if (!dt_date) return null;
+ var arr_time = String(str_time ? str_time : '').split(':');
+
+ if (!arr_time[0]) dt_date.setHours(0);
+ else if (RE_NUM.exec(arr_time[0]))
+ if (arr_time[0] < 24) dt_date.setHours(arr_time[0]);
+ else return cal_error("Invalid hours value: '" + arr_time[0] + "'.\nAllowed range is 00-23.");
+ else return cal_error("Invalid hours value: '" + arr_time[0] + "'.\nAllowed values are unsigned integers.");
+
+ if (!arr_time[1]) dt_date.setMinutes(0);
+ else if (RE_NUM.exec(arr_time[1]))
+ if (arr_time[1] < 60) dt_date.setMinutes(arr_time[1]);
+ else return cal_error("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed range is 00-59.");
+ else return cal_error("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed values are unsigned integers.");
+
+ if (!arr_time[2]) dt_date.setSeconds(0);
+ else if (RE_NUM.exec(arr_time[2]))
+ if (arr_time[2] < 60) dt_date.setSeconds(arr_time[2]);
+ else return cal_error("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed range is 00-59.");
+ else return cal_error("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed values are unsigned integers.");
+
+ dt_date.setMilliseconds(0);
+ return dt_date;
+}
+
+function cal_error(str_message) {
+ alert(str_message);
+ return null;
+}
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/src/db.config
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/src/db.config?rev=1341732&view=auto
==============================================================================
--- incubator/airavata/sandbox/workflow-monitoring-util/web/src/db.config (added)
+++ incubator/airavata/sandbox/workflow-monitoring-util/web/src/db.config Wed May 23 02:29:03 2012
@@ -0,0 +1,6 @@
+#database connection string
+
+##mySQL
+jdbcDriver=com.mysql.jdbc.Driver
+
+#jdbcUrl=jdbc:mysql://localhost:3306/wsnt?user=wsnt2&password=PASSWORD
\ No newline at end of file
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/QueryManager.java
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/QueryManager.java?rev=1341732&view=auto
==============================================================================
--- incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/QueryManager.java (added)
+++ incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/QueryManager.java Wed May 23 02:29:03 2012
@@ -0,0 +1,271 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.tools.workflow.monitoring;
+
+import org.apache.airavata.tools.workflow.monitoring.db.DBConstants;
+import org.apache.airavata.tools.workflow.monitoring.db.JdbcStorage;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class QueryManager {
+ private static JdbcStorage database = new JdbcStorage(Server.DB_CONFIG_NAME, true);
+
+ private Connection connection;
+ private PreparedStatement preparedStatement;
+ private ResultSet resultSet;
+
+ public QueryManager() {
+ }
+
+ public void close() throws WorkflowMonitoringException {
+ try {
+ if (resultSet != null) {
+ resultSet.close();
+ }
+ if (preparedStatement != null) {
+ preparedStatement.close();
+ }
+ if (connection != null) {
+ database.closeConnection(connection);
+ }
+ } catch (SQLException e) {
+ throw new WorkflowMonitoringException(e);
+ }
+ }
+
+ public ResultSet getDataRelatesToWorkflowId(String workflowId) throws WorkflowMonitoringException {
+
+ try {
+
+ connection = database.connect();
+ preparedStatement = connection.prepareStatement("SELECT * FROM " + DBConstants.T_FAULTS_NAME + " WHERE "
+ + DBConstants.T_FAULTS_WORKFLOW_ID + " = '" + workflowId + "'");
+ resultSet = preparedStatement.executeQuery();
+
+ return resultSet;
+ } catch (SQLException e) {
+ throw new WorkflowMonitoringException(e);
+ }
+
+ }
+
+ public ResultSet getWorkflowsWithinTimeRange(long startDate, long endDate) throws WorkflowMonitoringException {
+
+ // do a bit of validation here
+ if (startDate < 0) {
+ return null;
+ }
+ try {
+
+ String sqlString = getSQLForWorkflowInformationRetrieval(startDate, endDate);
+
+ connection = database.connect();
+ preparedStatement = connection.prepareStatement(sqlString);
+ resultSet = preparedStatement.executeQuery();
+
+ return resultSet;
+
+ } catch (SQLException e) {
+ throw new WorkflowMonitoringException(e);
+ }
+
+ }
+
+ public ResultSet getWorkflowsOfUser(String username) throws WorkflowMonitoringException {
+
+ // do a bit of validation here
+ if (username != null || "".equals(username)) {
+ return null;
+ }
+
+ try {
+
+ String sqlString = getSQLForWorkflowInformationRetrieval(username);
+
+ System.out.println("sqlString = " + sqlString);
+
+ connection = database.connect();
+ preparedStatement = connection.prepareStatement(sqlString);
+ resultSet = preparedStatement.executeQuery();
+
+ return resultSet;
+
+ } catch (SQLException e) {
+ throw new WorkflowMonitoringException(e);
+ }
+
+ }
+
+ /**
+ * This will process the input dates and provide with an SQL to retrieve workflow data from the database
+ * <p/>
+ * Note : This method assumes the inputs are validated by the caller before passing them here.
+ *
+ * @param startDate
+ * @param endDate
+ * @return
+ */
+ private String getSQLForWorkflowInformationRetrieval(long startDate, long endDate) {
+
+ String sql = "SELECT * FROM " + DBConstants.T_SUMMARY_NAME + " WHERE " + DBConstants.T_SUMMARY_START_TIME
+ + " > " + startDate;
+
+ if (endDate > 0) {
+ sql += " AND " + DBConstants.T_SUMMARY_START_TIME + " < " + endDate;
+ }
+ return sql;
+ }
+
+ private String getSQLForWorkflowInformationRetrieval(String username) {
+ return "SELECT * FROM " + DBConstants.T_SUMMARY_NAME + " WHERE " + DBConstants.T_SUMMARY_USERNAME + " LIKE \"%"
+ + username + "%\"";
+
+ }
+
+ /**
+ * This will retrieve summary information for all the workflow that had started within the given time range. If no
+ * end time is given, the current time is assumed.
+ *
+ * @param startDate
+ * @param endDate
+ * @return
+ */
+ public ResultSet getSummaryInformation(long startDate, long endDate) {
+
+ // do a bit of validation here
+ if (startDate < 0) {
+ return null;
+ }
+ try {
+
+ String sql = "SELECT count(*) as total, " + DBConstants.T_SUMMARY_STATUS + " FROM "
+ + DBConstants.T_SUMMARY_NAME + " WHERE " + DBConstants.T_SUMMARY_START_TIME + " > " + startDate;
+
+ if (endDate > 0) {
+ sql += " AND " + DBConstants.T_SUMMARY_START_TIME + " < " + endDate;
+ }
+
+ sql += " GROUP BY " + DBConstants.T_SUMMARY_STATUS;
+
+ connection = database.connect();
+ preparedStatement = connection.prepareStatement(sql);
+ resultSet = preparedStatement.executeQuery();
+
+ return resultSet;
+
+ } catch (SQLException e) {
+ throw new WorkflowMonitoringException(e);
+ }
+ }
+
+ public ResultSet getSummaryInformationForTemplates(long startDate, long endDate) {
+
+ // do a bit of validation here
+ if (startDate < 0) {
+ return null;
+ }
+
+ try {
+
+ String sql = "SELECT count(*) as total, " + DBConstants.T_SUMMARY_STATUS + ", "
+ + DBConstants.T_SUMMARY_TEMPLATE_ID + " FROM " + DBConstants.T_SUMMARY_NAME + " WHERE "
+ + DBConstants.T_SUMMARY_START_TIME + " > " + startDate;
+
+ if (endDate > 0) {
+ sql += " AND " + DBConstants.T_SUMMARY_START_TIME + " < " + endDate;
+ }
+
+ sql += " GROUP BY " + DBConstants.T_SUMMARY_TEMPLATE_ID + ", " + DBConstants.T_SUMMARY_STATUS;
+
+ connection = database.connect();
+ preparedStatement = connection.prepareStatement(sql);
+ resultSet = preparedStatement.executeQuery();
+
+ return resultSet;
+ } catch (SQLException e) {
+ throw new WorkflowMonitoringException(e);
+ }
+ }
+
+ /**
+ * There can be workflows successful now, but those might be failed earlier and recovered. We need to find why those
+ * failed earlier to diagnose errors in the system. This will retrieve all the workflows with the current status set
+ * to SUCCESSFUL but has faults registered in faults table.
+ *
+ * @param startDate
+ * @param endDate
+ * @return
+ */
+ public ResultSet getPreviouslyFailedSuccessfulInstances(long startDate, long endDate) {
+ String sql = "SELECT summary." + DBConstants.T_SUMMARY_WORKFLOW_ID + " FROM " + DBConstants.T_SUMMARY_NAME
+ + " summary, " + DBConstants.T_FAULTS_NAME + " faults " + " WHERE " + DBConstants.T_SUMMARY_START_TIME
+ + " > " + startDate + " AND summary." + DBConstants.T_SUMMARY_WORKFLOW_ID + "=faults."
+ + DBConstants.T_FAULTS_WORKFLOW_ID + " AND summary." + DBConstants.T_SUMMARY_STATUS + "='SUCCESSFUL' ";
+
+ if (endDate > 0) {
+ sql += " AND " + DBConstants.T_SUMMARY_START_TIME + " < " + endDate;
+ }
+
+ try {
+
+ connection = database.connect();
+ preparedStatement = connection.prepareStatement(sql);
+ resultSet = preparedStatement.executeQuery();
+
+ return resultSet;
+
+ } catch (SQLException e) {
+ throw new WorkflowMonitoringException(e);
+ }
+
+ }
+
+ /**
+ * There can be workflows successful now, but those might be failed earlier and recovered. We need to find why those
+ * failed earlier to diagnose errors in the system. This will retrieve all the workflows with the current status set
+ * to SUCCESSFUL but has faults registered in faults table.
+ *
+ * @param startDate
+ * @param endDate
+ * @return
+ */
+ public ResultSet getPreviouslyFailedSuccessfulInstances(String username) {
+ String sql = "SELECT summary." + DBConstants.T_SUMMARY_WORKFLOW_ID + " FROM " + DBConstants.T_SUMMARY_NAME
+ + " summary, " + DBConstants.T_FAULTS_NAME + " faults " + " WHERE " + DBConstants.T_SUMMARY_USERNAME
+ + " = '" + username + "' " + " AND summary." + DBConstants.T_SUMMARY_WORKFLOW_ID + "=faults."
+ + DBConstants.T_FAULTS_WORKFLOW_ID + " AND summary." + DBConstants.T_SUMMARY_STATUS + "='SUCCESSFUL' ";
+ try {
+
+ connection = database.connect();
+ preparedStatement = connection.prepareStatement(sql);
+ resultSet = preparedStatement.executeQuery();
+
+ return resultSet;
+
+ } catch (SQLException e) {
+ throw new WorkflowMonitoringException(e);
+ }
+
+ }
+}
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/bean/TemplateInfoBean.java
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/bean/TemplateInfoBean.java?rev=1341732&view=auto
==============================================================================
--- incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/bean/TemplateInfoBean.java (added)
+++ incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/bean/TemplateInfoBean.java Wed May 23 02:29:03 2012
@@ -0,0 +1,67 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.tools.workflow.monitoring.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TemplateInfoBean {
+
+ private String templateID;
+
+ // I will store the status and the status count in two different array lists. The count for status[i] will be in
+ // statusCount[i].
+ // To optimize the number of array list usages, I defined a an initial capacity as 3 assuming most of the time
+ // each template may exist in one of the three status.
+
+ private int AVERAGE_STATUS_SIZE = 3;
+
+ private long totalCount = 0;
+
+ private List<String> status = new ArrayList<String>(3);
+ private List<Long> statusCount = new ArrayList<Long>(AVERAGE_STATUS_SIZE);
+
+ public TemplateInfoBean(String templateID) {
+ this.templateID = templateID;
+ }
+
+ public void addStatusInfo(String status, long statusCount) {
+ this.status.add(status);
+ this.statusCount.add(new Long(statusCount));
+ totalCount += statusCount;
+ }
+
+ public String getTemplateID() {
+ return templateID;
+ }
+
+ public List<String> getAllStatusNames() {
+ return status;
+ }
+
+ public List<Long> getAllStatusCounts() {
+ return statusCount;
+ }
+
+ public long getTotalCount() {
+ return totalCount;
+ }
+}
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/bean/WorkflowInfo.java
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/bean/WorkflowInfo.java?rev=1341732&view=auto
==============================================================================
--- incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/bean/WorkflowInfo.java (added)
+++ incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/bean/WorkflowInfo.java Wed May 23 02:29:03 2012
@@ -0,0 +1,100 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.tools.workflow.monitoring.bean;
+
+import java.util.Date;
+
+public class WorkflowInfo implements Comparable {
+ private String workflowId;
+ private String templateId;
+ private String username = "";
+ private String status;
+ private String startTime;
+ private String endTime;
+ private boolean faultsAvailable;
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getWorkflowId() {
+ return workflowId;
+ }
+
+ public void setWorkflowId(String workflowId) {
+ this.workflowId = workflowId;
+ }
+
+ public String getTemplateId() {
+ return templateId;
+ }
+
+ public void setTemplateId(String templateId) {
+ this.templateId = templateId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(String startTime) {
+ this.startTime = startTime;
+ }
+
+ public String getEndTime() {
+ return endTime;
+ }
+
+ public void setEndTime(String endTime) {
+ this.endTime = endTime;
+ }
+
+ public boolean isFaultsAvailable() {
+ return faultsAvailable;
+ }
+
+ public void setFaultsAvailable(boolean faultsAvailable) {
+ this.faultsAvailable = faultsAvailable;
+ }
+
+ public int compareTo(Object o) {
+ if (o instanceof WorkflowInfo) {
+ WorkflowInfo workflowInfo = (WorkflowInfo) o;
+ return new Date(startTime).before(new Date(workflowInfo.getStartTime())) ? -1 : 1;
+ }
+ // If this < o, return a negative value
+ // If this = o, return 0
+ // If this > o, return a positive value
+ return 0;
+ }
+}
Added: incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/util/Util.java
URL: http://svn.apache.org/viewvc/incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/util/Util.java?rev=1341732&view=auto
==============================================================================
--- incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/util/Util.java (added)
+++ incubator/airavata/sandbox/workflow-monitoring-util/web/src/org/apache/airavata/tools/workflow/monitoring/util/Util.java Wed May 23 02:29:03 2012
@@ -0,0 +1,95 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.airavata.tools.workflow.monitoring.util;
+
+import org.apache.airavata.tools.workflow.monitoring.WorkflowMonitoringException;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+public class Util {
+ public static final String DATE_FORMAT = "mm/dd/yyyy hh:mm:ss";
+
+ /**
+ * This will convert a give date time string in to the its equivalent time in milliseconds. This could have been
+ * done easily using DateFormat class in java, but for some reason it was not working as expected.
+ *
+ * @param timeString
+ * - the format must be mm/dd/yyyy hh:mm:ss.
+ * @return
+ */
+ public static long getTime(String timeString) throws WorkflowMonitoringException {
+ String[] dateAndTime = timeString.split(" ");
+
+ if (dateAndTime.length == 2) {
+ String[] dateComponents = dateAndTime[0].split("/");
+ String[] timeComponents = dateAndTime[1].split(":");
+
+ if (dateComponents.length == 3 && timeComponents.length == 3) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(Integer.parseInt(dateComponents[2]), Integer.parseInt(dateComponents[0]) - 1,
+ Integer.parseInt(dateComponents[1]), Integer.parseInt(timeComponents[0]),
+ Integer.parseInt(timeComponents[1]), Integer.parseInt(timeComponents[2]));
+
+ return calendar.getTime().getTime();
+ } else {
+ throw new WorkflowMonitoringException("Date time string should be of the format " + DATE_FORMAT);
+ }
+ } else {
+ throw new WorkflowMonitoringException("Date time string should be of the format " + DATE_FORMAT);
+ }
+
+ }
+
+ /**
+ * This method will construct a formatted date and time string from a give date. The date is given as a string which
+ * represents the time in milliseconds.
+ *
+ * @param time
+ * - this is the string presentation of the time in milliseconds
+ * @return
+ */
+ public static String getFormattedDateFromLongValue(String time) {
+ Date date = new Date(Long.parseLong(time));
+ Calendar calendar = new GregorianCalendar();
+ calendar.setTime(date);
+
+ return (calendar.get(Calendar.MONTH) + 1) + "/" + calendar.get(Calendar.DATE) + "/"
+ + calendar.get(Calendar.YEAR) + " " + calendar.get(Calendar.HOUR_OF_DAY) + ":"
+ + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND);
+ }
+
+ public static String extractUsername(String userDN) {
+ int lastIndex;
+ if (userDN.lastIndexOf("/") == userDN.indexOf("/CN")) {
+ lastIndex = userDN.length();
+ } else {
+ lastIndex = userDN.lastIndexOf("/");
+ }
+
+ return userDN.substring(userDN.indexOf("/CN=") + 4, lastIndex);
+ }
+
+ public static String extractShortTemplateId(String templateId) {
+ return templateId.substring(templateId.lastIndexOf("/") + 1);
+ }
+}