From 6c1818d544bdb0d278e42da217e4c308702db085 Mon Sep 17 00:00:00 2001 From: Dustin Johnson Date: Tue, 22 Jan 2013 15:11:17 -0600 Subject: [PATCH 01/13] Issue #1519 Fix max latency calculations for adhoc queries Amend: Peer review comments. Change-Id: Ifa76b145616d8fdcf4ba41cd3744cfc3991b902c Former-commit-id: e9d88236907b98f7e461807592e580bdf1ecedb9 --- .../GriddedTimingSelectionPresenter.java | 30 ++------ .../datadelivery/utils/DataDeliveryUtils.java | 60 +++++++++++++--- .../datadelivery/utils/DataSetFrequency.java | 21 ++++-- .../uf/common/time/util/TimeUtil.java | 16 ++++- .../OpenDapGriddedDataSetFixture.java | 1 + .../utils/DataDeliveryUtilsTest.java | 68 ++++++++++++++++--- 6 files changed, 143 insertions(+), 53 deletions(-) diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/subset/presenter/GriddedTimingSelectionPresenter.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/subset/presenter/GriddedTimingSelectionPresenter.java index 29cefc9159..e7ab74b795 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/subset/presenter/GriddedTimingSelectionPresenter.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/subset/presenter/GriddedTimingSelectionPresenter.java @@ -19,8 +19,8 @@ **/ package com.raytheon.uf.viz.datadelivery.subscription.subset.presenter; -import java.util.ArrayList; -import java.util.Collections; +import static com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.getMaxLatency; + import java.util.List; import com.google.common.annotations.VisibleForTesting; @@ -44,6 +44,7 @@ import com.raytheon.viz.ui.presenter.components.ListConf; * Sep 27, 2012 1202 bgonzale Set selectionDate to date and cycle. * Oct 11, 2012 1263 jpiatt Modified for cancel flag. * Jan 04, 2013 1420 mpduff Add the dataset object. + * Jan 22, 2013 1519 djohnson Use DataDeliveryUtils.getMaxLatency(). * * * @@ -173,7 +174,7 @@ public class GriddedTimingSelectionPresenter { } DataDeliveryGUIUtils.latencyValidChk(view.getLatency(), - getMaxLatency()); + getMaxLatency(dataSet)); // parse off the date/cycle time selected String[] parts = selection.split(" - "); @@ -188,29 +189,6 @@ public class GriddedTimingSelectionPresenter { return true; } - /** - * Max latency value in minutes. - * - * @return - */ - private int getMaxLatency() { - List cycleList = new ArrayList(dataSet.getCycles()); - Collections.sort(cycleList); - - int max = 0; - - for (int i = 0; i < cycleList.size(); i++) { - if (i + 1 <= cycleList.size()) { - int tempMax = cycleList.get(i + 1) - cycleList.get(i); - if (tempMax > max) { - max = tempMax; - } - } - } - - return max * 60; - } - /** * This method is called via the "Use Latest Data" checkbox being * selected/unselected. diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataDeliveryUtils.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataDeliveryUtils.java index 4c6a91e566..ccca8f2a19 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataDeliveryUtils.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataDeliveryUtils.java @@ -32,6 +32,7 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.datadelivery.registry.Coverage; import com.raytheon.uf.common.datadelivery.registry.DataLevelType; +import com.raytheon.uf.common.datadelivery.registry.GriddedDataSet; import com.raytheon.uf.common.datadelivery.registry.Parameter; import com.raytheon.uf.common.datadelivery.registry.Subscription; import com.raytheon.uf.common.datadelivery.registry.Time; @@ -57,10 +58,11 @@ import com.vividsolutions.jts.geom.Coordinate; * Jul 25, 2012 955 djohnson Use List instead of ArrayList, thread-safe access to DecimalFormat. * Aug 29, 2012 223 mpduff Add cycles to the subscription details. * Oct 31, 2012 1278 mpduff Moved spatial methods to SpatialUtils. - * Nov 20, 2012 1286 djohnson Add showYesNoMessage. - * Dec 20, 2012 1413 bgonzale Added PendingSubColumnNames.valueOfColumnName(String). - * Jan 10, 2013 1420 mdpuff Added getMaxLatency(). + * Nov 20, 2012 1286 djohnson Add showYesNoMessage. + * Dec 20, 2012 1413 bgonzale Added PendingSubColumnNames.valueOfColumnName(String). + * Jan 10, 2013 1420 mdpuff Added getMaxLatency(). * Jan 14, 2013 1286 djohnson Fix IndexOutOfBounds exception from getMaxLatency. + * Jan 22, 2013 1519 djohnson Correct getMaxLatency() calculations. * * * @author mpduff @@ -69,6 +71,18 @@ import com.vividsolutions.jts.geom.Coordinate; public class DataDeliveryUtils { + /** + * Default latency applied to hourly datasets. + */ + public static final int HOURLY_DATASET_LATENCY_IN_MINUTES = 40; + + /** + * Default latency applied non-hourly datasets. + */ + public static final int NON_HOURLY_DATASET_LATENCY_IN_MINUTES = 75; + + private static final int UNSET = -1; + /** Decimal format */ private final static ThreadLocal format = new ThreadLocal() { @@ -551,20 +565,48 @@ public class DataDeliveryUtils { * @return the maximum latency in minutes */ public static int getMaxLatency(Subscription subscription) { - List cycles = subscription.getTime().getCycleTimes(); + return getMaxLatency(subscription.getTime().getCycleTimes()); + } + + /** + * Get the maximum latency for the provided cycles. Calculated as the + * maximum cyclic difference. + * + * @param cycles + * The list of cycles + * @return the maximum latency in minutes + */ + public static int getMaxLatency(List cycles) { Collections.sort(cycles); - int max = TimeUtil.HOURS_PER_DAY * TimeUtil.MINUTES_PER_HOUR; + int maximumTimeBetweenCycles = UNSET; final int size = cycles.size(); for (int i = 0; i < size; i++) { final int nextIndex = i + 1; if (nextIndex < size) { int tempMax = cycles.get(nextIndex) - cycles.get(i); - if (tempMax > max) { - max = tempMax; - } + maximumTimeBetweenCycles = Math.max(maximumTimeBetweenCycles, tempMax); } } - return max; + + // If there was only one cycle, then default to the number of minutes in + // the day + if (maximumTimeBetweenCycles == UNSET) { + maximumTimeBetweenCycles = TimeUtil.HOURS_PER_DAY; + } + + return maximumTimeBetweenCycles * TimeUtil.MINUTES_PER_HOUR; + } + + /** + * Get the maximum latency for the provided dataSet. Calculated as the + * maximum cyclic difference. + * + * @param dataSet + * the dataset + * @return the maximum latency in minutes + */ + public static int getMaxLatency(GriddedDataSet dataSet) { + return getMaxLatency(new ArrayList(dataSet.getCycles())); } } diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataSetFrequency.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataSetFrequency.java index e655eec99e..70d49d782c 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataSetFrequency.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataSetFrequency.java @@ -21,6 +21,8 @@ package com.raytheon.uf.viz.datadelivery.utils; import java.util.List; +import com.raytheon.uf.common.time.util.TimeUtil; + /** * Data Set Frequency Enumeration. * @@ -30,7 +32,8 @@ import java.util.List; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jan 8, 2013 1420 mpduff Initial creation. + * Jan 08, 2013 1420 mpduff Initial creation. + * Jan 22, 2013 1519 djohnson Correct the non-hourly default latency to match requirements. * * * @@ -39,8 +42,11 @@ import java.util.List; */ public enum DataSetFrequency { - HOURLY(40), SIX_HOURLY(115), TWELVE_HOURLY(115), DAILY(115); - + HOURLY(DataDeliveryUtils.HOURLY_DATASET_LATENCY_IN_MINUTES), SIX_HOURLY( + DataDeliveryUtils.NON_HOURLY_DATASET_LATENCY_IN_MINUTES), TWELVE_HOURLY( + DataDeliveryUtils.NON_HOURLY_DATASET_LATENCY_IN_MINUTES), DAILY( + DataDeliveryUtils.NON_HOURLY_DATASET_LATENCY_IN_MINUTES); + private int defaultLatency; private DataSetFrequency(int defaultLatency) { @@ -49,13 +55,14 @@ public enum DataSetFrequency { public static DataSetFrequency fromCycleTimes(List cycleTimes) { if (cycleTimes.size() > 1) { - if ((cycleTimes.get(1) - cycleTimes.get(0)) == 1) { + final int hoursBetweenCycles = cycleTimes.get(1) - cycleTimes.get(0); + if (hoursBetweenCycles == 1) { return DataSetFrequency.HOURLY; - } else if ((cycleTimes.get(1) - cycleTimes.get(0)) == 6) { + } else if (hoursBetweenCycles == TimeUtil.HOURS_PER_QUARTER_DAY) { return DataSetFrequency.SIX_HOURLY; - } else if ((cycleTimes.get(1) - cycleTimes.get(0)) == 12) { + } else if (hoursBetweenCycles == TimeUtil.HOURS_PER_HALF_DAY) { return DataSetFrequency.TWELVE_HOURLY; - } else if ((cycleTimes.get(1) - cycleTimes.get(0)) == 24) { + } else if (hoursBetweenCycles == TimeUtil.HOURS_PER_DAY) { return DataSetFrequency.DAILY; } } diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java index aa760e8c2a..d7555357a5 100644 --- a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java @@ -45,14 +45,14 @@ import com.raytheon.uf.common.time.domain.api.ITimePoint; * Nov 21, 2012 728 mpduff Added MILLIS_PER_MONTH. * Jan 07, 2013 1451 djohnson Add newGmtCalendar() and time constants. * Jan 22, 2013 1484 mpduff Add HOURS_PER_WEEK. + * Jan 22, 2013 1519 djohnson Add MINUTES_PER_DAY. * * * * @author njensen * @version 1.0 */ - -public class TimeUtil { +public final class TimeUtil { /** * A clock that does not really return the current time. Useful when you @@ -97,6 +97,12 @@ public class TimeUtil { public static final int HOURS_PER_DAY = 24; + public static final int HOURS_PER_HALF_DAY = HOURS_PER_DAY / 2; + + public static final int HOURS_PER_QUARTER_DAY = HOURS_PER_HALF_DAY / 2; + + public static final int MINUTES_PER_DAY = MINUTES_PER_HOUR * HOURS_PER_DAY; + private static final int DAYS_PER_WEEK = 7; public static final int HOURS_PER_WEEK = HOURS_PER_DAY * DAYS_PER_WEEK; @@ -385,4 +391,10 @@ public class TimeUtil { } return calendar; } + + /** + * Disabled constructor. + */ + private TimeUtil() { + } } diff --git a/tests/unit/com/raytheon/uf/common/datadelivery/registry/OpenDapGriddedDataSetFixture.java b/tests/unit/com/raytheon/uf/common/datadelivery/registry/OpenDapGriddedDataSetFixture.java index 12c01faea7..1e522d47ca 100644 --- a/tests/unit/com/raytheon/uf/common/datadelivery/registry/OpenDapGriddedDataSetFixture.java +++ b/tests/unit/com/raytheon/uf/common/datadelivery/registry/OpenDapGriddedDataSetFixture.java @@ -76,6 +76,7 @@ public class OpenDapGriddedDataSetFixture extends obj.setDataSetName("dataSetName" + seedValue); obj.setDataSetType(DataType.GRID); obj.setForecastHours(CollectionUtil.asSet(0)); + obj.setTime(TimeFixture.INSTANCE.get(seedValue)); // TODO: ParameterFixture obj.setParameters(Collections. emptyMap()); obj.setProviderName(ProviderFixture.INSTANCE.get(seedValue).getName()); diff --git a/tests/unit/com/raytheon/uf/viz/datadelivery/utils/DataDeliveryUtilsTest.java b/tests/unit/com/raytheon/uf/viz/datadelivery/utils/DataDeliveryUtilsTest.java index 1af63c3f8b..afb47cae91 100644 --- a/tests/unit/com/raytheon/uf/viz/datadelivery/utils/DataDeliveryUtilsTest.java +++ b/tests/unit/com/raytheon/uf/viz/datadelivery/utils/DataDeliveryUtilsTest.java @@ -20,17 +20,23 @@ package com.raytheon.uf.viz.datadelivery.utils; import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Sets.newHashSet; +import static org.junit.Assert.assertEquals; import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; import org.junit.Test; +import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSet; +import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSetFixture; import com.raytheon.uf.common.datadelivery.registry.Subscription; import com.raytheon.uf.common.datadelivery.registry.SubscriptionFixture; import com.raytheon.uf.common.datadelivery.registry.Time; /** - * TODO Add Description + * Test {@link DataDeliveryUtils}. * *
  * 
@@ -39,31 +45,75 @@ import com.raytheon.uf.common.datadelivery.registry.Time;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Jan 14, 2013 1286       djohnson     Initial creation
+ * Jan 22, 2013 1519       djohnson     Add tests for getMaxLatency calculations.
  * 
  * 
* * @author djohnson * @version 1.0 */ - public class DataDeliveryUtilsTest { - /** - * The method was throwing {@link IndexOutOfBoundsException}, this will - * prevent that regression. - */ + // These constants are not using TimeUtil to make sure we get a + // "second opinion" when using TimeUtil in the code under test + private static final long THREE_HOURS_AS_MINUTES = TimeUnit.HOURS + .toMinutes(3); + + private static final long MINUTES_PER_DAY = TimeUnit.DAYS.toMinutes(1); + @Test - public void testMaxLatencyDoesntOverrunListIndex() { + public void maxLatencyReturnsMaxCyclicDifferenceForSubscribedToCycles() { List cycleTimes = newArrayList(); cycleTimes.add(0); cycleTimes.add(1); - cycleTimes.add(2); + cycleTimes.add(4); Subscription subscription = SubscriptionFixture.INSTANCE.get(); Time subTime = subscription.getTime(); subTime.setCycleTimes(cycleTimes); - DataDeliveryUtils.getMaxLatency(subscription); + assertEquals(THREE_HOURS_AS_MINUTES, + DataDeliveryUtils.getMaxLatency(subscription)); + } + + @Test + public void maxLatencyDefaultsToOneDayForSubscriptionWithOneCycle() { + List cycleTimes = newArrayList(); + cycleTimes.add(0); + + Subscription subscription = SubscriptionFixture.INSTANCE.get(); + Time subTime = subscription.getTime(); + subTime.setCycleTimes(cycleTimes); + + assertEquals(MINUTES_PER_DAY, + DataDeliveryUtils.getMaxLatency(subscription)); + } + + @Test + public void maxLatencyForDataSetWithOneCycleDefaultsToOneDay() { + Set cycleTimes = newHashSet(); + cycleTimes.add(0); + + OpenDapGriddedDataSet dataset = OpenDapGriddedDataSetFixture.INSTANCE + .get(); + dataset.setCycles(cycleTimes); + + assertEquals(MINUTES_PER_DAY, DataDeliveryUtils.getMaxLatency(dataset)); + } + + @Test + public void maxLatencyForDataSetWithMultipleCyclesReturnsMaxCyclicDifference() { + Set cycleTimes = newHashSet(); + cycleTimes.add(0); + cycleTimes.add(1); + cycleTimes.add(4); + + OpenDapGriddedDataSet dataset = OpenDapGriddedDataSetFixture.INSTANCE + .get(); + dataset.setCycles(cycleTimes); + + assertEquals(THREE_HOURS_AS_MINUTES, + DataDeliveryUtils.getMaxLatency(dataset)); } } From ddcd0f82227245bf1d177554189b74dd75498ab4 Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Wed, 23 Jan 2013 08:13:35 -0600 Subject: [PATCH 02/13] Issue #1520 - Change delete notifications to hide. Remove accelerators Change-Id: I2954c1324cbdf1bc4e5577925dbcd10e5faa6156 Former-commit-id: 0378ff80cc3592379ec3d49efc895adafa05109a --- .../notification/NotificationDlg.java | 49 ++++++++-------- .../notification/NotificationTableComp.java | 57 ++++++++++--------- .../subscription/SubscriptionManagerDlg.java | 49 ++++++++-------- 3 files changed, 80 insertions(+), 75 deletions(-) diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/notification/NotificationDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/notification/NotificationDlg.java index 2342df35d2..602302293e 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/notification/NotificationDlg.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/notification/NotificationDlg.java @@ -95,6 +95,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Oct 22, 2012 1284 mpduff Code Cleanup. * Dec 03, 2012 1285 bgonzale Added implementation of the tableLock method. * Update title bar text when paused. + * Jan 22, 2013 1520 mpduff Change delete menus to hide. * * * @@ -272,7 +273,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, MenuItem setDefaultMI = new MenuItem(fileMenu, SWT.NONE); lockableMenuItems.add(setDefaultMI); - setDefaultMI.setText("&Set as Default"); + setDefaultMI.setText("Set as Default"); setDefaultMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -282,7 +283,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, MenuItem loadConfigMI = new MenuItem(fileMenu, SWT.NONE); lockableMenuItems.add(loadConfigMI); - loadConfigMI.setText("&Load Configuration..."); + loadConfigMI.setText("Load Configuration..."); loadConfigMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -298,7 +299,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, MenuItem saveConfigMI = new MenuItem(fileMenu, SWT.NONE); lockableMenuItems.add(saveConfigMI); - saveConfigMI.setText("&Save Configuration"); + saveConfigMI.setText("Save Configuration"); saveConfigMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -308,7 +309,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, MenuItem saveConfigAsMI = new MenuItem(fileMenu, SWT.NONE); lockableMenuItems.add(saveConfigAsMI); - saveConfigAsMI.setText("&Save Configuration As..."); + saveConfigAsMI.setText("Save Configuration As..."); saveConfigAsMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -318,7 +319,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, MenuItem deleteConfigMI = new MenuItem(fileMenu, SWT.NONE); lockableMenuItems.add(deleteConfigMI); - deleteConfigMI.setText("&Delete Configuration..."); + deleteConfigMI.setText("Delete Configuration..."); deleteConfigMI.addSelectionListener(new SelectionAdapter() { @Override @@ -330,7 +331,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, new MenuItem(fileMenu, SWT.SEPARATOR); MenuItem exitMI = new MenuItem(fileMenu, SWT.NONE); - exitMI.setText("&Exit"); + exitMI.setText("Exit"); exitMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -348,7 +349,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, // Find Menu MenuItem findMI = new MenuItem(editMenu, SWT.CASCADE); lockableMenuItems.add(findMI); - findMI.setText("&Find..."); + findMI.setText("Find..."); findMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -356,10 +357,10 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, } }); - MenuItem delPriorityMI = new MenuItem(editMenu, SWT.CASCADE); - lockableMenuItems.add(delPriorityMI); - delPriorityMI.setText("&Delete by Priority"); - delPriorityMI.addSelectionListener(new SelectionAdapter() { + MenuItem hidePriorityMI = new MenuItem(editMenu, SWT.CASCADE); + lockableMenuItems.add(hidePriorityMI); + hidePriorityMI.setText("Hide by Priority"); + hidePriorityMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -367,14 +368,14 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, }); Menu subMenu = new Menu(menuBar); - delPriorityMI.setMenu(subMenu); + hidePriorityMI.setMenu(subMenu); createPriorityMenus(subMenu); - MenuItem deleteOlderMI = new MenuItem(editMenu, SWT.NONE); - lockableMenuItems.add(deleteOlderMI); - deleteOlderMI.setText("&Delete Older Than Selected"); - deleteOlderMI.addSelectionListener(new SelectionAdapter() { + MenuItem hideOlderMI = new MenuItem(editMenu, SWT.NONE); + lockableMenuItems.add(hideOlderMI); + hideOlderMI.setText("Hide Older Than Selected"); + hideOlderMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { tableComp.handleDeleteOlderThan(); @@ -382,10 +383,10 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, }); - MenuItem deleteMI = new MenuItem(editMenu, SWT.NONE); - lockableMenuItems.add(deleteMI); - deleteMI.setText("&Delete Notification(s)"); - deleteMI.addSelectionListener(new SelectionAdapter() { + MenuItem hideMI = new MenuItem(editMenu, SWT.NONE); + lockableMenuItems.add(hideMI); + hideMI.setText("Hide Notification(s)"); + hideMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { tableComp.handleDeleteNotification(); @@ -401,7 +402,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, MenuItem configureMI = new MenuItem(settingsMenu, SWT.NONE); lockableMenuItems.add(configureMI); - configureMI.setText("&Configure Table..."); + configureMI.setText("Configure Table..."); configureMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -411,7 +412,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, MenuItem filterMI = new MenuItem(settingsMenu, SWT.NONE); lockableMenuItems.add(filterMI); - filterMI.setText("&Filter Table..."); + filterMI.setText("Filter Table..."); filterMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -420,7 +421,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, }); tooltipMI = new MenuItem(settingsMenu, SWT.CHECK); - tooltipMI.setText("&Tooltips"); + tooltipMI.setText("Tooltips"); tooltipMI.setSelection(false); tooltipMI.addSelectionListener(new SelectionAdapter() { @Override @@ -438,7 +439,7 @@ public class NotificationDlg extends CaveSWTDialog implements ITableChange, helpMenuItem.setMenu(helpMenu); MenuItem helpNotTableMI = new MenuItem(helpMenu, SWT.NONE); - helpNotTableMI.setText("&About Notification Center..."); + helpNotTableMI.setText("About Notification Center..."); helpNotTableMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/notification/NotificationTableComp.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/notification/NotificationTableComp.java index 20373b8bdc..2be48e7781 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/notification/NotificationTableComp.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/notification/NotificationTableComp.java @@ -75,7 +75,7 @@ import com.raytheon.uf.viz.datadelivery.utils.NotificationHandler; * Sep 06, 2012 687 mpduff Call the table selection method of the ITableChanged interface. * Oct 22, 2012 1284 mpduff Fix the start/end index for pagination of new records, code cleanup. * Nov 29, 2012 1285 bgonzale Added a refresh pause button to the Notification Center Dialog. - * + * Jan 22, 2013 1520 mpduff Update javadoc. * * * @author lvenable @@ -197,12 +197,12 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Constructor. - * + * * Note: For the super class we are passing in a false for the notification * flag. This is turned off because the notification dialog is using the * NotificationHandler and it contains the necessary code that needs to be * executed. - * + * * @param parent * @param tableConfig * @param callback @@ -287,6 +287,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { + " not refresh, re-sort, or allow user modification" + " until unchecked."); pauseButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { boolean isLocked = pauseButton.getSelection(); @@ -320,7 +321,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Get the entire table list. - * + * * @return TableDataManager obj */ public TableDataManager getMasterTableList() { @@ -329,7 +330,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Get the table list with filters applied. - * + * * @return TableDataManager obj */ public TableDataManager getFilteredTableList() { @@ -338,7 +339,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Get the table list for display. - * + * * @return TableDataManager obj */ public ArrayList getVisibleTableList() { @@ -347,7 +348,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Get the rows of data to display. - * + * * @return list of Notification Row Data objects */ private ArrayList getTableRows() { @@ -359,7 +360,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { // Recalculate start/end indices for visible page if (numRows > endIndex && endIndex - startIndex < pageConfig) { - endIndex = startIndex + pageConfig - 1;//numRows -1; + endIndex = startIndex + pageConfig - 1;// numRows -1; if (endIndex - startIndex > pageConfig - 1) { startIndex = ((pageConfig * selectedPage) - (pageConfig - 1)) - 1; } @@ -390,7 +391,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Delete table rows. - * + * * @param deleteRecordIds */ public void deleteTableDataRows(ArrayList deleteRecordIds) { @@ -408,7 +409,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Get the table obj. - * + * * @return the table obj. */ public Table getTable() { @@ -432,7 +433,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { } /** - * Action taken when deleting a notification. + * Action taken when deleting a notification from view. */ public void handleDeleteNotification() { @@ -472,7 +473,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Action taken when tool tip is selected. - * + * * @param showToolTips * true when tooltips are on */ @@ -612,7 +613,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { } /** - * Action taken when deleted notifications by time. + * Action taken when deleted notifications from view by time. */ public void handleDeleteOlderThan() { @@ -689,8 +690,8 @@ public class NotificationTableComp extends TableComp implements ITableFind { } /** - * Action taken to delete notifications by priority. - * + * Action taken to delete notifications from view by priority. + * * @param priority * priority indicator */ @@ -726,7 +727,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Get the start index. - * + * * @return start index */ public int getStartIndex() { @@ -735,7 +736,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Get the end index. - * + * * @return end index */ public int getEndIndex() { @@ -744,7 +745,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Get the selected index. - * + * * @return selected index */ public int getSelectedIndex() { @@ -753,7 +754,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Get the table cell text. - * + * * @param name * The column name * @param rd @@ -782,7 +783,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Populate the NotificationRowData objects - * + * * @param notificationRecords * list of notification records */ @@ -857,7 +858,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Pass filter information. - * + * * @param username * user name table data * @param priority @@ -915,11 +916,11 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Pass filter information. - * + * * @param records * Notification record * @return boolean true if passes filter - * + * */ public boolean passesFilter(List records) { for (NotificationRecord record : records) { @@ -933,10 +934,10 @@ public class NotificationTableComp extends TableComp implements ITableFind { /** * Get the column data. - * + * * @param colName * The column name of interest - * + * * @return The populated ColumnXML object */ private ColumnXML getColumnData(String colName) { @@ -1144,7 +1145,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /* * (non-Javadoc) - * + * * @see * com.raytheon.uf.viz.datadelivery.common.ui.TableComp#handleTableMouseClick * (org.eclipse.swt.events.MouseEvent) @@ -1156,7 +1157,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /* * (non-Javadoc) - * + * * @see com.raytheon.uf.viz.datadelivery.common.ui.TableComp# * handleTableSelectionChange(org.eclipse.swt.events.SelectionEvent) */ @@ -1169,7 +1170,7 @@ public class NotificationTableComp extends TableComp implements ITableFind { /* * (non-Javadoc) - * + * * @see com.raytheon.uf.viz.core.notification.INotificationObserver# * notificationArrived * (com.raytheon.uf.viz.core.notification.NotificationMessage[]) diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionManagerDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionManagerDlg.java index e3ec6a4950..d7ce4442f9 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionManagerDlg.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionManagerDlg.java @@ -114,6 +114,7 @@ import com.raytheon.viz.ui.presenter.IDisplay; * and SubscriptionConfigurationManager. * Jan 21, 2013 1501 djohnson Only send notification if subscription was actually activated/deactivated, * remove race condition of GUI thread updating the table after notification. + * Jan 22, 2013 1520 mpduff Removed menu accelerators. * * * @author mpduff @@ -317,7 +318,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements fileMenuItem.setMenu(fileMenu); MenuItem newMI = new MenuItem(fileMenu, SWT.NONE); - newMI.setText("&New Subscription..."); + newMI.setText("New Subscription..."); newMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -326,7 +327,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements }); MenuItem groupMI = new MenuItem(fileMenu, SWT.NONE); - groupMI.setText("&New Group..."); + groupMI.setText("New Group..."); groupMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -358,7 +359,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements new MenuItem(fileMenu, SWT.SEPARATOR); MenuItem exitMI = new MenuItem(fileMenu, SWT.NONE); - exitMI.setText("&Exit"); + exitMI.setText("Exit"); exitMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -376,7 +377,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements settingsMenuItem.setMenu(settingsMenu); MenuItem configureMI = new MenuItem(settingsMenu, SWT.NONE); - configureMI.setText("&Configure Table..."); + configureMI.setText("Configure Table..."); configureMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -385,7 +386,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements }); tooltipMI = new MenuItem(settingsMenu, SWT.CHECK); - tooltipMI.setText("&Tooltips"); + tooltipMI.setText("Tooltips"); tooltipMI.setSelection(false); tooltipMI.addSelectionListener(new SelectionAdapter() { @Override @@ -403,7 +404,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements helpMenuItem.setMenu(helpMenu); MenuItem helpNotTableMI = new MenuItem(helpMenu, SWT.NONE); - helpNotTableMI.setText("&About Subscription Manager..."); + helpNotTableMI.setText("About Subscription Manager..."); helpNotTableMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -423,7 +424,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements editMenuItem.setMenu(editMenu); MenuItem editMI = new MenuItem(editMenu, SWT.NONE); - editMI.setText("&Edit Subscription..."); + editMI.setText("Edit Subscription..."); editMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -432,7 +433,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements }); MenuItem copyMI = new MenuItem(editMenu, SWT.NONE); - copyMI.setText("&Copy Subscription..."); + copyMI.setText("Copy Subscription..."); copyMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -441,7 +442,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements }); MenuItem deleteMI = new MenuItem(editMenu, SWT.NONE); - deleteMI.setText("&Delete Subscription"); + deleteMI.setText("Delete Subscription"); deleteMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { @@ -591,8 +592,8 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements String msg = user.uniqueId() + " is not authorized to create subscriptions"; try { - if (DataDeliveryServices.getPermissionsService().checkPermission(user, msg, permission) - .isAuthorized()) { + if (DataDeliveryServices.getPermissionsService() + .checkPermission(user, msg, permission).isAuthorized()) { DataBrowserAction action = new DataBrowserAction(); Map params = new HashMap(); ExecutionEvent ee = new ExecutionEvent(null, params, null, null); @@ -622,8 +623,8 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements + permission; try { - if (DataDeliveryServices.getPermissionsService().checkPermission(user, msg, permission) - .isAuthorized()) { + if (DataDeliveryServices.getPermissionsService() + .checkPermission(user, msg, permission).isAuthorized()) { if (create) { if (createGroupDlg == null) { createGroupDlg = new CreateGroupDefinitionDlg( @@ -744,8 +745,8 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements + permission; try { - if (DataDeliveryServices.getPermissionsService().checkPermission(user, msg, permission) - .isAuthorized()) { + if (DataDeliveryServices.getPermissionsService() + .checkPermission(user, msg, permission).isAuthorized()) { String message = null; if (selectionCount > 1) { @@ -831,8 +832,8 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements + " Subscriptions\nPermission: " + permission; try { - if (DataDeliveryServices.getPermissionsService().checkPermission(user, msg, permission) - .isAuthorized()) { + if (DataDeliveryServices.getPermissionsService() + .checkPermission(user, msg, permission).isAuthorized()) { final List updatedList = new ArrayList(); int count = tableComp.getTable().getSelectionCount(); @@ -1055,10 +1056,12 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements String msg = user.uniqueId() + " is not authorized to access Subscription Approval"; - return DataDeliveryServices.getPermissionsService().checkPermissions(user, msg, - DataDeliveryPermission.SUBSCRIPTION_APPROVE_SITE, - DataDeliveryPermission.SUBSCRIPTION_APPROVE_USER, - DataDeliveryPermission.SUBSCRIPTION_APPROVE_VIEW) + return DataDeliveryServices + .getPermissionsService() + .checkPermissions(user, msg, + DataDeliveryPermission.SUBSCRIPTION_APPROVE_SITE, + DataDeliveryPermission.SUBSCRIPTION_APPROVE_USER, + DataDeliveryPermission.SUBSCRIPTION_APPROVE_VIEW) .isAuthorized(); } catch (VizException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); @@ -1088,8 +1091,8 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements for (Subscription subscription : subscriptions) { subscriptionNotificationService - .sendDeletedSubscriptionNotification( - subscription, username); + .sendDeletedSubscriptionNotification(subscription, + username); } } catch (RegistryHandlerException e) { exceptions.add(e); From ffca96956074fc306a462cf79c2ada6a6a8295f9 Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Thu, 17 Jan 2013 18:15:24 -0600 Subject: [PATCH 03/13] Issue #1357 - Remaining stats items implemented. Peer Review Fixes Change-Id: I94d2e3fc08af2bef5e1e57c4ad7caf826e254ae1 Former-commit-id: 19e1608c44d314e11bb7cba809e1cc0a6bb68dc5 --- .../META-INF/MANIFEST.MF | 3 +- .../subscription/xml/RuleXML.java | 3 +- .../system/CreateEditRuleDlg.java | 5 +- .../META-INF/MANIFEST.MF | 3 +- .../uf/viz/stats/ui/GroupingComp.java | 97 ++++-- .../com/raytheon/uf/viz/stats/ui/HideDlg.java | 161 +++++++++ .../uf/viz/stats/ui/IGroupSelection.java | 31 +- .../uf/viz/stats/ui/IStatsDisplay.java | 27 +- .../uf/viz/stats/ui/SelectionManagerDlg.java | 43 ++- .../uf/viz/stats/ui/StatsControlDlg.java | 24 +- .../uf/viz/stats/ui/StatsDisplayCanvas.java | 322 +++++++++++++----- .../uf/viz/stats/ui/StatsGraphDlg.java | 94 ++++- .../META-INF/MANIFEST.MF | 4 +- .../uf/common/stats/GraphDataRequest.java | 5 + .../uf/common/stats/data/DataPoint.java | 84 ++--- .../uf/common/stats/data/GraphData.java | 113 ++++-- .../uf/common/stats/data/StatsBin.java | 30 +- .../uf/common/stats/data/StatsData.java | 52 ++- .../uf/common/stats/util/DataView.java | 77 +++++ .../uf/common/stats/util/DataViewUtils.java | 54 --- .../uf/common/stats/util/UnitUtils.java | 315 +++++++++-------- .../uf/common/time/util/TimeUtil.java | 6 +- .../uf/common/units}/DataSizeUnit.java | 6 +- .../edex/stats/data/StatsDataAccumulator.java | 41 ++- .../base/stats/edexProcessStats.xml | 2 + tests/.classpath | 1 + .../uf/common/stats/data/DataPointTest.java | 12 +- .../uf/common/stats/data/StatsDataTest.java | 10 +- .../uf/common/stats/util/UnitUtilsTest.java | 179 ++++++++++ .../stats/data/StatsDataAccumulatorTest.java | 2 +- .../subscription/xml/LatencyRuleXMLTest.java | 3 +- .../subscription/xml/RuleXMLTest.java | 3 +- .../datadelivery/utils/DataSizeUtilTest.java | 5 +- 33 files changed, 1291 insertions(+), 526 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/HideDlg.java create mode 100644 edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/DataView.java delete mode 100644 edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/DataViewUtils.java rename {cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils => edexOsgi/com.raytheon.uf.common.units/src/com/raytheon/uf/common/units}/DataSizeUnit.java (96%) create mode 100644 tests/unit/com/raytheon/uf/common/stats/util/UnitUtilsTest.java diff --git a/cave/com.raytheon.uf.viz.datadelivery/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.datadelivery/META-INF/MANIFEST.MF index 9f6390cc64..5795520503 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.datadelivery/META-INF/MANIFEST.MF @@ -30,7 +30,8 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.common.gridcoverage;bundle-version="1.0.0", com.raytheon.uf.common.datadelivery.bandwidth;bundle-version="1.0.0", com.raytheon.uf.common.datadelivery.retrieval;bundle-version="1.0.0", - com.raytheon.uf.common.datadelivery.service;bundle-version="1.0.0" + com.raytheon.uf.common.datadelivery.service;bundle-version="1.0.0", + com.raytheon.uf.common.units;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.viz.datadelivery;uses:="org.eclipse.ui.plugin,org.osgi.framework", diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/xml/RuleXML.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/xml/RuleXML.java index 7a9904d210..8ee0d441a1 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/xml/RuleXML.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/xml/RuleXML.java @@ -27,10 +27,10 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import com.raytheon.uf.common.datadelivery.registry.Subscription; +import com.raytheon.uf.common.units.DataSizeUnit; import com.raytheon.uf.viz.datadelivery.system.CreateEditRuleDlg.FreqUnitOptions; import com.raytheon.uf.viz.datadelivery.system.Operator; import com.raytheon.uf.viz.datadelivery.system.OpsNetFieldNames; -import com.raytheon.uf.viz.datadelivery.utils.DataSizeUnit; /** * Parent Rules xml class @@ -43,6 +43,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataSizeUnit; * ------------ ---------- ----------- -------------------------- * Dec 19, 2012 1420 mpduff Initial creation. * Jan 14, 2013 1286 djohnson Correct string conversion of units and use {@link Operator}. + * Jan 17, 2013 1357 mpduff Moved DataSizeUnit. * * * diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/system/CreateEditRuleDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/system/CreateEditRuleDlg.java index b5cb686005..4027ddd2ce 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/system/CreateEditRuleDlg.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/system/CreateEditRuleDlg.java @@ -38,6 +38,7 @@ import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.units.DataSizeUnit; import com.raytheon.uf.viz.datadelivery.subscription.xml.LatencyRuleXML; import com.raytheon.uf.viz.datadelivery.subscription.xml.OperatorAdapter; import com.raytheon.uf.viz.datadelivery.subscription.xml.PriorityRuleXML; @@ -45,7 +46,6 @@ import com.raytheon.uf.viz.datadelivery.subscription.xml.RuleXML; import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils; import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils.SubscriptionPriority; import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils; -import com.raytheon.uf.viz.datadelivery.utils.DataSizeUnit; import com.raytheon.uf.viz.datadelivery.utils.NameOperationItems; import com.raytheon.uf.viz.datadelivery.utils.TypeOperationItems; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; @@ -67,7 +67,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Dec 18, 2012 1417 bgonzale Changed value initialization in handleSave(). * Jan 04, 2013 1420 mpduff Remove code to apply rules changes to existing subscription, * rules are only for future subscriptions. - * Jan 14, 2013 1286 djohnson Rule operators are now used as objects. + * Jan 14, 2013 1286 djohnson Rule operators are now used as objects. + * Jan 17, 2013 1357 mpduff Moved DataSizeUnit. * * * diff --git a/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF index bbc9e9368e..87e75da1c0 100644 --- a/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF @@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.common.stats;bundle-version="1.0.0", com.raytheon.uf.common.time;bundle-version="1.12.1174", com.raytheon.uf.common.util;bundle-version="1.12.1174", - com.google.guava;bundle-version="1.0.0" + com.google.guava;bundle-version="1.0.0", + com.raytheon.uf.common.units;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.viz.stats, diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/GroupingComp.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/GroupingComp.java index 3f9e39259b..f3033d655b 100644 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/GroupingComp.java +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/GroupingComp.java @@ -35,7 +35,6 @@ package com.raytheon.uf.viz.stats.ui; * @author mpduff * @version 1.0 */ -import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -59,22 +58,25 @@ import org.eclipse.swt.widgets.ColorDialog; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; import com.raytheon.uf.common.stats.data.GraphData; /** * Composites that contains the controls to change colors and to determine what * is displayed. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Oct 16, 2012            lvenable     Initial creation
- *
+ * Oct 16, 2012            lvenable    Initial creation
+ * Jan 11, 2013   1357     mpduff      Implement.
+ * 
  * 
- * + * * @author lvenable * @version 1.0 */ @@ -108,7 +110,7 @@ public class GroupingComp extends Composite implements IGroupSelection { /** * Constructor. - * + * * @param parentComp * Parent composite. * @param swtStyle @@ -245,22 +247,22 @@ public class GroupingComp extends Composite implements IGroupSelection { displaySelectionMgrDlg(); } }); -// Not including this functionality in the branch. -// gd = new GridData(buttonWidth, SWT.DEFAULT); -// Button colorMgrBtn = new Button(buttonComp, SWT.PUSH); -// colorMgrBtn.setText("Color Manager..."); -// colorMgrBtn.setLayoutData(gd); -// colorMgrBtn.addSelectionListener(new SelectionAdapter() { -// @Override -// public void widgetSelected(SelectionEvent e) { -// displayColorMgrDlg(); -// } -// }); + // Not including this functionality in the branch. + // gd = new GridData(buttonWidth, SWT.DEFAULT); + // Button colorMgrBtn = new Button(buttonComp, SWT.PUSH); + // colorMgrBtn.setText("Color Manager..."); + // colorMgrBtn.setLayoutData(gd); + // colorMgrBtn.addSelectionListener(new SelectionAdapter() { + // @Override + // public void widgetSelected(SelectionEvent e) { + // displayColorMgrDlg(); + // } + // }); } /** * Handle the check button event. - * + * * @param btn * Check box being checked/unchecked. */ @@ -278,7 +280,7 @@ public class GroupingComp extends Composite implements IGroupSelection { /** * Handle the color label that is being clicked. - * + * * @param lbl * Label that was clicked. */ @@ -343,20 +345,19 @@ public class GroupingComp extends Composite implements IGroupSelection { if (selectionMangerDlg == null || selectionMangerDlg.isDisposed()) { selectionMangerDlg = new SelectionManagerDlg(getShell(), graphData, this); - selectionMangerDlg.open(); - } else { - selectionMangerDlg.bringToTop(); } + + selectionMangerDlg.open(); } /** * Display the Color Manager dialog. */ // Implementing in the next release. -// private void displayColorMgrDlg() { -// ColorManagerDlg dlg = new ColorManagerDlg(getShell(), graphData, this); -// dlg.open(); -// } + // private void displayColorMgrDlg() { + // ColorManagerDlg dlg = new ColorManagerDlg(getShell(), graphData, this); + // dlg.open(); + // } /** * {@inheritDoc} @@ -365,14 +366,11 @@ public class GroupingComp extends Composite implements IGroupSelection { public void setSelections(Map> selectionMap) { List keySequence = graphData.getKeySequence(); - Map> offMap = new HashMap>(); + Multimap offMap = ArrayListMultimap.create(); for (String key : selectionMap.keySet()) { for (String selection : selectionMap.get(key).keySet()) { if (!selectionMap.get(key).get(selection)) { - if (!offMap.containsKey(key)) { - offMap.put(key, new ArrayList()); - } - offMap.get(key).add(selection); + offMap.put(key, selection); } } } @@ -390,7 +388,9 @@ public class GroupingComp extends Composite implements IGroupSelection { for (String group : offMap.keySet()) { for (String part : parts) { int idx = keySequence.indexOf(part); - if (idx >= 0 && offMap.get(group).contains(keySequence.get(idx))) { + if (idx >= 0 + && offMap.get(group).contains( + keySequence.get(idx))) { checkBtnMap.get(btnKey).setSelection(false); keyRgbMap.remove(btnKey); } else { @@ -405,4 +405,33 @@ public class GroupingComp extends Composite implements IGroupSelection { fireCallback(); } + + /** + * {@inheritDoc} + */ + @Override + public void setItemsOff(List keys) { + for (String key : keys) { + if (checkBtnMap.containsKey(key)) { + checkBtnMap.get(key).setSelection(false); + keyRgbMap.remove(key); + } + } + + fireCallback(); + } + + /** + * {@inheritDoc} + */ + @Override + public Map getStates() { + Map stateMap = new HashMap(); + + for (Map.Entry state : checkBtnMap.entrySet()) { + stateMap.put(state.getKey(), state.getValue().getSelection()); + } + + return stateMap; + } } diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/HideDlg.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/HideDlg.java new file mode 100644 index 0000000000..82c9893bb2 --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/HideDlg.java @@ -0,0 +1,161 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.stats.ui; + +import java.util.Arrays; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Shell; + +import com.raytheon.viz.ui.dialogs.CaveSWTDialog; + +/** + * Hide graph lines dialog. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 4, 2012    1357     mpduff      Initial creation.
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class HideDlg extends CaveSWTDialog { + /** Data List Widget */ + private List dataList; + + /** List of keys */ + private final java.util.List keyList; + + /** Callback to hide the lines */ + private final IGroupSelection callback; + + /** + * Constructor. + * + * @param parent + * The parent shell + * @param keyList + * The list of keys + * @param callback + * the callback + */ + public HideDlg(Shell parent, java.util.List keyList, + IGroupSelection callback) { + super(parent); + setText("Hide Graph Lines"); + + this.keyList = keyList; + this.callback = callback; + } + + /** + * {@inheritDoc} + */ + @Override + protected Layout constructShellLayout() { + // Create the main layout for the shell. + GridLayout mainLayout = new GridLayout(1, true); + mainLayout.marginHeight = 1; + mainLayout.marginWidth = 1; + return mainLayout; + } + + /** + * {@inheritDoc} + */ + @Override + protected void initializeComponents(Shell shell) { + setReturnValue(false); + + Composite mainComp = new Composite(shell, SWT.NONE); + GridLayout gl = new GridLayout(1, false); + gl.marginHeight = 0; + gl.marginWidth = 0; + gl.horizontalSpacing = 0; + gl.verticalSpacing = 5; + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + mainComp.setLayout(gl); + mainComp.setLayoutData(gd); + + GridData listData = new GridData(SWT.FILL, SWT.FILL, true, true); + listData.widthHint = 200; + listData.heightHint = 300; + dataList = new List(mainComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL + | SWT.H_SCROLL); + dataList.setLayoutData(listData); + dataList.setItems(keyList.toArray(new String[keyList.size()])); + + Composite buttonComp = new Composite(shell, SWT.NONE); + buttonComp.setLayout(new GridLayout(2, false)); + buttonComp.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, + false)); + + int buttonWidth = 120; + gd = new GridData(buttonWidth, SWT.DEFAULT); + Button hideBtn = new Button(buttonComp, SWT.PUSH); + hideBtn.setText("Hide Graph Lines"); + hideBtn.setLayoutData(gd); + hideBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleHide(); + } + }); + + gd = new GridData(buttonWidth, SWT.DEFAULT); + Button closeBtn = new Button(buttonComp, SWT.PUSH); + closeBtn.setText("Close"); + closeBtn.setLayoutData(gd); + closeBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + close(); + } + }); + } + + /** + * Hide event handler + */ + private void handleHide() { + if (dataList.getSelectionCount() > 0) { + String[] itemsToHide = dataList.getSelection(); + callback.setItemsOff(Arrays.asList(itemsToHide)); + for (String item : itemsToHide) { + dataList.remove(item); + } + } + } +} diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IGroupSelection.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IGroupSelection.java index e6ba63b898..9f546562d2 100644 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IGroupSelection.java +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IGroupSelection.java @@ -19,21 +19,23 @@ **/ package com.raytheon.uf.viz.stats.ui; +import java.util.List; import java.util.Map; /** * Interface for Group Selections. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Oct 18, 2012    728     mpduff     Initial creation
- *
+ * Oct 18, 2012    728     mpduff      Initial creation.
+ * Jan 17, 2013   1357     mpduff      Added setItemsOff and getStates.
+ * 
  * 
- * + * * @author mpduff * @version 1.0 */ @@ -41,8 +43,23 @@ import java.util.Map; public interface IGroupSelection { /** * Set the selections. - * + * * @param selectionMap */ void setSelections(Map> selectionMap); + + /** + * Turn off the provided items. + * + * @param keys + * keys of the items to not draw + */ + void setItemsOff(List keys); + + /** + * Get the state of each item. + * + * @return Map of item -> checked or not checked + */ + Map getStates(); } diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IStatsDisplay.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IStatsDisplay.java index 12afff43ba..49ef4ef9a1 100644 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IStatsDisplay.java +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IStatsDisplay.java @@ -24,21 +24,21 @@ import java.util.Map; import org.eclipse.swt.graphics.RGB; import com.raytheon.uf.common.stats.data.GraphData; - +import com.raytheon.uf.common.stats.util.UnitUtils; /** * Stats display interface. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Oct 3, 2012     728     mpduff      Initial creation
- *
+ * 
  * 
- * + * * @author mpduff * @version 1.0 */ @@ -46,29 +46,36 @@ import com.raytheon.uf.common.stats.data.GraphData; public interface IStatsDisplay { /** * Get the GraphData object - * + * * @return GraphData */ GraphData getGraphData(); /** * Draw grid lines flag - * + * * @return true to draw the grid lines */ boolean drawGridLines(); /** * Draw data lines flag - * + * * @return true to draw the data lines */ boolean drawDataLines(); /** * Get the group settings. - * + * * @return The group settings map */ Map getGroupSettings(); + + /** + * Get the UnitUtils object. + * + * @return the UnitUtils object + */ + UnitUtils getUnitUtils(); } diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionManagerDlg.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionManagerDlg.java index 71f48ae27d..2b46907b56 100644 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionManagerDlg.java +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionManagerDlg.java @@ -21,8 +21,10 @@ package com.raytheon.uf.viz.stats.ui; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -44,17 +46,18 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase; /** * Stats Selection Manager Dialog. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Oct 18, 2012            lvenable     Initial creation
- *
+ * Oct 18, 2012            lvenable    Initial creation
+ * Jan 17, 2013  1357      mpduff      Added selection state handling.
+ * 
  * 
- * + * * @author lvenable * @version 1.0 */ @@ -74,7 +77,7 @@ public class SelectionManagerDlg extends CaveSWTDialogBase { /** * Constructor. - * + * * @param parentShell * @param graphData * @param callback @@ -202,7 +205,7 @@ public class SelectionManagerDlg extends CaveSWTDialogBase { /** * Check the path of the item. - * + * * @param item * @param checked * @param grayed @@ -232,7 +235,7 @@ public class SelectionManagerDlg extends CaveSWTDialogBase { /** * Check or uncheck the items in the TreeItem - * + * * @param item * @param checked */ @@ -251,6 +254,7 @@ public class SelectionManagerDlg extends CaveSWTDialogBase { private void populateTree() { Map> grpMemberMap = graphData .getGroupAndNamesMap(); + Map stateMap = callback.getStates(); for (String key : grpMemberMap.keySet()) { TreeItem treeItem = new TreeItem(selectionTree, SWT.NONE); @@ -262,7 +266,25 @@ public class SelectionManagerDlg extends CaveSWTDialogBase { TreeItem subTreeItem = new TreeItem(treeItem, SWT.NONE); subTreeItem.setText(subKey); - subTreeItem.setChecked(true); + subTreeItem.setChecked(stateMap.get(subKey)); + } + } + + // Determine group checkbox setting, unchecked, grayed, checked + TreeItem[] children = selectionTree.getItems(); + Set selectionSet = new HashSet(); + for (TreeItem item : children) { + item.setChecked(true); + for (TreeItem subItem : item.getItems()) { + selectionSet.add(subItem.getChecked()); + } + + if (selectionSet.contains(Boolean.TRUE) + && selectionSet.contains(Boolean.FALSE)) { + item.setChecked(true); + item.setGrayed(true); + } else if (!selectionSet.contains(Boolean.TRUE)) { + item.setChecked(false); } } } @@ -314,6 +336,5 @@ public class SelectionManagerDlg extends CaveSWTDialogBase { } else { callback.setSelections(selectionMap); } - } } diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsControlDlg.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsControlDlg.java index 013b15fec7..62e63e59f1 100644 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsControlDlg.java +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsControlDlg.java @@ -69,7 +69,8 @@ import com.raytheon.viz.ui.widgets.duallist.IUpdate; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 25, 2012 mpduff Initial creation + * Sep 25, 2012 1357 mpduff Initial creation. + * Jan 17, 2013 1357 mpduff Added timestep settings. * * * @@ -92,7 +93,7 @@ public class StatsControlDlg extends CaveSWTDialog implements IStatsControl, TimeUtil.MILLIS_PER_HOUR * 3, TimeUtil.MILLIS_PER_HOUR * 6, TimeUtil.MILLIS_PER_HOUR * 12, TimeUtil.MILLIS_PER_DAY, TimeUtil.MILLIS_PER_WEEK, TimeUtil.MILLIS_PER_WEEK * 2, - TimeUtil.MILLIS_PER_MONTH }; + TimeUtil.MILLIS_PER_30_DAYS }; /** Date Format object */ private final ThreadLocal sdf = new ThreadLocal() { @@ -619,7 +620,24 @@ public class StatsControlDlg extends CaveSWTDialog implements IStatsControl, } TimeRange tr = new TimeRange(start, end); request.setTimeRange(tr); - request.setTimeStep(5); + + if (tr.getDuration() <= TimeUtil.MILLIS_PER_HOUR) { + request.setTimeStep(5); + } else if (tr.getDuration() <= TimeUtil.MILLIS_PER_HOUR * 3) { + request.setTimeStep(5); + } else if (tr.getDuration() <= TimeUtil.MILLIS_PER_HOUR * 6) { + request.setTimeStep(10); + } else if (tr.getDuration() <= TimeUtil.MILLIS_PER_HOUR * 12) { + request.setTimeStep(20); + } else if (tr.getDuration() <= TimeUtil.MILLIS_PER_HOUR * 24) { + request.setTimeStep(40); + } else if (tr.getDuration() <= TimeUtil.MILLIS_PER_DAY * 7) { + request.setTimeStep(240); + } else if (tr.getDuration() <= TimeUtil.MILLIS_PER_DAY * 14) { + request.setTimeStep(480); + } else { + request.setTimeStep(1000); + } try { GraphDataResponse response = (GraphDataResponse) ThriftClient diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java index 99a28584f7..8f7aa0ce04 100644 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java @@ -23,15 +23,19 @@ import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TimeZone; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseMoveListener; import org.eclipse.swt.events.PaintEvent; @@ -47,15 +51,24 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; +import com.google.common.base.Strings; import com.raytheon.uf.common.stats.data.DataPoint; import com.raytheon.uf.common.stats.data.GraphData; import com.raytheon.uf.common.stats.data.StatsData; -import com.raytheon.uf.common.stats.util.DataViewUtils; +import com.raytheon.uf.common.stats.util.DataView; +import com.raytheon.uf.common.stats.util.UnitUtils; +import com.raytheon.uf.common.stats.util.UnitUtils.TimeConversion; +import com.raytheon.uf.common.stats.util.UnitUtils.UnitTypes; import com.raytheon.uf.common.time.TimeRange; import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.common.units.DataSizeUnit; import com.raytheon.uf.viz.core.RGBColors; import com.raytheon.uf.viz.stats.display.ScaleManager; @@ -68,7 +81,12 @@ import com.raytheon.uf.viz.stats.display.ScaleManager; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- + * <<<<<<< HEAD * Oct 3, 2012 728 mpduff Initial creation + * ======= + * Oct 03, 2012 728 mpduff Initial creation. + * Jan 17, 2013 1357 mpduff Added mouse listeners. + * >>>>>>> Issue #1357 - Remaining stats items implemented. * * * @@ -106,6 +124,15 @@ public class StatsDisplayCanvas extends Canvas { } }; + /** Decimal Format object */ + private final ThreadLocal decFormat = new ThreadLocal() { + @Override + protected DecimalFormat initialValue() { + DecimalFormat format = new DecimalFormat("########.#"); + return format; + } + }; + /** Constant */ private final String COLON = ":"; @@ -185,17 +212,14 @@ public class StatsDisplayCanvas extends Canvas { /** Tooltip shell */ private Shell tooltip; - /** Graph Data object */ - private GraphData graphData; + /** Data View, avg, min, max, etc. */ + private DataView view = DataView.AVG; - /** Smallest value in the data set */ - private double minValue; + /** Group selection callback */ + private IGroupSelection groupCallback; - /** Largest value in the data set */ - private double maxValue; - - private String view = DataViewUtils.DataView.AVG.getView(); // Defaults to - // average + /** Hide dataset dialog */ + private HideDlg hideDlg; /** * Constructor @@ -214,8 +238,7 @@ public class StatsDisplayCanvas extends Canvas { this.callback = callback; this.graphTitle = graphTitle; - this.graphData = callback.getGraphData(); - TimeRange tr = graphData.getTimeRange(); + TimeRange tr = callback.getGraphData().getTimeRange(); String start = titleDateFormat.get().format(tr.getStart()); String end = titleDateFormat.get().format(tr.getEnd()); @@ -258,6 +281,13 @@ public class StatsDisplayCanvas extends Canvas { handleMouseMoveEvent(e); } }); + + addMouseListener(new MouseAdapter() { + @Override + public void mouseDown(MouseEvent e) { + handleMouseDownEvent(e); + } + }); } /** @@ -342,8 +372,7 @@ public class StatsDisplayCanvas extends Canvas { List dateList = new ArrayList(); SimpleDateFormat sdf = axisFormat.get(); - - TimeRange tr = graphData.getTimeRange(); + TimeRange tr = callback.getGraphData().getTimeRange(); dateList.add(tr.getStart()); // Add the first date long milliRange = tr.getDuration(); @@ -356,13 +385,15 @@ public class StatsDisplayCanvas extends Canvas { long startMillis = tr.getStart().getTime(); StringBuilder buffer = new StringBuilder(); - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + Calendar cal = TimeUtil.newGmtCalendar(); for (long i = tr.getStart().getTime(); i <= tr.getEnd().getTime(); i += TimeUtil.MILLIS_PER_HOUR) { cal.setTimeInMillis(i); int[] tickArray = { - (int) (GRAPH_BORDER + (i - startMillis) / millisPerPixelX), + Math.round(GRAPH_BORDER + (i - startMillis) + / millisPerPixelX), GRAPH_BORDER + GRAPH_HEIGHT, - (int) (GRAPH_BORDER + (i - startMillis) / millisPerPixelX), + Math.round(GRAPH_BORDER + (i - startMillis) + / millisPerPixelX), GRAPH_BORDER + GRAPH_HEIGHT + height }; if (cal.get(Calendar.HOUR_OF_DAY) == 0 && cal.get(Calendar.MINUTE) == 0) { @@ -372,9 +403,11 @@ public class StatsDisplayCanvas extends Canvas { } int hour = cal.get(Calendar.HOUR_OF_DAY); + // Draw the tick marks if ((numHours / 24 <= 7) || (hour % 6) == 0) { gc.drawPolyline(tickArray); + // Draw grid lines if (callback.drawGridLines()) { boolean draw = false; if (numHours <= 6) { @@ -387,19 +420,20 @@ public class StatsDisplayCanvas extends Canvas { if (draw) { int[] gridLine = new int[] { - (int) (GRAPH_BORDER + (i - startMillis) + Math.round(GRAPH_BORDER + (i - startMillis) / millisPerPixelX), GRAPH_BORDER + GRAPH_HEIGHT, - (int) (GRAPH_BORDER + (i - startMillis) + Math.round(GRAPH_BORDER + (i - startMillis) / millisPerPixelX), GRAPH_BORDER }; gc.drawPolyline(gridLine); } } } + // Save the Zero hour for later if (hour == 0) { - dateLocationList.add((int) (GRAPH_BORDER + (i - startMillis) - / millisPerPixelX)); + dateLocationList.add(Math.round(GRAPH_BORDER + + (i - startMillis) / millisPerPixelX)); if (!dateList.contains(cal.getTime())) { dateList.add(cal.getTime()); } @@ -409,13 +443,15 @@ public class StatsDisplayCanvas extends Canvas { int hr = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); + // Draw the tick marks if ((numHours <= 24) || (hour % 6 == 0 && numHours <= 168)) { if (numHours <= 3) { for (int j = 0; j < TimeUtil.MINUTES_PER_HOUR; j += 15) { buffer.setLength(0); - int x = (int) (GRAPH_BORDER + (i - startMillis + j - * TimeUtil.MILLIS_PER_MINUTE) + int x = Math.round(GRAPH_BORDER + + (i - startMillis + j + * TimeUtil.MILLIS_PER_MINUTE) / millisPerPixelX); if (numHours == 1 || (numHours == 3 && (j == 0 || j == 30))) { @@ -434,13 +470,13 @@ public class StatsDisplayCanvas extends Canvas { if (callback.drawGridLines()) { int[] gridLineArray = { - (int) (GRAPH_BORDER + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE - * j) - / millisPerPixelX), + Math.round(GRAPH_BORDER + + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE + * j) / millisPerPixelX), GRAPH_BORDER + GRAPH_HEIGHT, - (int) (GRAPH_BORDER + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE - * j) - / millisPerPixelX), + Math.round(GRAPH_BORDER + + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE + * j) / millisPerPixelX), GRAPH_BORDER }; if (hr == 0 && minute == 0) { gc.setLineWidth(3); @@ -460,19 +496,20 @@ public class StatsDisplayCanvas extends Canvas { } } + // Minor tick marks int[] minorTickArray = { - (int) (GRAPH_BORDER + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE - * j) - / millisPerPixelX), + Math.round(GRAPH_BORDER + + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE + * j) / millisPerPixelX), GRAPH_BORDER + GRAPH_HEIGHT, - (int) (GRAPH_BORDER + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE - * j) - / millisPerPixelX), + Math.round(GRAPH_BORDER + + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE + * j) / millisPerPixelX), GRAPH_BORDER + GRAPH_HEIGHT + height - 5 }; gc.drawPolyline(minorTickArray); } } else { - int x = (int) (GRAPH_BORDER + (i - startMillis) + int x = Math.round(GRAPH_BORDER + (i - startMillis) / millisPerPixelX); String hrStr = (hr < 10) ? ZERO.concat(String.valueOf(hr)) : String.valueOf(hr); @@ -485,10 +522,10 @@ public class StatsDisplayCanvas extends Canvas { || (numHours == TimeUtil.HOURS_PER_WEEK && hr == 0)) { int[] gridLineArray = { - (int) (GRAPH_BORDER + (i - startMillis) + Math.round(GRAPH_BORDER + (i - startMillis) / millisPerPixelX), GRAPH_BORDER + GRAPH_HEIGHT, - (int) (GRAPH_BORDER + (i - startMillis) + Math.round(GRAPH_BORDER + (i - startMillis) / millisPerPixelX), GRAPH_BORDER }; gc.setLineWidth(1); gc.drawPolyline(gridLineArray); @@ -497,7 +534,7 @@ public class StatsDisplayCanvas extends Canvas { } } } else if (numHours == 336 && hour == 0) { - int x = (int) (GRAPH_BORDER + (i - startMillis) + int x = Math.round(GRAPH_BORDER + (i - startMillis) / millisPerPixelX); buffer.append(cal.get(Calendar.MONTH) + 1); buffer.append("/"); @@ -509,10 +546,10 @@ public class StatsDisplayCanvas extends Canvas { // show every other line if (showLine) { int[] gridLineArray = { - (int) (GRAPH_BORDER + (i - startMillis) + Math.round(GRAPH_BORDER + (i - startMillis) / millisPerPixelX), GRAPH_BORDER + GRAPH_HEIGHT, - (int) (GRAPH_BORDER + (i - startMillis) + Math.round(GRAPH_BORDER + (i - startMillis) / millisPerPixelX), GRAPH_BORDER }; gc.setLineWidth(1); gc.drawPolyline(gridLineArray); @@ -523,7 +560,7 @@ public class StatsDisplayCanvas extends Canvas { } else if (numHours == 720) { if (cal.get(Calendar.DAY_OF_MONTH) % 2 == 0 && hour == 0) { - int x = (int) (GRAPH_BORDER + (i - startMillis) + int x = Math.round(GRAPH_BORDER + (i - startMillis) / millisPerPixelX); buffer.append(cal.get(Calendar.MONTH) + 1); buffer.append("/"); @@ -533,10 +570,10 @@ public class StatsDisplayCanvas extends Canvas { if (callback.drawGridLines()) { if (showLine) { int[] gridLineArray = { - (int) (GRAPH_BORDER + (i - startMillis) + Math.round(GRAPH_BORDER + (i - startMillis) / millisPerPixelX), GRAPH_BORDER + GRAPH_HEIGHT, - (int) (GRAPH_BORDER + (i - startMillis) + Math.round(GRAPH_BORDER + (i - startMillis) / millisPerPixelX), GRAPH_BORDER }; gc.setLineWidth(1); gc.drawPolyline(gridLineArray); @@ -588,14 +625,21 @@ public class StatsDisplayCanvas extends Canvas { gc.drawPolyline(yAxis); Map groupSettings = callback.getGroupSettings(); - + GraphData graphData = callback.getGraphData(); double minVal = graphData.getMinValue(groupSettings.keySet(), view); double maxVal = graphData.getMaxValue(groupSettings.keySet(), view); + if (view != DataView.COUNT) { + UnitUtils uu = callback.getUnitUtils(); + minVal = uu.convertValue(minVal); + maxVal = uu.convertValue(maxVal); + } + + setScaleValues(minVal, maxVal); + int numberTicks = 4; double inc = 5; double minScaleVal = 0; double maxScaleVal = 10; - scalingManager = new ScaleManager(minVal, maxVal); numberTicks = scalingManager.getMajorTickCount(); inc = scalingManager.getMajorTickIncrement(); @@ -632,12 +676,15 @@ public class StatsDisplayCanvas extends Canvas { * The Graphics Context */ private void drawYAxisLabel(GC gc) { - String unit = this.graphData.getDisplayUnit(); + GraphData graphData = callback.getGraphData(); + String unit = graphData.getDisplayUnit(); StringBuilder yAxisLabel = new StringBuilder(graphTitle); - if (unit != null && !unit.equalsIgnoreCase(COUNT) && unit.length() > 0 - && !view.equals(DataViewUtils.DataView.COUNT.getView())) { + if (!Strings.isNullOrEmpty(unit) && !unit.equalsIgnoreCase(COUNT) + && !view.equals(DataView.COUNT)) { yAxisLabel.append(" (").append(unit).append(")"); + } else if (view.equals(DataView.COUNT)) { + yAxisLabel.append(" Counts"); } gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK)); @@ -667,6 +714,8 @@ public class StatsDisplayCanvas extends Canvas { double maxScaleVal = scalingManager.getMaxScaleValue(); double minScaleVal = scalingManager.getMinScaleValue(); Map groupSettings = callback.getGroupSettings(); + UnitUtils uu = callback.getUnitUtils(); + GraphData graphData = callback.getGraphData(); for (String key : graphData.getKeysWithData()) { if (groupSettings.containsKey(key)) { @@ -692,30 +741,28 @@ public class StatsDisplayCanvas extends Canvas { int lastYpix = -999; for (DataPoint point : dataList) { long x = point.getX(); - double y; + double y = point.getValue(view); - if (view.equals(DataViewUtils.DataView.AVG - .getView())) { - y = point.getAvg(); - } else if (view.equals(DataViewUtils.DataView.MIN - .getView())) { - y = point.getMin(); - } else if (view.equals(DataViewUtils.DataView.MAX - .getView())) { - y = point.getMax(); - } else if (view.equals(DataViewUtils.DataView.SUM - .getView())) { - y = point.getSum(); - } else { - y = point.getCount(); + if (view != DataView.COUNT) { + y = uu.convertValue(y); } + + int xPix = 0; int yPix = y2pixel(minScaleVal, maxScaleVal, y); - int xPix = (int) ((x - startMillis) - / millisPerPixelX + GRAPH_BORDER); + + long diff = x - startMillis; + if (diff == 0) { + xPix = Math + .round((x / millisPerPixelX + GRAPH_BORDER)); + } else { + xPix = Math + .round((diff / millisPerPixelX + GRAPH_BORDER)); + } if (xPix > GRAPH_BORDER + GRAPH_WIDTH) { - break; + continue; } + pointList.add(xPix); pointList.add(yPix); Rectangle rect = new Rectangle(xPix - 3, yPix - 3, @@ -730,6 +777,7 @@ public class StatsDisplayCanvas extends Canvas { lastYpix = yPix; } + // Draw each rectangle for (int i = 0; i < rectangleMap.get(key).size(); i++) { Rectangle rect = rectangleMap.get(key).get(i); gc.setForeground(color); @@ -759,7 +807,7 @@ public class StatsDisplayCanvas extends Canvas { private int y2pixel(double yMin, double yMax, double y) { double yDiff = yMax - yMin; double yValue = (GRAPH_HEIGHT / yDiff) * (y - yMin); - return (int) (GRAPH_HEIGHT - Math.round(yValue) + GRAPH_BORDER); + return Math.round(GRAPH_HEIGHT - Math.round(yValue) + GRAPH_BORDER); } /** @@ -778,6 +826,8 @@ public class StatsDisplayCanvas extends Canvas { if (graphData == null) { return; } + + UnitUtils uu = callback.getUnitUtils(); for (String key : graphData.getKeys()) { int idx = 0; if (rectangleMap.containsKey(key)) { @@ -791,7 +841,24 @@ public class StatsDisplayCanvas extends Canvas { sb.append(key).append(colon); DataPoint point = graphData.getStatsData(key) .getData().get(idx); - sb.append(point.getSampleText(view)); + double value = point.getValue(view); + + if (!view.equals(DataView.COUNT.getView())) { + if (uu.getUnitType() == UnitTypes.DATA_SIZE) { + value = uu.convertDataSizeValue( + DataSizeUnit.BYTE, value); + } else if (uu.getUnitType() == UnitTypes.TIME) { + value = uu.convertTimeValue( + TimeConversion.MS, (long) value); + } + } + + SimpleDateFormat dateFormat = titleDateFormat.get(); + DecimalFormat decimalFormat = decFormat.get(); + + sb.append(dateFormat.format(new Date(point.getX()))) + .append("Z, "); + sb.append(decimalFormat.format(value)); } } idx++; @@ -810,6 +877,99 @@ public class StatsDisplayCanvas extends Canvas { } } + private void setScaleValues(double minVal, double maxVal) { + scalingManager = new ScaleManager(minVal, maxVal); + } + + private void handleMouseDownEvent(MouseEvent e) { + if (e.button == 3) { + GraphData graphData = callback.getGraphData(); + if (graphData == null) { + return; + } + + int x = e.x; + int y = e.y; + List keyList = new ArrayList(); + for (String key : graphData.getKeys()) { + if (rectangleMap.containsKey(key)) { + for (Rectangle rect : rectangleMap.get(key)) { + if (callback.getGroupSettings().containsKey(key)) { + // if true then data are on the graph + if (rect.contains(x, y)) { + keyList.add(key); + } + } + } + } + } + + if (!keyList.isEmpty()) { + showPopup(keyList); + } + } + } + + private void showPopup(final List inputList) { + // Remove the tooltip if it is up + if (tooltip != null && !tooltip.isDisposed()) { + tooltip.dispose(); + } + + // Remove any duplicate entries + Set set = new HashSet(inputList); + final List keyList = new ArrayList(set); + Collections.sort(keyList); + + Menu menu = new Menu(this.getShell(), SWT.POP_UP); + + if (keyList.size() == 1) { + MenuItem selectAll = new MenuItem(menu, SWT.NONE); + selectAll.setText("Hide " + keyList.get(0)); + selectAll.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event event) { + handleHide(keyList); + } + }); + } else if (keyList.size() > 1) { + MenuItem hideAll = new MenuItem(menu, SWT.NONE); + hideAll.setText("Hide All Data At Point"); + hideAll.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event event) { + handleHide(keyList); + } + }); + + new MenuItem(menu, SWT.SEPARATOR); + + MenuItem hideGraphDlgMI = new MenuItem(menu, SWT.NONE); + hideGraphDlgMI.setText("Hide Graph Lines..."); + hideGraphDlgMI.addListener(SWT.Selection, new Listener() { + @Override + public void handleEvent(Event event) { + showHideDlg(keyList); + } + }); + } + + // We need to make the menu visible + menu.setVisible(true); + } + + private void handleHide(List keyList) { + groupCallback.setItemsOff(keyList); + redraw(); + } + + private void showHideDlg(List keyList) { + if (hideDlg == null || hideDlg.isDisposed()) { + this.hideDlg = new HideDlg(getShell(), keyList, groupCallback); + } + hideDlg.open(); + } + /** * Show the "tooltip" mouseover. * @@ -856,22 +1016,20 @@ public class StatsDisplayCanvas extends Canvas { } /** - * Set the graph data. - * - * @param graphData - * The GraphData object - */ - public void setGraphData(GraphData graphData) { - this.graphData = graphData; - } - - /** - * Set the view type. - * * @param view * The view type */ - public void setView(String view) { + public void setView(DataView view) { this.view = view; } + + /** + * Set the group selection callback. + * + * @param groupCallback + * The group callback + */ + public void setCallback(IGroupSelection groupCallback) { + this.groupCallback = groupCallback; + } } diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsGraphDlg.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsGraphDlg.java index bec4cb0584..6960fa20a2 100644 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsGraphDlg.java +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsGraphDlg.java @@ -20,8 +20,11 @@ package com.raytheon.uf.viz.stats.ui; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -48,7 +51,8 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.stats.GraphDataRequest; import com.raytheon.uf.common.stats.GraphDataResponse; import com.raytheon.uf.common.stats.data.GraphData; -import com.raytheon.uf.common.stats.util.DataViewUtils; +import com.raytheon.uf.common.stats.util.DataView; +import com.raytheon.uf.common.stats.util.UnitUtils; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -69,6 +73,7 @@ import com.raytheon.viz.ui.widgets.duallist.ButtonImages.ButtonImage; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Oct 03, 2012 728 mpduff Initial creation. + * Jan 17, 2013 1357 mpduff Add ability to change units. * Jan 18, 2013 1386 mpduff Change menu text. * * @@ -144,6 +149,14 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay, /** Data view combo */ private Combo viewCombo; + /** Menu item map */ + private final Map menuItemMap = new HashMap(); + + /** The currently displayed unit */ + private String displayUnit; + + private UnitUtils unitUtils; + /** * Constructor. * @@ -205,6 +218,8 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay, groupComp.setLayout(gl); groupComp.setLayoutData(gd); + displayCanvas.setCallback(groupComp); + gd = new GridData(SWT.FILL, SWT.DEFAULT, false, true); gl = new GridLayout(2, false); Composite ctrlComp = new Composite(leftComp, SWT.NONE); @@ -221,11 +236,11 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay, graphLabel.setText("Graph: "); List viewList = new ArrayList(); - viewList.add(DataViewUtils.DataView.AVG.getView()); - viewList.add(DataViewUtils.DataView.MIN.getView()); - viewList.add(DataViewUtils.DataView.MAX.getView()); - viewList.add(DataViewUtils.DataView.SUM.getView()); - viewList.add(DataViewUtils.DataView.COUNT.getView()); + viewList.add(DataView.AVG.getView()); + viewList.add(DataView.MIN.getView()); + viewList.add(DataView.MAX.getView()); + viewList.add(DataView.SUM.getView()); + viewList.add(DataView.COUNT.getView()); gd = new GridData(SWT.LEFT, SWT.CENTER, true, false); viewCombo = new Combo(dataComp, SWT.READ_ONLY); @@ -372,6 +387,58 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay, displayCanvas.redraw(); } }); + + // Set up the display units menu choices + MenuItem unitsMI = new MenuItem(graphMenu, SWT.CASCADE); + unitsMI.setText("Display Units"); + + unitUtils = new UnitUtils(graphData.getEventType(), + graphData.getDataType()); + String displayUnit = graphData.getDisplayUnit(); + unitUtils.setUnitType(displayUnit); + unitUtils.setDisplayUnit(displayUnit); + Set units = unitUtils.getUnitOptions(); + + Menu unitsMenu = new Menu(graphMenu); + unitsMI.setMenu(unitsMenu); + + for (String unit : units) { + MenuItem mi = new MenuItem(unitsMenu, SWT.CHECK); + mi.setText(unit); + if (unit.equals(graphData.getDisplayUnit())) { + mi.setSelection(true); + } + mi.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleUnitsSelection(e); + } + }); + + menuItemMap.put(unit, mi); + } + } + + /** + * Handle the unit selection event. + * + * @param e + * The selection event + */ + private void handleUnitsSelection(SelectionEvent e) { + MenuItem m = (MenuItem) e.getSource(); + for (Entry es : menuItemMap.entrySet()) { + MenuItem mi = es.getValue(); + if (es.getKey().equals(m.getText())) { + m.setSelection(true); + displayUnit = m.getText(); + unitUtils.setDisplayUnit(displayUnit); + graphData.setDisplayUnit(displayUnit); + displayCanvas.redraw(); + } else { + mi.setSelection(false); + } + } } /** @@ -517,7 +584,6 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay, default: return; } - GraphDataRequest request = new GraphDataRequest(); request.setGrouping(this.groupList); request.setCategory(this.category); @@ -526,7 +592,7 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay, request.setField(dataTypeID); TimeRange newTimeRange = new TimeRange(newStart, newEnd); request.setTimeRange(newTimeRange); - request.setTimeStep(5); + request.setTimeStep((int) graphData.getTimeStep()); try { GraphDataResponse response = (GraphDataResponse) ThriftClient .sendRequest(request); @@ -545,7 +611,6 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay, } this.graphData = localGraphData; - this.displayCanvas.setGraphData(graphData); this.displayCanvas.redraw(); } catch (VizException e) { this.statusHandler.handle(Priority.ERROR, "Error Requesting Data", @@ -557,7 +622,8 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay, * Handler for data view combo box change. */ private void handleDataViewChange() { - String view = viewCombo.getText(); + String viewStr = viewCombo.getText(); + DataView view = DataView.fromString(viewStr); this.displayCanvas.setView(view); this.displayCanvas.redraw(); } @@ -631,4 +697,12 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay, public void setDataType(String dataTypeID) { this.dataTypeID = dataTypeID; } + + /** + * {@inheritDoc} + */ + @Override + public UnitUtils getUnitUtils() { + return this.unitUtils; + } } diff --git a/edexOsgi/com.raytheon.uf.common.stats/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.stats/META-INF/MANIFEST.MF index 81c3d897a6..3ecb4c506e 100644 --- a/edexOsgi/com.raytheon.uf.common.stats/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.stats/META-INF/MANIFEST.MF @@ -17,4 +17,6 @@ Require-Bundle: com.raytheon.uf.common.time;bundle-version="1.12.1174", com.raytheon.uf.common.event;bundle-version="1.0.0", com.google.guava;bundle-version="1.0.0", com.raytheon.uf.common.util;bundle-version="1.12.1174", - com.raytheon.uf.common.status;bundle-version="1.12.1174" + com.raytheon.uf.common.status;bundle-version="1.12.1174", + javax.measure;bundle-version="1.0.0", + com.raytheon.uf.common.units;bundle-version="1.0.0" diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/GraphDataRequest.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/GraphDataRequest.java index 340fb9ff9b..0803581c90 100644 --- a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/GraphDataRequest.java +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/GraphDataRequest.java @@ -36,6 +36,7 @@ import com.raytheon.uf.common.time.TimeRange; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 11, 2012 728 mpduff Initial creation + * Jan 17, 2013 1357 mpudff Javadoc update. * * * @@ -139,6 +140,8 @@ public class GraphDataRequest implements IServerRequest { } /** + * The time step of the data in minutes. + * * @param timeStep * the timeStep to set */ @@ -147,6 +150,8 @@ public class GraphDataRequest implements IServerRequest { } /** + * Get the time step in minute. + * * @return the timeStep */ public int getTimeStep() { diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/DataPoint.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/DataPoint.java index 569bd719cd..4173991538 100644 --- a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/DataPoint.java +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/DataPoint.java @@ -20,10 +20,6 @@ package com.raytheon.uf.common.stats.data; import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -31,7 +27,8 @@ import javax.xml.bind.annotation.XmlRootElement; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; -import com.raytheon.uf.common.stats.util.DataViewUtils; +import com.raytheon.uf.common.stats.util.DataView; +import com.raytheon.uf.common.stats.util.UnitUtils.UnitTypes; /** * Class holding an x,y data point and other associated information for the @@ -43,7 +40,8 @@ import com.raytheon.uf.common.stats.util.DataViewUtils; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 7, 2012 mpduff Initial creation + * Sep 7, 2012 mpduff Initial creation + * Jan 17, 2013 1357 mpduff Moved sample code out of this class. * * * @@ -55,37 +53,12 @@ import com.raytheon.uf.common.stats.util.DataViewUtils; @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize public class DataPoint implements Comparable { - /** Date Format object */ - private final ThreadLocal sdf = new ThreadLocal() { - @Override - protected SimpleDateFormat initialValue() { - SimpleDateFormat sTemp = new SimpleDateFormat("MM/dd/yyyy HH:mm"); - sTemp.setTimeZone(TimeZone.getTimeZone("GMT")); - return sTemp; - } - }; - - /** Decimal Format object */ - private final ThreadLocal decFormat = new ThreadLocal() { - @Override - protected DecimalFormat initialValue() { - DecimalFormat format = new DecimalFormat("########.#"); - return format; - } - }; - /** * X value - millis */ @DynamicSerializeElement private long x; - /** - * Text display for the sampling of this point - */ - @DynamicSerializeElement - protected String sampleText; - /** Min value */ @DynamicSerializeElement private BigDecimal min = new BigDecimal(Integer.MAX_VALUE); @@ -102,6 +75,9 @@ public class DataPoint implements Comparable { @DynamicSerializeElement private BigDecimal sum = new BigDecimal(0); + @DynamicSerializeElement + private UnitTypes unitType; + /** Constructor */ public DataPoint() { sum = sum.setScale(1, BigDecimal.ROUND_HALF_UP); @@ -110,27 +86,6 @@ public class DataPoint implements Comparable { count = count.setScale(1, BigDecimal.ROUND_HALF_UP); } - /** - * @param sampleText - * the sampleText to set - */ - public void setSampleText(String sampleText) { - this.sampleText = sampleText; - } - - /** - * Get the sample text for this point object - * - * @return the sample text string - */ - public String getSampleText(String view) { - SimpleDateFormat dateFormat = sdf.get(); - DecimalFormat decimalFormat = decFormat.get(); - - return dateFormat.format(new Date(x)) + "Z, " - + decimalFormat.format(getValue(view)); - } - /** * @param x * the x to set @@ -258,20 +213,35 @@ public class DataPoint implements Comparable { return 0; } + /** + * @return the unitType + */ + public UnitTypes getUnitType() { + return unitType; + } + + /** + * @param unitType + * the unitType to set + */ + public void setUnitType(UnitTypes unitType) { + this.unitType = unitType; + } + /** * Get the value for the provided data view type. * * @param view * the view type */ - public double getValue(String view) { - if (view.equals(DataViewUtils.DataView.AVG.getView())) { + public double getValue(DataView view) { + if (view.equals(DataView.AVG)) { return getAvg(); - } else if (view.equals(DataViewUtils.DataView.MIN.getView())) { + } else if (view.equals(DataView.MIN)) { return getMin(); - } else if (view.equals(DataViewUtils.DataView.MAX.getView())) { + } else if (view.equals(DataView.MAX)) { return getMax(); - } else if (view.equals(DataViewUtils.DataView.SUM.getView())) { + } else if (view.equals(DataView.SUM)) { return getSum(); } else { return getCount(); diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/GraphData.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/GraphData.java index c05481534f..9e13e54f5a 100644 --- a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/GraphData.java +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/GraphData.java @@ -33,7 +33,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.stats.AggregateRecord; import com.raytheon.uf.common.stats.StatisticsEvent; -import com.raytheon.uf.common.stats.util.UnitUtils; +import com.raytheon.uf.common.stats.util.DataView; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -43,17 +43,18 @@ import com.raytheon.uf.common.util.ReflectionUtil; /** * Data object for the statistics graph. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Oct 3, 2012     728     mpduff      Initial creation
- *
+ * Oct 03, 2012    728     mpduff      Initial creation
+ * Jan 17, 2013   1357     mpduff      Add timestep.
+ * 
  * 
- * + * * @author mpduff * @version 1.0 */ @@ -96,8 +97,17 @@ public class GraphData { @DynamicSerializeElement private String displayUnit; - /** UnitUtils object */ - private UnitUtils unitUtils; + /** Timestep value */ + @DynamicSerializeElement + private long timeStep; + + /** Event Type value */ + @DynamicSerializeElement + private String eventType; + + /** Data Type value */ + @DynamicSerializeElement + private String dataType; /** * Constructor. @@ -130,7 +140,7 @@ public class GraphData { /** * Add an AggregateRecord. - * + * * @param record */ public void addRecord(AggregateRecord record) { @@ -148,7 +158,7 @@ public class GraphData { /** * Get a list of group memebers. - * + * * @return */ public List getGroupMembers() { @@ -160,7 +170,7 @@ public class GraphData { /** * Get the smallest value in the data set. - * + * * @return */ public double getMinValue() { @@ -177,7 +187,7 @@ public class GraphData { /** * Get the largest value in the data set. - * + * * @return */ public double getMaxValue() { @@ -194,10 +204,10 @@ public class GraphData { /** * Get the smallest value in the data set. - * + * * @return */ - public double getMinValue(Set visibleDataSet, String view) { + public double getMinValue(Set visibleDataSet, DataView view) { if (visibleDataSet.isEmpty()) { return 0; } @@ -217,10 +227,10 @@ public class GraphData { /** * Get the largest value in the data set. - * + * * @return */ - public double getMaxValue(Set visibleDataSet, String view) { + public double getMaxValue(Set visibleDataSet, DataView view) { if (visibleDataSet.isEmpty()) { return 1; } @@ -239,7 +249,7 @@ public class GraphData { /** * Get the time range for this object. - * + * * @return */ public TimeRange getTimeRange() { @@ -248,7 +258,7 @@ public class GraphData { /** * Set the TimeRange - * + * * @param timeRange */ public void setTimeRange(TimeRange timeRange) { @@ -257,7 +267,7 @@ public class GraphData { /** * Set the key sequence - * + * * @param keySequence */ public void setKeySequence(List keySequence) { @@ -270,7 +280,7 @@ public class GraphData { /** * Get the key sequence. - * + * * @return */ public List getKeySequence() { @@ -279,7 +289,7 @@ public class GraphData { /** * Get a list of all keys. - * + * * @return the keys */ public List getKeys() { @@ -288,7 +298,7 @@ public class GraphData { /** * Get a list of keys that contain data. - * + * * @return the keys with data */ public List getKeysWithData() { @@ -305,7 +315,7 @@ public class GraphData { /** * Set the StatsLabelData object - * + * * @param statsLabelData */ public void setStatsLabelData(StatsLabelData statsLabelData) { @@ -315,7 +325,7 @@ public class GraphData { /** * Get the StatsLabelData - * + * * @return */ public StatsLabelData getStatsLabelData() { @@ -324,7 +334,7 @@ public class GraphData { /** * Get the group and names map. - * + * * @return */ public Map> getGroupAndNamesMap() { @@ -333,12 +343,12 @@ public class GraphData { /** * Get the units from the event object - * + * * @param eventId * Event id * @param field * data field - * + * * @return The units */ @VisibleForTesting @@ -397,7 +407,7 @@ public class GraphData { /** * Set the StatsData map. - * + * * @param statsDataMap */ public void setStatsDataMap(Map statsDataMap) { @@ -405,18 +415,47 @@ public class GraphData { } /** - * @return the unitUtils + * @return the timeStep */ - public UnitUtils getUnitUtils() { - return unitUtils; + public long getTimeStep() { + return timeStep; } /** - * @param unitUtils - * the unitUtils to set + * @param timeStep + * the timeStep to set */ - public void setUnitUtils(UnitUtils unitUtils) { - this.unitUtils = unitUtils; - this.unitUtils.setConversion(this.getMaxValue()); + public void setTimeStep(long timeStep) { + this.timeStep = timeStep; + } + + /** + * @return the eventType + */ + public String getEventType() { + return eventType; + } + + /** + * @param eventType + * the eventType to set + */ + public void setEventType(String eventType) { + this.eventType = eventType; + } + + /** + * @return the dataType + */ + public String getDataType() { + return dataType; + } + + /** + * @param dataType + * the dataType to set + */ + public void setDataType(String dataType) { + this.dataType = dataType; } } diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/StatsBin.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/StatsBin.java index b06266cf9f..5174931dd4 100644 --- a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/StatsBin.java +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/StatsBin.java @@ -28,17 +28,18 @@ import com.raytheon.uf.common.stats.AggregateRecord; /** * A bin of Statistical data. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Sep 11, 2012   723      mpduff      Initial creation
- *
+ * Sep 11, 2012   723      mpduff      Initial creation.
+ * Jan 17, 2013  1357      mpduff      Change method name.
+ * 
  * 
- * + * * @author mpduff * @version 1.0 */ @@ -57,6 +58,17 @@ public class StatsBin { } + /** + * Copy constructor. + * + * @param bin + * The StatsBin object to copy + */ + public StatsBin(StatsBin bin) { + this.setBinMillis(bin.getBinMillis()); + data.addAll(bin.getData()); + } + /** * @return the binMillis */ @@ -74,16 +86,16 @@ public class StatsBin { /** * Add an AggregateRecord object. - * + * * @param record */ - public void setData(AggregateRecord record) { + public void addData(AggregateRecord record) { this.data.add(record); } /** * Get the AggregateRecord objects - * + * * @return */ public List getData() { diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/StatsData.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/StatsData.java index 2b4dc162ff..5481057de8 100644 --- a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/StatsData.java +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/StatsData.java @@ -32,22 +32,23 @@ import javax.xml.bind.annotation.XmlRootElement; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.stats.AggregateRecord; -import com.raytheon.uf.common.stats.util.UnitUtils; +import com.raytheon.uf.common.stats.util.DataView; import com.raytheon.uf.common.time.TimeRange; /** * Statistical data object holding data to be graphed. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Sep 07, 2012    728     mpduff      Initial creation
- *
+ * Sep 07, 2012    728     mpduff      Initial creation.
+ * Jan 17, 2013   1357     mpduff      Store data in raw units, not converted.
+ * 
  * 
- * + * * @author mpduff * @version 1.0 */ @@ -84,9 +85,6 @@ public class StatsData { @DynamicSerializeElement private Map bins; - /** UnitUtils object */ - private UnitUtils unitUtils; - /** Constructor */ public StatsData() { @@ -94,7 +92,7 @@ public class StatsData { /** * Constructor - * + * * @param key * Key to the object * @param tsMillis @@ -104,12 +102,10 @@ public class StatsData { * @param unitUtils * UnitUtils object */ - public StatsData(String key, long tsMillis, TimeRange timeRange, - UnitUtils unitUtils) { + public StatsData(String key, long tsMillis, TimeRange timeRange) { this.key = key; this.dataFrequency = (int) tsMillis; this.timeRange = timeRange; - this.unitUtils = unitUtils; } /** @@ -130,7 +126,7 @@ public class StatsData { /** * @return the minValue */ - public Double getMinValue(String view) { + public Double getMinValue(DataView view) { double minValue = Integer.MAX_VALUE; for (DataPoint point : pointList) { @@ -145,7 +141,7 @@ public class StatsData { /** * @return the minValue */ - public Double getMaxValue(String view) { + public Double getMaxValue(DataView view) { double maxValue = Integer.MIN_VALUE; for (DataPoint point : pointList) { @@ -189,7 +185,7 @@ public class StatsData { /** * Get the list of DataPoint objects for the key. - * + * * @param key * The key * @return List of DataPoint objects @@ -216,7 +212,7 @@ public class StatsData { /** * Add an AggregateRecord. - * + * * @param rec * the record to add */ @@ -226,7 +222,7 @@ public class StatsData { /** * Get the key - * + * * @return */ public String getKey() { @@ -235,7 +231,7 @@ public class StatsData { /** * Set the key - * + * * @param key * the key to set */ @@ -245,7 +241,7 @@ public class StatsData { /** * Set the StatsBin object map. - * + * * @param bins */ public void setBins(Map bins) { @@ -263,7 +259,7 @@ public class StatsData { long start = startDate.getTime(); long bin = getBinKey(start); if (bins.get(bin) != null) { - bins.get(bin).setData(record); + bins.get(bin).addData(record); } } @@ -272,13 +268,11 @@ public class StatsData { /** * Create the points for this key. - * + * * @param dataKey */ private void createPoints() { // Bins are created, now make the graph group member and point objects - // convert the data values before storing in the data object - double conversion = unitUtils.getConversion(); for (long key : bins.keySet()) { StatsBin sb = bins.get(key); List dataList = sb.getData(); @@ -288,9 +282,9 @@ public class StatsData { for (AggregateRecord rec : dataList) { // Check for an existing point object - point.setMax(rec.getMax() / conversion); - point.setMin(rec.getMin() / conversion); - point.setSum(rec.getSum() / conversion); + point.setMax(rec.getMax()); + point.setMin(rec.getMin()); + point.setSum(rec.getSum()); point.addToCount(rec.getCount()); } @@ -301,7 +295,7 @@ public class StatsData { /** * Get the bin key for the given millisecond value. - * + * * @param millis * The millisecond value * @return The bin that should hold this millisecond value diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/DataView.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/DataView.java new file mode 100644 index 0000000000..73ba4e3300 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/DataView.java @@ -0,0 +1,77 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.common.stats.util; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import com.raytheon.uf.common.units.DataSizeUnit; + +/** + * Data view enumeration. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 18, 2013    1357    mpduff      Moved to its own file.
+ * 
+ * 
+ * + * @author djohnson + * @version 1.0 + */ + +public enum DataView { + AVG("Average"), MIN("Minimum"), MAX("Maximum"), SUM("Sum"), COUNT("Count"); + + private final String view; + + private DataView(String view) { + this.view = view; + } + + public String getView() { + return view; + } + + private static final Map LOOKUP_MAP; + static { + Map map = new HashMap(); + for (DataView view : DataView.values()) { + map.put(view.getView(), view); + } + LOOKUP_MAP = Collections.unmodifiableMap(map); + } + + /** + * Retrieve the {@link DataSizeUnit} for its string representation. + * + * @param asString + * @return + */ + public static DataView fromString(String asString) { + return LOOKUP_MAP.get(asString); + } + +} \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/DataViewUtils.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/DataViewUtils.java deleted file mode 100644 index a9566df815..0000000000 --- a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/DataViewUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.common.stats.util; - -/** - * TODO Add Description - * - *
- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Nov 27, 2012            mpduff     Initial creation
- *
- * 
- * - * @author mpduff - * @version 1.0 - */ - -public class DataViewUtils { - public enum DataView { - AVG("Average"), MIN("Minimum"), MAX("Maximum"), - SUM("Sum"), COUNT("Count"); - - private final String view; - - private DataView(String view) { - this.view = view; - } - - public String getView() { - return view; - } - } -} diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/UnitUtils.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/UnitUtils.java index 3369c245a6..23b6f368c6 100644 --- a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/UnitUtils.java +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/UnitUtils.java @@ -19,125 +19,113 @@ **/ package com.raytheon.uf.common.stats.util; +import java.util.Collections; import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.Set; +import java.util.concurrent.TimeUnit; +import com.google.common.annotations.VisibleForTesting; import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; -import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.common.units.DataSizeUnit; /** * Utility class for data size conversions. KB vs MB vs GB - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Nov 14, 2012    728     mpduff      Initial creation.
- *
+ * Jan 17, 2013   1357     mpduff      Refactored to use DataSizeUnit and TimeUnit.
+ * 
  * 
- * + * * @author mpduff * @version 1.0 */ @DynamicSerialize public class UnitUtils implements ISerializableObject { - /** Bytes per Kilobyte */ - private static final double BYTES_PER_KILOBYTE = 1024.0; - /** Different unit types for statistics */ public static enum UnitTypes { DATA_SIZE, TIME, COUNT } /** - * Data Size Conversions + * Time Conversions. */ - public static enum DataSize { - KB("KB", BYTES_PER_KILOBYTE), MB("MB", BYTES_PER_KILOBYTE - * BYTES_PER_KILOBYTE), GB("GB", BYTES_PER_KILOBYTE - * BYTES_PER_KILOBYTE * BYTES_PER_KILOBYTE); + public static enum TimeConversion { + MS("ms", "MILLISECONDS"), Second("Seconds", "SECONDS"), Minute( + "Minutes", "MINUTES"), Hour("Hours", "HOURS"); private final String unit; - private final double conversion; + private final String fullUnit; - private static Set dataUnits; + private TimeUnit timeUnit; - private DataSize(String unit, double conversion) { + private TimeConversion(String unit, String fullUnit) { this.unit = unit; - this.conversion = conversion; - populateSet(); - } - - private static void populateSet() { - dataUnits = new HashSet(); - dataUnits.add("KB"); - dataUnits.add("MB"); - dataUnits.add("GB"); + this.fullUnit = fullUnit; + timeUnit = TimeUnit.valueOf(fullUnit); } public String getDataUnit() { return unit; } - public double getConversion() { - return conversion; + public String getFullUnit() { + return fullUnit; } - public static Set getDataUnits() { - return dataUnits; + public TimeUnit getTimeUnit() { + return timeUnit; + } + + public static TimeConversion getInstance(String unit) { + return TIME_UNIT_LOOKUP.get(unit); } } /** - * Time Conversions. + * Data size unit lookup map. */ - public static enum TimeConversion { - MS("ms", 1), Second("seconds", TimeUtil.MILLIS_PER_SECOND), Minute( - "minutes", TimeUtil.MILLIS_PER_MINUTE), Hour("hours", - TimeUtil.MILLIS_PER_HOUR); - - private static Set dataUnits; - - private final String unit; - - private final double conversion; - - private TimeConversion(String unit, double conversion) { - this.unit = unit; - this.conversion = conversion; - populateSet(); + private static final Map DATA_SIZE_UNIT_LOOKUP; + static { + DataSizeUnit[] values = DataSizeUnit.values(); + Map map = new LinkedHashMap( + values.length); + for (DataSizeUnit dataSize : values) { + map.put(dataSize.getUnit(), dataSize); } + DATA_SIZE_UNIT_LOOKUP = Collections.unmodifiableMap(map); + } - private static void populateSet() { - dataUnits = new HashSet(); - dataUnits.add("seconds"); - dataUnits.add("ms"); - dataUnits.add("minutes"); - dataUnits.add("hours"); - } - - public String getDataUnit() { - return unit; - } - - public double getConversion() { - return conversion; - } - - public static Set getDataUnits() { - return dataUnits; + /** + * Time unit lookup map. + */ + private static final Map TIME_UNIT_LOOKUP; + static { + TimeConversion[] values = TimeConversion.values(); + Map map = new LinkedHashMap( + values.length); + for (TimeConversion timeConversion : values) { + map.put(timeConversion.getDataUnit(), timeConversion); } + TIME_UNIT_LOOKUP = Collections.unmodifiableMap(map); } /** The event type */ + @DynamicSerializeElement private String eventType; /** The data type */ + @DynamicSerializeElement private String dataType; /** The display unit */ @@ -148,10 +136,6 @@ public class UnitUtils implements ISerializableObject { @DynamicSerializeElement private UnitTypes unitType; - /** Copnversion factor */ - @DynamicSerializeElement - private double conversion = 1; - /** * Constructor */ @@ -161,7 +145,7 @@ public class UnitUtils implements ISerializableObject { /** * Constructor - * + * * @param eventType * event type * @param dataType @@ -174,38 +158,6 @@ public class UnitUtils implements ISerializableObject { this.unitType = UnitTypes.COUNT; } - /** - * The largest value of the data set. This is used to determine which - * conversion to use if one is not specified. - * - * @param value - * Largest value of the data set - * - * @return The conversion factor - */ - public void setConversion(double value) { - // Which unit type is it? - if (unitType == UnitTypes.COUNT) { - conversion = 1; - } else if (unitType == UnitTypes.DATA_SIZE) { - if (value < DataSize.MB.getConversion()) { - conversion = DataSize.KB.getConversion(); - } else if (value < DataSize.GB.getConversion()) { - conversion = DataSize.MB.getConversion(); - } else if (value >= DataSize.GB.getConversion()) { - conversion = DataSize.GB.getConversion(); - } - } else if (unitType == UnitTypes.TIME) { - if (value < TimeUtil.MILLIS_PER_MINUTE) { - conversion = TimeUtil.MILLIS_PER_SECOND; - } else if (value < TimeUtil.MILLIS_PER_HOUR) { - conversion = TimeUtil.MILLIS_PER_MINUTE; - } else { - conversion = TimeUtil.MILLIS_PER_SECOND; - } - } - } - /** * @return the eventType */ @@ -220,15 +172,6 @@ public class UnitUtils implements ISerializableObject { return dataType; } - /** - * Get the conversion - * - * @return - */ - public double getConversion() { - return conversion; - } - /** * @return the unitType */ @@ -252,36 +195,140 @@ public class UnitUtils implements ISerializableObject { } /** - * Set the display unit. - * * @param displayUnit + * the displayUnit to set */ public void setDisplayUnit(String displayUnit) { this.displayUnit = displayUnit; + setUnitType(displayUnit); + } - // Determine the unitType - if (DataSize.getDataUnits().contains(displayUnit)) { - unitType = UnitTypes.DATA_SIZE; - } else if (TimeConversion.getDataUnits().contains(displayUnit)) { - unitType = UnitTypes.TIME; - } + /** + * @param eventType + * the eventType to set + */ + public void setEventType(String eventType) { + this.eventType = eventType; + } - if (unitType == UnitTypes.DATA_SIZE) { - if (displayUnit.equals(DataSize.KB.getDataUnit())) { - conversion = DataSize.KB.getConversion(); - } else if (displayUnit.equals(DataSize.MB.getDataUnit())) { - conversion = DataSize.MB.getConversion(); - } else if (displayUnit.equals(DataSize.GB.getDataUnit())) { - conversion = DataSize.GB.getConversion(); - } - } else if (unitType == UnitTypes.TIME) { - if (displayUnit.equals(TimeConversion.MS.getDataUnit())) { - conversion = 1; - } else if (displayUnit.equals(TimeConversion.Second.getDataUnit())) { - conversion = TimeUtil.MILLIS_PER_SECOND; - } else if (displayUnit.equals(TimeConversion.Minute.getDataUnit())) { - conversion = TimeUtil.MILLIS_PER_MINUTE; - } + /** + * @param dataType + * the dataType to set + */ + public void setDataType(String dataType) { + this.dataType = dataType; + } + + /** + * Set the unit type based on the display unit. + * + * @param displayUnit + * The display unit + */ + public void setUnitType(String displayUnit) { + if (TIME_UNIT_LOOKUP.containsKey(displayUnit)) { + this.setUnitType(UnitTypes.TIME); + } else if (DATA_SIZE_UNIT_LOOKUP.containsKey(displayUnit)) { + this.setUnitType(UnitTypes.DATA_SIZE); } } + + /** + * Get the available units for the provided unit type. + * + * @param type + * The type of unit + * @return The available units + */ + @VisibleForTesting + public Set getUnitOptions(UnitTypes type) { + Set units = Collections.emptySet(); + + switch (type) { + case DATA_SIZE: + units = DATA_SIZE_UNIT_LOOKUP.keySet(); + break; + case TIME: + units = TIME_UNIT_LOOKUP.keySet(); + // units = TimeConversion.getDataUnits(); + break; + case COUNT: + units = new HashSet(); + units.add("Count"); + break; + default: + break; + } + + return units; + } + + /** + * Convert the value in original units to displayUnits. + * + * @param unit + * original unit + * @param value + * in bytes + * @return converted value + */ + @VisibleForTesting + public double convertDataSizeValue(DataSizeUnit unit, double value) { + DataSizeUnit ds = DataSizeUnit.fromString(displayUnit); + if (ds != null) { + if (ds == DataSizeUnit.BYTE) { + return unit.toByte((long) value); + } else if (ds == DataSizeUnit.KB) { + return unit.toKB((long) value); + } else if (ds == DataSizeUnit.MB) { + return unit.toMB((long) value); + } else if (ds == DataSizeUnit.GB) { + return unit.toGB((long) value); + } + + return value; + } + + return value; + } + + /** + * Convert a time from one unit to the display unit. + * + * @param unit + * Originating unit + * @param value + * value to convert + * @return value converted to display unit + */ + @VisibleForTesting + public long convertTimeValue(TimeConversion unit, long value) { + TimeConversion outputTc = TimeConversion.getInstance(displayUnit); + return outputTc.getTimeUnit().convert(value, unit.getTimeUnit()); + } + + /** + * Convert the provided value. Time types expect source units to be ms and + * data size units to be Bytes. + * + * @param value + * @param view + * @param displayUnit + * @return The converted value + */ + public double convertValue(double value) { + if (getUnitType() == UnitTypes.TIME) { + return convertTimeValue(TimeConversion.MS, (long) value); + } else { + return convertDataSizeValue(DataSizeUnit.BYTE, value); + } + + } + + /** + * Get the different unit options for the provided unit type. + */ + public Set getUnitOptions() { + return this.getUnitOptions(this.unitType); + } } diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java index d7555357a5..ac04d0011f 100644 --- a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java @@ -44,6 +44,7 @@ import com.raytheon.uf.common.time.domain.api.ITimePoint; * Nov 09, 2012 1322 djohnson Add SECONDS_PER_MINUTE. * Nov 21, 2012 728 mpduff Added MILLIS_PER_MONTH. * Jan 07, 2013 1451 djohnson Add newGmtCalendar() and time constants. + * Jan 17, 2013 1357 mpduff Change MILLIS_PER_MONTH to MILLIS_PER_30_DAYS * Jan 22, 2013 1484 mpduff Add HOURS_PER_WEEK. * Jan 22, 2013 1519 djohnson Add MINUTES_PER_DAY. * @@ -121,10 +122,7 @@ public final class TimeUtil { public static final long MILLIS_PER_WEEK = MILLIS_PER_DAY * DAYS_PER_WEEK; - /** - * Note: This constant assumes a month of 30 days. - */ - public static final long MILLIS_PER_MONTH = MILLIS_PER_DAY * 30; + public static final long MILLIS_PER_30_DAYS = MILLIS_PER_DAY * 30; /** * Note: This constant does not take into account leap years. diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataSizeUnit.java b/edexOsgi/com.raytheon.uf.common.units/src/com/raytheon/uf/common/units/DataSizeUnit.java similarity index 96% rename from cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataSizeUnit.java rename to edexOsgi/com.raytheon.uf.common.units/src/com/raytheon/uf/common/units/DataSizeUnit.java index b45cea2fc0..89f23ca2d0 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/utils/DataSizeUnit.java +++ b/edexOsgi/com.raytheon.uf.common.units/src/com/raytheon/uf/common/units/DataSizeUnit.java @@ -1,4 +1,4 @@ -package com.raytheon.uf.viz.datadelivery.utils; +package com.raytheon.uf.common.units; import java.util.Collections; import java.util.HashMap; @@ -6,7 +6,6 @@ import java.util.Map; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; /** * Enumeration for Data Size units and conversions. Based off of TimeUnit class. @@ -19,13 +18,14 @@ import javax.xml.bind.annotation.XmlType; * ------------ ---------- ----------- -------------------------- * Jan 08, 2013 1420 mpduff Initial creation. * Jan 14, 2013 1286 djohnson Add lookup map via string version. + * Jan 17, 2013 1357 mpduff Moved to com.raytheon.uf.common.units so other plugins can use it. * * * * @author mpduff * @version 1.0 */ -@XmlType(name = "ruleUnit") + @XmlEnum public enum DataSizeUnit { @XmlEnumValue("Byte") diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/data/StatsDataAccumulator.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/data/StatsDataAccumulator.java index 233a1bd749..d207d2d13d 100644 --- a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/data/StatsDataAccumulator.java +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/data/StatsDataAccumulator.java @@ -20,7 +20,6 @@ package com.raytheon.uf.edex.stats.data; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -34,8 +33,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.raytheon.uf.common.serialization.JAXBManager; -import com.raytheon.uf.common.serialization.SerializationException; -import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.stats.AggregateRecord; import com.raytheon.uf.common.stats.StatsGrouping; import com.raytheon.uf.common.stats.StatsGroupingColumn; @@ -43,7 +40,6 @@ import com.raytheon.uf.common.stats.data.GraphData; import com.raytheon.uf.common.stats.data.StatsBin; import com.raytheon.uf.common.stats.data.StatsData; import com.raytheon.uf.common.stats.data.StatsLabelData; -import com.raytheon.uf.common.stats.util.UnitUtils; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -62,6 +58,7 @@ import com.raytheon.uf.common.util.CollectionUtil; * ------------ ---------- ----------- -------------------------- * Nov 15, 2012 728 mpduff Initial creation * Jan 15, 2013 1487 djohnson Use xml for the grouping information on an {@link AggregateRecord}. + * Jan 17, 2013 1357 mpduff Remove unit conversions, add time step, other cleanup. * * * @@ -74,8 +71,12 @@ public class StatsDataAccumulator { private static final IUFStatusHandler statusHandler = UFStatus .getHandler(StatsDataAccumulator.class); + /** + * Constant. + */ private static final String COLON = ":"; + /** JaxB manager instance. */ private static final JAXBManager JAXB_MANAGER; static { try { @@ -166,8 +167,6 @@ public class StatsDataAccumulator { // Loop backwards over the data StatsLabelData prevLabelData = null; StatsLabelData statsLabelData = null; - UnitUtils unitUtils = new UnitUtils(eventType, dataType); - unitUtils.setDisplayUnit(displayUnit); for (int i = groups.size() - 1; i >= 0; i--) { String group = groups.get(i); @@ -179,7 +178,7 @@ public class StatsDataAccumulator { prevLabelData = statsLabelData; } - gather(unitUtils, groups); + gather(groups); // StatsLabelData is created and holds all the keys GraphData graphData = new GraphData(); @@ -188,8 +187,10 @@ public class StatsDataAccumulator { graphData.setStatsDataMap(statsDataMap); graphData.setTimeRange(timeRange); graphData.setKeys(new ArrayList(this.statsDataMap.keySet())); - graphData.setUnitUtils(unitUtils); graphData.setKeySequence(groups); + graphData.setTimeStep(this.timeStep); + graphData.setEventType(eventType); + graphData.setDataType(dataType); return graphData; } @@ -203,7 +204,7 @@ public class StatsDataAccumulator { * List of groups */ @VisibleForTesting - void createStatsDataMap(UnitUtils unitUtils, List groups) { + void createStatsDataMap(List groups) { Map keySequenceMap = new LinkedHashMap(); for (String key : groups) { keySequenceMap.put(key, ""); @@ -249,7 +250,7 @@ public class StatsDataAccumulator { if (!statsDataMap.containsKey(builtKey)) { statsDataMap.put(builtKey, new StatsData(builtKey, - timeStep, this.timeRange, unitUtils)); + timeStep, this.timeRange)); } statsDataMap.get(builtKey).addRecord(record); @@ -289,21 +290,17 @@ public class StatsDataAccumulator { * @param groups * List of groups */ - @SuppressWarnings("unchecked") - private void gather(UnitUtils unitUtils, List groups) { - createStatsDataMap(unitUtils, groups); + private void gather(List groups) { + createStatsDataMap(groups); calculateBins(); + Map newMap = new TreeMap(); for (String key : statsDataMap.keySet()) { - Map newMap = Collections.emptyMap(); - try { - newMap = SerializationUtil.transformFromThrift(Map.class, - SerializationUtil.transformToThrift(bins)); - } catch (SerializationException e) { - statusHandler - .handle(Priority.PROBLEM, - "Error serializing/deserializing StatsBin data. Skipping...", - e); + // Copy the bins object + for (long lkey : bins.keySet()) { + StatsBin sb = new StatsBin(bins.get(lkey)); + newMap.put(lkey, sb); } + StatsData data = statsDataMap.get(key); data.setBins(newMap); data.accumulate(); diff --git a/edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml b/edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml index ed85b9c2e7..90c2d74058 100644 --- a/edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml +++ b/edexOsgi/com.raytheon.uf.edex.stats/utility/edex_static/base/stats/edexProcessStats.xml @@ -3,6 +3,8 @@ + + diff --git a/tests/unit/com/raytheon/uf/common/stats/data/DataPointTest.java b/tests/unit/com/raytheon/uf/common/stats/data/DataPointTest.java index 675fa61bb1..e65a4d3530 100644 --- a/tests/unit/com/raytheon/uf/common/stats/data/DataPointTest.java +++ b/tests/unit/com/raytheon/uf/common/stats/data/DataPointTest.java @@ -10,7 +10,7 @@ import java.util.TimeZone; import org.junit.Test; import com.raytheon.uf.common.stats.AggregateRecord; -import com.raytheon.uf.common.stats.util.DataViewUtils; +import com.raytheon.uf.common.stats.util.DataView; public class DataPointTest { private final String eventType = "com.raytheon.uf.common.stats.ProcessEvent"; @@ -38,7 +38,7 @@ public class DataPointTest { assertEquals("Count does not match", expectedCount, point.getCount(), 0); assertEquals("Count does not match", expectedCount, - point.getValue(DataViewUtils.DataView.COUNT.getView()), 0); + point.getValue(DataView.COUNT), 0); } @Test @@ -60,7 +60,7 @@ public class DataPointTest { assertEquals("Sum does not match", expectedSum, point.getSum(), 0); assertEquals("Sum does not match", expectedSum, - point.getValue(DataViewUtils.DataView.SUM.getView()), 0); + point.getValue(DataView.SUM), 0); } @Test @@ -82,7 +82,7 @@ public class DataPointTest { assertEquals("Min does not match", expectedMin, point.getMin(), 0); assertEquals("Min does not match", expectedMin, - point.getValue(DataViewUtils.DataView.MIN.getView()), 0); + point.getValue(DataView.MIN), 0); } @Test @@ -104,7 +104,7 @@ public class DataPointTest { assertEquals("Max does not match", expectedMax, point.getMax(), 0); assertEquals("Max does not match", expectedMax, - point.getValue(DataViewUtils.DataView.MAX.getView()), 0); + point.getValue(DataView.MAX), 0); } @Test @@ -128,7 +128,7 @@ public class DataPointTest { assertEquals("Avg does not match", expectedAvg, point.getAvg(), 0.25); assertEquals("Avg does not match", expectedAvg, - point.getValue(DataViewUtils.DataView.AVG.getView()), 0.25); + point.getValue(DataView.AVG), 0.25); } // Build the Aggregate records diff --git a/tests/unit/com/raytheon/uf/common/stats/data/StatsDataTest.java b/tests/unit/com/raytheon/uf/common/stats/data/StatsDataTest.java index a809993eff..39f11bb83d 100644 --- a/tests/unit/com/raytheon/uf/common/stats/data/StatsDataTest.java +++ b/tests/unit/com/raytheon/uf/common/stats/data/StatsDataTest.java @@ -17,7 +17,9 @@ import com.raytheon.uf.common.time.util.TimeUtil; public class StatsDataTest { private final String eventType = "com.raytheon.uf.common.stats.ProcessEvent"; + private final String field = "processingTime"; + private final String grouping = "pluginName:obs"; final Map bins = new TreeMap(); @@ -41,7 +43,8 @@ public class StatsDataTest { UnitUtils unitUtils = new UnitUtils(eventType, field); unitUtils.setDisplayUnit("ms"); - StatsData statsData = new StatsData("key", TimeUtil.MILLIS_PER_MINUTE, null, unitUtils); + StatsData statsData = new StatsData("key", TimeUtil.MILLIS_PER_MINUTE, + null); statsData.setBins(bins); statsData.addRecord(records.get(0)); statsData.addRecord(records.get(1)); @@ -50,11 +53,10 @@ public class StatsDataTest { List pointList = statsData.getData(); int expectedPointCount = 2; - assertEquals("Point Counts differ", expectedPointCount, pointList.size(), 0); + assertEquals("Point Counts differ", expectedPointCount, + pointList.size(), 0); } - - // Build the Aggregate records private List getTestRecords() { List records = new ArrayList(); diff --git a/tests/unit/com/raytheon/uf/common/stats/util/UnitUtilsTest.java b/tests/unit/com/raytheon/uf/common/stats/util/UnitUtilsTest.java new file mode 100644 index 0000000000..3515ba3021 --- /dev/null +++ b/tests/unit/com/raytheon/uf/common/stats/util/UnitUtilsTest.java @@ -0,0 +1,179 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.common.stats.util; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.raytheon.uf.common.stats.ProcessEvent; +import com.raytheon.uf.common.stats.util.UnitUtils.TimeConversion; +import com.raytheon.uf.common.stats.util.UnitUtils.UnitTypes; +import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.common.units.DataSizeUnit; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 17, 2013   1357      mpduff     Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class UnitUtilsTest { + + private static final String EVENT_TYPE = ProcessEvent.class.getName(); + + private static final String DATA_TYPE = "processingTime"; + + @Test + public void testConvertBytesToBytes() { + UnitUtils uu = new UnitUtils(EVENT_TYPE, DATA_TYPE); + uu.setUnitType(DataSizeUnit.BYTE.getUnit()); + uu.setDisplayUnit(DataSizeUnit.BYTE.getUnit()); + + double value = uu.convertDataSizeValue(DataSizeUnit.BYTE, 100); + + assertEquals(100, value, 0); + } + + @Test + public void testConvertBytesToKb() { + UnitUtils uu = new UnitUtils(EVENT_TYPE, DATA_TYPE); + uu.setUnitType(DataSizeUnit.BYTE.getUnit()); + uu.setDisplayUnit(DataSizeUnit.KB.getUnit()); + + double value = uu.convertDataSizeValue(DataSizeUnit.BYTE, 1024); + + assertEquals(1, value, 0); + } + + @Test + public void testConvertBytesToMb() { + UnitUtils uu = new UnitUtils(EVENT_TYPE, DATA_TYPE); + uu.setUnitType(DataSizeUnit.BYTE.getUnit()); + uu.setDisplayUnit(DataSizeUnit.MB.getUnit()); + + double value = uu.convertDataSizeValue(DataSizeUnit.BYTE, 1048576); + + assertEquals(1, value, 0); + } + + @Test + public void testConvertValueFromMsToSecond() { + UnitUtils uu = new UnitUtils(EVENT_TYPE, DATA_TYPE); + uu.setUnitType(TimeConversion.MS.getDataUnit()); + uu.setDisplayUnit(TimeConversion.Second.getDataUnit()); + + double value = uu.convertTimeValue(TimeConversion.MS, + TimeUtil.MILLIS_PER_SECOND * 3); + + assertEquals(3, value, 0); + } + + @Test + public void testConvertValueFromMsToMinute() { + UnitUtils uu = new UnitUtils(EVENT_TYPE, DATA_TYPE); + uu.setUnitType(TimeConversion.MS.getDataUnit()); + uu.setDisplayUnit(TimeConversion.Minute.getDataUnit()); + + double value = uu.convertTimeValue(TimeConversion.MS, + TimeUtil.MILLIS_PER_MINUTE * 2); + + assertEquals(2, value, 0); + } + + @Test + public void testConvertValueFromMsToHours() { + UnitUtils uu = new UnitUtils(EVENT_TYPE, DATA_TYPE); + uu.setUnitType(TimeConversion.MS.getDataUnit()); + uu.setDisplayUnit(TimeConversion.Hour.getDataUnit()); + + double value = uu.convertTimeValue(TimeConversion.MS, + TimeUtil.MILLIS_PER_HOUR); + + assertEquals(1, value, 0); + } + + @Test + public void testConvertValueFromHoursToMs() { + UnitUtils uu = new UnitUtils(EVENT_TYPE, DATA_TYPE); + uu.setUnitType(TimeConversion.Hour.getDataUnit()); + uu.setDisplayUnit(TimeConversion.MS.getDataUnit()); + + double value = uu.convertTimeValue(TimeConversion.Hour, 1); + + assertEquals(TimeUtil.MILLIS_PER_HOUR, value, 0); + } + + @Test + public void testVerifyDisplayUnitIsTime() { + UnitUtils uu = new UnitUtils(EVENT_TYPE, DATA_TYPE); + uu.setUnitType(TimeConversion.Hour.getDataUnit()); + uu.setDisplayUnit(TimeConversion.MS.getDataUnit()); + + UnitTypes type = uu.getUnitType(); + + assertEquals(UnitTypes.TIME, type); + } + + @Test + public void testVerifyDisplayUnitIsSize() { + UnitUtils uu = new UnitUtils(EVENT_TYPE, DATA_TYPE); + uu.setUnitType(DataSizeUnit.KB.getUnit()); + uu.setDisplayUnit(DataSizeUnit.MB.getUnit()); + + UnitTypes type = uu.getUnitType(); + + assertEquals(UnitTypes.DATA_SIZE, type); + } + + @Test + public void testConvertValueToSec() { + UnitUtils uu = new UnitUtils(EVENT_TYPE, DATA_TYPE); + uu.setUnitType(TimeConversion.MS.getDataUnit()); + uu.setDisplayUnit(TimeConversion.Second.getDataUnit()); + + double value = uu.convertValue(TimeUtil.MILLIS_PER_SECOND * 3); + + assertEquals(3, value, 0); + } + + @Test + public void testConvertValueToMinute() { + UnitUtils uu = new UnitUtils(EVENT_TYPE, DATA_TYPE); + uu.setUnitType(TimeConversion.MS.getDataUnit()); + uu.setDisplayUnit(TimeConversion.Minute.getDataUnit()); + + double value = uu.convertValue(TimeUtil.MILLIS_PER_MINUTE * 3); + + assertEquals(3, value, 0); + } + +} diff --git a/tests/unit/com/raytheon/uf/edex/stats/data/StatsDataAccumulatorTest.java b/tests/unit/com/raytheon/uf/edex/stats/data/StatsDataAccumulatorTest.java index 7b9e9664f0..b07a538238 100644 --- a/tests/unit/com/raytheon/uf/edex/stats/data/StatsDataAccumulatorTest.java +++ b/tests/unit/com/raytheon/uf/edex/stats/data/StatsDataAccumulatorTest.java @@ -153,7 +153,7 @@ public class StatsDataAccumulatorTest { acc.setDataType(dataType); acc.setupGroupings(); - acc.createStatsDataMap(unitUtils, acc.groups); + acc.createStatsDataMap(acc.groups); Set expectedSet = new HashSet(); expectedSet.add("owner0:nomads"); diff --git a/tests/unit/com/raytheon/uf/viz/datadelivery/subscription/xml/LatencyRuleXMLTest.java b/tests/unit/com/raytheon/uf/viz/datadelivery/subscription/xml/LatencyRuleXMLTest.java index 2031fefa7d..2ac91180a3 100644 --- a/tests/unit/com/raytheon/uf/viz/datadelivery/subscription/xml/LatencyRuleXMLTest.java +++ b/tests/unit/com/raytheon/uf/viz/datadelivery/subscription/xml/LatencyRuleXMLTest.java @@ -24,11 +24,11 @@ import javax.xml.bind.JAXBException; import org.junit.Test; import com.raytheon.uf.common.datadelivery.registry.SubscriptionFixture; +import com.raytheon.uf.common.units.DataSizeUnit; import com.raytheon.uf.common.util.CollectionUtil; import com.raytheon.uf.viz.datadelivery.system.CreateEditRuleDlg.FreqUnitOptions; import com.raytheon.uf.viz.datadelivery.system.OperatorTypes; import com.raytheon.uf.viz.datadelivery.system.OpsNetFieldNames; -import com.raytheon.uf.viz.datadelivery.utils.DataSizeUnit; /** * Test {@link LatencyRulesXML}. @@ -40,6 +40,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataSizeUnit; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 14, 2013 1286 djohnson Initial creation + * Jan 17, 2013 1357 mpduff DataSizeUnits was moved. * * * diff --git a/tests/unit/com/raytheon/uf/viz/datadelivery/subscription/xml/RuleXMLTest.java b/tests/unit/com/raytheon/uf/viz/datadelivery/subscription/xml/RuleXMLTest.java index 8115767058..d219a1cbe2 100644 --- a/tests/unit/com/raytheon/uf/viz/datadelivery/subscription/xml/RuleXMLTest.java +++ b/tests/unit/com/raytheon/uf/viz/datadelivery/subscription/xml/RuleXMLTest.java @@ -30,11 +30,11 @@ import org.junit.Test; import com.raytheon.uf.common.datadelivery.registry.DataType; import com.raytheon.uf.common.datadelivery.registry.Subscription; +import com.raytheon.uf.common.units.DataSizeUnit; import com.raytheon.uf.viz.datadelivery.system.CreateEditRuleDlg.FreqUnitOptions; import com.raytheon.uf.viz.datadelivery.system.Operator; import com.raytheon.uf.viz.datadelivery.system.OperatorTypes; import com.raytheon.uf.viz.datadelivery.system.OpsNetFieldNames; -import com.raytheon.uf.viz.datadelivery.utils.DataSizeUnit; import com.raytheon.uf.viz.datadelivery.utils.NameOperationItems; import com.raytheon.uf.viz.datadelivery.utils.TypeOperationItems; @@ -49,6 +49,7 @@ import com.raytheon.uf.viz.datadelivery.utils.TypeOperationItems; * ------------ ---------- ----------- -------------------------- * Jan 03, 2013 1420 mpduff Initial creation. * Jan 14, 2013 1286 djohnson Use the rule operator as an {@link Operator}. + * Jan 17, 2013 1357 mpduff DataSizeUnits was moved. * * * diff --git a/tests/unit/com/raytheon/uf/viz/datadelivery/utils/DataSizeUtilTest.java b/tests/unit/com/raytheon/uf/viz/datadelivery/utils/DataSizeUtilTest.java index f246a52532..134298cb9d 100644 --- a/tests/unit/com/raytheon/uf/viz/datadelivery/utils/DataSizeUtilTest.java +++ b/tests/unit/com/raytheon/uf/viz/datadelivery/utils/DataSizeUtilTest.java @@ -25,6 +25,8 @@ import static org.junit.Assert.assertThat; import org.junit.Test; +import com.raytheon.uf.common.units.DataSizeUnit; + /** * Test {@link DataSizeUnit} * @@ -34,7 +36,8 @@ import org.junit.Test; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jan 8, 2013 1420 mpduff Initial creation + * Jan 08, 2013 1420 mpduff Initial creation + * Jan 17, 2013 1357 mpduff DataSizeUnits was moved. * * * From 9c033e6484301ac9ec2ee7aef5575dee662367dc Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Wed, 23 Jan 2013 14:40:23 -0600 Subject: [PATCH 04/13] Issue #1523 - Finalize registry and data delivery stats Former-commit-id: d691b22ff903b2231e2a04747a8b4f93174ec4e3 --- .../uf/common/stats/data/StatsEventData.java | 21 +++++++------- .../uf/common/stats/util/UnitUtils.java | 1 - .../base/stats/retrievalProcessStats.xml | 29 +++++++++++++++++++ .../base/stats/registryProcessStats.xml | 14 +++++++++ 4 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/utility/edex_static/base/stats/retrievalProcessStats.xml create mode 100644 edexOsgi/com.raytheon.uf.edex.registry.ebxml/utility/edex_static/base/stats/registryProcessStats.xml diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/StatsEventData.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/StatsEventData.java index c7351576bd..f33f0be176 100644 --- a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/StatsEventData.java +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/data/StatsEventData.java @@ -26,17 +26,18 @@ import java.util.Map; /** * Stats Event helper object. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Nov 8, 2012    728      mpduff      Initial creation
- *
+ * Nov 08, 2012    728     mpduff      Initial creation.
+ * Jan 23, 2013   1523     mpduff      Fix list length.
+ * 
  * 
- * + * * @author mpduff * @version 1.0 */ @@ -136,7 +137,7 @@ public class StatsEventData { /** * Get the group list - * + * * @return */ public String[] getGroups() { @@ -145,16 +146,16 @@ public class StatsEventData { /** * Get the attribute list - * + * * @return */ public String[] getAttributes() { - return attributeList.toArray(new String[groupList.size()]); + return attributeList.toArray(new String[attributeList.size()]); } /** * Get the group name from the display name. - * + * * @param displayName * @return */ diff --git a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/UnitUtils.java b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/UnitUtils.java index 23b6f368c6..0dbb319678 100644 --- a/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/UnitUtils.java +++ b/edexOsgi/com.raytheon.uf.common.stats/src/com/raytheon/uf/common/stats/util/UnitUtils.java @@ -250,7 +250,6 @@ public class UnitUtils implements ISerializableObject { break; case TIME: units = TIME_UNIT_LOOKUP.keySet(); - // units = TimeConversion.getDataUnits(); break; case COUNT: units = new HashSet(); diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/utility/edex_static/base/stats/retrievalProcessStats.xml b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/utility/edex_static/base/stats/retrievalProcessStats.xml new file mode 100644 index 0000000000..2759dde1d3 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/utility/edex_static/base/stats/retrievalProcessStats.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/utility/edex_static/base/stats/registryProcessStats.xml b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/utility/edex_static/base/stats/registryProcessStats.xml new file mode 100644 index 0000000000..7c3ed01ee8 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/utility/edex_static/base/stats/registryProcessStats.xml @@ -0,0 +1,14 @@ + + + + + + + + + + From 8c2789a1a70f314014376264f86c6e893ee17593 Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Wed, 23 Jan 2013 15:02:36 -0600 Subject: [PATCH 05/13] Issue #1386 - Remove Save Stats Graph Menu Item. Former-commit-id: a201a22bb4271c94b1fda7f4eaa1f1b74b9d1859 --- .../uf/viz/stats/ui/StatsGraphDlg.java | 124 +++++++++--------- 1 file changed, 59 insertions(+), 65 deletions(-) diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsGraphDlg.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsGraphDlg.java index 6960fa20a2..172f9daba3 100644 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsGraphDlg.java +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsGraphDlg.java @@ -29,18 +29,12 @@ import java.util.Set; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.ImageLoader; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Menu; @@ -107,8 +101,8 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay, /** Menu bar */ private Menu menuBar; - /** Save Menu Item */ - private MenuItem saveMI; + // /** Save Menu Item */ + // private MenuItem saveMI; /** Exit Menu item */ private MenuItem exitMI; @@ -330,15 +324,15 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay, Menu fileMenu = new Menu(menuBar); fileMenuItem.setMenu(fileMenu); - saveMI = new MenuItem(fileMenu, SWT.NONE); - saveMI.setText("&Save Graph Image\tCtrl+S"); - saveMI.setAccelerator(SWT.CTRL + 'S'); - saveMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - saveGraph(); - } - }); + // saveMI = new MenuItem(fileMenu, SWT.NONE); + // saveMI.setText("&Save Graph Image\tCtrl+S"); + // saveMI.setAccelerator(SWT.CTRL + 'S'); + // saveMI.addSelectionListener(new SelectionAdapter() { + // @Override + // public void widgetSelected(SelectionEvent event) { + // saveGraph(); + // } + // }); exitMI = new MenuItem(fileMenu, SWT.NONE); exitMI.setText("&Quit\tCtrl+Q"); @@ -496,55 +490,55 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay, this.graphTitle = graphTitle; } - /** - * Open a file dialog for saving the canvas. - */ - private void saveGraph() { - FileDialog dialog = new FileDialog(shell, SWT.SAVE); - String filename = dialog.open(); - if (filename == null) { - return; - } - saveCanvas(filename); - } + // /** + // * Open a file dialog for saving the canvas. + // */ + // private void saveGraph() { + // FileDialog dialog = new FileDialog(shell, SWT.SAVE); + // String filename = dialog.open(); + // if (filename == null) { + // return; + // } + // saveCanvas(filename); + // } - /** - * Captures the canvas and saves the result into a file in a format - * determined by the filename extension . - * - * @param control - * The control to save - * @param fileName - * The name of the image to be saved - */ - public void saveCanvas(String filename) { - StringBuilder sb = new StringBuilder(); - Display display = displayCanvas.getDisplay(); - Image image = new Image(display, displayCanvas.getBounds().width, - displayCanvas.getBounds().height); - GC gc = new GC(image); - - displayCanvas.drawCanvas(gc); - - /* Default to PNG */ - int style = SWT.IMAGE_PNG; - - if ((filename.endsWith(".jpg") == true) || filename.endsWith("jpeg")) { - style = SWT.IMAGE_JPEG; - } else if (filename.endsWith(".bmp") == true) { - style = SWT.IMAGE_BMP; - } else { - filename += ".png"; - } - - ImageLoader loader = new ImageLoader(); - loader.data = new ImageData[] { image.getImageData() }; - loader.save(filename, style); - - sb.setLength(0); - image.dispose(); - gc.dispose(); - } + // /** + // * Captures the canvas and saves the result into a file in a format + // * determined by the filename extension . + // * + // * @param control + // * The control to save + // * @param fileName + // * The name of the image to be saved + // */ + // public void saveCanvas(String filename) { + // StringBuilder sb = new StringBuilder(); + // Display display = displayCanvas.getDisplay(); + // Image image = new Image(display, displayCanvas.getBounds().width, + // displayCanvas.getBounds().height); + // GC gc = new GC(image); + // + // displayCanvas.drawCanvas(gc); + // + // /* Default to PNG */ + // int style = SWT.IMAGE_PNG; + // + // if ((filename.endsWith(".jpg") == true) || filename.endsWith("jpeg")) { + // style = SWT.IMAGE_JPEG; + // } else if (filename.endsWith(".bmp") == true) { + // style = SWT.IMAGE_BMP; + // } else { + // filename += ".png"; + // } + // + // ImageLoader loader = new ImageLoader(); + // loader.data = new ImageData[] { image.getImageData() }; + // loader.save(filename, style); + // + // sb.setLength(0); + // image.dispose(); + // gc.dispose(); + // } /** * Request the graph be redrawn with a new time range. From 229a0c77fa4572dab7a396e0d8d0d529b5675aae Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Wed, 23 Jan 2013 15:15:08 -0600 Subject: [PATCH 06/13] Issue #1523 - Fix for count Former-commit-id: 35fbd9ce448a17d761bd4f745fd2f1339d82537b --- .../src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java index 8f7aa0ce04..bb343de1d6 100644 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java @@ -843,7 +843,7 @@ public class StatsDisplayCanvas extends Canvas { .getData().get(idx); double value = point.getValue(view); - if (!view.equals(DataView.COUNT.getView())) { + if (!view.equals(DataView.COUNT)) { if (uu.getUnitType() == UnitTypes.DATA_SIZE) { value = uu.convertDataSizeValue( DataSizeUnit.BYTE, value); From 13fd81366090e7bdd5ed32c6b40f9bcacf289be8 Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Wed, 16 Jan 2013 10:55:14 -0600 Subject: [PATCH 07/13] Issue #1479 fix mod families Former-commit-id: 76b5a4fcf313e2a028662a1e07871fff2e328d48 --- .../cave/etc/bundles/volume/ModelFamilyA.xml | 2 +- .../cave/etc/bundles/volume/ModelFamilyB.xml | 8 +++---- .../cave/etc/bundles/volume/ModelFamilyC.xml | 2 +- .../cave/etc/bundles/volume/ModelFamilyD.xml | 22 +++++++++---------- .../cave/etc/bundles/volume/ModelFamilyH.xml | 10 ++++----- .../cave/etc/bundles/volume/ModelFamilyU.xml | 22 +++++++++---------- .../cave/etc/bundles/volume/ModelFamilyV.xml | 8 +++---- .../cave/etc/bundles/volume/ModelFamilyW.xml | 14 ++++++------ .../cave/etc/bundles/volume/ModelFamilyX.xml | 2 +- .../cave/etc/bundles/volume/ModelFamilyY.xml | 8 +++---- .../cave/etc/bundles/volume/ModelFamilyYY.xml | 10 ++++----- 11 files changed, 54 insertions(+), 54 deletions(-) diff --git a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyA.xml b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyA.xml index 7bfb35758e..ac3186ce95 100644 --- a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyA.xml +++ b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyA.xml @@ -59,7 +59,7 @@ ModFamA| |N|Conv: NonSupercell Tor Family| |OTHER | | \ PLAN_VIEW - + diff --git a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyB.xml b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyB.xml index dff95859dd..6589a91894 100644 --- a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyB.xml +++ b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyB.xml @@ -56,7 +56,7 @@ ModFamB| |N|Conv: Storm Init Family| |OTHER | | \ PLAN_VIEW - + @@ -188,7 +188,7 @@ ModFamB| |N|Conv: Storm Init Family| |OTHER | | \ PLAN_VIEW - + @@ -322,7 +322,7 @@ ModFamB| |N|Conv: Storm Init Family| |OTHER | | \ PLAN_VIEW - + @@ -488,7 +488,7 @@ ModFamB| |N|Conv: Storm Init Family| |OTHER | | \ PLAN_VIEW - + diff --git a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyC.xml b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyC.xml index 10a80f7b61..ab4de75eff 100644 --- a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyC.xml +++ b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyC.xml @@ -166,7 +166,7 @@ ModFamC| |N|Conv: Hail Family| |OTHER | | \ PLAN_VIEW - + diff --git a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyD.xml b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyD.xml index fb9cb3d22b..82af335064 100644 --- a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyD.xml +++ b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyD.xml @@ -70,7 +70,7 @@ ModFamD| |N|Winter: Family| |OTHER | | \ PLAN_VIEW - + @@ -169,7 +169,7 @@ ModFamD| |N|Winter: Family| |OTHER | | \ PLAN_VIEW - + @@ -268,7 +268,7 @@ ModFamD| |N|Winter: Family| |OTHER | | \ PLAN_VIEW - + @@ -367,7 +367,7 @@ ModFamD| |N|Winter: Family| |OTHER | | \ PLAN_VIEW - + @@ -466,7 +466,7 @@ ModFamD| |N|Winter: Family| |OTHER | | \ PLAN_VIEW - + @@ -702,7 +702,7 @@ ModFamD| |N|Winter: Family| |OTHER | | \ PLAN_VIEW - + @@ -981,7 +981,7 @@ ModFamD| |N|Winter: Family| |OTHER | | \ PLAN_VIEW - + @@ -1152,7 +1152,7 @@ ModFamD| |N|Winter: Family| |OTHER | | \ PLAN_VIEW - + @@ -1287,7 +1287,7 @@ ModFamD| |N|Winter: Family| |OTHER | | \ PLAN_VIEW - + @@ -1386,7 +1386,7 @@ ModFamD| |N|Winter: Family| |OTHER | | \ PLAN_VIEW - + @@ -1485,7 +1485,7 @@ ModFamD| |N|Winter: Family| |OTHER | | \ PLAN_VIEW - + diff --git a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyH.xml b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyH.xml index 6fbc209871..14ecfd1bfd 100644 --- a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyH.xml +++ b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyH.xml @@ -139,7 +139,7 @@ ModFamH | | N|Conv: QLCS/Wind Family| | OTHER| | PLAN_VIEW - + @@ -269,7 +269,7 @@ ModFamH | | N|Conv: QLCS/Wind Family| | OTHER| | PLAN_VIEW - + @@ -396,7 +396,7 @@ ModFamH | | N|Conv: QLCS/Wind Family| | OTHER| | PLAN_VIEW - + @@ -496,7 +496,7 @@ ModFamH | | N|Conv: QLCS/Wind Family| | OTHER| | PLAN_VIEW - + @@ -1025,7 +1025,7 @@ ModFamH | | N|Conv: QLCS/Wind Family| | OTHER| | PLAN_VIEW - + diff --git a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyU.xml b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyU.xml index ed14cd5b97..a8b7de6ee7 100644 --- a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyU.xml +++ b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyU.xml @@ -66,7 +66,7 @@ ModFamU| |N|Briefing Family| |OTHER | | \ PLAN_VIEW - + @@ -165,7 +165,7 @@ ModFamU| |N|Briefing Family| |OTHER | | \ PLAN_VIEW - + @@ -264,7 +264,7 @@ ModFamU| |N|Briefing Family| |OTHER | | \ PLAN_VIEW - + @@ -363,7 +363,7 @@ ModFamU| |N|Briefing Family| |OTHER | | \ PLAN_VIEW - + @@ -462,7 +462,7 @@ ModFamU| |N|Briefing Family| |OTHER | | \ PLAN_VIEW - + @@ -594,7 +594,7 @@ ModFamU| |N|Briefing Family| |OTHER | | \ PLAN_VIEW - + @@ -873,7 +873,7 @@ ModFamU| |N|Briefing Family| |OTHER | | \ PLAN_VIEW - + @@ -1044,7 +1044,7 @@ ModFamU| |N|Briefing Family| |OTHER | | \ PLAN_VIEW - + @@ -1179,7 +1179,7 @@ ModFamU| |N|Briefing Family| |OTHER | | \ PLAN_VIEW - + @@ -1278,7 +1278,7 @@ ModFamU| |N|Briefing Family| |OTHER | | \ PLAN_VIEW - + @@ -1377,7 +1377,7 @@ ModFamU| |N|Briefing Family| |OTHER | | \ PLAN_VIEW - + diff --git a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyV.xml b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyV.xml index b7fe7fff6a..f907b5f8a8 100644 --- a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyV.xml +++ b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyV.xml @@ -135,7 +135,7 @@ ModFamV | | N|Conv: Severe Type Family| | OTHER| | \ PLAN_VIEW - + @@ -341,7 +341,7 @@ ModFamV | | N|Conv: Severe Type Family| | OTHER| | \ PLAN_VIEW - + @@ -479,7 +479,7 @@ ModFamV | | N|Conv: Severe Type Family| | OTHER| | \ PLAN_VIEW - + @@ -902,7 +902,7 @@ ModFamV | | N|Conv: Severe Type Family| | OTHER| | \ PLAN_VIEW - + diff --git a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyW.xml b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyW.xml index 11ae214077..ec2f37ca3f 100644 --- a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyW.xml +++ b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyW.xml @@ -135,7 +135,7 @@ PLAN_VIEW - + @@ -235,7 +235,7 @@ PLAN_VIEW - + @@ -371,7 +371,7 @@ PLAN_VIEW - + @@ -544,7 +544,7 @@ PLAN_VIEW - + @@ -644,7 +644,7 @@ PLAN_VIEW - + @@ -1093,7 +1093,7 @@ PLAN_VIEW - + @@ -1194,7 +1194,7 @@ PLAN_VIEW - + diff --git a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyX.xml b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyX.xml index 13ea2f7a5c..b3f9a3011d 100644 --- a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyX.xml +++ b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyX.xml @@ -110,7 +110,7 @@ PLAN_VIEW - + diff --git a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyY.xml b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyY.xml index 1bb9f5a9cd..b1948592a0 100644 --- a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyY.xml +++ b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyY.xml @@ -127,7 +127,7 @@ PLAN_VIEW - + @@ -227,7 +227,7 @@ PLAN_VIEW - + @@ -327,7 +327,7 @@ PLAN_VIEW - + @@ -610,7 +610,7 @@ PLAN_VIEW - + diff --git a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyYY.xml b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyYY.xml index 67c3e4954d..9f7f9995c9 100644 --- a/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyYY.xml +++ b/cave/build/static/common/cave/etc/bundles/volume/ModelFamilyYY.xml @@ -129,7 +129,7 @@ PLAN_VIEW - + @@ -229,7 +229,7 @@ PLAN_VIEW - + @@ -329,7 +329,7 @@ PLAN_VIEW - + @@ -429,7 +429,7 @@ PLAN_VIEW - + @@ -731,7 +731,7 @@ PLAN_VIEW - + From 718f1da85b6c7ff7cf255ed1ad3f2e4633bc0815 Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Wed, 23 Jan 2013 16:34:41 -0600 Subject: [PATCH 08/13] Issue #1524 Fix discrete color bar. Former-commit-id: 7edd57ef71e8a22aa25870477844ba063da0b9d3 --- .../gfe/rsc/colorbar/DiscreteColorbar.java | 79 +++++++++++-------- .../gfe/rsc/colorbar/GFEColorbarResource.java | 10 ++- 2 files changed, 51 insertions(+), 38 deletions(-) diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/DiscreteColorbar.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/DiscreteColorbar.java index 503d3ad132..a504f92471 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/DiscreteColorbar.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/DiscreteColorbar.java @@ -82,7 +82,7 @@ import com.vividsolutions.jts.geom.Coordinate; /** * Implements a colorbar for continuous (scalar and vector) elements - * + * *
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
@@ -91,11 +91,13 @@ import com.vividsolutions.jts.geom.Coordinate;
  * Aug 20, 2008            dglazesk    Updated for the new ColorMap interface
  * Aug 20, 2012      1079  randerso    Changed to display all discrete values for
  *                                     non-overlapping discretes
- * Jan 9, 2013  15661      ryu         Set font for drawing regular Wx/discrete parm labels.
- * Jan 10, 2013  15548     ryu         Update colorbar when new discrete colormap is selected
- *
+ * Jan  9, 2013     15661  ryu         Set font for drawing regular Wx/discrete parm labels.
+ * Jan 10, 2013     15548  ryu         Update colorbar when new discrete colormap is selected
+ * Jan 23, 2013     #1524  randerso    Fix missing discrete color bar and error when clicking 
+ *                                     on discrete color bar when no grid exists
+ * 
  * 
- * + * * @author chammack * @version 1.0 */ @@ -139,7 +141,7 @@ public class DiscreteColorbar implements IColorBarDisplay, /** * Constructor for the Discrete Color Bar - * + * * @param parm * The parm * @param colorbarResource @@ -162,8 +164,7 @@ public class DiscreteColorbar implements IColorBarDisplay, DataManager dataManager = parm.getDataManager(); ISpatialDisplayManager spatialDisplayManager = dataManager .getSpatialDisplayManager(); - ResourcePair resourcePair = spatialDisplayManager - .getResourcePair(parm); + ResourcePair resourcePair = spatialDisplayManager.getResourcePair(parm); AbstractVizResource resource = resourcePair.getResource(); ColorMapParameters params = resource.getCapability( ColorMapCapability.class).getColorMapParameters(); @@ -172,7 +173,7 @@ public class DiscreteColorbar implements IColorBarDisplay, /* * (non-Javadoc) - * + * * @see com.raytheon.viz.gfe.rsc.colorbar.IColorBarDisplay#dispose() */ @Override @@ -193,7 +194,7 @@ public class DiscreteColorbar implements IColorBarDisplay, /** * Gets the Discrete Color map. - * + * * @return Returns the color map used for the discrete data. */ public static ColorMap getFallbackColorMap() { @@ -202,7 +203,7 @@ public class DiscreteColorbar implements IColorBarDisplay, /* * (non-Javadoc) - * + * * @see * com.raytheon.viz.core.drawables.IRenderable#paint(com.raytheon.viz.core * .IGraphicsTarget, com.raytheon.viz.core.drawables.PaintProperties) @@ -210,7 +211,7 @@ public class DiscreteColorbar implements IColorBarDisplay, @Override public void paint(IGraphicsTarget target, PaintProperties paintProps) throws VizException { - DataTime currentTime = paintProps.getDataTime(); + DataTime currentTime = paintProps.getFramesInfo().getCurrentFrame(); if (parm == null || currentTime == null) { return; } @@ -426,7 +427,7 @@ public class DiscreteColorbar implements IColorBarDisplay, * Labels that do not fit their designated band on the bar will be * truncated. Pickup value text will always be displayed in full, so any * text it overlaps will not be drawn. - * + * * @param target * The graphics target on which to draw * @param colorTable @@ -557,7 +558,7 @@ public class DiscreteColorbar implements IColorBarDisplay, /** * Draws the colorbar once colors and patterns have been decided. - * + * * @param target * The graphics target on which to draw. * @param pixelExtent @@ -657,34 +658,42 @@ public class DiscreteColorbar implements IColorBarDisplay, /* * (non-Javadoc) - * + * * @see * com.raytheon.viz.gfe.rsc.colorbar.IColorBarDisplay#getValueAt(double[], * int) */ @Override public WxValue getValueAt(double[] coord, int mouseButton) { - PixelExtent lastExtent = colorbarResource.getExtent(); - float fractionX = (float) ((coord[0] - lastExtent.getMinX()) / (lastExtent - .getMaxX() - lastExtent.getMinX())); - int index = (int) (gridKeys.size() * fractionX); - if (index >= gridKeys.size()) { - index = gridKeys.size() - 1; - } + WxValue retVal = null; + if (!gridKeys.isEmpty()) { + PixelExtent lastExtent = colorbarResource.getExtent(); + float fractionX = (float) ((coord[0] - lastExtent.getMinX()) / (lastExtent + .getMaxX() - lastExtent.getMinX())); + int index = (int) (gridKeys.size() * fractionX); + if (index >= gridKeys.size()) { + index = gridKeys.size() - 1; + } - switch (parm.getGridInfo().getGridType()) { - case DISCRETE: { - DiscreteWxValue castedVal = (DiscreteWxValue) gridKeys.get(index); - return new DiscreteWxValue(castedVal.getDiscreteKey(), parm); - } - case WEATHER: { - WeatherWxValue castedVal = (WeatherWxValue) gridKeys.get(index); - return new WeatherWxValue(castedVal.getWeatherKey(), parm); - } - default: - throw new IllegalArgumentException( - "getValueAt does not support type: " - + parm.getGridInfo().getGridType()); + switch (parm.getGridInfo().getGridType()) { + case DISCRETE: { + DiscreteWxValue castedVal = (DiscreteWxValue) gridKeys + .get(index); + retVal = new DiscreteWxValue(castedVal.getDiscreteKey(), parm); + break; + } + case WEATHER: { + WeatherWxValue castedVal = (WeatherWxValue) gridKeys.get(index); + retVal = new WeatherWxValue(castedVal.getWeatherKey(), parm); + + break; + } + default: + throw new IllegalArgumentException( + "getValueAt does not support type: " + + parm.getGridInfo().getGridType()); + } } + return retVal; } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/GFEColorbarResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/GFEColorbarResource.java index 9e5888fdf6..22a6bafaec 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/GFEColorbarResource.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/GFEColorbarResource.java @@ -28,8 +28,6 @@ import java.util.Set; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord.GridType; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; @@ -98,8 +96,10 @@ import com.raytheon.viz.ui.input.InputAdapter; * 05Aug2008 #1405 ebabin Fix fo delta not displaying after first use. * 06/03/2011 #8919 rferrel No longer display color bar when * VisMode is GRAPHIC - * 11/13/20112 #1298 rferrel Changes for non-blocking SetDeltaDialog. + * 11/13/2012 #1298 rferrel Changes for non-blocking SetDeltaDialog. * Changes for non-blocking SetValueDialog. + * 01/23/2013 #1524 randerso Fix error when clicking on discrete color bar when + * no grid exists * * * @@ -175,6 +175,10 @@ public class GFEColorbarResource extends private void setPickup(double[] v, int mouseButton) { WxValue val = colorbarDisplay.getValueAt(v, mouseButton); + if (val == null) { + return; + } + Parm parm = getParm(); if (parm == null) { throw new IllegalStateException("Parm is null from colorbar"); From 9655d64069e13600e017f63e9e558c9618e46b56 Mon Sep 17 00:00:00 2001 From: Max Schenkelberg Date: Wed, 23 Jan 2013 15:10:17 -0600 Subject: [PATCH 09/13] Issue #1474 Fixed MetarPrecipResourceData and LightningResourceData so updates do not required requery. Made an AutoUpdater per plugin so they process independently of each other. Amend: Only register product alerts in thin client if JMS is not disabled Change-Id: Ic46daf57ef3ede3aad2a2f067e9764f85f7df9a2 Former-commit-id: 115dc26748e0779b4c67cc74fe08c5bf17542632 --- .../raytheon/uf/viz/core/RecordFactory.java | 64 +++++++------ .../rsc/AbstractRequestableResourceData.java | 7 +- .../thinclient/cave/ThinClientComponent.java | 10 +- .../observers/ProductAlertObserver.java | 85 ++++++++--------- .../raytheon/viz/grid/inv/GridUpdater.java | 2 +- .../raytheon/viz/grid/inv/RadarUpdater.java | 2 +- .../viz/lightning/LightningResourceData.java | 10 ++ .../pointdata/rsc/MetarPrecipResource.java | 91 +++++++++++++------ .../rsc/MetarPrecipResourceData.java | 10 ++ .../util/PointMetadataContainer.java | 16 ++-- .../awips/AbstractCAVEComponent.java | 13 ++- .../src/com/raytheon/viz/ui/BundleLoader.java | 2 +- 12 files changed, 183 insertions(+), 129 deletions(-) diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/RecordFactory.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/RecordFactory.java index 530ccb3231..1f1bf5ad41 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/RecordFactory.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/RecordFactory.java @@ -19,8 +19,10 @@ **/ package com.raytheon.uf.viz.core; +import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.TreeSet; import org.apache.commons.beanutils.ConstructorUtils; @@ -56,7 +58,7 @@ public class RecordFactory { private static RecordFactory instance = new RecordFactory(); /** Map containing the pluginName/Record class pairs */ - private Map> defMap; + private Map> defMap = new HashMap>(); public static final String WILDCARD = "%"; @@ -82,36 +84,39 @@ public class RecordFactory { } @SuppressWarnings("unchecked") - private synchronized void loadDefMap() throws VizException { - if (defMap == null) { - GetPluginRecordMapRequest req = new GetPluginRecordMapRequest(); - Map pluginRecordMap = (Map) ThriftClient - .sendRequest(req); - Map> newDefMap = new HashMap>( - pluginRecordMap.size()); - for (Map.Entry entry : pluginRecordMap.entrySet()) { - String pluginName = entry.getKey(); - String record = entry.getValue(); - if (record != null) { - try { - Class clazz = (Class) Class - .forName(record); - newDefMap.put(pluginName, clazz); - } catch (Exception e) { - statusHandler.handle(Priority.DEBUG, - "Can't find record class for " + pluginName - + " plugin", e); - System.out - .println("DEBUG: Can't find record class for " - + pluginName + " plugin - alerts on " - + pluginName + " data will be ignored"); - } + private void loadDefMap() throws VizException { + GetPluginRecordMapRequest req = new GetPluginRecordMapRequest(); + Map pluginRecordMap = (Map) ThriftClient + .sendRequest(req); + for (Map.Entry entry : pluginRecordMap.entrySet()) { + String pluginName = entry.getKey(); + String record = entry.getValue(); + if (record != null) { + try { + Class clazz = (Class) Class + .forName(record); + defMap.put(pluginName, clazz); + } catch (Exception e) { + statusHandler.handle(Priority.DEBUG, + "Can't find record class for " + pluginName + + " plugin", e); + System.out.println("DEBUG: Can't find record class for " + + pluginName + " plugin - alerts on " + pluginName + + " data will be ignored"); } } - defMap = newDefMap; } } + /** + * Returns a collection of all supported plugins + * + * @return + */ + public Collection getSupportedPlugins() { + return new TreeSet(defMap.keySet()); + } + /** * Creates a map of the fields and values that compose a given dataURI * @@ -123,7 +128,6 @@ public class RecordFactory { */ public Map loadMapFromUri(String dataURI) throws VizException { - // If no dataURI return if (dataURI == null) { return null; @@ -181,10 +185,10 @@ public class RecordFactory { */ public Class getPluginClass(String pluginName) throws VizException { - if (defMap == null) { - loadDefMap(); + Class retVal = null; + if (defMap != null) { + retVal = defMap.get(pluginName); } - Class retVal = defMap.get(pluginName); if (retVal == null) { throw new NoPluginException("Can't find record class for " + pluginName + " plugin"); diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/AbstractRequestableResourceData.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/AbstractRequestableResourceData.java index 8056384cfd..e3090c49b3 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/AbstractRequestableResourceData.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/AbstractRequestableResourceData.java @@ -288,7 +288,7 @@ public abstract class AbstractRequestableResourceData extends } } } - + this.fireChangeListeners(ChangeType.DATA_UPDATE, updateData); } @@ -683,7 +683,6 @@ public abstract class AbstractRequestableResourceData extends int result = 1; result = prime * result + ((binOffset == null) ? 0 : binOffset.hashCode()); - result = prime * result + (isUpdatingOnMetadataOnly ? 1231 : 1237); result = prime * result + ((metadataMap == null) ? 0 : metadataMap.hashCode()); result = prime * result @@ -724,10 +723,6 @@ public abstract class AbstractRequestableResourceData extends return false; } - if (isUpdatingOnMetadataOnly != other.isUpdatingOnMetadataOnly) { - return false; - } - if (!isObjectsEqual(metadataMap, other.metadataMap)) { return false; } diff --git a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java index 7a7b439666..f2a2ff1134 100644 --- a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java +++ b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java @@ -55,9 +55,6 @@ import com.raytheon.uf.viz.thinclient.localization.LocalizationCachePersistence; import com.raytheon.uf.viz.thinclient.localization.ThinClientLocalizationInitializer; import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; import com.raytheon.uf.viz.thinclient.refresh.TimedRefresher; -import com.raytheon.viz.alerts.jobs.AutoUpdater; -import com.raytheon.viz.alerts.jobs.MenuUpdater; -import com.raytheon.viz.alerts.observers.ProductAlertObserver; import com.raytheon.viz.ui.personalities.awips.AbstractCAVEComponent; import com.raytheon.viz.ui.personalities.awips.CAVE; @@ -188,8 +185,11 @@ public class ThinClientComponent extends CAVE implements IThinClientComponent { @Override protected void initializeObservers() { ThinClientNotificationManagerJob.getInstance(); - ProductAlertObserver.addObserver(null, new MenuUpdater()); - ProductAlertObserver.addObserver(null, new AutoUpdater()); + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + if (store.getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS) == false) { + // JMS Enabled, register product alerts + registerProductAlerts(); + } } public void stopComponent() { diff --git a/cave/com.raytheon.viz.alerts/src/com/raytheon/viz/alerts/observers/ProductAlertObserver.java b/cave/com.raytheon.viz.alerts/src/com/raytheon/viz/alerts/observers/ProductAlertObserver.java index c83bf232d9..7fc148a79f 100644 --- a/cave/com.raytheon.viz.alerts/src/com/raytheon/viz/alerts/observers/ProductAlertObserver.java +++ b/cave/com.raytheon.viz.alerts/src/com/raytheon/viz/alerts/observers/ProductAlertObserver.java @@ -19,6 +19,7 @@ **/ package com.raytheon.viz.alerts.observers; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -306,58 +307,49 @@ public class ProductAlertObserver implements INotificationObserver { PracticeDataURINotificationMessage uriMsg = (PracticeDataURINotificationMessage) payLoad; dataURIs = uriMsg.getDataURIs(); } - for (int i = 0; i < dataURIs.length; ++i) { - String str = dataURIs[i]; - processDataURI(str); - } - - startWrappers(); - - if (dataURIs != null && dataURIs.length > 0) { - alertsProcessed += dataURIs.length; - } - - long curTime = System.currentTimeMillis(); - if (curTime - ALERT_LOG_INTERVAL > lastLogTime) { - if (alertsProcessed > 0) { - statusHandler.handle(Priority.VERBOSE, "Processed " - + alertsProcessed + " alerts in the last " - + ((curTime - lastLogTime) / 60000) - + " minutes"); - alertsProcessed = 0; - } - lastLogTime = curTime; - } + processDataURIs(Arrays.asList(dataURIs)); } } } - public static void processDerivedAlerts(Collection datauris) { - for (String datauri : datauris) { - getInstance().processDataURI(datauri); + /** + * Processes the DataURIs as alert messages + * + * @param datauris + */ + public static void processDataURIAlerts(Collection datauris) { + getInstance().processDataURIs(datauris); + } + + private synchronized void processDataURIs(Collection dataURIs) { + for (String str : dataURIs) { + processDataURI(str); + } + + startWrappers(); + + if (dataURIs != null && dataURIs.size() > 0) { + alertsProcessed += dataURIs.size(); + } + + long curTime = System.currentTimeMillis(); + if (curTime - ALERT_LOG_INTERVAL > lastLogTime) { + if (alertsProcessed > 0) { + statusHandler.handle(Priority.VERBOSE, "Processed " + + alertsProcessed + " alerts in the last " + + ((curTime - lastLogTime) / 60000) + " minutes"); + alertsProcessed = 0; + } + lastLogTime = curTime; } - getInstance().startWrappers(); } private void processDataURI(String datauri) { if (datauri == null) return; try { - Map attribs; - try { - attribs = RecordFactory.getInstance().loadMapFromUri(datauri); - - } catch (NoPluginException e) { - // ignore, if we hit this it means we received an alert from - // edex about ingested data, but viz doesn't have the necessary - // plugins to do anything with it - return; - } catch (Exception e1) { - statusHandler.handle(Priority.WARN, e1.getLocalizedMessage(), - e1); - return; - } - + Map attribs = RecordFactory.getInstance() + .loadMapFromUri(datauri); AlertMessage am = new AlertMessage(); am.dataURI = datauri; am.decodedAlert = Collections.unmodifiableMap(attribs); @@ -379,11 +371,12 @@ public class ProductAlertObserver implements INotificationObserver { sendToObserver(obs, am); } } - - } catch (RuntimeException e) { - statusHandler - .handle(Priority.PROBLEM, "Error preparing updates", e); - + } catch (NoPluginException e) { + // ignore, if we hit this it means we received an alert from + // edex about ingested data, but viz doesn't have the necessary + // plugins to do anything with it + } catch (Exception e1) { + statusHandler.handle(Priority.WARN, e1.getLocalizedMessage(), e1); } } diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/GridUpdater.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/GridUpdater.java index 227c654343..367873f2e3 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/GridUpdater.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/GridUpdater.java @@ -298,7 +298,7 @@ public class GridUpdater implements IAlertObserver { } } myUpdates.addAll(datauris); - ProductAlertObserver.processDerivedAlerts(datauris); + ProductAlertObserver.processDataURIAlerts(datauris); } /** diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/RadarUpdater.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/RadarUpdater.java index 81c04a55b4..8dc2089ab6 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/RadarUpdater.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/RadarUpdater.java @@ -203,7 +203,7 @@ public class RadarUpdater implements IAlertObserver { "Unable to generate updates for derived product", e); } } - ProductAlertObserver.processDerivedAlerts(datauris); + ProductAlertObserver.processDataURIAlerts(datauris); } private CacheKey getCacheKey(RadarRequestableLevelNode rNode) { diff --git a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResourceData.java b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResourceData.java index 71705c8b2d..10340b221c 100644 --- a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResourceData.java +++ b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResourceData.java @@ -81,6 +81,16 @@ public class LightningResourceData extends AbstractRequestableResourceData { return rsc; } + @Override + public boolean isUpdatingOnMetadataOnly() { + return true; + } + + @Override + public boolean isRetrieveData() { + return true; + } + /** * @return the handlingPositiveStrikes */ diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java index 06c0dcd3aa..58a3d61d28 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java @@ -157,7 +157,11 @@ public class MetarPrecipResource extends @Override protected void paintInternal(IGraphicsTarget target, PaintProperties paintProps) throws VizException { - List precips = data.get(paintProps.getDataTime()); + DataTime time = paintProps.getDataTime(); + if (time == null) { + return; + } + List precips = getPrecipData(time); if (precips == null) { dataProcessJob.schedule(); return; @@ -201,6 +205,19 @@ public class MetarPrecipResource extends target.drawStrings(strings); } + private List getPrecipData(DataTime time) { + List currData = null; + synchronized (data) { + currData = data.get(time); + } + if (currData != null) { + synchronized (currData) { + return new ArrayList(currData); + } + } + return null; + } + @Override protected void initInternal(IGraphicsTarget target) throws VizException { @@ -262,7 +279,7 @@ public class MetarPrecipResource extends Double magnification = getCapability(MagnificationCapability.class) .getMagnification(); - List precips = data.get(descriptor + List precips = getPrecipData(descriptor .getTimeForResource(this)); if (precips == null || precips.isEmpty()) { @@ -299,12 +316,14 @@ public class MetarPrecipResource extends private void processReproject() { if (reproject) { reproject = false; - for (List dataList : data.values()) { - for (RenderablePrecipData precip : dataList) { - Coordinate latLon = precip.getLatLon(); - double[] px = descriptor.worldToPixel(new double[] { - latLon.x, latLon.y }); - precip.string.setCoordinates(px[0], px[1], px[2]); + synchronized (data) { + for (List dataList : data.values()) { + for (RenderablePrecipData precip : dataList) { + Coordinate latLon = precip.getLatLon(); + double[] px = descriptor.worldToPixel(new double[] { + latLon.x, latLon.y }); + precip.string.setCoordinates(px[0], px[1], px[2]); + } } } } @@ -312,10 +331,12 @@ public class MetarPrecipResource extends } private void processRemoves() { - while (!removes.isEmpty()) { - DataTime toRemove = removes.poll(); - this.dataTimes.remove(toRemove); - this.data.remove(toRemove); + synchronized (data) { + while (!removes.isEmpty()) { + DataTime toRemove = removes.poll(); + this.dataTimes.remove(toRemove); + this.data.remove(toRemove); + } } } @@ -354,10 +375,13 @@ public class MetarPrecipResource extends // No need to reprocess times after the earliest update. continue; } - Iterator iter = entry.getValue().iterator(); - while (iter.hasNext()) { - if (newStations.contains(iter.next().getStationName())) { - iter.remove(); + synchronized (entry.getValue()) { + Iterator iter = entry.getValue() + .iterator(); + while (iter.hasNext()) { + if (newStations.contains(iter.next().getStationName())) { + iter.remove(); + } } } addData(time, container.getBasePrecipData(time)); @@ -393,6 +417,9 @@ public class MetarPrecipResource extends } int curIndex = frameInfo.getFrameIndex(); int count = frameInfo.getFrameCount(); + if (times.length != count) { + System.out.println("Uh oh"); + } // This will generate the number series 0, -1, 1, -2, 2, -3, 3... for (int i = 0; i < count / 2 + 1; i = i < 0 ? -i : -i - 1) { int index = (count + curIndex + i) % count; @@ -417,27 +444,31 @@ public class MetarPrecipResource extends } } } - // This will only happen if frames were removed while we were processing - // DOn't leave any half created frames - for (DataTime time : baseOnly) { - this.dataTimes.remove(time); - this.data.remove(time); + + synchronized (data) { + // This will only happen if frames were removed while we were + // processing. Don't leave any half created frames + for (DataTime time : baseOnly) { + this.dataTimes.remove(time); + this.data.remove(time); + } } } private void addData(DataTime time, List precips) { if (precips.isEmpty()) { if (!dataTimes.contains(time)) { - List newPrecips = Collections.emptyList(); - data.put(time, newPrecips); + synchronized (data) { + List newPrecips = Collections + .emptyList(); + data.put(time, newPrecips); + } dataTimes.add(time); } } if (data.containsKey(time)) { precips = new ArrayList(precips); - for (RenderablePrecipData pData : data.get(time)) { - precips.add(pData); - } + precips.addAll(getPrecipData(time)); } Collections.sort(precips, new Comparator() { @@ -480,9 +511,11 @@ public class MetarPrecipResource extends data.distValue = bestDist; newPrecips.add(data); } - data.put(time, newPrecips); - if (!dataTimes.contains(time)) { - dataTimes.add(time); + synchronized (data) { + data.put(time, newPrecips); + if (!dataTimes.contains(time)) { + dataTimes.add(time); + } } issueRefresh(); } diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResourceData.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResourceData.java index 2e0f5e823a..f6c2be7742 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResourceData.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResourceData.java @@ -67,6 +67,16 @@ public class MetarPrecipResourceData extends AbstractRequestableResourceData { this.duration = duration; } + @Override + public boolean isUpdatingOnMetadataOnly() { + return true; + } + + @Override + public boolean isRetrieveData() { + return false; + } + @Override public int hashCode() { final int prime = 31; diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/PointMetadataContainer.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/PointMetadataContainer.java index 35e06b2f6f..5e48511836 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/PointMetadataContainer.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/PointMetadataContainer.java @@ -102,15 +102,17 @@ public class PointMetadataContainer extends MetadataContainer { } pdc = pdca.getBaseRecords(baseParams, originalConstraints); for (PointDataLevelNode node : nodes) { - IDataRecord rec = pdc.getParameterRecord(node.getParameter()); Set cacheSet = new HashSet(); - cacheSet.add(new PointRequestableData(rec, pdc.getDescription( - node.getParameter()).getUnitObject())); - dataCache.put(node, cacheSet); - if (!Arrays.asList("id", "latitude", "longitude", "dataURI") - .contains(rec.getName())) { - pdc.remove(rec.getName()); + if (pdc != null) { + IDataRecord rec = pdc.getParameterRecord(node.getParameter()); + cacheSet.add(new PointRequestableData(rec, pdc.getDescription( + node.getParameter()).getUnitObject())); + if (!Arrays.asList("id", "latitude", "longitude", "dataURI") + .contains(rec.getName())) { + pdc.remove(rec.getName()); + } } + dataCache.put(node, cacheSet); } } diff --git a/cave/com.raytheon.viz.ui.personalities.awips/src/com/raytheon/viz/ui/personalities/awips/AbstractCAVEComponent.java b/cave/com.raytheon.viz.ui.personalities.awips/src/com/raytheon/viz/ui/personalities/awips/AbstractCAVEComponent.java index e9b60f47b8..72495a05bd 100644 --- a/cave/com.raytheon.viz.ui.personalities.awips/src/com/raytheon/viz/ui/personalities/awips/AbstractCAVEComponent.java +++ b/cave/com.raytheon.viz.ui.personalities.awips/src/com/raytheon/viz/ui/personalities/awips/AbstractCAVEComponent.java @@ -54,6 +54,7 @@ import com.raytheon.uf.viz.alertviz.SystemStatusHandler; import com.raytheon.uf.viz.alertviz.ui.dialogs.AlertVisualization; import com.raytheon.uf.viz.application.ProgramArguments; import com.raytheon.uf.viz.application.component.IStandaloneComponent; +import com.raytheon.uf.viz.core.RecordFactory; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.localization.CAVELocalizationNotificationObserver; import com.raytheon.uf.viz.core.localization.LocalizationConstants; @@ -383,9 +384,15 @@ public abstract class AbstractCAVEComponent implements IStandaloneComponent { protected void initializeObservers() { // Setup cave notification observer CAVELocalizationNotificationObserver.register(); - // Register product observers - ProductAlertObserver.addObserver(null, new MenuUpdater()); - ProductAlertObserver.addObserver(null, new AutoUpdater()); + registerProductAlerts(); } + protected void registerProductAlerts() { + // Register product observers + ProductAlertObserver.addObserver(null, new MenuUpdater()); + for (String plugin : RecordFactory.getInstance().getSupportedPlugins()) { + // Create separate AutoUpdater per plugin + ProductAlertObserver.addObserver(plugin, new AutoUpdater()); + } + } } diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/BundleLoader.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/BundleLoader.java index 7b765c885d..c9056f8739 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/BundleLoader.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/BundleLoader.java @@ -204,7 +204,7 @@ public class BundleLoader extends Job { if (containerPanes.length != bundleDisplays.length) { boolean success = ensureOneToOne(container, bundle); containerPanes = container.getDisplayPanes(); - if (success) { + if (success == false) { throw new VizException("Unable to load " + bundleDisplays.length + " displays onto container with " From e28749bc03c1d5bf7d51987da6161826140f8d56 Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Thu, 24 Jan 2013 10:53:51 -0600 Subject: [PATCH 10/13] Issue #1495 fix fens regex. Former-commit-id: fda3d6ae8ecd44d03b9c4afb1fd0b93b0f3aaccf --- .../base/datadelivery/harvester/NOMADS-harvester.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/utility/common_static/base/datadelivery/harvester/NOMADS-harvester.xml b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/utility/common_static/base/datadelivery/harvester/NOMADS-harvester.xml index c15966e7cd..eed51c2d9d 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/utility/common_static/base/datadelivery/harvester/NOMADS-harvester.xml +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/utility/common_static/base/datadelivery/harvester/NOMADS-harvester.xml @@ -45,7 +45,7 @@ \.das$ \.dds$ help$ - fens\d\d\d + fens\d\d\d_ cmcens[cp]\d\d ge[cp]\d\d From da22ae4a5f0f3b8e4482d9937968c588cbc689e7 Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Thu, 24 Jan 2013 11:37:23 -0600 Subject: [PATCH 11/13] Issue #1357 - fix for data plotting in the x direction. Former-commit-id: 862ca86596fb59ce5c0b6cbcce320303f6cda3b3 --- .../com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java index bb343de1d6..20bb6fa534 100644 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java @@ -81,12 +81,8 @@ import com.raytheon.uf.viz.stats.display.ScaleManager; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * <<<<<<< HEAD - * Oct 3, 2012 728 mpduff Initial creation - * ======= * Oct 03, 2012 728 mpduff Initial creation. * Jan 17, 2013 1357 mpduff Added mouse listeners. - * >>>>>>> Issue #1357 - Remaining stats items implemented. * * * @@ -752,8 +748,7 @@ public class StatsDisplayCanvas extends Canvas { long diff = x - startMillis; if (diff == 0) { - xPix = Math - .round((x / millisPerPixelX + GRAPH_BORDER)); + xPix = GRAPH_BORDER; } else { xPix = Math .round((diff / millisPerPixelX + GRAPH_BORDER)); From ba5014b162300da7c9bd23dc562ab4c74fe714ee Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Thu, 24 Jan 2013 10:57:17 -0600 Subject: [PATCH 12/13] Issue #1523 - Fix problem with legend keys. Change-Id: Iea9cf5a95767b8c3a71ddc022757d9d5dda5a931 Former-commit-id: c625174317778f673a8f3b5062e1bd7832b70ed4 --- .../uf/viz/stats/ui/GroupingComp.java | 60 ++++++++----- .../uf/viz/stats/ui/SelectionEntry.java | 87 +++++++++++++++++++ .../uf/viz/stats/ui/SelectionManagerDlg.java | 8 +- .../raytheon/uf/edex/stats/util/Archiver.java | 32 ++++--- tests/.classpath | 1 + .../uf/viz/stats/ui/SelectionEntryTest.java | 54 ++++++++++++ 6 files changed, 201 insertions(+), 41 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionEntry.java create mode 100644 tests/unit/com/raytheon/uf/viz/stats/ui/SelectionEntryTest.java diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/GroupingComp.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/GroupingComp.java index f3033d655b..61bb2f5ae4 100644 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/GroupingComp.java +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/GroupingComp.java @@ -20,7 +20,7 @@ package com.raytheon.uf.viz.stats.ui; /** - * TODO Add Description + * Grouping Composite for the Stats Graph. * *
  *
@@ -35,10 +35,14 @@ package com.raytheon.uf.viz.stats.ui;
  * @author mpduff
  * @version 1.0
  */
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.regex.Pattern;
 
 import org.eclipse.swt.SWT;
@@ -108,6 +112,8 @@ public class GroupingComp extends Composite implements IGroupSelection {
     /** Grouping callback */
     private final IStatsGroup callback;
 
+    private final List selectionEntries = new ArrayList();
+
     /**
      * Constructor.
      * 
@@ -193,12 +199,26 @@ public class GroupingComp extends Composite implements IGroupSelection {
      */
     private void createControls() {
         List keyArray = graphData.getKeysWithData();
+        Map> grpNameMap = graphData.getGroupAndNamesMap();
 
+        // Create the Selection Entry objects
         for (String key : keyArray) {
+            SelectionEntry se = new SelectionEntry();
+            String[] parts = colonPattern.split(key);
+
+            Set grpNames = grpNameMap.keySet();
+            Iterator iter = grpNames.iterator();
+            for (int i = 0; i < grpNames.size(); i++) {
+                se.addPair(iter.next(), parts[i]);
+            }
+            this.selectionEntries.add(se);
+        }
+
+        for (SelectionEntry se : selectionEntries) {
             GridData gd = new GridData(20, 10);
             Label lbl = new Label(controlComp, SWT.BORDER);
             lbl.setLayoutData(gd);
-            lbl.setData(key);
+            lbl.setData(se);
             lbl.addMouseListener(new MouseAdapter() {
                 @Override
                 public void mouseDown(MouseEvent e) {
@@ -208,8 +228,9 @@ public class GroupingComp extends Composite implements IGroupSelection {
             });
 
             Button btn = new Button(controlComp, SWT.CHECK);
-            btn.setText(key);
+            btn.setText(se.toString());
             btn.setSelection(true);
+            btn.setData(se);
             btn.addSelectionListener(new SelectionAdapter() {
                 @Override
                 public void widgetSelected(SelectionEvent e) {
@@ -218,8 +239,8 @@ public class GroupingComp extends Composite implements IGroupSelection {
                 }
             });
 
-            labelMap.put(key, lbl);
-            checkBtnMap.put(key, btn);
+            labelMap.put(se.toString(), lbl);
+            checkBtnMap.put(se.toString(), btn);
         }
     }
 
@@ -286,7 +307,7 @@ public class GroupingComp extends Composite implements IGroupSelection {
      */
     private void handleLabelClickEvent(Label lbl) {
         RGB rgb = lbl.getBackground().getRGB();
-        String key = (String) lbl.getData();
+        String key = ((SelectionEntry) lbl.getData()).toString();
 
         ColorDialog colorDlg = new ColorDialog(this.getShell());
         colorDlg.setRGB(rgb);
@@ -364,8 +385,6 @@ public class GroupingComp extends Composite implements IGroupSelection {
      */
     @Override
     public void setSelections(Map> selectionMap) {
-        List keySequence = graphData.getKeySequence();
-
         Multimap offMap = ArrayListMultimap.create();
         for (String key : selectionMap.keySet()) {
             for (String selection : selectionMap.get(key).keySet()) {
@@ -383,21 +402,18 @@ public class GroupingComp extends Composite implements IGroupSelection {
             }
         } else {
             for (String btnKey : checkBtnMap.keySet()) {
-                String[] parts = colonPattern.split(btnKey);
+                Button b = checkBtnMap.get(btnKey);
+                SelectionEntry se = (SelectionEntry) b.getData();
 
-                for (String group : offMap.keySet()) {
-                    for (String part : parts) {
-                        int idx = keySequence.indexOf(part);
-                        if (idx >= 0
-                                && offMap.get(group).contains(
-                                        keySequence.get(idx))) {
-                            checkBtnMap.get(btnKey).setSelection(false);
-                            keyRgbMap.remove(btnKey);
-                        } else {
-                            checkBtnMap.get(btnKey).setSelection(true);
-                            keyRgbMap.put(btnKey, labelMap.get(btnKey)
-                                    .getBackground().getRGB());
-                        }
+                for (String key : offMap.keySet()) {
+                    Collection valueList = offMap.get(key);
+                    if (valueList.contains(se.getValue(key))) {
+                        checkBtnMap.get(btnKey).setSelection(false);
+                        keyRgbMap.remove(btnKey);
+                    } else {
+                        checkBtnMap.get(btnKey).setSelection(true);
+                        keyRgbMap.put(btnKey, labelMap.get(btnKey)
+                                .getBackground().getRGB());
                     }
                 }
             }
diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionEntry.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionEntry.java
new file mode 100644
index 0000000000..b8b4620c8e
--- /dev/null
+++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionEntry.java
@@ -0,0 +1,87 @@
+/**
+ * This software was developed and / or modified by Raytheon Company,
+ * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
+ * 
+ * U.S. EXPORT CONTROLLED TECHNICAL DATA
+ * This software product contains export-restricted data whose
+ * export/transfer/disclosure is restricted by U.S. law. Dissemination
+ * to non-U.S. persons whether in the United States or abroad requires
+ * an export license or other authorization.
+ * 
+ * Contractor Name:        Raytheon Company
+ * Contractor Address:     6825 Pine Street, Suite 340
+ *                         Mail Stop B8
+ *                         Omaha, NE 68106
+ *                         402.291.0100
+ * 
+ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
+ * further licensing information.
+ **/
+package com.raytheon.uf.viz.stats.ui;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Stats Graph Item.
+ * 
+ * 
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 24, 2013            mpduff     Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ +public class SelectionEntry { + private final Map values = new LinkedHashMap(); + + private boolean checked = true; + + public SelectionEntry() { + + } + + public void addPair(String key, String value) { + values.put(key, value); + } + + public String getValue(String key) { + return values.get(key); + } + + /** + * @return the checked + */ + public boolean isChecked() { + return checked; + } + + /** + * @param checked + * the checked to set + */ + public void setChecked(boolean checked) { + this.checked = checked; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + + for (Iterator iter = values.values().iterator(); iter.hasNext();) { + sb.append(iter.next()); + if (iter.hasNext()) { + sb.append(":"); + } + } + + return sb.toString(); + } +} diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionManagerDlg.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionManagerDlg.java index 2b46907b56..d12231d3c5 100644 --- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionManagerDlg.java +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionManagerDlg.java @@ -79,7 +79,7 @@ public class SelectionManagerDlg extends CaveSWTDialogBase { * Constructor. * * @param parentShell - * @param graphData + * @param selectionEntries * @param callback */ public SelectionManagerDlg(Shell parentShell, GraphData graphData, @@ -89,8 +89,8 @@ public class SelectionManagerDlg extends CaveSWTDialogBase { | CAVE.INDEPENDENT_SHELL); setText("Selection Manager"); - this.graphData = graphData; this.callback = callback; + this.graphData = graphData; } /** @@ -254,7 +254,6 @@ public class SelectionManagerDlg extends CaveSWTDialogBase { private void populateTree() { Map> grpMemberMap = graphData .getGroupAndNamesMap(); - Map stateMap = callback.getStates(); for (String key : grpMemberMap.keySet()) { TreeItem treeItem = new TreeItem(selectionTree, SWT.NONE); @@ -265,8 +264,7 @@ public class SelectionManagerDlg extends CaveSWTDialogBase { for (String subKey : array) { TreeItem subTreeItem = new TreeItem(treeItem, SWT.NONE); subTreeItem.setText(subKey); - - subTreeItem.setChecked(stateMap.get(subKey)); + subTreeItem.setChecked(true); } } diff --git a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/util/Archiver.java b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/util/Archiver.java index 9150f940a2..59dd45cd2e 100644 --- a/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/util/Archiver.java +++ b/edexOsgi/com.raytheon.uf.edex.stats/src/com/raytheon/uf/edex/stats/util/Archiver.java @@ -54,6 +54,7 @@ import com.raytheon.uf.common.time.TimeRange; * ------------ ---------- ----------- -------------------------- * Aug 21, 2012 jsanchez Initial creation. * Nov 09, 2012 dhladky Changed to CSV output + * Jan 24, 2013 1357 mpduff Fix comma output and paths. * *
* @@ -91,6 +92,8 @@ public class Archiver { private static final String COMMA = ","; + private static final Pattern NLPattern = Pattern.compile("[\\n\\r]+"); + private static final IUFStatusHandler statusHandler = UFStatus .getHandler(Archiver.class); @@ -116,15 +119,13 @@ public class Archiver { * @param items * @return */ - private String createFilename(TimeRange tr, String eventType, String group) { + private String createFilename(TimeRange tr, String eventType) { SimpleDateFormat fileDateFormatter = new SimpleDateFormat( FILE_DATE_FORMAT); StringBuilder sb = new StringBuilder("stats/aggregates"); String[] chunks = PERIOD_PATTERN.split(eventType); sb.append("/"); - sb.append(group); - sb.append("/"); sb.append(chunks[chunks.length - 1]); sb.append("."); sb.append(fileDateFormatter.format(tr.getStart())); @@ -156,24 +157,29 @@ public class Archiver { double count = agrec.getCount(); if (eventType != null) { - sb.append(eventType).append(COMMA); + sb.append(eventType); } + sb.append(COMMA); if (startDate != null) { - sb.append(dateFormat.format(startDate.getTime())) - .append(COMMA); + sb.append(dateFormat.format(startDate.getTime())); } + sb.append(COMMA); if (endDate != null) { - sb.append(dateFormat.format(endDate.getTime())).append( - COMMA); + sb.append(dateFormat.format(endDate.getTime())); } + sb.append(COMMA); + if (grouping != null) { - sb.append(grouping).append(COMMA); + sb.append(NLPattern.matcher(grouping).replaceAll("")); } + sb.append(COMMA); + if (field != null) { - sb.append(field).append(COMMA); + sb.append(field); } + sb.append(COMMA); sb.append(max).append(COMMA); sb.append(min).append(COMMA); @@ -212,10 +218,9 @@ public class Archiver { for (StatisticsKey key : statisticsMap.keySet()) { String eventType = key.eventType; - String grouping = key.grouping; List records = statisticsMap.get(key); - String filename = createFilename(key.timeRange, eventType, grouping); + String filename = createFilename(key.timeRange, eventType); try { writeToFile(filename, records); } catch (JAXBException e) { @@ -243,8 +248,7 @@ public class Archiver { siteLocalization.getFile().getParentFile().mkdirs(); // Write this to output CSV try { - bw = new BufferedWriter(new FileWriter( - outputFilePath)); + bw = new BufferedWriter(new FileWriter(outputFilePath)); if (bw != null) { for (AggregateRecord agrec : records) { bw.write(getCSVOutput(agrec, dateFormatter)); diff --git a/tests/.classpath b/tests/.classpath index f3924ee656..a139e358aa 100644 --- a/tests/.classpath +++ b/tests/.classpath @@ -70,5 +70,6 @@ + diff --git a/tests/unit/com/raytheon/uf/viz/stats/ui/SelectionEntryTest.java b/tests/unit/com/raytheon/uf/viz/stats/ui/SelectionEntryTest.java new file mode 100644 index 0000000000..d728231f3e --- /dev/null +++ b/tests/unit/com/raytheon/uf/viz/stats/ui/SelectionEntryTest.java @@ -0,0 +1,54 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.stats.ui; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * SelectionEntry test class. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 24, 2013            mpduff     Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class SelectionEntryTest { + + @Test + public void testCreateSelectionEntryClassAndAddKeys() { + SelectionEntry se = new SelectionEntry(); + se.addPair("Key", "Value"); + se.addPair("Key2", "Value2"); + se.addPair("Key3", "Value3"); + assertTrue("Keys are wrong", se.toString() + .equals("Value:Value2:Value3")); + } +} From 49c66d2e47f673f3ee83623d225cbb6d3569c048 Mon Sep 17 00:00:00 2001 From: Benjamin Phillippe Date: Thu, 24 Jan 2013 13:17:28 -0600 Subject: [PATCH 13/13] Issue #1525 Improved Dataset Discovery Browser query performance Change-Id: Ic7c7994e5768238393c1fdbb73ec043cc1eb86f1 Former-commit-id: b112d2eba2395f693beedd64ca97c140cba161f1 --- .../xsd/rim/v4/ExtensibleObjectType.java | 7 +- .../res/scripts/RegistryIndices.sql | 4 + .../uf/edex/registry/ebxml/dao/DbInit.java | 95 +++++++++++++++++++ 3 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/scripts/RegistryIndices.sql diff --git a/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ExtensibleObjectType.java b/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ExtensibleObjectType.java index 85ed507ab1..037b20e33d 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ExtensibleObjectType.java +++ b/edexOsgi/com.raytheon.uf.common.registry.schemas.ebxml/src/oasis/names/tc/ebxml/regrep/xsd/rim/v4/ExtensibleObjectType.java @@ -24,6 +24,7 @@ import java.util.HashSet; import java.util.Set; import javax.persistence.CascadeType; +import javax.persistence.FetchType; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; @@ -39,6 +40,7 @@ import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType; import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryRequestType; import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseType; +import org.hibernate.annotations.BatchSize; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; @@ -82,10 +84,11 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; RegistryResponseType.class, RegistryRequestType.class }) @DynamicSerialize @MappedSuperclass -@Cache(region="registryObjects",usage = CacheConcurrencyStrategy.TRANSACTIONAL, include = "all") +@Cache(region = "registryObjects", usage = CacheConcurrencyStrategy.TRANSACTIONAL, include = "all") public abstract class ExtensibleObjectType { - @ManyToMany(cascade = CascadeType.ALL) + @BatchSize(size = 15) + @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinTable(inverseJoinColumns = @JoinColumn(name = "child_slot_key")) @XmlElement(name = "Slot") @DynamicSerializeElement diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/scripts/RegistryIndices.sql b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/scripts/RegistryIndices.sql new file mode 100644 index 0000000000..cb1fa73597 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/res/scripts/RegistryIndices.sql @@ -0,0 +1,4 @@ +CREATE INDEX "intlstring_localizedStrings_idx" ON intlstring_localizedstrings USING btree (intlstring_key); +CREATE INDEX "versionInfo_idx" ON versioninfo USING btree (versionname,userversionname); +CREATE INDEX registryobject_slot_idx ON registryobject_slot USING btree (registryobject_id); +CREATE INDEX value_value_idx ON value_value USING btree (value_key); \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/DbInit.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/DbInit.java index 3385e3a615..609b624349 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/DbInit.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/DbInit.java @@ -20,7 +20,11 @@ package com.raytheon.uf.edex.registry.ebxml.dao; +import java.io.BufferedReader; import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.lang.reflect.Field; import java.sql.Connection; import java.sql.ResultSet; @@ -28,7 +32,10 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Collection; +import java.util.Enumeration; import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException; import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.SubmitObjectsRequest; @@ -48,6 +55,7 @@ import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.util.ReflectionUtil; +import com.raytheon.uf.edex.core.props.PropertiesFactory; import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException; import com.raytheon.uf.edex.registry.ebxml.services.lifecycle.LifecycleManagerImpl; import com.raytheon.uf.edex.registry.ebxml.services.util.RegistrySessionManager; @@ -169,6 +177,15 @@ public class DbInit extends RegistryDao { e); } + statusHandler.info("Executing additional registry SQL..."); + try { + executeRegistrySql(); + } catch (EbxmlRegistryException e) { + throw new EbxmlRegistryException( + "An unexpected database error occurred while executing additional sql on the registry", + e); + } + try { populateDB(); } catch (SerializationException e) { @@ -398,6 +415,84 @@ public class DbInit extends RegistryDao { } + /** + * Executes any additional SQL statements contained in the res/scripts + * directory of this jar. The purpose of this method is primarily to add + * additional indices that cannot be automaically be generated by Hibernate + * + * @throws EbxmlRegistryException + */ + private void executeRegistrySql() throws EbxmlRegistryException { + JarFile jar = null; + + try { + jar = new JarFile(PropertiesFactory.getInstance() + .getEnvProperties().getEnvValue("PLUGINDIR") + + "com.raytheon.uf.edex.registry.ebxml.jar"); + } catch (IOException e) { + throw new EbxmlRegistryException("Unable to find registry jar!", e); + } + + Enumeration entries = jar.entries(); + while (entries.hasMoreElements()) { + JarEntry entry = entries.nextElement(); + String name = entry.getName(); + if (name.startsWith("res/scripts") && name.endsWith(".sql")) { + BufferedReader reader = null; + InputStream stream = null; + + try { + stream = jar.getInputStream(entry); + reader = new BufferedReader(new InputStreamReader(stream)); + String line = null; + final StringBuilder buffer = new StringBuilder(); + while ((line = reader.readLine()) != null) { + buffer.append(line); + } + this.doInTransaction(new RegistryTransactionCallback() { + @Override + public Object execute(Session session) + throws EbxmlRegistryException { + session.doWork(new Work() { + @Override + public void execute(Connection connection) + throws SQLException { + Statement stmt = connection + .createStatement(); + stmt.execute(buffer.toString()); + connection.commit(); + } + }); + return null; + } + }); + } catch (Exception e) { + throw new EbxmlRegistryException( + "Unable to execute SQL Scripts for registry", e); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + throw new EbxmlRegistryException( + "Unable to close file reader while reading registry SQL files", + e); + } + } + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { + throw new EbxmlRegistryException( + "Unable to close file input stream while reading registry SQL files", + e); + } + } + } + } + } + } + /** * Method used to ensure that all objects added during the registry * initialization have an owner assigned to them. If no owner is assigned,