From a6d5ff3e2c9cfe4b3328f662706f74dac1e7e3ca Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Wed, 28 Aug 2013 15:35:22 -0500 Subject: [PATCH] Issue #2290 - fix subscription status Change-Id: I93ca6074af9eeec1b2cda9145418daa569817d10 Former-commit-id: f2cd68bf1a7a21ed7d21d2c0f81ea54cca9a55dd --- .../subscription/SubscriptionStatusDlg.java | 16 +++- .../data/SubscriptionStatusSummary.java | 16 ++-- .../hibernate/HibernateBandwidthDao.java | 80 ++++++++++--------- 3 files changed, 67 insertions(+), 45 deletions(-) diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionStatusDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionStatusDlg.java index 0cb17fa311..d3586c885d 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionStatusDlg.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionStatusDlg.java @@ -49,6 +49,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * Jul 18, 2013 1653 mpduff Initial creation * Aug 21, 2013 2248 bgonzale Changed label to minutes. + * Aug 28, 2013 2290 mpduff Changed output to work with unscheduled subs. * * * @@ -168,10 +169,15 @@ public class SubscriptionStatusDlg extends CaveSWTDialog { l3.setText("Start Time: "); Calendar cal = TimeUtil.newGmtCalendar(); - cal.setTimeInMillis(summary.getStartTime()); Label l33 = new Label(sumComp, SWT.NONE); l33.setLayoutData(new GridData(SWT.LEFT, SWT.DEFAULT, true, false)); - l33.setText(sdf.format(cal.getTime())); + if (summary.getStartTime() != SubscriptionStatusSummary.MISSING_VALUE) { + cal.setTimeInMillis(summary.getStartTime()); + l33.setText(sdf.format(cal.getTime())); + } else { + l33.setText(""); + + } Label l4 = new Label(sumComp, SWT.NONE); l4.setLayoutData(new GridData(SWT.LEFT, SWT.DEFAULT, false, false)); @@ -180,6 +186,10 @@ public class SubscriptionStatusDlg extends CaveSWTDialog { cal.setTimeInMillis(summary.getEndTime()); Label l44 = new Label(sumComp, SWT.NONE); l44.setLayoutData(new GridData(SWT.LEFT, SWT.DEFAULT, true, false)); - l44.setText(sdf.format(cal.getTime())); + if (summary.getEndTime() != SubscriptionStatusSummary.MISSING_VALUE) { + l44.setText(sdf.format(cal.getTime())); + } else { + l44.setText(""); + } } } diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/SubscriptionStatusSummary.java b/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/SubscriptionStatusSummary.java index e648f59879..f9850a1a5e 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/SubscriptionStatusSummary.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/SubscriptionStatusSummary.java @@ -36,6 +36,7 @@ import com.raytheon.uf.common.util.StringUtil; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 17, 2013 1653 mpduff Initial creation + * Aug 28, 2013 2290 mpduff Added default missing values. * * * @@ -44,17 +45,22 @@ import com.raytheon.uf.common.util.StringUtil; */ @DynamicSerialize public class SubscriptionStatusSummary { - @DynamicSerializeElement - private long dataSize; + /** + * Missing data value. + */ + public static final long MISSING_VALUE = -9999; @DynamicSerializeElement - private long startTime; + private long dataSize = MISSING_VALUE; @DynamicSerializeElement - private long endTime; + private long startTime = MISSING_VALUE; @DynamicSerializeElement - private long latency; + private long endTime = MISSING_VALUE; + + @DynamicSerializeElement + private long latency = MISSING_VALUE; /** * @return the dataSize diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthDao.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthDao.java index 38959d6517..14432a8b93 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthDao.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthDao.java @@ -62,6 +62,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil; * Jun 13, 2013 2095 djohnson Implement ability to store a collection of subscriptions. * Jun 24, 2013 2106 djohnson Implement new methods. * Jul 18, 2013 1653 mpduff Added getSubscriptionStatusSummary. + * Aug 28, 2013 2290 mpduff Check for no subscriptions. * * * @@ -528,47 +529,52 @@ public class HibernateBandwidthDao implements IBandwidthDao { List bandwidthSubList = this .getBandwidthSubscription(sub); - Collections.sort(bandwidthSubList, - new Comparator() { - @Override - public int compare(BandwidthSubscription o1, - BandwidthSubscription o2) { - Calendar date1 = o1.getBaseReferenceTime(); - Calendar date2 = o2.getBaseReferenceTime(); - if (date1.before(date2)) { - return -1; - } else if (date1.after(date2)) { - return 1; + + if (bandwidthSubList != null && !bandwidthSubList.isEmpty()) { + Collections.sort(bandwidthSubList, + new Comparator() { + @Override + public int compare(BandwidthSubscription o1, + BandwidthSubscription o2) { + Calendar date1 = o1.getBaseReferenceTime(); + Calendar date2 = o2.getBaseReferenceTime(); + if (date1.before(date2)) { + return -1; + } else if (date1.after(date2)) { + return 1; + } + + return 0; + } + }); + + List subRetrievalList = this + .querySubscriptionRetrievals(bandwidthSubList.get(0)); + Collections.sort(subRetrievalList, + new Comparator() { + @Override + public int compare(SubscriptionRetrieval o1, + SubscriptionRetrieval o2) { + Calendar date1 = o1.getStartTime(); + Calendar date2 = o2.getStartTime(); + if (date1.before(date2)) { + return -1; + } else if (date1.after(date2)) { + return 1; + } + + return 0; } - return 0; - } - }); + }); - List subRetrievalList = this - .querySubscriptionRetrievals(bandwidthSubList.get(0)); - Collections.sort(subRetrievalList, - new Comparator() { - @Override - public int compare(SubscriptionRetrieval o1, - SubscriptionRetrieval o2) { - Calendar date1 = o1.getStartTime(); - Calendar date2 = o2.getStartTime(); - if (date1.before(date2)) { - return -1; - } else if (date1.after(date2)) { - return 1; - } + summary.setStartTime(subRetrievalList.get(0).getStartTime() + .getTimeInMillis()); + summary.setEndTime(subRetrievalList + .get(subRetrievalList.size() - 1).getEndTime() + .getTimeInMillis()); + } - return 0; - } - - }); - - summary.setStartTime(subRetrievalList.get(0).getStartTime() - .getTimeInMillis()); - summary.setEndTime(subRetrievalList.get(subRetrievalList.size() - 1) - .getEndTime().getTimeInMillis()); summary.setDataSize(sub.getDataSetSize()); summary.setLatency(sub.getLatencyInMinutes());