Merge branch '13.2.1_delivery' into development

Former-commit-id: 5c6a08af0ad5f6185645e53143bf88d8c27f10d0
This commit is contained in:
Steve Harris 2013-01-25 10:54:51 -06:00
commit f673583915
64 changed files with 2125 additions and 904 deletions

View file

@ -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<String, Class<PluginDataObject>> defMap;
private Map<String, Class<PluginDataObject>> defMap = new HashMap<String, Class<PluginDataObject>>();
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<String, String> pluginRecordMap = (Map<String, String>) ThriftClient
.sendRequest(req);
Map<String, Class<PluginDataObject>> newDefMap = new HashMap<String, Class<PluginDataObject>>(
pluginRecordMap.size());
for (Map.Entry<String, String> entry : pluginRecordMap.entrySet()) {
String pluginName = entry.getKey();
String record = entry.getValue();
if (record != null) {
try {
Class<PluginDataObject> clazz = (Class<PluginDataObject>) 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<String, String> pluginRecordMap = (Map<String, String>) ThriftClient
.sendRequest(req);
for (Map.Entry<String, String> entry : pluginRecordMap.entrySet()) {
String pluginName = entry.getKey();
String record = entry.getValue();
if (record != null) {
try {
Class<PluginDataObject> clazz = (Class<PluginDataObject>) 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<String> getSupportedPlugins() {
return new TreeSet<String>(defMap.keySet());
}
/**
* Creates a map of the fields and values that compose a given dataURI
*
@ -123,7 +128,6 @@ public class RecordFactory {
*/
public Map<String, Object> loadMapFromUri(String dataURI)
throws VizException {
// If no dataURI return
if (dataURI == null) {
return null;
@ -181,10 +185,10 @@ public class RecordFactory {
*/
public Class<PluginDataObject> getPluginClass(String pluginName)
throws VizException {
if (defMap == null) {
loadDefMap();
Class<PluginDataObject> retVal = null;
if (defMap != null) {
retVal = defMap.get(pluginName);
}
Class<PluginDataObject> retVal = defMap.get(pluginName);
if (retVal == null) {
throw new NoPluginException("Can't find record class for "
+ pluginName + " plugin");

View file

@ -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;
}

View file

@ -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",

View file

@ -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.
*
* </pre>
*
@ -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) {

View file

@ -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.
* </pre>
*
* @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<NotificationRowData> getMasterTableList() {
@ -329,7 +330,7 @@ public class NotificationTableComp extends TableComp implements ITableFind {
/**
* Get the table list with filters applied.
*
*
* @return TableDataManager obj
*/
public TableDataManager<NotificationRowData> getFilteredTableList() {
@ -338,7 +339,7 @@ public class NotificationTableComp extends TableComp implements ITableFind {
/**
* Get the table list for display.
*
*
* @return TableDataManager obj
*/
public ArrayList<NotificationRowData> 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<NotificationRowData> 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<Integer> 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<NotificationRecord> 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[])

View file

@ -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.
* </pre>
*
* @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<String, String> params = new HashMap<String, String>();
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<Subscription> updatedList = new ArrayList<Subscription>();
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);

View file

@ -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().
*
* </pre>
*
@ -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<Integer> cycleList = new ArrayList<Integer>(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.

View file

@ -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.
*
* </pre>
*

View file

@ -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.
*
* </pre>
*

View file

@ -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.
* </pre>
*
* @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<DecimalFormat> format = new ThreadLocal<DecimalFormat>() {
@ -551,20 +565,48 @@ public class DataDeliveryUtils {
* @return the maximum latency in minutes
*/
public static int getMaxLatency(Subscription subscription) {
List<Integer> 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<Integer> 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<Integer>(dataSet.getCycles()));
}
}

View file

@ -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.
*
* </pre>
*
@ -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<Integer> 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;
}
}

View file

@ -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,

View file

@ -20,7 +20,7 @@
package com.raytheon.uf.viz.stats.ui;
/**
* TODO Add Description
* Grouping Composite for the Stats Graph.
*
* <pre>
*
@ -36,10 +36,13 @@ package com.raytheon.uf.viz.stats.ui;
* @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;
@ -59,22 +62,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.
*
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 16, 2012 lvenable Initial creation
*
* Oct 16, 2012 lvenable Initial creation
* Jan 11, 2013 1357 mpduff Implement.
*
* </pre>
*
*
* @author lvenable
* @version 1.0
*/
@ -106,9 +112,11 @@ public class GroupingComp extends Composite implements IGroupSelection {
/** Grouping callback */
private final IStatsGroup callback;
private final List<SelectionEntry> selectionEntries = new ArrayList<SelectionEntry>();
/**
* Constructor.
*
*
* @param parentComp
* Parent composite.
* @param swtStyle
@ -191,12 +199,26 @@ public class GroupingComp extends Composite implements IGroupSelection {
*/
private void createControls() {
List<String> keyArray = graphData.getKeysWithData();
Map<String, List<String>> grpNameMap = graphData.getGroupAndNamesMap();
// Create the Selection Entry objects
for (String key : keyArray) {
SelectionEntry se = new SelectionEntry();
String[] parts = colonPattern.split(key);
Set<String> grpNames = grpNameMap.keySet();
Iterator<String> 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) {
@ -206,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) {
@ -216,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);
}
}
@ -245,22 +268,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,13 +301,13 @@ public class GroupingComp extends Composite implements IGroupSelection {
/**
* Handle the color label that is being clicked.
*
*
* @param lbl
* Label that was clicked.
*/
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);
@ -343,36 +366,30 @@ 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}
*/
@Override
public void setSelections(Map<String, Map<String, Boolean>> selectionMap) {
List<String> keySequence = graphData.getKeySequence();
Map<String, List<String>> offMap = new HashMap<String, List<String>>();
Multimap<String, String> 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<String>());
}
offMap.get(key).add(selection);
offMap.put(key, selection);
}
}
}
@ -385,19 +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<String> 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());
}
}
}
@ -405,4 +421,33 @@ public class GroupingComp extends Composite implements IGroupSelection {
fireCallback();
}
/**
* {@inheritDoc}
*/
@Override
public void setItemsOff(List<String> keys) {
for (String key : keys) {
if (checkBtnMap.containsKey(key)) {
checkBtnMap.get(key).setSelection(false);
keyRgbMap.remove(key);
}
}
fireCallback();
}
/**
* {@inheritDoc}
*/
@Override
public Map<String, Boolean> getStates() {
Map<String, Boolean> stateMap = new HashMap<String, Boolean>();
for (Map.Entry<String, Button> state : checkBtnMap.entrySet()) {
stateMap.put(state.getKey(), state.getValue().getSelection());
}
return stateMap;
}
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 4, 2012 1357 mpduff Initial creation.
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class HideDlg extends CaveSWTDialog {
/** Data List Widget */
private List dataList;
/** List of keys */
private final java.util.List<String> 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<String> 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);
}
}
}
}

View file

@ -19,21 +19,23 @@
**/
package com.raytheon.uf.viz.stats.ui;
import java.util.List;
import java.util.Map;
/**
* Interface for Group Selections.
*
*
* <pre>
*
*
* 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.
*
* </pre>
*
*
* @author mpduff
* @version 1.0
*/
@ -41,8 +43,23 @@ import java.util.Map;
public interface IGroupSelection {
/**
* Set the selections.
*
*
* @param selectionMap
*/
void setSelections(Map<String, Map<String, Boolean>> selectionMap);
/**
* Turn off the provided items.
*
* @param keys
* keys of the items to not draw
*/
void setItemsOff(List<String> keys);
/**
* Get the state of each item.
*
* @return Map of item -> checked or not checked
*/
Map<String, Boolean> getStates();
}

View file

@ -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.
*
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 3, 2012 728 mpduff Initial creation
*
*
* </pre>
*
*
* @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<String, RGB> getGroupSettings();
/**
* Get the UnitUtils object.
*
* @return the UnitUtils object
*/
UnitUtils getUnitUtils();
}

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 24, 2013 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class SelectionEntry {
private final Map<String, String> values = new LinkedHashMap<String, String>();
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<String> iter = values.values().iterator(); iter.hasNext();) {
sb.append(iter.next());
if (iter.hasNext()) {
sb.append(":");
}
}
return sb.toString();
}
}

View file

@ -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.
*
*
* <pre>
*
*
* 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.
*
* </pre>
*
*
* @author lvenable
* @version 1.0
*/
@ -74,9 +77,9 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
/**
* Constructor.
*
*
* @param parentShell
* @param graphData
* @param selectionEntries
* @param callback
*/
public SelectionManagerDlg(Shell parentShell, GraphData graphData,
@ -86,8 +89,8 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
| CAVE.INDEPENDENT_SHELL);
setText("Selection Manager");
this.graphData = graphData;
this.callback = callback;
this.graphData = graphData;
}
/**
@ -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
*/
@ -261,10 +264,27 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
for (String subKey : array) {
TreeItem subTreeItem = new TreeItem(treeItem, SWT.NONE);
subTreeItem.setText(subKey);
subTreeItem.setChecked(true);
}
}
// Determine group checkbox setting, unchecked, grayed, checked
TreeItem[] children = selectionTree.getItems();
Set<Boolean> selectionSet = new HashSet<Boolean>();
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 +334,5 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
} else {
callback.setSelections(selectionMap);
}
}
}

View file

@ -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.
*
* </pre>
*
@ -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<SimpleDateFormat> sdf = new ThreadLocal<SimpleDateFormat>() {
@ -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

View file

@ -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,8 @@ import com.raytheon.uf.viz.stats.display.ScaleManager;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 3, 2012 728 mpduff Initial creation
* Oct 03, 2012 728 mpduff Initial creation.
* Jan 17, 2013 1357 mpduff Added mouse listeners.
*
* </pre>
*
@ -106,6 +120,15 @@ public class StatsDisplayCanvas extends Canvas {
}
};
/** Decimal Format object */
private final ThreadLocal<DecimalFormat> decFormat = new ThreadLocal<DecimalFormat>() {
@Override
protected DecimalFormat initialValue() {
DecimalFormat format = new DecimalFormat("########.#");
return format;
}
};
/** Constant */
private final String COLON = ":";
@ -185,17 +208,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 +234,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 +277,13 @@ public class StatsDisplayCanvas extends Canvas {
handleMouseMoveEvent(e);
}
});
addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
handleMouseDownEvent(e);
}
});
}
/**
@ -342,8 +368,7 @@ public class StatsDisplayCanvas extends Canvas {
List<Date> dateList = new ArrayList<Date>();
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 +381,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 +399,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 +416,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 +439,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 +466,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 +492,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 +518,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 +530,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 +542,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 +556,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 +566,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 +621,21 @@ public class StatsDisplayCanvas extends Canvas {
gc.drawPolyline(yAxis);
Map<String, RGB> 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 +672,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 +710,8 @@ public class StatsDisplayCanvas extends Canvas {
double maxScaleVal = scalingManager.getMaxScaleValue();
double minScaleVal = scalingManager.getMinScaleValue();
Map<String, RGB> groupSettings = callback.getGroupSettings();
UnitUtils uu = callback.getUnitUtils();
GraphData graphData = callback.getGraphData();
for (String key : graphData.getKeysWithData()) {
if (groupSettings.containsKey(key)) {
@ -692,30 +737,27 @@ 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 = 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 +772,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 +802,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 +821,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 +836,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)) {
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 +872,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<String> keyList = new ArrayList<String>();
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<String> inputList) {
// Remove the tooltip if it is up
if (tooltip != null && !tooltip.isDisposed()) {
tooltip.dispose();
}
// Remove any duplicate entries
Set<String> set = new HashSet<String>(inputList);
final List<String> keyList = new ArrayList<String>(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<String> keyList) {
groupCallback.setItemsOff(keyList);
redraw();
}
private void showHideDlg(List<String> keyList) {
if (hideDlg == null || hideDlg.isDisposed()) {
this.hideDlg = new HideDlg(getShell(), keyList, groupCallback);
}
hideDlg.open();
}
/**
* Show the "tooltip" mouseover.
*
@ -856,22 +1011,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;
}
}

View file

@ -20,24 +20,21 @@
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;
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;
@ -48,7 +45,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 +67,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.
*
* </pre>
@ -102,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;
@ -144,6 +143,14 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
/** Data view combo */
private Combo viewCombo;
/** Menu item map */
private final Map<String, MenuItem> menuItemMap = new HashMap<String, MenuItem>();
/** The currently displayed unit */
private String displayUnit;
private UnitUtils unitUtils;
/**
* Constructor.
*
@ -205,6 +212,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 +230,11 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
graphLabel.setText("Graph: ");
List<String> viewList = new ArrayList<String>();
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);
@ -315,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");
@ -372,6 +381,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<String> 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<String, MenuItem> 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);
}
}
}
/**
@ -429,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.
@ -517,7 +578,6 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
default:
return;
}
GraphDataRequest request = new GraphDataRequest();
request.setGrouping(this.groupList);
request.setCategory(this.category);
@ -526,7 +586,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 +605,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 +616,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 +691,12 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
public void setDataType(String dataTypeID) {
this.dataTypeID = dataTypeID;
}
/**
* {@inheritDoc}
*/
@Override
public UnitUtils getUnitUtils() {
return this.unitUtils;
}
}

View file

@ -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() {

View file

@ -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;
@ -330,58 +331,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<String> datauris) {
for (String datauri : datauris) {
getInstance().processDataURI(datauri);
/**
* Processes the DataURIs as alert messages
*
* @param datauris
*/
public static void processDataURIAlerts(Collection<String> datauris) {
getInstance().processDataURIs(datauris);
}
private synchronized void processDataURIs(Collection<String> 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<String, Object> 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<String, Object> attribs = RecordFactory.getInstance()
.loadMapFromUri(datauri);
AlertMessage am = new AlertMessage();
am.dataURI = datauri;
am.decodedAlert = Collections.unmodifiableMap(attribs);
@ -403,11 +395,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);
}
}

View file

@ -82,7 +82,7 @@ import com.vividsolutions.jts.geom.Coordinate;
/**
* Implements a colorbar for continuous (scalar and vector) elements
*
*
* <pre>
* 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
*
* </pre>
*
*
* @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;
}
}

View file

@ -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
*
* </pre>
*
@ -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");

View file

@ -298,7 +298,7 @@ public class GridUpdater implements IAlertObserver {
}
}
myUpdates.addAll(datauris);
ProductAlertObserver.processDerivedAlerts(datauris);
ProductAlertObserver.processDataURIAlerts(datauris);
}
/**

View file

@ -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) {

View file

@ -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
*/

View file

@ -157,7 +157,11 @@ public class MetarPrecipResource extends
@Override
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
List<RenderablePrecipData> precips = data.get(paintProps.getDataTime());
DataTime time = paintProps.getDataTime();
if (time == null) {
return;
}
List<RenderablePrecipData> precips = getPrecipData(time);
if (precips == null) {
dataProcessJob.schedule();
return;
@ -201,6 +205,19 @@ public class MetarPrecipResource extends
target.drawStrings(strings);
}
private List<RenderablePrecipData> getPrecipData(DataTime time) {
List<RenderablePrecipData> currData = null;
synchronized (data) {
currData = data.get(time);
}
if (currData != null) {
synchronized (currData) {
return new ArrayList<RenderablePrecipData>(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<RenderablePrecipData> precips = data.get(descriptor
List<RenderablePrecipData> 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<RenderablePrecipData> 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<RenderablePrecipData> 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<RenderablePrecipData> iter = entry.getValue().iterator();
while (iter.hasNext()) {
if (newStations.contains(iter.next().getStationName())) {
iter.remove();
synchronized (entry.getValue()) {
Iterator<RenderablePrecipData> 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<PrecipData> precips) {
if (precips.isEmpty()) {
if (!dataTimes.contains(time)) {
List<RenderablePrecipData> newPrecips = Collections.emptyList();
data.put(time, newPrecips);
synchronized (data) {
List<RenderablePrecipData> newPrecips = Collections
.emptyList();
data.put(time, newPrecips);
}
dataTimes.add(time);
}
}
if (data.containsKey(time)) {
precips = new ArrayList<PrecipData>(precips);
for (RenderablePrecipData pData : data.get(time)) {
precips.add(pData);
}
precips.addAll(getPrecipData(time));
}
Collections.sort(precips, new Comparator<PrecipData>() {
@ -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();
}

View file

@ -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;

View file

@ -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<AbstractRequestableData> cacheSet = new HashSet<AbstractRequestableData>();
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);
}
}

View file

@ -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;
@ -386,9 +387,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());
}
}
}

View file

@ -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 "

View file

@ -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

View file

@ -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"

View file

@ -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.
*
* </pre>
*
@ -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() {

View file

@ -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.
*
* </pre>
*
@ -55,37 +53,12 @@ import com.raytheon.uf.common.stats.util.DataViewUtils;
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class DataPoint implements Comparable<DataPoint> {
/** Date Format object */
private final ThreadLocal<SimpleDateFormat> sdf = new ThreadLocal<SimpleDateFormat>() {
@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<DecimalFormat> decFormat = new ThreadLocal<DecimalFormat>() {
@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<DataPoint> {
@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<DataPoint> {
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<DataPoint> {
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();

View file

@ -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.
*
*
* <pre>
*
*
* 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.
*
* </pre>
*
*
* @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<String> 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<String> visibleDataSet, String view) {
public double getMinValue(Set<String> 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<String> visibleDataSet, String view) {
public double getMaxValue(Set<String> 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<String> keySequence) {
@ -270,7 +280,7 @@ public class GraphData {
/**
* Get the key sequence.
*
*
* @return
*/
public List<String> getKeySequence() {
@ -279,7 +289,7 @@ public class GraphData {
/**
* Get a list of all keys.
*
*
* @return the keys
*/
public List<String> getKeys() {
@ -288,7 +298,7 @@ public class GraphData {
/**
* Get a list of keys that contain data.
*
*
* @return the keys with data
*/
public List<String> 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<String, List<String>> 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<String, StatsData> 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;
}
}

View file

@ -28,17 +28,18 @@ import com.raytheon.uf.common.stats.AggregateRecord;
/**
* A bin of Statistical data.
*
*
* <pre>
*
*
* 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.
*
* </pre>
*
*
* @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<AggregateRecord> getData() {

View file

@ -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.
*
*
* <pre>
*
*
* 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.
*
* </pre>
*
*
* @author mpduff
* @version 1.0
*/
@ -84,9 +85,6 @@ public class StatsData {
@DynamicSerializeElement
private Map<Long, StatsBin> 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<Long, StatsBin> 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<AggregateRecord> 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

View file

@ -26,17 +26,18 @@ import java.util.Map;
/**
* Stats Event helper object.
*
*
* <pre>
*
*
* 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.
*
* </pre>
*
*
* @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
*/

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 18, 2013 1357 mpduff Moved to its own file.
*
* </pre>
*
* @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<String, DataView> LOOKUP_MAP;
static {
Map<String, DataView> map = new HashMap<String, DataView>();
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);
}
}

View file

@ -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
*
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 14, 2012 728 mpduff Initial creation.
*
* Jan 17, 2013 1357 mpduff Refactored to use DataSizeUnit and TimeUnit.
*
* </pre>
*
*
* @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<String> 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<String>();
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<String> 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<String> 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<String, DataSizeUnit> DATA_SIZE_UNIT_LOOKUP;
static {
DataSizeUnit[] values = DataSizeUnit.values();
Map<String, DataSizeUnit> map = new LinkedHashMap<String, DataSizeUnit>(
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<String>();
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<String> getDataUnits() {
return dataUnits;
/**
* Time unit lookup map.
*/
private static final Map<String, TimeConversion> TIME_UNIT_LOOKUP;
static {
TimeConversion[] values = TimeConversion.values();
Map<String, TimeConversion> map = new LinkedHashMap<String, TimeConversion>(
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,139 @@ 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<String> getUnitOptions(UnitTypes type) {
Set<String> units = Collections.emptySet();
switch (type) {
case DATA_SIZE:
units = DATA_SIZE_UNIT_LOOKUP.keySet();
break;
case TIME:
units = TIME_UNIT_LOOKUP.keySet();
break;
case COUNT:
units = new HashSet<String>();
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<String> getUnitOptions() {
return this.getUnitOptions(this.unitType);
}
}

View file

@ -44,15 +44,16 @@ 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.
*
* </pre>
*
* @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 +98,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;
@ -115,10 +122,7 @@ public 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.
@ -385,4 +389,10 @@ public class TimeUtil {
}
return calendar;
}
/**
* Disabled constructor.
*/
private TimeUtil() {
}
}

View file

@ -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.
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
@XmlType(name = "ruleUnit")
@XmlEnum
public enum DataSizeUnit {
@XmlEnumValue("Byte")

View file

@ -45,7 +45,7 @@
<ignore>\.das$</ignore>
<ignore>\.dds$</ignore>
<ignore>help$</ignore>
<ignore>fens\d\d\d</ignore>
<ignore>fens\d\d\d_</ignore>
<ignore>cmcens[cp]\d\d</ignore>
<ignore>ge[cp]\d\d</ignore>
<!-- seed scan once a day at 12z -->

View file

@ -0,0 +1,29 @@
<statisticsConfig>
<!-- Event Type should be fully qualified name of stat event -->
<statisticsEvent type="com.raytheon.uf.common.datadelivery.event.retrieval.SubscriptionRetrievalEvent"
displayName="Subscription Retrieval" category="Data Delivery">
<statisticsGroup name="plugin" displayName="Data Type" />
<statisticsGroup name="provider" displayName="Data Provider" />
<statisticsGroup name="owner" displayName="Owner" />
<statisticsGroup name="network" displayName="Network Route" />
<statisticsGroup name="subscriptionType" displayName="Subscription Type" />
<statisticsAggregate field="numFailed"
displayName="Number of Failed Subscriptions" displayUnit="Count" />
<statisticsAggregate field="numComplete"
displayName="Number of Completed Subscriptions" displayUnit="Count" />
</statisticsEvent>
<statisticsEvent type="com.raytheon.uf.common.datadelivery.event.retrieval.DataRetrievalEvent"
displayName="Data Retrieval" category="Data Delivery">
<statisticsGroup name="plugin" displayName="Data Type" />
<statisticsGroup name="provider" displayName="Data Provider" />
<statisticsGroup name="owner" displayName="Owner" />
<statisticsGroup name="network" displayName="Network Route" />
<!--
Display unit options are bytes, KB, MB, GB
-->
<statisticsAggregate field="bytes"
displayName="Amount of Data Downloaded" displayUnit="MB" />
<statisticsAggregate field="numRecords"
displayName="Number of Records Downloaded" displayUnit="Count" />
</statisticsEvent>
</statisticsConfig>

View file

@ -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);

View file

@ -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<JarEntry> 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,

View file

@ -0,0 +1,14 @@
<statisticsConfig>
<!-- Event Type should be fully qualified name of stat event -->
<statisticsEvent type="com.raytheon.uf.common.registry.event.RegistryStatisticsEvent"
displayName="Registry Statistics" category="Registry">
<statisticsGroup name="owner" displayName="Transaction Owner" />
<statisticsGroup name="status" displayName="Transaction Status" />
<statisticsGroup name="type" displayName="Transaction Type" />
<!--
Display unit options are ms, Seconds, Minutes, Hours
-->
<statisticsAggregate field="duration"
displayName="Total Registry Duration" displayUnit="Minutes" />
</statisticsEvent>
</statisticsConfig>

View file

@ -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.
*
* </pre>
*
@ -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<String>(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<String> groups) {
void createStatsDataMap(List<String> groups) {
Map<String, String> keySequenceMap = new LinkedHashMap<String, String>();
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<String> groups) {
createStatsDataMap(unitUtils, groups);
private void gather(List<String> groups) {
createStatsDataMap(groups);
calculateBins();
Map<Long, StatsBin> newMap = new TreeMap<Long, StatsBin>();
for (String key : statsDataMap.keySet()) {
Map<Long, StatsBin> 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();

View file

@ -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.
*
* </pre>
*
@ -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<AggregateRecord> 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));

View file

@ -3,6 +3,8 @@
<statisticsEvent type="com.raytheon.uf.common.stats.ProcessEvent"
displayName="Processing Events" category="Data Ingest Events">
<statisticsGroup name="pluginName" displayName="Data Type" />
<!-- Processing time available display units:
ms, Seconds, Minutes, Hours -->
<statisticsAggregate field="processingTime"
displayName="Processing Time" displayUnit="ms" />
<statisticsAggregate field="processingLatency"

View file

@ -69,5 +69,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.viz.plugin.nwsauth"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.edex.plugin.nwsauth"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.datadelivery.service"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.units"/>
<classpathentry kind="src" path="/com.raytheon.uf.viz.stats"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -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.<String, Parameter> emptyMap());
obj.setProviderName(ProviderFixture.INSTANCE.get(seedValue).getName());

View file

@ -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

View file

@ -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<Long, StatsBin> bins = new TreeMap<Long, StatsBin>();
@ -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<DataPoint> 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<AggregateRecord> getTestRecords() {
List<AggregateRecord> records = new ArrayList<AggregateRecord>();

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 17, 2013 1357 mpduff Initial creation
*
* </pre>
*
* @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);
}
}

View file

@ -153,7 +153,7 @@ public class StatsDataAccumulatorTest {
acc.setDataType(dataType);
acc.setupGroupings();
acc.createStatsDataMap(unitUtils, acc.groups);
acc.createStatsDataMap(acc.groups);
Set<String> expectedSet = new HashSet<String>();
expectedSet.add("owner0:nomads");

View file

@ -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.
*
* </pre>
*

View file

@ -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.
*
* </pre>
*

View file

@ -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}.
*
* <pre>
*
@ -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.
*
* </pre>
*
* @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<Integer> 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<Integer> 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<Integer> 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<Integer> 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));
}
}

View file

@ -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.
*
* </pre>
*

View file

@ -1,54 +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.common.stats.util;
package com.raytheon.uf.viz.stats.ui;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* TODO Add Description
*
* SelectionEntry test class.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 27, 2012 mpduff Initial creation
*
* Jan 24, 2013 mpduff Initial creation
*
* </pre>
*
*
* @author mpduff
* @version 1.0
*/
public class DataViewUtils {
public enum DataView {
AVG("Average"), MIN("Minimum"), MAX("Maximum"),
SUM("Sum"), COUNT("Count");
public class SelectionEntryTest {
private final String view;
private DataView(String view) {
this.view = view;
}
public String getView() {
return view;
}
@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"));
}
}