[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rhq-commits
Subject:    [rhq] modules/enterprise
From:       mike thompson <mithomps () fedoraproject ! org>
Date:       2013-11-26 20:24:00
Message-ID: 20131126202400.E7882609C4 () fedorahosted ! org
[Download RAW message or body]

 modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java \
|  314 ++++-----  modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java \
|  317 ++++------  2 files changed, 271 insertions(+), 360 deletions(-)

New commits:
commit a532e90dd41ce1fcfb3f3d9fbdf126448ac80c1c
Author: Mike Thompson <mithomps@redhat.com>
Date:   Tue Nov 26 12:20:40 2013 -0800

    [BZ1034991]  Summary Last Metrics values are different values than Chart Last \
Metric values.

diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
 index 9fe962c..b3b734a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
                
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
 @@ -68,15 +68,16 @@ import \
org.rhq.coregui.client.dashboard.portlets.PortletConfigurationEditorCompo  import \
org.rhq.coregui.client.gwt.GWTServiceLookup;  import \
org.rhq.coregui.client.inventory.common.detail.summary.AbstractActivityView;  import \
org.rhq.coregui.client.inventory.common.detail.summary.AbstractActivityView.ChartViewWindow;
 +import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
 import org.rhq.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView;
  import org.rhq.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3MultiLineGraph;
  import org.rhq.coregui.client.inventory.resource.type.ResourceTypeRepository;
 import org.rhq.coregui.client.util.BrowserUtility;
 import org.rhq.coregui.client.util.Log;
-import org.rhq.coregui.client.util.MeasurementUtility;
 import org.rhq.coregui.client.util.enhanced.EnhancedVLayout;
 
-/**This portlet allows the end user to customize the metric display
+/**
+ * This portlet allows the end user to customize the metric display
  *
  * @author Simeon Pinder
  */
@@ -86,11 +87,6 @@ public class GroupMetricsPortlet extends EnhancedVLayout \
implements CustomSettin  private EntityContext context;
     protected Canvas recentMeasurementsContent = new Canvas();
     protected boolean currentlyLoading = false;
-    protected long start = -1;
-    protected long end = -1;
-    protected int lastN = -1;
-    protected int units = -1;
-
     // A non-displayed, persisted identifier for the portlet
     public static final String KEY = "GroupMetrics";
     // A default displayed, persisted name for the portlet
@@ -216,46 +212,11 @@ public class GroupMetricsPortlet extends EnhancedVLayout \
                implements CustomSettin
      * digits.
      */
     protected void getRecentMetrics() {
-        final DashboardPortlet storedPortlet = \
                this.portletWindow.getStoredPortlet();
-        final Configuration portletConfig = storedPortlet.getConfiguration();
 
         //display container
         final VLayout column = new VLayout();
         column.setHeight(10);//pack
 
-        //initialize to defaults
-        end = -1;
-        start = -1;
-        lastN = -1;
-        units = -1;
-
-        //result timeframe if enabled
-        PropertySimple property = \
                portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
-        if (null != property && Boolean.valueOf(property.getBooleanValue())) {//then \
                proceed setting
-
-            boolean isAdvanced = \
                Boolean.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_BEGIN_END_FLAG,
                
-                Constant.METRIC_RANGE_BEGIN_END_FLAG_DEFAULT));
-            if (isAdvanced) {
-                //Advanced time settings
-                String currentSetting = \
                portletConfig.getSimpleValue(Constant.METRIC_RANGE,
-                    Constant.METRIC_RANGE_DEFAULT);
-                String[] range = currentSetting.split(",");
-                if (range.length == 2) {
-                    start = Long.valueOf(range[0]);
-                    end = Long.valueOf(range[1]);
-                }
-            } else {
-                //Simple time settings
-                property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
-                if (property != null) {
-                    lastN = \
                Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_LASTN,
                
-                        Constant.METRIC_RANGE_LASTN_DEFAULT));
-                    units = \
                Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_UNIT,
                
-                        Constant.METRIC_RANGE_UNIT_DEFAULT));
-                }
-            }
-        }
-
         //locate resourceGroupRef
         ResourceGroupCriteria criteria = new ResourceGroupCriteria();
         criteria.addFilterId(this.groupId);
@@ -324,158 +285,151 @@ public class GroupMetricsPortlet extends EnhancedVLayout \
                implements CustomSettin
                                                 .getId();
                                         }
 
-                                        \
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>> callback = new \
                AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
-                                            @Override
-                                            public void onFailure(Throwable caught) \
                {
-                                                Log.debug("Error retrieving recent \
                metrics charting data for group ["
-                                                    + groupId + "]:" + \
                caught.getMessage());
-                                                setRefreshing(false);
-                                            }
+                                        \
GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup( +            \
groupId, definitionArrayIds, +                                            \
CustomDateRangeState.getInstance().getStartTime(), +                                  \
CustomDateRangeState.getInstance().getEndTime(), 60, +                                \
new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() { +           \
@Override +                                                public void \
onFailure(Throwable caught) { +                                                    \
Log.debug("Error retrieving recent metrics charting data for group [" +               \
+ groupId + "]:" + caught.getMessage()); +                                            \
setRefreshing(false); +                                                }
 
-                                            @Override
-                                            public void onSuccess(
-                                                \
                List<List<MeasurementDataNumericHighLowComposite>> results) {
-                                                if (!results.isEmpty()) {
-                                                    boolean someChartedData = false;
-                                                    //iterate over the retrieved \
                charting data
-                                                    for (int index = 0; index < \
                displayOrder.length; index++) {
-                                                        //retrieve the correct \
                measurement definition
-                                                        final MeasurementDefinition \
                md = measurementDefMap
-                                                            \
                .get(displayOrder[index]);
-
-                                                        //load the data results for \
                the given metric definition
-                                                        \
                List<MeasurementDataNumericHighLowComposite> data = results
-                                                            .get(index);
-
-                                                        //locate last and minimum \
                values.
-                                                        double lastValue = -1;
-                                                        double minValue = \
                Double.MAX_VALUE;//
-                                                        for \
                (MeasurementDataNumericHighLowComposite d : data) {
-                                                            if \
                ((!Double.isNaN(d.getValue()))
-                                                                && \
                (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
-                                                                if (d.getValue() < \
                minValue) {
-                                                                    minValue = \
d.getValue(); +                                                @Override
+                                                public void onSuccess(
+                                                    \
List<List<MeasurementDataNumericHighLowComposite>> results) { +                       \
if (!results.isEmpty()) { +                                                        \
boolean someChartedData = false; +                                                    \
//iterate over the retrieved charting data +                                          \
for (int index = 0; index < displayOrder.length; index++) { +                         \
//retrieve the correct measurement definition +                                       \
final MeasurementDefinition md = measurementDefMap +                                  \
.get(displayOrder[index]); +
+                                                            //load the data results \
for the given metric definition +                                                     \
List<MeasurementDataNumericHighLowComposite> data = results +                         \
.get(index); +
+                                                            //locate last and \
minimum values. +                                                            double \
lastValue = -1; +                                                            double \
minValue = Double.MAX_VALUE;// +                                                      \
for (MeasurementDataNumericHighLowComposite d : data) { +                             \
if ((!Double.isNaN(d.getValue())) +                                                   \
&& (!String.valueOf(d.getValue()).contains("NaN"))) { +                               \
if (d.getValue() < minValue) { +                                                      \
minValue = d.getValue(); +                                                            \
} +                                                                    lastValue = \
d.getValue();  }
-                                                                lastValue = \
d.getValue();  }
-                                                        }
 
-                                                        //collapse the data into \
comma delimited list for consumption by third party javascript \
                library(jquery.sparkline)
-                                                        String commaDelimitedList = \
""; +                                                            //collapse the data \
into comma delimited list for consumption by third party javascript \
library(jquery.sparkline) +                                                           \
String commaDelimitedList = "";  
-                                                        for \
                (MeasurementDataNumericHighLowComposite d : data) {
-                                                            if \
                ((!Double.isNaN(d.getValue()))
-                                                                && \
                (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
-                                                                commaDelimitedList \
+= d.getValue() + ","; +                                                            \
for (MeasurementDataNumericHighLowComposite d : data) { +                             \
if ((!Double.isNaN(d.getValue())) +                                                   \
&& (!String.valueOf(d.getValue()).contains("NaN"))) { +                               \
commaDelimitedList += d.getValue() + ","; +                                           \
}  }
-                                                        }
-                                                        DynamicForm row = new \
                DynamicForm();
-                                                        row.setNumCols(3);
-                                                        row.setColWidths(65, "*", \
                100);
-                                                        row.setWidth100();
-                                                        row.setAutoHeight();
-                                                        \
                row.setOverflow(Overflow.VISIBLE);
-                                                        HTMLFlow graph = new \
                HTMLFlow();
-                                                        //                        \
String contents = "<span id='sparkline_" + index + "' class='dynamicsparkline' \
                width='0'>"
-                                                        //                           \
                + commaDelimitedList + "</span>";
-                                                        String contents = "<span \
                id='sparkline_" + index
-                                                            + "' \
                class='dynamicsparkline' width='0' " + "values='"
-                                                            + commaDelimitedList + \
                "'>...</span>";
-                                                        graph.setContents(contents);
-                                                        \
                graph.setContentsType(ContentsType.PAGE);
-                                                        //disable scrollbars on span
-                                                        graph.setScrollbarSize(0);
-
-                                                        CanvasItem graphContainer = \
                new CanvasItem();
-                                                        \
                graphContainer.setShowTitle(false);
-                                                        \
                graphContainer.setHeight(16);
-                                                        graphContainer.setWidth(60);
-                                                        \
                graphContainer.setCanvas(graph);
-
-                                                        final String title = \
                md.getDisplayName();
-                                                        LinkItem link = \
                AbstractActivityView.newLinkItem(title, null);
-                                                        link.setTooltip(title);
-                                                        \
                link.setTitleVAlign(VerticalAlignment.TOP);
-                                                        \
                link.setAlign(Alignment.LEFT);
-                                                        link.setClipValue(true);
-                                                        link.setWrap(true);
-                                                        link.setHeight(26);
-                                                        \
                if(!BrowserUtility.isBrowserPreIE9()){
-
-                                                        link.addClickHandler(new \
                ClickHandler() {
-                                                            @Override
-                                                            public void \
                onClick(ClickEvent event) {
-                                                                ChartViewWindow \
                window = new ChartViewWindow(title);
-                                                                \
                CompositeGroupD3GraphListView graph = new \
                CompositeGroupD3MultiLineGraph(
-                                                                    groupId, \
                md.getId(), isAutoGroup);
-                                                                \
                window.addItem(graph);
-                                                                \
                graph.populateData();
-                                                                window.show();
+                                                            DynamicForm row = new \
DynamicForm(); +                                                            \
row.setNumCols(3); +                                                            \
row.setColWidths(65, "*", 100); +                                                     \
row.setWidth100(); +                                                            \
row.setAutoHeight(); +                                                            \
row.setOverflow(Overflow.VISIBLE); +                                                  \
HTMLFlow graph = new HTMLFlow(); +                                                    \
//                        String contents = "<span id='sparkline_" + index + "' \
class='dynamicsparkline' width='0'>" +                                                \
//                            + commaDelimitedList + "</span>"; +                     \
String contents = "<span id='sparkline_" + index +                                    \
+ "' class='dynamicsparkline' width='0' " + "values='" +                              \
+ commaDelimitedList + "'>...</span>"; +                                              \
graph.setContents(contents); +                                                        \
graph.setContentsType(ContentsType.PAGE); +                                           \
//disable scrollbars on span +                                                        \
graph.setScrollbarSize(0); +
+                                                            CanvasItem \
graphContainer = new CanvasItem(); +                                                  \
graphContainer.setShowTitle(false); +                                                 \
graphContainer.setHeight(16); +                                                       \
graphContainer.setWidth(60); +                                                        \
graphContainer.setCanvas(graph); +
+                                                            final String title = \
md.getDisplayName(); +                                                            \
LinkItem link = AbstractActivityView.newLinkItem(title, +                             \
null); +                                                            \
link.setTooltip(title); +                                                            \
link.setTitleVAlign(VerticalAlignment.TOP); +                                         \
link.setAlign(Alignment.LEFT); +                                                      \
link.setClipValue(true); +                                                            \
link.setWrap(true); +                                                            \
link.setHeight(26); +                                                            if \
(!BrowserUtility.isBrowserPreIE9()) { +
+                                                                \
link.addClickHandler(new ClickHandler() { +                                           \
@Override +                                                                    public \
void onClick(ClickEvent event) { +                                                    \
ChartViewWindow window = new ChartViewWindow( +                                       \
title); +                                                                        \
CompositeGroupD3GraphListView graph = new CompositeGroupD3MultiLineGraph( +           \
groupId, md.getId(), isAutoGroup); +                                                  \
window.addItem(graph); +                                                              \
graph.populateData(); +                                                               \
window.show(); +                                                                    }
+                                                                });
+                                                            } else {
+                                                                link.disable();
                                                             }
-                                                        });
-                                                        }else {
-                                                            link.disable();
-                                                        }
-
 
-                                                        //Value
-                                                        String convertedValue = \
                AbstractActivityView
-                                                            \
                .convertLastValueForDisplay(lastValue, md);
-                                                        StaticTextItem value = \
                AbstractActivityView
-                                                            \
                .newTextItem(convertedValue);
-                                                        \
                value.setVAlign(VerticalAlignment.TOP);
-                                                        \
                value.setAlign(Alignment.RIGHT);
-                                                        value.setWidth("100%");
-
-                                                        row.setItems(graphContainer, \
                link, value);
-                                                        row.setWidth100();
-                                                        //if graph content returned
-                                                        if \
                ((!md.getName().trim().contains("Trait."))
-                                                            && (lastValue != -1)) {
+                                                            //Value
+                                                            String convertedValue = \
AbstractActivityView +                                                                \
.convertLastValueForDisplay(lastValue, md); +                                         \
StaticTextItem value = AbstractActivityView +                                         \
.newTextItem(convertedValue); +                                                       \
value.setVAlign(VerticalAlignment.TOP); +                                             \
value.setAlign(Alignment.RIGHT); +                                                    \
value.setWidth("100%"); +
+                                                            \
row.setItems(graphContainer, link, value); +                                          \
row.setWidth100(); +                                                            //if \
graph content returned +                                                            \
if ((!md.getName().trim().contains("Trait.")) +                                       \
&& (lastValue != -1)) { +                                                             \
column.addMember(row); +                                                              \
someChartedData = true; +                                                            \
} +                                                        }
+                                                        if (!someChartedData) {// \
when there are results but no chartable entries. +                                    \
DynamicForm row = AbstractActivityView +                                              \
                .createEmptyDisplayRow(AbstractActivityView.RECENT_MEASUREMENTS_GROUP_NONE);
                
                                                             column.addMember(row);
-                                                            someChartedData = true;
+                                                        } else {
+                                                            //insert see more link
+                                                            DynamicForm row = new \
DynamicForm(); +                                                            String \
link = LinkManager +                                                                \
.getGroupMonitoringGraphsLink(context); +                                             \
AbstractActivityView.addSeeMoreLink(row, link, column);  }
-                                                    }
-                                                    if (!someChartedData) {// when \
                there are results but no chartable entries.
-                                                        DynamicForm row = \
                AbstractActivityView
-                                                            \
                .createEmptyDisplayRow(AbstractActivityView.RECENT_MEASUREMENTS_GROUP_NONE);
                
-                                                        column.addMember(row);
+                                                        //call out to 3rd party \
javascript lib +                                                        new Timer() {
+                                                            @Override
+                                                            public void run() {
+                                                                \
BrowserUtility.graphSparkLines(); +                                                   \
} +                                                        }.schedule(200);
+
                                                     } else {
-                                                        //insert see more link
-                                                        DynamicForm row = new \
                DynamicForm();
-                                                        String link = \
                LinkManager.getGroupMonitoringGraphsLink(context);
-                                                        \
AbstractActivityView.addSeeMoreLink(row, link, column); +                             \
DynamicForm row = AbstractActivityView.createEmptyDisplayRow( +                       \
AbstractActivityView.RECENT_MEASUREMENTS_GROUP_NONE); +                               \
column.addMember(row);  }
-                                                    //call out to 3rd party \
                javascript lib
-                                                    new Timer(){
-                                                        @Override
-                                                        public void run() {
-                                                            \
                BrowserUtility.graphSparkLines();
-                                                        }
-                                                    }.schedule(200);
-                                                } else {
-                                                    DynamicForm row = \
                AbstractActivityView.createEmptyDisplayRow(
-
-                                                    \
                AbstractActivityView.RECENT_MEASUREMENTS_GROUP_NONE);
-                                                    column.addMember(row);
+                                                    setRefreshing(false);
                                                 }
-                                                setRefreshing(false);
                                             }
-                                        };
-
-                                        //make the asynchronous call for all the \
                measurement data
-                                        if (end != -1 && start != -1) {
-                                            \
                GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(
                
-                                                groupId, definitionArrayIds, start, \
                end, 60, callback);
-                                        } else if (lastN != -1 && units != -1) {
-                                            \
                GWTServiceLookup.getMeasurementDataService()
-                                                \
                .findDataForCompatibleGroupForLast(groupId, definitionArrayIds, \
                lastN,
-                                                    units, 60, callback);
-                                        } else {
-                                            \
                GWTServiceLookup.getMeasurementDataService()
-                                                \
                .findDataForCompatibleGroupForLast(groupId, definitionArrayIds, 8,
-                                                    MeasurementUtility.UNIT_HOURS, \
                60, callback);
-                                        }
+                                        );
                                     }
                                 });
                         }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java \
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
 index d470663..862749d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
                
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
 @@ -41,8 +41,6 @@ import \
com.smartgwt.client.widgets.form.fields.events.ClickHandler;  import \
com.smartgwt.client.widgets.layout.VLayout;  
 import org.rhq.core.domain.common.EntityContext;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
 import org.rhq.core.domain.criteria.ResourceCriteria;
 import org.rhq.core.domain.dashboard.DashboardPortlet;
 import org.rhq.core.domain.measurement.MeasurementDefinition;
@@ -54,18 +52,18 @@ import org.rhq.core.domain.util.PageList;
 import org.rhq.coregui.client.LinkManager;
 import org.rhq.coregui.client.dashboard.Portlet;
 import org.rhq.coregui.client.dashboard.PortletViewFactory;
-import org.rhq.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
  import org.rhq.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
 import org.rhq.coregui.client.gwt.GWTServiceLookup;
 import org.rhq.coregui.client.inventory.common.detail.summary.AbstractActivityView;
 import org.rhq.coregui.client.inventory.common.detail.summary.AbstractActivityView.ChartViewWindow;
 +import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
 import org.rhq.coregui.client.inventory.resource.detail.monitoring.D3GraphListView;
 import org.rhq.coregui.client.inventory.resource.type.ResourceTypeRepository;
 import org.rhq.coregui.client.util.BrowserUtility;
 import org.rhq.coregui.client.util.Log;
-import org.rhq.coregui.client.util.MeasurementUtility;
 
-/**This portlet allows the end user to customize the metric display
+/**
+ * This portlet allows the end user to customize the metric display
  *
  * @author Simeon Pinder
  */
@@ -106,45 +104,11 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet \
{  @Override
     protected void getRecentMetrics() {
         final DashboardPortlet storedPortlet = \
                this.portletWindow.getStoredPortlet();
-        final Configuration portletConfig = storedPortlet.getConfiguration();
         //display container
         final VLayout column = new VLayout();
         column.setHeight(10);//pack
         column.setWidth100();
 
-        //initialize to defaults
-        end = -1;
-        start = -1;
-        lastN = -1;
-        units = -1;
-
-        //result timeframe if enabled
-        PropertySimple property = \
                portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
-        if (null != property && property.getBooleanValue()) {//then proceed setting
-
-            boolean isAdvanced = \
                Boolean.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_BEGIN_END_FLAG,
                
-                Constant.METRIC_RANGE_BEGIN_END_FLAG_DEFAULT));
-            if (isAdvanced) {
-                //Advanced time settings
-                String currentSetting = \
                portletConfig.getSimpleValue(Constant.METRIC_RANGE,
-                    Constant.METRIC_RANGE_DEFAULT);
-                String[] range = currentSetting.split(",");
-                if (range.length == 2) {
-                    start = Long.valueOf(range[0]);
-                    end = Long.valueOf(range[1]);
-                }
-            } else {
-                //Simple time settings
-                property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
-                if (property != null) {
-                    lastN = \
                Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_LASTN,
                
-                        Constant.METRIC_RANGE_LASTN_DEFAULT));
-                    units = \
                Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_UNIT,
                
-                        Constant.METRIC_RANGE_UNIT_DEFAULT));
-                }
-            }
-        }
-
         //locate resource reference
         ResourceCriteria criteria = new ResourceCriteria();
         criteria.addFilterId(this.resourceId);
@@ -166,9 +130,8 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet {
                         final Resource resource = resourceComposite.getResource();
                         // Load the fully fetched ResourceType.
                         ResourceType resourceType = resource.getResourceType();
-                        ResourceTypeRepository.Cache.getInstance().getResourceTypes(
-                            resourceType.getId(),
-                            \
EnumSet.of(ResourceTypeRepository.MetadataType.measurements ), +                      \
ResourceTypeRepository.Cache.getInstance().getResourceTypes(resourceType.getId(), +   \
                EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
                             new ResourceTypeRepository.TypeLoadedCallback() {
                                 public void onTypesLoaded(ResourceType type) {
                                     resource.setResourceType(type);
@@ -194,158 +157,152 @@ public class ResourceMetricsPortlet extends \
                GroupMetricsPortlet {
                                             .getId();
                                     }
 
-                                    \
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>> callback = new \
                AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
-                                        @Override
-                                        public void onFailure(Throwable caught) {
-                                            Log.debug("Error retrieving recent \
                metrics charting data for resource ["
-                                                + resourceId + "]:" + \
                caught.getMessage());
-                                            setRefreshing(false);
-                                        }
+                                    \
GWTServiceLookup.getMeasurementDataService().findDataForResource(resourceId, +        \
definitionArrayIds, CustomDateRangeState.getInstance().getStartTime(), +              \
CustomDateRangeState.getInstance().getEndTime(), 60, +                                \
new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() { +           \
@Override +                                            public void \
onFailure(Throwable caught) { +                                                \
Log.debug("Error retrieving recent metrics charting data for resource [" +            \
+ resourceId + "]:" + caught.getMessage()); +                                         \
setRefreshing(false); +                                            }
 
-                                        @Override
-                                        public void \
                onSuccess(List<List<MeasurementDataNumericHighLowComposite>> results) \
                {
-                                            if (!results.isEmpty()) {
-                                                boolean someChartedData = false;
-                                                //iterate over the retrieved \
                charting data
-                                                for (int index = 0; index < \
                displayOrder.length; index++) {
-                                                    //retrieve the correct \
                measurement definition
-                                                    final MeasurementDefinition md = \
                measurementDefMap
-                                                        .get(displayOrder[index]);
-
-                                                    //load the data results for the \
                given metric definition
-                                                    \
                List<MeasurementDataNumericHighLowComposite> data = results
-                                                        .get(index);
-
-                                                    //locate last and minimum \
                values.
-                                                    double lastValue = -1;
-                                                    double minValue = \
                Double.MAX_VALUE;//
-                                                    for \
                (MeasurementDataNumericHighLowComposite d : data) {
-                                                        if \
                ((!Double.isNaN(d.getValue()))
-                                                            && \
                (!String.valueOf(d.getValue()).contains("NaN"))) {
-                                                            if (d.getValue() < \
                minValue) {
-                                                                minValue = \
d.getValue(); +                                            @Override
+                                            public void onSuccess(
+                                                \
List<List<MeasurementDataNumericHighLowComposite>> results) { +                       \
if (!results.isEmpty()) { +                                                    \
boolean someChartedData = false; +                                                    \
//iterate over the retrieved charting data +                                          \
for (int index = 0; index < displayOrder.length; index++) { +                         \
//retrieve the correct measurement definition +                                       \
final MeasurementDefinition md = measurementDefMap +                                  \
.get(displayOrder[index]); +
+                                                        //load the data results for \
the given metric definition +                                                        \
List<MeasurementDataNumericHighLowComposite> data = results +                         \
.get(index); +
+                                                        //locate last and minimum \
values. +                                                        double lastValue = \
-1; +                                                        double minValue = \
Double.MAX_VALUE;// +                                                        for \
(MeasurementDataNumericHighLowComposite d : data) { +                                 \
if ((!Double.isNaN(d.getValue())) +                                                   \
&& (!String.valueOf(d.getValue()).contains("NaN"))) { +                               \
if (d.getValue() < minValue) { +                                                      \
minValue = d.getValue(); +                                                            \
} +                                                                lastValue = \
d.getValue();  }
-                                                            lastValue = \
d.getValue();  }
-                                                    }
 
-                                                    //collapse the data into comma \
                delimited list for consumption by third party javascript \
                library(jquery.sparkline)
-                                                    String commaDelimitedList = "";
+                                                        //collapse the data into \
comma delimited list for consumption by third party javascript \
library(jquery.sparkline) +                                                        \
String commaDelimitedList = "";  
-                                                    for \
                (MeasurementDataNumericHighLowComposite d : data) {
-                                                        if \
                ((!Double.isNaN(d.getValue()))
-                                                            && \
                (!String.valueOf(d.getValue()).contains("NaN"))) {
-                                                            commaDelimitedList += \
                d.getValue() + ",";
-                                                        }
-                                                    }
-                                                    DynamicForm row = new \
                DynamicForm();
-                                                    row.setNumCols(3);
-                                                    row.setColWidths(65, "*", 100);
-                                                    row.setWidth100();
-                                                    row.setAutoHeight();
-                                                    \
                row.setOverflow(Overflow.VISIBLE);
-                                                    HTMLFlow sparklineGraph = new \
                HTMLFlow();
-                                                    String contents = "<span \
                id='sparkline_" + index
-                                                        + "' \
                class='dynamicsparkline' width='0' " + "values='"
-                                                        + commaDelimitedList + \
                "'>...</span>";
-                                                    \
                sparklineGraph.setContents(contents);
-                                                    \
                sparklineGraph.setContentsType(ContentsType.PAGE);
-                                                    //disable scrollbars on span
-                                                    \
                sparklineGraph.setScrollbarSize(0);
-
-                                                    CanvasItem sparklineContainer = \
                new CanvasItem();
-                                                    \
                sparklineContainer.setShowTitle(false);
-                                                    \
                sparklineContainer.setHeight(16);
-                                                    sparklineContainer.setWidth(60);
-                                                    \
                sparklineContainer.setCanvas(sparklineGraph);
-
-                                                    //Link/title element
-                                                    final String title = \
                md.getDisplayName();
-                                                    LinkItem link = \
                AbstractActivityView.newLinkItem(title, null);
-                                                    link.setTooltip(title);
-                                                    \
                link.setTitleVAlign(VerticalAlignment.TOP);
-                                                    link.setAlign(Alignment.LEFT);
-                                                    link.setClipValue(true);
-                                                    link.setWrap(true);
-                                                    link.setHeight(26);
-                                                    link.setWidth("100%");
-                                                    \
                if(!BrowserUtility.isBrowserPreIE9()){
-                                                        link.addClickHandler(new \
                ClickHandler() {
-                                                            @Override
-                                                            public void \
                onClick(ClickEvent event) {
-                                                                window = new \
                ChartViewWindow(title);
-
-                                                                graphView = \
                D3GraphListView
-                                                                    \
                .createSingleGraph(resourceComposite.getResource(),
-                                                                        md.getId(), \
                true);
-
-                                                                \
                window.addItem(graphView);
-                                                                window.show();
+                                                        for \
(MeasurementDataNumericHighLowComposite d : data) { +                                 \
if ((!Double.isNaN(d.getValue())) +                                                   \
&& (!String.valueOf(d.getValue()).contains("NaN"))) { +                               \
commaDelimitedList += d.getValue() + ",";  }
-                                                        });
-                                                    }else{
-                                                        link.disable();
-                                                    }
-
-
-                                                    //Value
-                                                    String convertedValue;
-                                                    convertedValue = \
                AbstractActivityView.convertLastValueForDisplay(
-                                                        lastValue, md);
-                                                    StaticTextItem value = \
                AbstractActivityView
-                                                        \
                .newTextItem(convertedValue);
-                                                    \
                value.setVAlign(VerticalAlignment.TOP);
-                                                    value.setAlign(Alignment.RIGHT);
+                                                        }
+                                                        DynamicForm row = new \
DynamicForm(); +                                                        \
row.setNumCols(3); +                                                        \
row.setColWidths(65, "*", 100); +                                                     \
row.setWidth100(); +                                                        \
row.setAutoHeight(); +                                                        \
row.setOverflow(Overflow.VISIBLE); +                                                  \
HTMLFlow sparklineGraph = new HTMLFlow(); +                                           \
String contents = "<span id='sparkline_" + index +                                    \
+ "' class='dynamicsparkline' width='0' " + "values='" +                              \
+ commaDelimitedList + "'>...</span>"; +                                              \
sparklineGraph.setContents(contents); +                                               \
sparklineGraph.setContentsType(ContentsType.PAGE); +                                  \
//disable scrollbars on span +                                                        \
sparklineGraph.setScrollbarSize(0); +
+                                                        CanvasItem \
sparklineContainer = new CanvasItem(); +                                              \
sparklineContainer.setShowTitle(false); +                                             \
sparklineContainer.setHeight(16); +                                                   \
sparklineContainer.setWidth(60); +                                                    \
sparklineContainer.setCanvas(sparklineGraph); +
+                                                        //Link/title element
+                                                        final String title = \
md.getDisplayName(); +                                                        \
LinkItem link = AbstractActivityView.newLinkItem(title, null); +                      \
link.setTooltip(title); +                                                        \
link.setTitleVAlign(VerticalAlignment.TOP); +                                         \
link.setAlign(Alignment.LEFT); +                                                      \
link.setClipValue(true); +                                                        \
link.setWrap(true); +                                                        \
link.setHeight(26); +                                                        \
link.setWidth("100%"); +                                                        if \
(!BrowserUtility.isBrowserPreIE9()) { +                                               \
link.addClickHandler(new ClickHandler() { +                                           \
@Override +                                                                public \
void onClick(ClickEvent event) { +                                                    \
window = new ChartViewWindow(title); +
+                                                                    graphView = \
D3GraphListView.createSingleGraph( +                                                  \
resourceComposite.getResource(), md.getId(), +                                        \
true); +
+                                                                    \
window.addItem(graphView); +                                                          \
window.show(); +                                                                }
+                                                            });
+                                                        } else {
+                                                            link.disable();
+                                                        }
 
-                                                    row.setItems(sparklineContainer, \
                link, value);
-                                                    row.setWidth100();
+                                                        //Value
+                                                        String convertedValue;
+                                                        convertedValue = \
AbstractActivityView +                                                            \
.convertLastValueForDisplay(lastValue, md); +                                         \
StaticTextItem value = AbstractActivityView +                                         \
.newTextItem(convertedValue); +                                                       \
value.setVAlign(VerticalAlignment.TOP); +                                             \
value.setAlign(Alignment.RIGHT); +
+                                                        \
row.setItems(sparklineContainer, link, value); +                                      \
row.setWidth100(); +
+                                                        //if graph content returned
+                                                        if \
((!md.getName().trim().contains("Trait.")) +                                          \
&& (lastValue != -1)) { +                                                            \
column.addMember(row); +                                                            \
someChartedData = true; +                                                        }
+                                                    }
+                                                    if (!someChartedData) {// when \
there are results but no chartable entries. +                                         \
DynamicForm row = AbstractActivityView.createEmptyDisplayRow(  
-                                                    //if graph content returned
-                                                    if \
((!md.getName().trim().contains("Trait.")) && (lastValue != -1)) { +                  \
                AbstractActivityView.RECENT_MEASUREMENTS_NONE);
                                                         column.addMember(row);
-                                                        someChartedData = true;
+                                                    } else {
+                                                        //insert see more link
+                                                        DynamicForm row = new \
DynamicForm(); +                                                        String link = \
LinkManager +                                                            \
.getResourceMonitoringGraphsLink(resourceId); +                                       \
AbstractActivityView.addSeeMoreLink(row, link, column);  }
-                                                }
-                                                if (!someChartedData) {// when there \
                are results but no chartable entries.
-                                                    DynamicForm row = \
                AbstractActivityView.createEmptyDisplayRow(
-
-                                                    \
                AbstractActivityView.RECENT_MEASUREMENTS_NONE);
-                                                    column.addMember(row);
+                                                    //call out to 3rd party \
javascript lib +                                                    new Timer() {
+                                                        @Override
+                                                        public void run() {
+                                                            \
BrowserUtility.graphSparkLines(); +                                                   \
} +                                                    }.schedule(200);
                                                 } else {
-                                                    //insert see more link
-                                                    DynamicForm row = new \
                DynamicForm();
-                                                    String link = LinkManager
-                                                        \
                .getResourceMonitoringGraphsLink(resourceId);
-                                                    \
AbstractActivityView.addSeeMoreLink(row, link, column); +                             \
DynamicForm row = AbstractActivityView +                                              \
.createEmptyDisplayRow(AbstractActivityView.RECENT_MEASUREMENTS_NONE); +              \
column.addMember(row);  }
-                                                //call out to 3rd party javascript \
                lib
-                                                new Timer(){
-                                                    @Override
-                                                    public void run() {
-                                                        \
                BrowserUtility.graphSparkLines();
-                                                    }
-                                                }.schedule(200);
-                                            } else {
-                                                DynamicForm row = \
                AbstractActivityView
-                                                    \
                .createEmptyDisplayRow(AbstractActivityView.RECENT_MEASUREMENTS_NONE);
                
-                                                column.addMember(row);
+                                                setRefreshing(false);
                                             }
-                                            setRefreshing(false);
                                         }
-                                    };
-
-                                    //make the asynchronous call for all the \
                measurement data
-                                    if (end != -1 && start != -1) {
-                                        \
                GWTServiceLookup.getMeasurementDataService().findDataForResource(resourceId,
                
-                                            definitionArrayIds, start, end, 60, \
                callback);
-                                    } else if (lastN != -1 && units != -1) {
-                                        \
                GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(
                
-                                            resourceId, definitionArrayIds, lastN, \
                units, 60, callback);
-                                    } else {
-                                        \
                GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(
                
-                                            resourceId, definitionArrayIds, 8, \
                MeasurementUtility.UNIT_HOURS, 60,
-                                            callback);
-                                    }
+
+                                    );
+
                                 }
                             });
                     }


_______________________________________________
rhq-commits mailing list
rhq-commits@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/rhq-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic