geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecr...@apache.org
Subject svn commit: r596811 [1/2] - in /geronimo/sandbox/monitoring/client/client-war/src/main: java/org/apache/geronimo/plugins/monitoring/client/ java/org/apache/geronimo/plugins/monitoring/client/util/ webapp/WEB-INF/view/
Date Tue, 20 Nov 2007 20:17:44 GMT
Author: ecraig
Date: Tue Nov 20 12:17:43 2007
New Revision: 596811

URL: http://svn.apache.org/viewvc?rev=596811&view=rev
Log:
Updated view add/edit pages to utilize checkboxes
Added graph edit/delete functionality
Added significant error checking on graph add/edit
Added ability to create graphs through both selecting data series as 
well as from selecting nothing to start with
Added back-end handling of various math options from graph add/edit


Added:
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp
Modified:
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/StatsGraph.java
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddView.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditView.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringPage.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java?rev=596811&r1=596810&r2=596811&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java Tue Nov 20 12:17:43 2007
@@ -43,263 +43,362 @@
 
     }
 
-    public StatsGraph buildOneDB(int snapcount, int graph_id) throws Exception
+    public StatsGraph buildOneDB(int snapcount, int graph_id)
     {
         PreparedStatement pStmt = null;
         ResultSet rsServer = null;
-
-        pStmt = Con
-                .prepareStatement("SELECT * from graphs WHERE enabled=1 AND graph_id="
-                        + graph_id);
-        ResultSet rs = pStmt.executeQuery();
-
-        if (rs.next())
+        try
         {
             pStmt = Con
-                    .prepareStatement("SELECT * from servers WHERE enabled=1 AND server_id="
-                            + rs.getInt("server_id"));
-            rsServer = pStmt.executeQuery();
+                    .prepareStatement("SELECT * from graphs WHERE enabled=1 AND graph_id="
+                            + graph_id);
+            ResultSet rs = pStmt.executeQuery();
 
-            if (rsServer.next())
+            if (rs.next())
             {
-                ServerIP = rsServer.getString("ip");
-
-                MRCConnection = new MRCConnector(ServerIP, rsServer
-                        .getString("username"), rsServer.getString("password"));
-                // DataNameList = MRCConnection.getDataNameList();
-
-            }
-            else
-                return null;
+                pStmt = Con
+                        .prepareStatement("SELECT * from servers WHERE enabled=1 AND server_id="
+                                + rs.getInt("server_id"));
+                rsServer = pStmt.executeQuery();
 
-            String mBeanName = rs.getString("mbean");
-            String dataName = rs.getString("dataname1");
-            String graphName = rs.getString("name");
-            timeFrame = rs.getInt("timeframe");
+                if (rsServer.next())
+                {
+                    ServerIP = rsServer.getString("ip");
 
-            snapCount = snapcount;
-            HashMap<String, Vector<Object>> DataList = new HashMap<String, Vector<Object>>();
+                    MRCConnection = new MRCConnector(ServerIP, rsServer
+                            .getString("username"), rsServer
+                            .getString("password"));
+                    // DataNameList = MRCConnection.getDataNameList();
 
-            DataList.put(graphName, new Vector<Object>());
+                }
+                else
+                    return null;
 
-            if ((timeFrame / 1440 == 30))
-                snapCount = 17;
-            else
-            {
-                if (((timeFrame / 1440) <= 7) && ((timeFrame / 60) > 24)
-                        && snapCount >= 14)
+                String mBeanName = rs.getString("mbean");
+                String dataName1 = rs.getString("dataname1");
+                String dataName2 = rs.getString("dataname2");
+                String graphName1 = rs.getString("dataname1");
+                String graphName2 = rs.getString("dataname2");
+                timeFrame = rs.getInt("timeframe");
+
+                snapCount = snapcount;
+                HashMap<String, Vector<Object>> DataList = new HashMap<String, Vector<Object>>();
+
+                DataList.put(graphName1, new Vector<Object>());
+                if (!dataName2.equals("time") && (dataName2 != null)
+                        && !dataName2.equals("null") && !dataName2.equals(""))
                 {
-                    if ((timeFrame / 1440) == 7)
-                        snapCount = 16;
-                    else
-                        snapCount = 12;
+                    DataList.put(graphName2, new Vector<Object>());
+                }
+                if ((timeFrame / 1440 == 30))
+                    snapCount = 17;
+                else
+                {
+                    if (((timeFrame / 1440) <= 7) && ((timeFrame / 60) > 24)
+                            && snapCount >= 14)
+                    {
+                        if ((timeFrame / 1440) == 7)
+                            snapCount = 16;
+                        else
+                            snapCount = 12;
+                    }
                 }
-            }
 
-            Vector<Object> snapshot_date = new Vector<Object>();
-            Vector<Object> snapshot_time = new Vector<Object>();
+                Vector<Object> snapshot_date = new Vector<Object>();
+                Vector<Object> snapshot_time = new Vector<Object>();
 
-            Vector<Object> PrettyTime = new Vector<Object>();
+                Vector<Object> PrettyTime = new Vector<Object>();
 
-            String prettyTimeFrame = new String();
-            DecimalFormat fmt = new DecimalFormat("0.##");
-            if (timeFrame / 60 > 24)
-                prettyTimeFrame = fmt.format((float) (timeFrame / 1440))
-                        + " day";
-            else
-            {
-                if (timeFrame > 60)
-                    prettyTimeFrame = fmt.format((float) timeFrame / 60)
-                            + " hour";
+                String prettyTimeFrame = new String();
+                DecimalFormat fmt = new DecimalFormat("0.##");
+                if (timeFrame / 60 > 24)
+                    prettyTimeFrame = fmt.format((float) (timeFrame / 1440))
+                            + " day";
                 else
-                    prettyTimeFrame = fmt.format(timeFrame) + " minute";
-            }
-
-            try
-            {
-                int skipCount = (int) ((timeFrame / (MRCConnector
-                        .getSnapshotDuration() / 60000)))
-                        / (snapCount - 2);
-                ArrayList<HashMap<String, HashMap<String, Object>>> snapshotList = MRCConnection
-                        .getSnapshots(snapCount, skipCount);
-                // Check if snapshotList is empty
+                {
+                    if (timeFrame > 60)
+                        prettyTimeFrame = fmt.format((float) timeFrame / 60)
+                                + " hour";
+                    else
+                        prettyTimeFrame = fmt.format(timeFrame) + " minute";
+                }
 
-                if (snapshotList.size() == 0)
+                try
                 {
-                    HashMap<String, HashMap<String, Object>> tempMap = new HashMap<String, HashMap<String, Object>>();
-                    HashMap<String, Object> subMap = new HashMap<String, Object>();
-                    subMap.put(dataName, new Long(0));
-                    tempMap.put(mBeanName, new HashMap<String, Object>(subMap));
-                    subMap.clear();
-                    subMap.put("snapshot_time", System.currentTimeMillis());
-                    Format formatter = null;
-                    formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                    Date date = new Date((Long) subMap.get("snapshot_time"));
-                    subMap.put("snapshot_date", formatter.format(date));
-                    tempMap.put("times", new HashMap<String, Object>(subMap));
-
-                    snapshotList
-                            .add(new HashMap<String, HashMap<String, Object>>(
-                                    tempMap));
-                    /*
-                     * If there are not enough snapshots available to fill the requested
-                     * number, insert some with values of 0 and the proper times.
-                     */
-                    while (snapshotList.size() < snapCount)
-                    {
-                        // Temporary, always is first element (oldest)
-                        HashMap<String, HashMap<String, Object>> mapTimeFix = snapshotList
-                                .get(0);
-
-                        // Temporary map, used to generate blank data to be
-                        // added to
-                        // the
-                        // list at position 0
-                        HashMap<String, HashMap<String, Object>> tempMap2 = new HashMap<String, HashMap<String, Object>>();
-
-                        // Temporary submap, used to store 0 elements to be
-                        // added to
-                        // the
-                        // tempmap
-                        HashMap<String, Object> subMap2 = new HashMap<String, Object>();
-
-                        // Calculate appropriate time, add it to the submap,
-                        // then
-                        // add
-                        // that to the tempMap
-                        subMap2.put("snapshot_time", ((Long) mapTimeFix.get(
-                                "times").get("snapshot_time") - (MRCConnector
-                                .getSnapshotDuration() * skipCount)));
-                        Format formatter2 = null;
-                        formatter2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                        Date date2 = new Date((Long) subMap2
-                                .get("snapshot_time"));
-                        subMap2.put("snapshot_date", formatter2.format(date2));
-
-                        // Add the submap back to the tempmap
-                        tempMap2.put("times", new HashMap<String, Object>(
-                                subMap2));
-
-                        // Clear out the subMap for use again
-                        subMap2.clear();
-
-                        // Run through the mbeans
-                        // Verify that it's not times
-                        // Run through the stats elements for the particular
-                        // mbean
-
-                        // Place faux data into the submap
-                        subMap2.put(dataName, new Long(0));
-
-                        // Add the submap to the tempmap, and clear it
-                        tempMap2.put(mBeanName, new HashMap<String, Object>(
-                                subMap2));
-
-                        snapshotList.add(0,
-                                new HashMap<String, HashMap<String, Object>>(
-                                        tempMap2));
-                    }
+                    int skipCount = (int) ((timeFrame / (MRCConnector
+                            .getSnapshotDuration() / 60000)))
+                            / (snapCount - 2);
+                    ArrayList<HashMap<String, HashMap<String, Object>>> snapshotList = MRCConnection
+                            .getSnapshots(snapCount, skipCount);
+                    // Check if snapshotList is empty
 
-                    /*
-                     * This is where we will be inserting data to fill 'gaps' in the
-                     * snapshots The initial for-loop will travel from the most recent
-                     * snapshot to the oldest, checking that the snapshot_time along the
-                     * way all align with what they should be
-                     */
-                    for (int i = snapshotList.size() - 1; i > 0; i--)
+                    if (snapshotList.size() == 0)
                     {
-                        if (i > 0)
+                        HashMap<String, HashMap<String, Object>> tempMap = new HashMap<String, HashMap<String, Object>>();
+                        HashMap<String, Object> subMap = new HashMap<String, Object>();
+                        subMap.put(dataName1, new Long(0));
+                        if (!dataName2.equals("time") && (dataName2 != null)
+                                && !dataName2.equals("null")
+                                && !dataName2.equals(""))
+                        {
+                            subMap.put(dataName2, new Long(0));
+                        }
+                        tempMap.put(mBeanName, new HashMap<String, Object>(
+                                subMap));
+                        subMap.clear();
+                        subMap.put("snapshot_time", System.currentTimeMillis());
+                        Format formatter = null;
+                        formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                        Date date = new Date((Long) subMap.get("snapshot_time"));
+                        subMap.put("snapshot_date", formatter.format(date));
+                        tempMap.put("times",
+                                new HashMap<String, Object>(subMap));
+
+                        snapshotList
+                                .add(new HashMap<String, HashMap<String, Object>>(
+                                        tempMap));
+                        /*
+                         * If there are not enough snapshots available to fill the requested
+                         * number, insert some with values of 0 and the proper times.
+                         */
+                        while (snapshotList.size() < snapCount)
                         {
+                            // Temporary, always is first element (oldest)
                             HashMap<String, HashMap<String, Object>> mapTimeFix = snapshotList
-                                    .get(i);
-                            HashMap<String, HashMap<String, Object>> mapTimeFix2 = snapshotList
-                                    .get(i - 1);
-                            // here is where we will in missing data
-                            while (((((Long) mapTimeFix.get("times").get(
-                                    "snapshot_time") / 1000) / 60)
-                                    - (((Long) mapTimeFix2.get("times").get(
-                                            "snapshot_time") / 1000) / 60) > (((MRCConnector
-                                    .getSnapshotDuration() / 1000) / 60) * skipCount)))
+                                    .get(0);
+
+                            // Temporary map, used to generate blank data to be
+                            // added to
+                            // the
+                            // list at position 0
+                            HashMap<String, HashMap<String, Object>> tempMap2 = new HashMap<String, HashMap<String, Object>>();
+
+                            // Temporary submap, used to store 0 elements to be
+                            // added to
+                            // the
+                            // tempmap
+                            HashMap<String, Object> subMap2 = new HashMap<String, Object>();
+
+                            // Calculate appropriate time, add it to the submap,
+                            // then
+                            // add
+                            // that to the tempMap
+                            subMap2
+                                    .put(
+                                            "snapshot_time",
+                                            ((Long) mapTimeFix.get("times")
+                                                    .get("snapshot_time") - (MRCConnector
+                                                    .getSnapshotDuration() * skipCount)));
+                            Format formatter2 = null;
+                            formatter2 = new SimpleDateFormat(
+                                    "yyyy-MM-dd HH:mm:ss");
+                            Date date2 = new Date((Long) subMap2
+                                    .get("snapshot_time"));
+                            subMap2.put("snapshot_date", formatter2
+                                    .format(date2));
+
+                            // Add the submap back to the tempmap
+                            tempMap2.put("times", new HashMap<String, Object>(
+                                    subMap2));
+
+                            // Clear out the subMap for use again
+                            subMap2.clear();
+
+                            // Run through the mbeans
+                            // Verify that it's not times
+                            // Run through the stats elements for the particular
+                            // mbean
+
+                            // Place faux data into the submap
+                            subMap2.put(dataName1, new Long(0));
+                            if (!dataName2.equals("time")
+                                    && (dataName2 != null)
+                                    && !dataName2.equals("null")
+                                    && !dataName2.equals(""))
                             {
-                                HashMap<String, HashMap<String, Object>> tempMap2 = new HashMap<String, HashMap<String, Object>>();
-                                HashMap<String, Object> subMap2 = new HashMap<String, Object>();
+                                subMap2.put(dataName2, new Long(0));
+                            }
+                            // Add the submap to the tempmap, and clear it
+                            tempMap2.put(mBeanName,
+                                    new HashMap<String, Object>(subMap2));
+
+                            snapshotList
+                                    .add(
+                                            0,
+                                            new HashMap<String, HashMap<String, Object>>(
+                                                    tempMap2));
+                        }
 
-                                // Verify that it's not times
-                                // Run through the stats elements for the
-                                // particular
-
-                                // Place faux data into the submap
-                                subMap2.put(dataName, new Long(0));
-
-                                // Add the submap to the tempmap, and clear it
-                                tempMap2.put(mBeanName,
-                                        new HashMap<String, Object>(subMap2));
-                                subMap2.clear();
-
-                                subMap2
-                                        .put(
-                                                "snapshot_time",
-                                                new Long(
-                                                        (Long) mapTimeFix
-                                                                .get("times")
-                                                                .get(
-                                                                        "snapshot_time")
-                                                                - (MRCConnector
-                                                                        .getSnapshotDuration() * skipCount)));
-                                Format formatter2 = null;
-                                formatter2 = new SimpleDateFormat(
-                                        "yyyy-MM-dd HH:mm:ss");
-                                Date date2 = new Date((Long) subMap2
-                                        .get("snapshot_time"));
-                                subMap2.put("snapshot_date", formatter2
-                                        .format(date2));
-                                tempMap2.put("times",
-                                        new HashMap<String, Object>(subMap2));
-                                subMap2.clear();
-                                snapshotList
-                                        .add(
-                                                i,
-                                                new HashMap<String, HashMap<String, Object>>(
-                                                        tempMap2));
-                                snapshotList.remove(0);
-                                mapTimeFix = tempMap2;
-                                mapTimeFix2 = snapshotList.get(i - 1);
+                        /*
+                         * This is where we will be inserting data to fill 'gaps' in the
+                         * snapshots The initial for-loop will travel from the most recent
+                         * snapshot to the oldest, checking that the snapshot_time along the
+                         * way all align with what they should be
+                         */
+                        for (int i = snapshotList.size() - 1; i > 0; i--)
+                        {
+                            if (i > 0)
+                            {
+                                HashMap<String, HashMap<String, Object>> mapTimeFix = snapshotList
+                                        .get(i);
+                                HashMap<String, HashMap<String, Object>> mapTimeFix2 = snapshotList
+                                        .get(i - 1);
+                                // here is where we will in missing data
+                                while (((((Long) mapTimeFix.get("times").get(
+                                        "snapshot_time") / 1000) / 60)
+                                        - (((Long) mapTimeFix2.get("times")
+                                                .get("snapshot_time") / 1000) / 60) > (((MRCConnector
+                                        .getSnapshotDuration() / 1000) / 60) * skipCount)))
+                                {
+                                    HashMap<String, HashMap<String, Object>> tempMap2 = new HashMap<String, HashMap<String, Object>>();
+                                    HashMap<String, Object> subMap2 = new HashMap<String, Object>();
+
+                                    // Verify that it's not times
+                                    // Run through the stats elements for the
+                                    // particular
+
+                                    // Place faux data into the submap
+                                    subMap2.put(dataName1, new Long(0));
+                                    if (!dataName2.equals("time")
+                                            && (dataName2 != null)
+                                            && !dataName2.equals("null")
+                                            && !dataName2.equals(""))
+                                    {
+                                        subMap2.put(dataName2, new Long(0));
+                                    }
+
+                                    // Add the submap to the tempmap, and clear
+                                    // it
+                                    tempMap2
+                                            .put(
+                                                    mBeanName,
+                                                    new HashMap<String, Object>(
+                                                            subMap2));
+                                    subMap2.clear();
+
+                                    subMap2
+                                            .put(
+                                                    "snapshot_time",
+                                                    new Long(
+                                                            (Long) mapTimeFix
+                                                                    .get(
+                                                                            "times")
+                                                                    .get(
+                                                                            "snapshot_time")
+                                                                    - (MRCConnector
+                                                                            .getSnapshotDuration() * skipCount)));
+                                    Format formatter2 = null;
+                                    formatter2 = new SimpleDateFormat(
+                                            "yyyy-MM-dd HH:mm:ss");
+                                    Date date2 = new Date((Long) subMap2
+                                            .get("snapshot_time"));
+                                    subMap2.put("snapshot_date", formatter2
+                                            .format(date2));
+                                    tempMap2
+                                            .put(
+                                                    "times",
+                                                    new HashMap<String, Object>(
+                                                            subMap2));
+                                    subMap2.clear();
+                                    snapshotList
+                                            .add(
+                                                    i,
+                                                    new HashMap<String, HashMap<String, Object>>(
+                                                            tempMap2));
+                                    snapshotList.remove(0);
+                                    mapTimeFix = tempMap2;
+                                    mapTimeFix2 = snapshotList.get(i - 1);
+                                }
                             }
                         }
                     }
+
+                    for (int i = 0; i < snapshotList.size(); i++)
+                    {
+                        HashMap<String, HashMap<String, Object>> map = snapshotList
+                                .get(i);
+                        snapshot_date
+                                .add(map.get("times").get("snapshot_date"));
+                        snapshot_time
+                                .add(map.get("times").get("snapshot_time"));
+                        Vector<Object> vectorTemp = DataList.get(graphName1);
+                        vectorTemp.add(map.get(mBeanName).get(dataName1));
+                        DataList.put(graphName1, vectorTemp);
+                        if (!dataName2.equals("time") && (dataName2 != null)
+                                && !dataName2.equals("null")
+                                && !dataName2.equals(""))
+                        {
+                            Vector<Object> vectorTemp2 = DataList
+                                    .get(graphName2);
+                            vectorTemp2.add(map.get(mBeanName).get(dataName2));
+                            DataList.put(graphName2, vectorTemp2);
+                        }
+
+                        PrettyTime.add((Long) map.get("times").get(
+                                "snapshot_time") / 1000);
+                    }
+
                 }
 
-                for (int i = 0; i < snapshotList.size(); i++)
+                catch (Exception e)
                 {
-                    HashMap<String, HashMap<String, Object>> map = snapshotList
-                            .get(i);
-                    snapshot_date.add(map.get("times").get("snapshot_date"));
-                    snapshot_time.add(map.get("times").get("snapshot_time"));
-                    Vector<Object> vectorTemp = DataList.get(graphName);
-                    vectorTemp.add(map.get(mBeanName).get(dataName));
-                    DataList.put(graphName, vectorTemp);
-                    PrettyTime
-                            .add((Long) map.get("times").get("snapshot_time") / 1000);
+                    e.printStackTrace();
                 }
-
+                if (dataName2.equals("time"))
+                    return (new StatsGraph(graph_id, ServerIP + " - "
+                            + rs.getString("xlabel") + " - " + prettyTimeFrame,
+                            rs.getString("description"), "Time - "
+                                    + prettyTimeFrame, rs.getString("ylabel"),
+                            rs.getString("data1operation").charAt(0), DataList
+                                    .get(graphName1),
+                            rs.getString("operation"), rs.getString(
+                                    "data2operation").charAt(0), PrettyTime,
+                            snapshot_time, (int) (MRCConnector
+                                    .getSnapshotDuration() / 1000), timeFrame,
+                            rs.getString("color"),
+                            rs.getFloat("warninglevel1"), rs
+                                    .getFloat("warninglevel1")));
+                else if (!dataName2.equals("time") && (dataName2 != null)
+                        && !dataName2.equals("null") && !dataName2.equals(""))
+                    return (new StatsGraph(graph_id, ServerIP + " - "
+                            + rs.getString("xlabel") + " - " + prettyTimeFrame,
+                            rs.getString("description"), "Time - "
+                                    + prettyTimeFrame, rs.getString("ylabel"),
+                            rs.getString("data1operation").charAt(0), DataList
+                                    .get(graphName1),
+                            rs.getString("operation"), rs.getString(
+                                    "data2operation").charAt(0), DataList
+                                    .get(graphName2), snapshot_time,
+                            (int) (MRCConnector.getSnapshotDuration() / 1000),
+                            timeFrame, rs.getString("color"), rs
+                                    .getFloat("warninglevel1"), rs
+                                    .getFloat("warninglevel1")));
+                else if (dataName2 == null || dataName2.equals("null")
+                        || dataName2.equals(""))
+                {
+                    return (new StatsGraph(graph_id, ServerIP + " - "
+                            + rs.getString("xlabel") + " - " + prettyTimeFrame,
+                            rs.getString("description"), "Time - "
+                                    + prettyTimeFrame, rs.getString("ylabel"),
+                            rs.getString("data1operation").charAt(0), DataList
+                                    .get(graphName1),
+                            rs.getString("operation"), snapshot_time,
+                            (int) (MRCConnector.getSnapshotDuration() / 1000),
+                            timeFrame, rs.getString("color"), rs
+                                    .getFloat("warninglevel1"), rs
+                                    .getFloat("warninglevel1")));
+                }
+                else
+                    return (new StatsGraph());
             }
 
-            catch (Exception e)
-            {
-                e.printStackTrace();
-            }
-            return (new StatsGraph(graph_id, ServerIP + " - "
-                    + rs.getString("xlabel") + " - " + prettyTimeFrame, rs
-                    .getString("description"), "Time - " + prettyTimeFrame, rs
-                    .getString("ylabel"), rs.getString("data1operation")
-                    .charAt(0), DataList.get(graphName), rs
-                    .getString("operation"), rs.getString("data2operation")
-                    .charAt(0), PrettyTime, snapshot_time, (int) (MRCConnector
-                    .getSnapshotDuration() / 1000), timeFrame, rs
-                    .getString("color"), rs.getFloat("warninglevel1"), rs
-                    .getFloat("warninglevel1")));
+            else
+                return null;
         }
-        else
+        catch (Exception e)
+        {
+            // TODO: Catch stuff
             return null;
+        }
     }
 }

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java?rev=596811&r1=596810&r2=596811&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java Tue Nov 20 12:17:43 2007
@@ -49,6 +49,8 @@
 
     private static final String      ADDGRAPH_JSP       = "/WEB-INF/view/monitoringAddGraph.jsp";
 
+    private static final String      EDITGRAPH_JSP      = "/WEB-INF/view/monitoringEditGraph.jsp";
+
     private static final String      VIEWSERVER_JSP     = "/WEB-INF/view/monitoringViewServer.jsp";
 
     private static final String      EDITSERVER_JSP     = "/WEB-INF/view/monitoringEditServer.jsp";
@@ -75,6 +77,8 @@
 
     private PortletRequestDispatcher addGraph;
 
+    private PortletRequestDispatcher editGraph;
+
     private PortletRequestDispatcher viewServer;
 
     private PortletRequestDispatcher editServer;
@@ -122,16 +126,34 @@
         else if (action.equals("showAddGraph"))
         {
             String server_id = actionRequest.getParameter("server_id");
-            actionResponse.setRenderParameter("server_id", server_id);
+            if (server_id != null)
+                actionResponse.setRenderParameter("server_id", server_id);
+
             String mbean = actionRequest.getParameter("mbean");
-            actionResponse.setRenderParameter("mbean", mbean);
+            if (mbean != null)
+                actionResponse.setRenderParameter("mbean", mbean);
+
             String dataname = actionRequest.getParameter("dataname");
-            actionResponse.setRenderParameter("dataname", dataname);
+            if (dataname != null)
+                actionResponse.setRenderParameter("dataname", dataname);
         }
         else if (action.equals("saveAddGraph"))
         {
             addGraph(actionRequest, actionResponse);
         }
+        else if (action.equals("showEditGraph"))
+        {
+            String graph_id = actionRequest.getParameter("graph_id");
+            actionResponse.setRenderParameter("graph_id", graph_id);
+        }
+        else if (action.equals("saveEditGraph"))
+        {
+            updateGraph(actionRequest, actionResponse);
+        }
+        else if (action.equals("deleteGraph"))
+        {
+            deleteGraph(actionRequest, actionResponse);
+        }
         else if (action.equals("deleteView"))
         {
             deleteView(actionRequest, actionResponse);
@@ -619,6 +641,26 @@
             request.setAttribute("message", message);
             normalView.include(request, response);
         }
+        else if (action.equals("showEditGraph"))
+        {
+            String graph_id = request.getParameter("graph_id");
+            request.setAttribute("graph_id", graph_id);
+            editGraph.include(request, response);
+        }
+        else if (action.equals("saveEditGraph"))
+        {
+            String graph_id = request.getParameter("graph_id");
+            request.setAttribute("graph_id", graph_id);
+            String message = request.getParameter("message");
+            request.setAttribute("message", message);
+            editGraph.include(request, response);
+        }
+        else if (action.equals("deleteGraph"))
+        {
+            String message = request.getParameter("message");
+            request.setAttribute("message", message);
+            normalView.include(request, response);
+        }
         else if (action.equals("deleteView"))
         {
             String message = request.getParameter("message");
@@ -669,22 +711,27 @@
         String name = actionRequest.getParameter("name");
         String description = actionRequest.getParameter("description");
         String[] graphsArray = actionRequest.getParameterValues("graph_ids");
-        String graph_ids = "";
-        if (graphsArray != null)
-            for (int i = 0; i < graphsArray.length; i++)
-            {
-                graph_ids = graph_ids + graphsArray[i] + ",";
-            }
         try
         {
             PreparedStatement pStmt = con
                     .prepareStatement("UPDATE views SET name='" + name
                             + "', description='" + description
-                            + "', graph_ids='" + graph_ids + "', graph_count="
-                            + graphsArray.length
+                            + "', graph_count=" + graphsArray.length
                             + ", modified=CURRENT_TIMESTAMP WHERE view_id="
                             + view_id);
             pStmt.executeUpdate();
+            pStmt = con
+                    .prepareStatement("DELETE FROM views_graphs WHERE view_id="
+                            + view_id);
+            pStmt.executeUpdate();
+            if (graphsArray != null)
+                for (int i = 0; i < graphsArray.length; i++)
+                {
+                    pStmt = con
+                            .prepareStatement("INSERT INTO views_graphs VALUES("
+                                    + view_id + "," + graphsArray[i] + ")");
+                    pStmt.executeUpdate();
+                }
             con.close();
             actionResponse.setRenderParameter("message",
                     "<font color=\"green\"><strong><li>View " + name
@@ -709,25 +756,33 @@
         String name = actionRequest.getParameter("name");
         String description = actionRequest.getParameter("description");
         String[] graphsArray = actionRequest.getParameterValues("graph_ids");
-        String graph_ids = "";
-        if (graphsArray != null)
-            for (int i = 0; i < graphsArray.length; i++)
-            {
-                graph_ids = graph_ids + graphsArray[i] + ",";
-            }
         try
         {
             PreparedStatement pStmt = con
-                    .prepareStatement("INSERT INTO views (name, description, graph_count, graph_ids, modified, added) VALUES ('"
+                    .prepareStatement("INSERT INTO views (name, description, graph_count, modified, added) VALUES ('"
                             + name
                             + "','"
                             + description
                             + "',"
                             + graphsArray.length
-                            + ",'"
-                            + graph_ids
-                            + "',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)");
+                            + ",CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)");
             pStmt.executeUpdate();
+            pStmt = con
+                    .prepareStatement("select view_id from views ORDER BY view_id DESC");
+            ResultSet rs = pStmt.executeQuery();
+            if (rs.next())
+            {
+                Integer view_id = rs.getInt("view_id");
+
+                if (graphsArray != null)
+                    for (int i = 0; i < graphsArray.length; i++)
+                    {
+                        pStmt = con
+                                .prepareStatement("INSERT INTO views_graphs VALUES("
+                                        + view_id + "," + graphsArray[i] + ")");
+                        pStmt.executeUpdate();
+                    }
+            }
             con.close();
             actionResponse.setRenderParameter("message",
                     "<font color=\"green\"><strong><li>View " + name
@@ -890,6 +945,10 @@
                     .prepareStatement("DELETE FROM views WHERE view_id="
                             + view_id);
             pStmt.executeUpdate();
+            pStmt = con
+                    .prepareStatement("DELETE FROM views_graphs WHERE view_id="
+                            + view_id);
+            pStmt.executeUpdate();
             con.close();
             actionResponse
                     .setRenderParameter("message",
@@ -918,7 +977,17 @@
         String ylabel = actionRequest.getParameter("ylabel");
         String timeframe = actionRequest.getParameter("timeframe");
         String mbean = actionRequest.getParameter("mbean");
-        String dataname = actionRequest.getParameter("dataname");
+        String dataname1 = actionRequest.getParameter("dataname1");
+        String data1operation = actionRequest.getParameter("data1operation");
+        String operation = actionRequest.getParameter("operation");
+        if (operation.equals("other"))
+        {
+            operation = actionRequest.getParameter("othermath");
+        }
+        String dataname2 = actionRequest.getParameter("dataname2");
+        String data2operation = actionRequest.getParameter("data2operation");
+        if (data2operation == null)
+            data2operation = "A";
         try
         {
             PreparedStatement pStmt = con
@@ -933,12 +1002,20 @@
                             + ",'"
                             + mbean
                             + "','"
-                            + dataname
+                            + dataname1
                             + "','"
                             + xlabel
                             + "','"
                             + ylabel
-                            + "','D','/','D','time',500.0,1024.0,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)");
+                            + "','"
+                            + data1operation
+                            + "','"
+                            + operation
+                            + "','"
+                            + data2operation
+                            + "','"
+                            + dataname2
+                            + "',0,0,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)");
             pStmt.executeUpdate();
             con.close();
             actionResponse.setRenderParameter("message",
@@ -956,6 +1033,112 @@
         }
     }
 
+    protected void updateGraph(ActionRequest actionRequest,
+            ActionResponse actionResponse)
+    {
+        DBManager DBase = new DBManager();
+        Connection con = DBase.getConnection();
+        String graph_id = actionRequest.getParameter("graph_id");
+        actionResponse.setRenderParameter("graph_id", graph_id);
+
+        String name = actionRequest.getParameter("name");
+        String description = actionRequest.getParameter("description");
+        String server_id = actionRequest.getParameter("server_id");
+        String xlabel = actionRequest.getParameter("xlabel");
+        String ylabel = actionRequest.getParameter("ylabel");
+        String timeframe = actionRequest.getParameter("timeframe");
+        String mbean = actionRequest.getParameter("mbean");
+        String dataname1 = actionRequest.getParameter("dataname1");
+        String data1operation = actionRequest.getParameter("data1operation");
+        String operation = actionRequest.getParameter("operation");
+        if (operation.equals("other"))
+        {
+            operation = actionRequest.getParameter("othermath");
+        }
+        String dataname2 = actionRequest.getParameter("dataname2");
+        String data2operation = actionRequest.getParameter("data2operation");
+        if (data2operation == null)
+            data2operation = "A";
+        try
+        {
+            PreparedStatement pStmt = con
+                    .prepareStatement("UPDATE graphs SET server_id="
+                            + server_id
+                            + ", name='"
+                            + name
+                            + "', description='"
+                            + description
+                            + "', timeframe="
+                            + timeframe
+                            + ", mbean='"
+                            + mbean
+                            + "', dataname1='"
+                            + dataname1
+                            + "', xlabel='"
+                            + xlabel
+                            + "', ylabel='"
+                            + ylabel
+                            + "', data1operation='"
+                            + data1operation
+                            + "', operation='"
+                            + operation
+                            + "', data2operation='"
+                            + data2operation
+                            + "', dataname2='"
+                            + dataname2
+                            + "', warninglevel1=0, warninglevel2=0, modified=CURRENT_TIMESTAMP WHERE graph_id="
+                            + graph_id);
+            pStmt.executeUpdate();
+            con.close();
+            actionResponse.setRenderParameter("message",
+                    "<font color=\"green\"><strong><li>Graph " + name
+                            + " has been updated.</li></strong></font>");
+            return;
+
+        }
+        catch (Exception e)
+        {
+            actionResponse.setRenderParameter("message",
+                    "<font color=\"red\"><strong><li>Error editing graph</li></strong></font>"
+                            + e.getMessage());
+            return;
+        }
+    }
+
+    protected void deleteGraph(ActionRequest actionRequest,
+            ActionResponse actionResponse)
+    {
+        String graph_id = actionRequest.getParameter("graph_id");
+        actionResponse.setRenderParameter("graph_id", graph_id);
+        DBManager DBase = new DBManager();
+        Connection con = DBase.getConnection();
+
+        try
+        {
+            PreparedStatement pStmt = con
+                    .prepareStatement("DELETE FROM graphs WHERE graph_id="
+                            + graph_id);
+            pStmt.executeUpdate();
+            pStmt = con
+                    .prepareStatement("DELETE FROM views_graphs WHERE graph_id="
+                            + graph_id);
+            pStmt.executeUpdate();
+            con.close();
+            actionResponse
+                    .setRenderParameter("message",
+                            "<font color=\"green\"><strong><li>Graph has been deleted</li></strong></font>");
+            return;
+
+        }
+        catch (Exception e)
+        {
+            actionResponse.setRenderParameter("message",
+                    "<font color=\"red\"><strong><li>Error deleting graph</li></strong></font>"
+                            + e.getMessage());
+            return;
+        }
+    }
+
     @Override
     public void init(PortletConfig portletConfig) throws PortletException
     {
@@ -970,6 +1153,8 @@
                 ADDVIEW_JSP);
         addGraph = portletConfig.getPortletContext().getRequestDispatcher(
                 ADDGRAPH_JSP);
+        editGraph = portletConfig.getPortletContext().getRequestDispatcher(
+                EDITGRAPH_JSP);
         viewServer = portletConfig.getPortletContext().getRequestDispatcher(
                 VIEWSERVER_JSP);
         editServer = portletConfig.getPortletContext().getRequestDispatcher(
@@ -996,6 +1181,7 @@
         editView = null;
         addView = null;
         addGraph = null;
+        editGraph = null;
         viewServer = null;
         editServer = null;
         addServer = null;

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/StatsGraph.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/StatsGraph.java?rev=596811&r1=596810&r2=596811&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/StatsGraph.java (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/StatsGraph.java Tue Nov 20 12:17:43 2007
@@ -60,18 +60,252 @@
         DivImplement = "<div id=\"" + DivName + "\"></div>" + "\n";
 
         GraphJS = "var " + "graph" + graph_id + "Data = \n" + "[\n";
+        if (data1operation == 'D' && data2operation == 'D')
+            for (int i = 1; i < dataSet1.size(); i++)
+            {
+                if (((Long) dataSet1.get(i) - (Long) dataSet1.get(i - 1)) < 0)
+                    dataSet1.set(i - 1, dataSet1.get(i));
+                GraphJS = GraphJS + " { index: " + (i)
+                        + ", value: Math.round(("
+                        + ((Long) dataSet1.get(i) - (Long) dataSet1.get(i - 1))
+                        + operation
+                        + ((Long) dataSet2.get(i) - (Long) dataSet2.get(i - 1))
+                        + ")*10)/10 },\n";
+            }
+        if (data1operation == 'D' && data2operation != 'D')
+            for (int i = 1; i < dataSet1.size(); i++)
+            {
+                if (((Long) dataSet1.get(i) - (Long) dataSet1.get(i - 1)) < 0)
+                    dataSet1.set(i - 1, dataSet1.get(i));
+                GraphJS = GraphJS + " { index: " + (i)
+                        + ", value: Math.round(("
+                        + ((Long) dataSet1.get(i) - (Long) dataSet1.get(i - 1))
+                        + operation + (dataSet2.get(i)) + ")*10)/10 },\n";
+            }
+        if (data1operation != 'D' && data2operation == 'D')
+            for (int i = 1; i < dataSet1.size(); i++)
+            {
+                if (((Long) dataSet1.get(i) - (Long) dataSet1.get(i - 1)) < 0)
+                    dataSet1.set(i - 1, dataSet1.get(i));
+                GraphJS = GraphJS + " { index: " + (i)
+                        + ", value: Math.round((" + (dataSet1.get(i))
+                        + operation
+                        + ((Long) dataSet2.get(i) - (Long) dataSet2.get(i - 1))
+                        + ")*10)/10 },\n";
+            }
+        if (data1operation != 'D' && data2operation != 'D')
+            for (int i = 1; i < dataSet1.size(); i++)
+            {
+                if (((Long) dataSet1.get(i) - (Long) dataSet1.get(i - 1)) < 0)
+                    dataSet1.set(i - 1, dataSet1.get(i));
+                GraphJS = GraphJS + " { index: " + (i)
+                        + ", value: Math.round((" + (dataSet1.get(i))
+                        + operation + (dataSet2.get(i)) + ")*10)/10 },\n";
+            }
+
+        GraphJS = GraphJS + "];\n";
+
+        GraphJS = GraphJS + "var " + "graph" + graph_id
+                + "Store = new dojo.collections.Store();\n";
+        GraphJS = GraphJS + "graph" + graph_id + "Store.setData(" + "graph"
+                + graph_id + "Data);\n";
+        GraphJS = GraphJS + "graph" + graph_id + "Max = 0;\n" + "graph"
+                + graph_id + "Min = 0;\n" + "graph" + graph_id + "Avg = 0;\n"
+                + "for (var i = 0; i<" + "graph" + graph_id
+                + "Data.length; i++)\n" + "{\n" + "graph" + graph_id
+                + "Max = Math.max(" + "graph" + graph_id + "Max," + "graph"
+                + graph_id + "Data[i].value);\n" + "graph" + graph_id
+                + "Min = Math.min(" + "graph" + graph_id + "Min," + "graph"
+                + graph_id + "Data[i].value);\n" + "graph" + graph_id
+                + "Avg = (" + "graph" + graph_id + "Avg + " + "graph"
+                + graph_id + "Data[i].value);\n" + "}\n" + "graph" + graph_id
+                + "Avg = Math.round(" + "graph" + graph_id + "Avg/" + "graph"
+                + graph_id + "Data.length*10)/10;\n" + "if (" + "graph"
+                + graph_id + "Max == 0)\n" + "graph" + graph_id + "Max = 1;\n";
+
+        // Setup the data series
+        GraphJS = GraphJS + "var " + "graph" + graph_id
+                + "Series = new dojo.charting.Series({\n";
+        GraphJS = GraphJS + "dataSource: " + "graph" + graph_id + "Store,\n";
+        GraphJS = GraphJS + "bindings: { x: \"index\", y: \"value\" },\n";
+        GraphJS = GraphJS + "label: \"" + "graph" + graph_id + "\"\n";
+        GraphJS = GraphJS + "});\n";
+
+        // Define the x-axis
+        GraphJS = GraphJS + "var " + "graph" + graph_id
+                + "xAxis = new dojo.charting.Axis(); \n";
+
+        // Set the upper and lower data range valuesprettyName
+        GraphJS = GraphJS + "graph" + graph_id + "xAxis.range = { lower: "
+                + "graph" + graph_id + "Data[0].index, upper: " + "graph"
+                + graph_id + "Data[" + "graph" + graph_id
+                + "Data.length-1].index };\n";
+
+        GraphJS = GraphJS + "graph" + graph_id + "xAxis.origin = \"" + "graph"
+                + graph_id + "Max\";\n";
+        GraphJS = GraphJS + "graph" + graph_id + "xAxis.showTicks = true;\n";
+        GraphJS = GraphJS + "graph" + graph_id + "xAxis.label = \""
+                + xAxisLabel + "\";\n";
+
+        // Setup the x tick marks on the chart
+        GraphJS = GraphJS + "graph" + graph_id + "xAxis.labels = [ \n";
+        // timeFrame = ((int) ((Long)snapshotTimes.get(0) - (Long)snapshotTimes
+        // .get(snapshotTimes.size() - 1)) / 60000);
+        Format formatter = new SimpleDateFormat("HH:mm");
+        if ((timeFrame / 1440) > 7)
+            formatter = new SimpleDateFormat("M/d");
+        else
+        {
+            if ((timeFrame / 60) > 24)
+                formatter = new SimpleDateFormat("E a");
+            else
+            {
+                // if (timeFrame > 60)
+                // formatter = new SimpleDateFormat("HH:mm");
+                // else
+                formatter = new SimpleDateFormat("HH:mm");
+            }
+        }
+
         for (int i = 1; i < dataSet1.size(); i++)
         {
-            if (((Long) dataSet1.get(i) - (Long) dataSet1.get(i - 1)) < 0)
-                dataSet1.set(i - 1, dataSet1.get(i));
-            GraphJS = GraphJS + " { index: " + (i) + ", value: Math.round(("
-                    + ((Long) dataSet1.get(i) - (Long) dataSet1.get(i - 1))
-                    + operation
-                    + ((Long) dataSet2.get(i) - (Long) dataSet2.get(i - 1))
-                    + ")*10)/10 },\n";
-            // System.out.println("StatsGraph Says: Data object "+i+" is
-            // "+dataSet2.get(i));
+            Date date = new Date((Long) snapshotTimes.get(i));
+            // System.out.println("StatsGraph Says: Time object "+i+" is
+            // "+snapshotTimes.get(i));
+            // System.out.println("StatsGraph Says: Time object "+i+" is
+            // "+formatter.format(date));
+            GraphJS = GraphJS + "{ label: '" + formatter.format(date)
+                    + "', value: " + (i) + " }, \n";
         }
+        GraphJS = GraphJS + "];\n";
+        // Define the y-axis
+        GraphJS = GraphJS + "var " + "graph" + graph_id
+                + "yAxis = new dojo.charting.Axis();\n";
+        GraphJS = GraphJS + "graph" + graph_id + "yAxis.range = { lower: "
+                + "graph" + graph_id + "Min, upper: " + "graph" + graph_id
+                + "Max+(0.1*" + "graph" + graph_id + "Max)};\n";
+        GraphJS = GraphJS + "graph" + graph_id + "yAxis.showLines = true;\n";
+        GraphJS = GraphJS + "graph" + graph_id + "yAxis.showTicks = true;\n";
+        GraphJS = GraphJS + "graph" + graph_id + "yAxis.label = \""
+                + yAxisLabel + "\";\n";
+
+        // Setup the y tick marks on the chart
+        GraphJS = GraphJS + "graph" + graph_id + "yAxis.labels = [ \n";
+        GraphJS = GraphJS + "{ label: \"min - \"+" + "graph" + graph_id
+                + "Min, value: " + "graph" + graph_id + "Min },\n";
+        GraphJS = GraphJS + "{ label: \"avg - \"+" + "graph" + graph_id
+                + "Avg, value: " + "graph" + graph_id + "Avg },\n";
+        GraphJS = GraphJS + "{ label: \"max - \"+" + "graph" + graph_id
+                + "Max, value: " + "graph" + graph_id + "Max },\n";
+        GraphJS = GraphJS + "{ label: Math.round((" + "graph" + graph_id
+                + "Max+(0.1*" + "graph" + graph_id + "Max))), value: "
+                + "graph" + graph_id + "Max+(0.1*" + "graph" + graph_id
+                + "Max) },\n";
+        GraphJS = GraphJS + "];  \n";
+
+        // Create the actual graph with the x and y axes defined above
+        GraphJS = GraphJS + "var " + "graph" + graph_id
+                + "chartPlotArea = new dojo.charting.PlotArea();\n";
+        GraphJS = GraphJS + "var " + "graph" + graph_id
+                + "chartPlot = new dojo.charting.Plot(" + "graph" + graph_id
+                + "xAxis, " + "graph" + graph_id + "yAxis);\n";
+        GraphJS = GraphJS + "graph" + graph_id
+                + "chartPlotArea.initializePlot(" + "graph" + graph_id
+                + "chartPlot);\n";
+        // graphOutput.add(graphName+"xAxis.initializeLabels();");
+        // graphOutput.add(graphName+"xAxis.renderLabels("+graphName+"chartPlotArea,
+        // "+graphName+"chartPlot, '200', '10', 'LABEL');");
+
+        // Add the time series to the graph. The plotter will be a curved
+        // area graph.
+        // Other available plotters are:
+        // Bar, HorizontalBar, Gantt, StackedArea, StackedCurvedArea,
+        // HighLow, HighLowClose, HighLowOpenClose, Bubble,
+        // DataBar, Line, CurvedLine, Area, CurvedArea, Scatter
+
+        GraphJS = GraphJS + "graph" + graph_id + "chartPlot.addSeries({ \n";
+        GraphJS = GraphJS + "data: " + "graph" + graph_id + "Series,\n";
+        GraphJS = GraphJS + "plotter: dojo.charting.Plotters.CurvedArea\n";
+        GraphJS = GraphJS + "});\n";
+
+        // Define the plot area
+
+        GraphJS = GraphJS + "graph" + graph_id
+                + "chartPlotArea.size = { width: 650, height: 200 };\n";
+        GraphJS = GraphJS
+                + "graph"
+                + graph_id
+                + "chartPlotArea.padding = { top: 10, right: 20, bottom: 30, left: 80 };\n";
+
+        // Add the plot to the area
+        GraphJS = GraphJS + "graph" + graph_id + "chartPlotArea.plots.push("
+                + "graph" + graph_id + "chartPlot);\n";
+        // Simply use the next available color when plotting the time series
+        // plot
+        GraphJS = GraphJS + "graph" + graph_id + "Series.color = '#" + hexColor
+                + "';\n";
+
+        // Create the actual chart "canvas"
+        GraphJS = GraphJS + "var " + "graph" + graph_id
+                + "chart = new dojo.charting.Chart(null, \"" + "graph"
+                + graph_id
+                + "\", \"This is the example chart description\");\n";
+
+        // Add the plot area at an offset of 10 pixels from the top left
+        GraphJS = GraphJS + "graph" + graph_id + "chart.addPlotArea({ x: "
+                + dataSet1.size() + ", y: " + dataSet1.size() + ", plotArea: "
+                + "graph" + graph_id + "chartPlotArea });\n";
+
+        // Setup the chart to be added to the DOM on load
+        GraphJS = GraphJS + "dojo.addOnLoad(function()\n{\n" + "graph"
+                + graph_id + "chart.node = dojo.byId(\"" + DivName + "\");";
+
+        GraphJS = GraphJS + "graph" + graph_id + "chart.render();\n});\n";
+
+    }
+
+    public StatsGraph(Integer graph_id, String graphName, String description,
+            String xAxisLabel, String yAxisLabel, char data1operation,
+            Vector<Object> dataSet1, String operation,
+            Vector<Object> snapshotTimes, int snapshotDuration, int timeFrame,
+            String hexColor, float warninglevel1, float warninglevel2)
+    {
+
+        DivName = "graph" + graph_id + "Container";
+        GraphName = graphName;
+        Description = description;
+        XAxisLabel = xAxisLabel;
+        YAxisLabel = yAxisLabel;
+        SnapshotDuration = snapshotDuration;
+        TimeFrame = timeFrame;
+        PointCount = dataSet1.size();
+        HexColor = hexColor;
+
+        DivDefine = "#" + DivName + "\n" + "{\n" + "margin: 0px;\n"
+                + "width: 670px;\n" + "height: 240px;\n" + "}";
+
+        DivImplement = "<div id=\"" + DivName + "\"></div>" + "\n";
+
+        GraphJS = "var " + "graph" + graph_id + "Data = \n" + "[\n";
+        if (data1operation == 'D')
+            for (int i = 1; i < dataSet1.size(); i++)
+            {
+                if (((Long) dataSet1.get(i) - (Long) dataSet1.get(i - 1)) < 0)
+                    dataSet1.set(i - 1, dataSet1.get(i));
+                GraphJS = GraphJS + " { index: " + (i)
+                        + ", value: Math.round(("
+                        + ((Long) dataSet1.get(i) - (Long) dataSet1.get(i - 1))
+                        + operation + ")*10)/10 },\n";
+            }
+        if (data1operation != 'D')
+            for (int i = 1; i < dataSet1.size(); i++)
+            {
+                if (((Long) dataSet1.get(i) - (Long) dataSet1.get(i - 1)) < 0)
+                    dataSet1.set(i - 1, dataSet1.get(i));
+                GraphJS = GraphJS + " { index: " + (i)
+                        + ", value: Math.round((" + (dataSet1.get(i))
+                        + operation + ")*10)/10 },\n";
+            }
 
         GraphJS = GraphJS + "];\n";
 

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java?rev=596811&r1=596810&r2=596811&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java Tue Nov 20 12:17:43 2007
@@ -150,10 +150,13 @@
                             + "name        VARCHAR(128) NOT NULL,"
                             + "description LONG VARCHAR DEFAULT NULL,"
                             + "graph_count INTEGER NOT NULL DEFAULT 0,"
-                            + "graph_ids   LONG VARCHAR NOT NULL,"
                             + "added       TIMESTAMP NOT NULL,"
                             + "modified    TIMESTAMP NOT NULL)");
             pStmt.executeUpdate();
+            pStmt = con.prepareStatement("CREATE TABLE views_graphs("
+                    + "view_id     INTEGER NOT NULL,"
+                    + "graph_id     INTEGER NOT NULL)");
+            pStmt.executeUpdate();
             pStmt = con
                     .prepareStatement("INSERT INTO servers VALUES(DEFAULT, DEFAULT, 'Local host', '127.0.0.1', 'system', 'manager', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
             pStmt.executeUpdate();
@@ -223,9 +226,20 @@
                     + "DEFAULT," + "DEFAULT,"
                     + "'Tomcat Web Connector 60 mins',"
                     + "'Tomcat Web Connector 60 minute graphs'," + "4,"
-                    + "'0,1,2,3,'," + "CURRENT_TIMESTAMP,"
-                    + "CURRENT_TIMESTAMP)");
+                    + "CURRENT_TIMESTAMP," + "CURRENT_TIMESTAMP)");
 
+            pStmt.executeUpdate();
+            pStmt = con
+                    .prepareStatement("INSERT INTO views_graphs VALUES(0,0)");
+            pStmt.executeUpdate();
+            pStmt = con
+                    .prepareStatement("INSERT INTO views_graphs VALUES(0,1)");
+            pStmt.executeUpdate();
+            pStmt = con
+                    .prepareStatement("INSERT INTO views_graphs VALUES(0,2)");
+            pStmt.executeUpdate();
+            pStmt = con
+                    .prepareStatement("INSERT INTO views_graphs VALUES(0,3)");
             pStmt.executeUpdate();
             success = true;
         }

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp?rev=596811&r1=596810&r2=596811&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp Tue Nov 20 12:17:43 2007
@@ -23,6 +23,7 @@
 <%@ page import="java.util.Iterator" %>
 <%@ page import="java.util.HashMap" %>
 <%@ page import="java.util.TreeMap" %>
+<%@ page import="java.util.ArrayList" %>
 <%@ page import="java.lang.String" %>
 <%@ page import="java.sql.Connection" %>
 <%@ page import="java.sql.DatabaseMetaData" %>
@@ -38,22 +39,92 @@
 
 String message = (String) request.getAttribute("message");
 String mbean = (String) request.getAttribute("mbean");
-String dataname = (String) request.getAttribute("dataname");
+String dataname1 = (String) request.getAttribute("dataname");
 String server_id = (String) request.getAttribute("server_id");
 
+DBManager DBase = new DBManager();
+Connection con = DBase.getConnection();
+
+PreparedStatement pStmt = con.prepareStatement("SELECT * FROM servers WHERE enabled=1");
+ResultSet rs = pStmt.executeQuery();
+MRCConnector MRCConnection = null;
+ArrayList<String> serverIds = new ArrayList<String>();
+ArrayList<String> serverNames = new ArrayList<String>();
+
 if (message == null)
     message = new String("");
+if (mbean == null)
+    mbean = new String("");
+if (dataname1 == null)
+    dataname1 = new String("");
+if (server_id == null)
+    server_id = new String("");
+
+%>
+<script type = "text/javascript">
+var serverBeans = new Array();
+var serverPrettyBeans = new Array();
+var serverBeanStatAttributes = new Array();
+var server_id = "<%=server_id%>";
+var mbean = "<%=mbean%>";
+var dataname1 = "<%=dataname1%>";
+
 
+<%
+while (rs.next())
+{
+    TreeMap <String,String> trackedBeansMap = null;
+    try {
+        MRCConnection = new MRCConnector(rs.getString("ip"), rs.getString("username"), rs.getString("password"));
+        trackedBeansMap = MRCConnection.getTrackedBeansMap();
+        serverIds.add(rs.getString("server_id"));
+        serverNames.add(rs.getString("name") +" - "+rs.getString("ip"));
+        %>
+        serverBeans[<%=rs.getString("server_id")%>] = new Array();
+        serverPrettyBeans[<%=rs.getString("server_id")%>] = new Array();
+        serverBeanStatAttributes[<%=rs.getString("server_id")%>] = new Array();
+        <%
+        int i = 0;
+        for (Iterator <String> it = trackedBeansMap.keySet().iterator(); it.hasNext();)
+            {
+                String prettyBean = it.next().toString();
+                Set<String> statAttributes = MRCConnection.getStatAttributesOnMBean(trackedBeansMap.get(prettyBean));
+                %>
+                serverBeans[<%=rs.getString("server_id")%>][<%=i%>]="<%=trackedBeansMap.get(prettyBean)%>";
+                serverPrettyBeans[<%=rs.getString("server_id")%>][<%=i%>]="<%=prettyBean%>";
+                serverBeanStatAttributes[<%=rs.getString("server_id")%>][<%=i%>] = new Array();
+                <%
+                int j = 0;
+                for (Iterator <String> itt = statAttributes.iterator(); itt.hasNext();)
+                {
+                    %>
+                    serverBeanStatAttributes[<%=rs.getString("server_id")%>][<%=i%>][<%=j%>]="<%=itt.next().toString()%>";
+                    <%
+                    j++;
+                }
+                i++;
+            }       
+         %>
+             
+        <%
+    }
+    catch (Exception e)
+    {
+        
+    }
+    %>
+    
+<%}
 
 %>
+</script>
 <!-- <head> -->
 
     <style type='text/css'>
     </style>
-    <script type='text/javascript' src='/dojo/dojo.js'>
-    </script>
-        <script type = "text/javascript">
+    <script type = "text/javascript">
 <!--
+
 function hide(x) {
 document.getElementById(x).style.display='none';
 }
@@ -61,20 +132,253 @@
 document.getElementById(x).style.display='';
 }
 function validate() {
-   if (! (document.addGraph.name.value 
-      && document.addGraph.description.value 
-      && document.addGraph.dataname.value
-      && document.addGraph.mbean.value ))
+   if (! (document.addGraph.name.value  
+      && document.addGraph.dataname1.value
+      && document.addGraph.mbean.value
+      && document.addGraph.server_id.value
+      && document.addGraph.timeframe.value ))
    {
-      alert("Name, Description, Dataname and mbean are all required fields");
+      alert("Server, Name, Data Series, MBean and Timeframe are all required fields");
       return false;
    }
+   if (document.addGraph.operation.value == 'other')
+   {
+       if (!document.addGraph.othermath.value)
+       {
+            alert("If operation is other, field must contain a math operation");
+            return false;
+       }
+       var mathChars= /[\+\-\*\/]/;
+       if (!document.addGraph.othermath.value.match(mathChars)) {
+            alert("Operation must use at least one math symbol (+, -, *, /)");
+            return false;
+        }
+       if (document.addGraph.othermath.value.length > 1) 
+       {
+        if (!document.addGraph.othermath.value.charAt(0).match(mathChars) || !document.addGraph.othermath.value.charAt(document.addGraph.othermath.value.length - 1).match(mathChars))
+        {
+            alert("Operation must create a valid formula");
+            return false;
+        }
+        }
+        if (document.addGraph.othermath.value.length == 2) 
+       {
+            alert("Operation must create a valid formula");
+            return false;
+       }
+   }
    return;
 }
 function noAlpha(obj){
     reg = /[^0-9]/g;
     obj.value =  obj.value.replace(reg,"");
  }
+ 
+ function noAlphaMath(obj){
+    reg = /[^0-9,\-,\+,\*,\/,\.]/g;
+    obj.value =  obj.value.replace(reg,"");
+ }
+ 
+ function clearList(selectbox)
+{
+    var i;
+    for(i=selectbox.options.length-1;i>=0;i--)
+    {
+        selectbox.remove(i);
+    }
+}
+
+
+function addOption(selectbox, value, text )
+{
+    var optn = document.createElement("OPTION");
+    optn.text = text;
+    optn.value = value;
+    if (selectbox == document.addGraph.mbean)
+    {
+        if (value==mbean)
+            optn.selected = "selected";
+    }
+    else if (selectbox == document.addGraph.dataname2 && (document.addGraph.dataname2.disabled = ""))
+    {
+        if (value=="time")
+            optn.selected = "selected";
+    }
+    else if (selectbox == document.addGraph.dataname1)
+    {
+        if (value==dataname1)
+            optn.selected = "selected";
+    }
+    selectbox.options.add(optn);
+}
+ 
+ 
+ function updateMbeanList(){
+    clearList(document.addGraph.mbean);
+    if (document.addGraph.server_id.value)
+    {
+        addOption(document.addGraph.mbean, "", "-Select MBean-");
+        for (var i = 0; i < serverPrettyBeans[document.addGraph.server_id.value].length; i++)
+        {
+            addOption(document.addGraph.mbean, serverBeans[document.addGraph.server_id.value][i], serverPrettyBeans[document.addGraph.server_id.value][i]);
+        }
+    }
+    else
+        addOption(document.addGraph.mbean, "", "-Select Server First-");
+    updateDatanameList();
+ }
+ 
+  function updateDatanameList(){
+    clearList(document.addGraph.dataname1);
+    if (document.addGraph.mbean.value)
+    {
+        addOption(document.addGraph.dataname1, "", "-Select Data Name-");
+        for (var i = 0; i < serverBeanStatAttributes[document.addGraph.server_id.value][document.addGraph.mbean.selectedIndex-1].length; i++)
+        {
+            addOption(document.addGraph.dataname1, serverBeanStatAttributes[document.addGraph.server_id.value][document.addGraph.mbean.selectedIndex-1][i], serverBeanStatAttributes[document.addGraph.server_id.value][document.addGraph.mbean.selectedIndex-1][i]);
+        }
+    }
+    else
+        addOption(document.addGraph.dataname1, "", "-Select MBean First-");
+    updateDataname2List();
+ }
+ 
+   function updateDataname2List(){
+    clearList(document.addGraph.dataname2);
+    if (document.addGraph.mbean.value)
+    {
+        if (document.addGraph.operation.value=="other")
+            addOption(document.addGraph.dataname2, "", "none");
+        addOption(document.addGraph.dataname2, "time", "Time");
+        for (var i = 0; i < serverBeanStatAttributes[document.addGraph.server_id.value][document.addGraph.mbean.selectedIndex-1].length; i++)
+        {
+            addOption(document.addGraph.dataname2, serverBeanStatAttributes[document.addGraph.server_id.value][document.addGraph.mbean.selectedIndex-1][i], serverBeanStatAttributes[document.addGraph.server_id.value][document.addGraph.mbean.selectedIndex-1][i]);
+        }
+    }
+    else
+        addOption(document.addGraph.dataname2, "", "-Select MBean First-");
+        
+     if (document.addGraph.operation.value=="")
+     {
+        document.addGraph.data2operation.selectedIndex=0;
+        document.addGraph.dataname2.selectedIndex=0;
+        document.addGraph.data2operation.disabled="disabled";
+        document.addGraph.dataname2.disabled="disabled";
+     }
+ }
+ 
+   function checkOtherMath(){
+    if (document.addGraph.operation.value=="other")
+    {
+        document.addGraph.othermath.style.display='';
+    }
+    else
+        document.addGraph.othermath.style.display='none';
+   if (document.addGraph.operation.value=="")
+   {
+        document.addGraph.data2operation.selectedIndex=0;
+        document.addGraph.dataname2.selectedIndex=0;
+        document.addGraph.data2operation.disabled="disabled";
+        document.addGraph.dataname2.disabled="disabled";
+   }
+   else
+   {
+       document.addGraph.dataname2.disabled="";
+       document.addGraph.data2operation.disabled="";
+       updateDataname2List();
+       checkNoData2();
+   }
+
+ }
+ 
+ function checkNoData2()
+ {
+    if (document.addGraph.dataname2.value == "")
+    {
+        document.addGraph.data2operation.selectedIndex = 0;
+        document.addGraph.data2operation.disabled="disabled";
+    }
+    else
+    {
+        document.addGraph.data2operation.disabled="";
+    }
+ }
+ 
+ function getObject(obj) {
+  var theObj;
+  if(document.all) {
+    if(typeof obj=="string") {
+      return document.all(obj);
+    } else {
+      return obj.style;
+    }
+  }
+  if(document.getElementById) {
+    if(typeof obj=="string") {
+      return document.getElementById(obj);
+    } else {
+      return obj.style;
+    }
+  }
+  return null;
+}
+ 
+    function updateFormula()
+    {
+        var exitObj=getObject('formulaData1operation');
+        if (document.addGraph.dataname1.value)
+        {
+            if (document.addGraph.data1operation.value == 'D')
+                exitObj.innerHTML = "(Delta)";
+            else
+                exitObj.innerHTML = "";
+            exitObj=getObject('formulaDataname1');
+            exitObj.innerHTML = document.addGraph.dataname1.value;
+            if (document.addGraph.operation.value)
+            {
+                if (document.addGraph.operation.value == "other")
+                {
+                    exitObj=getObject('formulaOperation');
+                    exitObj.innerHTML = document.addGraph.othermath.value;
+                }
+                else
+                {
+                    exitObj=getObject('formulaOperation');
+                    exitObj.innerHTML = document.addGraph.operation.value;
+                }
+                exitObj=getObject('formulaData2operation');
+                if (document.addGraph.data2operation.value == 'D')
+                    exitObj.innerHTML = "(Delta)";
+                else
+                    exitObj.innerHTML = "";
+                exitObj=getObject('formulaDataname2');
+                exitObj.innerHTML = document.addGraph.dataname2.value;
+            }
+            else
+            {
+                exitObj=getObject('formulaOperation');
+                exitObj.innerHTML = "";
+                exitObj=getObject('formulaData2operation');
+                exitObj.innerHTML = "";
+                exitObj=getObject('formulaDataname2');
+                exitObj.innerHTML = "";
+            }
+            
+        }
+        else
+        {
+            exitObj=getObject('formulaData1operation');
+            exitObj.innerHTML = "";
+            exitObj=getObject('formulaDataname1');
+            exitObj.innerHTML = "";
+            exitObj=getObject('formulaOperation');
+            exitObj.innerHTML = "";
+            exitObj=getObject('formulaData2operation');
+            exitObj.innerHTML = "";
+            exitObj=getObject('formulaDataname2');
+            exitObj.innerHTML = "";
+        }
+    }
 
 //-->
 </script>
@@ -103,7 +407,20 @@
    <tr>
       <td>Server:</td>
       <td>&nbsp;</td>
-      <td align="right"><input type="text" name="server_id" readonly="readonly" value="<%=server_id %>"></td>
+      <td align="right">
+    <select name="server_id" onChange="updateMbeanList(); updateFormula();">
+      <option value="">-Select Server-</option>
+    </select>    
+    <script type='text/javascript'>
+    <% 
+    for (int i = 1; i < serverIds.size()+1; i++)
+    {
+    %>
+        document.addGraph.server_id.options[<%=i%>]=new Option("<%=serverNames.get(i-1)%>", "<%=serverIds.get(i-1)%>", <%if (server_id.equals(serverIds.get(i-1))){%>true<%}else{%>false<%}%>);
+    <%
+    }%>
+    </script>
+    </td>
       <td></td>
     </tr>
     <tr>
@@ -139,16 +456,61 @@
     <tr>
       <td>Mbean:</td>
       <td>&nbsp;</td>
-      <td align="right"><input type="text" readonly="readonly" name="mbean" value="<%=mbean %>"/></td>
+      <td align="right">
+    <select name="mbean" onChange="updateDatanameList(); updateFormula();">
+      <option value="">-Select Server First-</option>
+    </select>
+    </td>
       <td></td>
     </tr>
     <tr>
-      <td>Data Name:</td>
+      <td>Data series:</td>
       <td>&nbsp;</td>
-      <td align="right"><input type="text" readonly="readonly" name="dataname" value="<%=dataname %>"/></td>
+      <td align="right">
+      <select name="data1operation" onchange="updateFormula();">
+        <option value="A" selected="selected">As-is</option>
+        <option value="D">Change (Delta) in</option>
+      </select>
+      <select name="dataname1" onchange="updateFormula();">
+        <option value="">-Select MBean First-</option>
+      </select>
+      </td>
       <td></td>
     </tr>
-    <tr><td colspan="2"><font size="-2">&nbsp;</font></td></tr>
+    <tr>
+      <td>Math operation:</td>
+      <td>&nbsp;</td>
+        <td align="right">
+      <select name="operation" onChange="checkOtherMath(); updateFormula();">
+        <option value="" selected="selected">none</option>
+        <option value="+">+</option>
+        <option value="-">-</option>
+        <option value="*">*</option>
+        <option value="/">/</option>
+        <option value="other">Other</option>
+      </select>
+      </td>
+      <td><input type="text" style="display: none;" width="6" size="8" name="othermath" onKeyUp='noAlphaMath(this); updateFormula();' onKeyPress='noAlphaMath(this); updateFormula();' value=""/></td>
+    </tr>
+    <tr>
+      <td>Data series 2:</td>
+      <td>&nbsp;</td>
+      <td align="right">
+      <select name="data2operation" disabled="disabled" onchange="updateFormula();">
+        <option value="A" selected="selected">As-is</option>
+        <option value="D">Change (Delta) in</option>
+      </select>
+      <select name="dataname2" disabled="disabled" onchange="updateFormula(); checkNoData2();">
+        <option value="">-Select Operation First-</option>
+      </select>
+      <script type='text/javascript'>
+        updateMbeanList();
+      </script>
+      </td>
+      <td></td>
+    </tr>
+    <tr><td>Graphing: </td><td colspan="2"><strong><span id="formulaData1operation"></span> <span id="formulaDataname1"></span> <span id="formulaOperation"></span> <span id="formulaData2operation"></span> <span id="formulaDataname2"></span></strong></td></tr>
+    <tr><td colspan="3"><font size="-2">&nbsp;</font></td></tr>
     <tr>
       <td colspan="1" align="left"><button type="button" value="Cancel" onclick="javascript:history.go(-1)">Cancel</button></td>
       <td>&nbsp;</td>
@@ -157,9 +519,11 @@
     </tr>
   </table>
   </form>
-
             </p>
-
+      <script type='text/javascript'>
+        updateFormula();
+        checkNoData2();
+      </script>
         </td>
      
          <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddView.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddView.jsp?rev=596811&r1=596810&r2=596811&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddView.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddView.jsp Tue Nov 20 12:17:43 2007
@@ -76,14 +76,14 @@
  if (!message.equals(""))
  {
  %>
-<div align="left" style="width: 500px">
+<div align="left" style="width: 650px">
 <%=message %><br>
 </div>
 <%} %>
 <table>
     <tr>
         <!-- Body -->
-        <td width="90%" align="left" valign="top">
+        <td width="100%" align="left" valign="top">
             <p>
             <font face="Verdana" size="+1">
             Adding a new view
@@ -96,45 +96,60 @@
       <td>Name:</td>
       <td>&nbsp;</td>
       <td align="right"><input size="50" type="text" name="name" value=""></td>
-      <td></td>
     </tr>
     <tr>
       <td>Description:</td>
       <td>&nbsp;</td>
       <td align="right"><textarea rows="5" cols="50" name="description"></textarea></td>
-      <td></td>
     </tr>
     <tr>
-      <td>Included graphs:</td>
+      <td>Graphs:</td>
       <td>&nbsp;</td>
       <td align="right">
       <%
       DBManager DBase = new DBManager();
       Connection con = DBase.getConnection();
-          PreparedStatement pStmt = con.prepareStatement("SELECT * FROM graphs");
-          ResultSet rs = pStmt.executeQuery();
-      %>
-      <select name="graph_ids" size="15" multiple="multiple" id="graph_ids">
+      PreparedStatement pStmt = con.prepareStatement("SELECT * FROM graphs");
+      ResultSet rs = pStmt.executeQuery();
+       %>
+            <table cellpadding="1" cellspacing="1">
+            <tr>
+            <th width="5%"></th>
+            <th>Name</th>
+            <th>Timeframe</th>
+            <th width="20%">Server</th>
+            <th>Edit</th>
+            </tr>
       <%
           while (rs.next())
           {
-      %>
-          
-            <option value="<%=rs.getString("graph_id")%>"><%=rs.getString("name")%></option>
+              pStmt = con.prepareStatement("SELECT name FROM servers WHERE server_id="+rs.getString("server_id"));
+              ResultSet rs2 = pStmt.executeQuery();
+              if (rs2.next())
+              {
+      %>     
+            <tr>
+            <td align="left" width="5%"><input type="checkbox" name="graph_ids" value="<%=rs.getString("graph_id")%>"></td>
+            <td align="left"><a href="<portlet:actionURL portletMode="view"><portlet:param name="action" value="showGraph" /><portlet:param name="graph_id" value="<%=rs.getString("graph_id")%>" /></portlet:actionURL>"><%=rs.getString("name")%></a></td>
+            <td align="left"><%=rs.getString("timeframe")%> min.</td>
+            <td align="left"><a href="<portlet:actionURL portletMode="view"><portlet:param name="action" value="showServer" /><portlet:param name="server_id" value="<%=rs.getString("server_id")%>" /></portlet:actionURL>"><%=rs2.getString("name")%></a></td>
+            <td align="center"><a href="<portlet:actionURL portletMode="edit"><portlet:param name="action" value="showEditGraph" /><portlet:param name="graph_id" value="<%=rs.getString("graph_id")%>" /></portlet:actionURL>">~</a></td>
+            </tr>
       <%
+
+              }
+              rs2.close();
           }
       rs.close();
       %>
-      </select>
+            </table>
 </td>
-      <td></td>
     </tr>
     <tr><td colspan="2"><font size="-2">&nbsp;</font></td></tr>
     <tr>
       <td colspan="1" align="left"><button type="button" value="Cancel" onclick="javascript:history.go(-1)">Cancel</button></td>
       <td>&nbsp;</td>
       <td colspan="1" align="right"><input type="submit" value="Save" /></td>
-      <td></td>
     </tr>
   </table>
   </form>
@@ -158,7 +173,7 @@
                     <td bgcolor="#FFFFFF" nowrap>
                         &nbsp;<br />
                         <ul>
-                        <li><a href="#">Create a new graph</a></li>
+                        <li><a href="<portlet:actionURL portletMode="edit"><portlet:param name="action" value="showAddGraph" /></portlet:actionURL>">Create a new graph</a></li>
                         </ul>
                         &nbsp;<br />
                     </td>   



Mime
View raw message