Merge branch '13.2.1_delivery' into development
Conflicts: edexOsgi/com.raytheon.uf.edex.ohd/src/com/raytheon/uf/edex/ohd/pproc/MpeLightningSrv.java Former-commit-id:407d73a04f
[formerly cda6b1137d9052b0859f2b51f5bdadecad411e43] Former-commit-id:2c9c6b7dde
This commit is contained in:
commit
89f3120c0c
56 changed files with 1910 additions and 438 deletions
|
@ -26,11 +26,11 @@ import com.raytheon.uf.common.datadelivery.event.notification.PendingSubscriptio
|
|||
import com.raytheon.uf.common.datadelivery.event.notification.SubscriptionNotificationRequest;
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
|
||||
import com.raytheon.uf.common.serialization.comm.RequestRouter;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ISubscriptionNotificationService} that sends the
|
||||
|
@ -42,7 +42,8 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 4, 2013 1441 djohnson Initial creation
|
||||
* Jan 04, 2013 1441 djohnson Initial creation
|
||||
* Jan 17, 2013 1501 djohnson Route to datadelivery.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -207,8 +208,7 @@ public class SendToServerSubscriptionNotificationService implements
|
|||
*/
|
||||
@Override
|
||||
public void sendSubscriptionActivatedNotification(
|
||||
Subscription subscription,
|
||||
String username) {
|
||||
Subscription subscription, String username) {
|
||||
SubscriptionNotificationRequest req = new SubscriptionNotificationRequest();
|
||||
req.setUserId(username);
|
||||
req.setCategory("Subscription");
|
||||
|
@ -223,8 +223,7 @@ public class SendToServerSubscriptionNotificationService implements
|
|||
*/
|
||||
@Override
|
||||
public void sendSubscriptionDeactivatedNotification(
|
||||
Subscription subscription,
|
||||
String username) {
|
||||
Subscription subscription, String username) {
|
||||
SubscriptionNotificationRequest req = new SubscriptionNotificationRequest();
|
||||
req.setUserId(username);
|
||||
req.setCategory("Subscription");
|
||||
|
@ -241,8 +240,9 @@ public class SendToServerSubscriptionNotificationService implements
|
|||
*/
|
||||
private void sendRequest(BaseSubscriptionNotificationRequest<?> req) {
|
||||
try {
|
||||
ThriftClient.sendRequest(req);
|
||||
} catch (VizException e) {
|
||||
RequestRouter
|
||||
.route(req, DataDeliveryConstants.DATA_DELIVERY_SERVER);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@ 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.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
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;
|
||||
|
@ -54,11 +52,6 @@ import com.raytheon.uf.viz.datadelivery.utils.DataSizeUnit;
|
|||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public abstract class RuleXML {
|
||||
|
||||
/** Status Handler */
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RuleXML.class);
|
||||
|
||||
/** Rule name */
|
||||
@XmlElement
|
||||
protected String ruleName;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.datadelivery.system;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -227,6 +228,9 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
this(parent, create, null, ruleType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the rule header.
|
||||
*/
|
||||
private void createRuleHeader() {
|
||||
if (create) {
|
||||
if (PRIORITY_TYPE.equals(ruleType)) {
|
||||
|
@ -269,9 +273,9 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
protected void initializeComponents(Shell shell) {
|
||||
if (!create) {
|
||||
if (PRIORITY_TYPE.equals(ruleType)) {
|
||||
ruleXml = srm.loadPriorityRule(ruleName);
|
||||
ruleXml = srm.getPriorityRule(ruleName);
|
||||
} else {
|
||||
ruleXml = srm.loadLatencyRule(ruleName);
|
||||
ruleXml = srm.getLatencyRule(ruleName);
|
||||
}
|
||||
|
||||
if (DATASET_SIZE.equals(ruleXml.getRuleField())) {
|
||||
|
@ -411,7 +415,6 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
String item = fieldCombo.getItem(index);
|
||||
updateSelectionFields(item);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
OpsNetFieldNames[] fieldItems = OpsNetFieldNames.values();
|
||||
|
@ -450,7 +453,6 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
createFreqUnitItems();
|
||||
}
|
||||
unitsCombo.select(0);
|
||||
|
||||
}
|
||||
|
||||
if (PRIORITY_TYPE.equals(ruleType)) {
|
||||
|
@ -481,7 +483,6 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
}
|
||||
|
||||
priorityCombo.select(0);
|
||||
|
||||
} else {
|
||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
gl = new GridLayout(3, false);
|
||||
|
@ -507,19 +508,16 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
Label minutesLbl = new Label(latencySelectionComp, SWT.NONE);
|
||||
minutesLbl.setLayoutData(gd);
|
||||
minutesLbl.setText("Minutes");
|
||||
|
||||
}
|
||||
|
||||
populateFields();
|
||||
ruleDefinitionGroup.pack();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Upon edit, populate the fields.
|
||||
*/
|
||||
private void populateFields() {
|
||||
|
||||
if (!create) {
|
||||
String field = ruleXml.getRuleField();
|
||||
if (!field.isEmpty()) {
|
||||
|
@ -602,7 +600,6 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
close();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -651,6 +648,13 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
Operator operator = OperatorAdapter.fromString(operationCombo
|
||||
.getItem(operationCombo.getSelectionIndex()));
|
||||
|
||||
List<String> ruleNames = null;
|
||||
if (PRIORITY_TYPE.equals(ruleType)) {
|
||||
ruleNames = srm.getPriorityRuleNames();
|
||||
} else {
|
||||
ruleNames = srm.getLatencyRuleNames();
|
||||
}
|
||||
|
||||
if (create) {
|
||||
valid = DataDeliveryGUIUtils.hasText(ruleNameText);
|
||||
|
||||
|
@ -663,13 +667,29 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
}
|
||||
|
||||
ruleName = ruleNameText.getText();
|
||||
}
|
||||
|
||||
if (INVALID_PATTERN.matcher(ruleName.trim()).find()) {
|
||||
DataDeliveryUtils.showMessage(getShell(), SWT.ERROR,
|
||||
INVALID_CHARS_TITLE, INVALID_CHARS_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for duplicate rule name
|
||||
if (ruleNames.contains(ruleName)) {
|
||||
DataDeliveryUtils
|
||||
.showMessage(
|
||||
shell,
|
||||
SWT.ERROR,
|
||||
"Duplicate Rule",
|
||||
"A rule titled "
|
||||
+ ruleName
|
||||
+ " already exists.\n\nPlease select a different name.");
|
||||
ruleNameText.selectAll();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
String value = null;
|
||||
if (DataDeliveryGUIUtils.hasText(ruleValue)) {
|
||||
value = ruleValue.getText();
|
||||
|
@ -770,21 +790,12 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
}
|
||||
|
||||
setReturnValue(saved);
|
||||
|
||||
if (!saved) {
|
||||
DataDeliveryUtils
|
||||
.showMessage(
|
||||
getShell(),
|
||||
SWT.OK,
|
||||
"Duplicate Name",
|
||||
"A rule named "
|
||||
+ ruleName
|
||||
+ " already exists\n\nPlease select a different name.");
|
||||
ruleNameText.selectAll();
|
||||
}
|
||||
return saved;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the units combo.
|
||||
*/
|
||||
private void createSizeUnitItems() {
|
||||
unitsCombo.removeAll();
|
||||
DataSizeUnit[] sizeUnits = DataSizeUnit.values();
|
||||
|
@ -793,6 +804,9 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the operation combo.
|
||||
*/
|
||||
private void createSizeOpItems() {
|
||||
operationCombo.removeAll();
|
||||
OperatorTypes[] sizeOps = OperatorTypes.values();
|
||||
|
@ -801,6 +815,9 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the frequency units combo.
|
||||
*/
|
||||
private void createFreqUnitItems() {
|
||||
FreqUnitOptions[] freqUnits = FreqUnitOptions.values();
|
||||
for (FreqUnitOptions fuo : freqUnits) {
|
||||
|
@ -808,6 +825,9 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* populate the operation combo.
|
||||
*/
|
||||
private void createNameOpItems() {
|
||||
operationCombo.removeAll();
|
||||
NameOperationItems[] nameOperation = NameOperationItems.values();
|
||||
|
|
|
@ -17,13 +17,10 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.datadelivery.retrieval.util;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.LevelLookup;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterLookup;
|
||||
package com.raytheon.uf.viz.datadelivery.system;
|
||||
|
||||
/**
|
||||
* Makes parser created XML not write out in test
|
||||
* Rules file update notifier interface.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -31,30 +28,17 @@ import com.raytheon.uf.common.datadelivery.retrieval.xml.ParameterLookup;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 10, 2013 djohnson Initial creation
|
||||
* Jan 16, 2013 1420 mpduff Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @author mpduff
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class NullXmlWriter implements LevelXmlWriter, ParameterXmlWriter {
|
||||
|
||||
public interface IRulesUpdateListener {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Update rules.
|
||||
*/
|
||||
@Override
|
||||
public void writeParameterXml(ParameterLookup pl, String modelName)
|
||||
throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void writeLevelXml(LevelLookup ll, String modelName)
|
||||
throws Exception {
|
||||
}
|
||||
|
||||
void update();
|
||||
}
|
|
@ -263,10 +263,7 @@ public class SystemLatencyTab {
|
|||
ruleDlg = new CreateEditRuleDlg(parentComp.getShell(),
|
||||
create, ruleName, LATENCY_TYPE);
|
||||
}
|
||||
boolean reloadFlag = (Boolean) ruleDlg.open();
|
||||
if (reloadFlag) {
|
||||
loadList();
|
||||
}
|
||||
ruleDlg.open();
|
||||
} else {
|
||||
ruleDlg.bringToTop();
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
|||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.util.StringUtil;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.ForceApplyPromptResponse;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceApplyPromptDisplayText;
|
||||
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
||||
|
@ -64,6 +65,8 @@ import com.raytheon.viz.ui.presenter.IDisplay;
|
|||
* Oct 23, 2012 1286 djohnson Hook into bandwidth management.
|
||||
* Nov 20, 2012 1286 djohnson Implement IDisplay.
|
||||
* Jan 04, 2013 1420 mpduff Remove applying of rules.
|
||||
* Jan 17, 2013 1501 djohnson Close the dialog when force apply occurs,
|
||||
* and check whether changes have already been applied when OK is pressed.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -71,7 +74,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
|
||||
IForceApplyPromptDisplayText {
|
||||
IForceApplyPromptDisplayText, IRulesUpdateListener {
|
||||
|
||||
/** Status Handler */
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
|
@ -128,10 +131,18 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
|
|||
/** OK button */
|
||||
private Button okBtn;
|
||||
|
||||
/** Available bandwidth modified flag */
|
||||
private boolean availableBandwidthModified;
|
||||
|
||||
/** Available bandwidth spinner widget */
|
||||
private Spinner availBandwidthSpinner;
|
||||
|
||||
/** The system latency tab */
|
||||
private SystemLatencyTab lTab;
|
||||
|
||||
/** The system priority tab */
|
||||
private SystemPriorityTab pTab;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -141,6 +152,7 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
|
|||
public SystemManagementDlg(Shell parent) {
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.NONE);
|
||||
setText("Data Delivery System Management");
|
||||
SystemRuleManager.getInstance().registerAsListener(this);
|
||||
|
||||
}
|
||||
|
||||
|
@ -181,6 +193,17 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||
*/
|
||||
@Override
|
||||
protected void disposed() {
|
||||
super.disposed();
|
||||
SystemRuleManager.getInstance().deregisterAsListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create top bar route information.
|
||||
*/
|
||||
|
@ -283,7 +306,7 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
|
|||
priorityComp.setLayout(gl);
|
||||
priorityComp.setLayoutData(gd);
|
||||
priorityTab.setControl(priorityComp);
|
||||
SystemPriorityTab pTab = new SystemPriorityTab(priorityComp);
|
||||
pTab = new SystemPriorityTab(priorityComp);
|
||||
|
||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
gl = new GridLayout(1, false);
|
||||
|
@ -296,7 +319,7 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
|
|||
latencyComp.setLayout(gl);
|
||||
latencyComp.setLayoutData(gd);
|
||||
latencyTab.setControl(latencyComp);
|
||||
SystemLatencyTab lTab = new SystemLatencyTab(latencyComp);
|
||||
lTab = new SystemLatencyTab(latencyComp);
|
||||
|
||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
|
||||
gl = new GridLayout(1, false);
|
||||
|
@ -309,6 +332,9 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
|
|||
routingComp.setLayoutData(gd);
|
||||
routingTab.setControl(routingComp);
|
||||
SystemRoutingTab rTab = new SystemRoutingTab(routingComp);
|
||||
|
||||
lTab.loadList();
|
||||
pTab.loadList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -413,21 +439,26 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
|
|||
sb.append("Would you like to change the bandwidth anyways?.");
|
||||
int response = DataDeliveryUtils.showMessage(getShell(),
|
||||
SWT.YES | SWT.NO, "Bandwidth Amount", sb.toString());
|
||||
boolean forceApplied = false;
|
||||
if (response == SWT.YES) {
|
||||
boolean forceApplied = SystemRuleManager
|
||||
forceApplied = SystemRuleManager
|
||||
.forceSetAvailableBandwidth(Network.OPSNET,
|
||||
bandwidth);
|
||||
if (!forceApplied) {
|
||||
if (forceApplied) {
|
||||
availableBandwidthModified = false;
|
||||
} else {
|
||||
statusHandler
|
||||
.handle(Priority.ERROR,
|
||||
"Bandwidth Change",
|
||||
"Unable to change the bandwidth for network "
|
||||
+ Network.OPSNET
|
||||
+ ". Please check the server for details.");
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return forceApplied;
|
||||
} else {
|
||||
availableBandwidthModified = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -466,4 +497,17 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
|
|||
"Don't know how to handle option [" + option + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
VizApp.runAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!shell.isDisposed()) {
|
||||
lTab.loadList();
|
||||
pTab.loadList();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,10 +268,7 @@ public class SystemPriorityTab {
|
|||
create, ruleName, PRIORITY_TYPE);
|
||||
}
|
||||
|
||||
boolean reloadFlag = (Boolean) ruleDlg.open();
|
||||
if (reloadFlag) {
|
||||
loadList();
|
||||
}
|
||||
ruleDlg.open();
|
||||
} else {
|
||||
ruleDlg.bringToTop();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ import javax.xml.bind.Unmarshaller;
|
|||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthService;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.localization.FileUpdatedMessage;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
|
@ -89,6 +91,12 @@ public class SystemRuleManager {
|
|||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(SystemRuleManager.class);
|
||||
|
||||
/** Latency Rules Localization File */
|
||||
private LocalizationFile latencyRulesLocFile;
|
||||
|
||||
/** Priority Rules Localization File */
|
||||
private LocalizationFile priorityRulesLocFile;
|
||||
|
||||
/** JAXB context */
|
||||
private JAXBContext jax;
|
||||
|
||||
|
@ -101,11 +109,21 @@ public class SystemRuleManager {
|
|||
/** Bandwidth service */
|
||||
private IBandwidthService bandwidthService;
|
||||
|
||||
/** Latency Rules XML object */
|
||||
private LatencyRulesXML latencyRules;
|
||||
|
||||
/** Priority Rules XML object */
|
||||
private PriorityRulesXML priorityRules;
|
||||
|
||||
private final List<IRulesUpdateListener> listeners = new ArrayList<IRulesUpdateListener>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
private SystemRuleManager() {
|
||||
createContext();
|
||||
loadLatencyRules();
|
||||
loadPriorityRules();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,7 +162,7 @@ public class SystemRuleManager {
|
|||
* @throws JAXBException
|
||||
*/
|
||||
public List<String> getPriorityRuleNames() {
|
||||
return getPriorityRules().getRuleNames();
|
||||
return getPriorityRules(false).getRuleNames();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,8 +172,8 @@ public class SystemRuleManager {
|
|||
* the name of the rule
|
||||
* @return the PriorityRuleXML object
|
||||
*/
|
||||
public PriorityRuleXML loadPriorityRule(String name) {
|
||||
PriorityRulesXML priorityRules = getPriorityRules();
|
||||
public PriorityRuleXML getPriorityRule(String name) {
|
||||
PriorityRulesXML priorityRules = getPriorityRules(false);
|
||||
for (PriorityRuleXML rule : priorityRules.getRules()) {
|
||||
if (rule.getRuleName().equals(name)) {
|
||||
return rule;
|
||||
|
@ -172,8 +190,8 @@ public class SystemRuleManager {
|
|||
* the name of the rule
|
||||
* @return the LatencyRuleXML object
|
||||
*/
|
||||
public LatencyRuleXML loadLatencyRule(String name) {
|
||||
LatencyRulesXML latencyRules = getLatencyRules();
|
||||
public LatencyRuleXML getLatencyRule(String name) {
|
||||
LatencyRulesXML latencyRules = getLatencyRules(false);
|
||||
for (LatencyRuleXML rule : latencyRules.getRules()) {
|
||||
if (rule.getRuleName().equals(name)) {
|
||||
return rule;
|
||||
|
@ -190,7 +208,7 @@ public class SystemRuleManager {
|
|||
* @throws JAXBException
|
||||
*/
|
||||
public List<String> getLatencyRuleNames() {
|
||||
return getLatencyRules().getRuleNames();
|
||||
return getLatencyRules(false).getRuleNames();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -203,15 +221,22 @@ public class SystemRuleManager {
|
|||
public boolean savePriorityRules(PriorityRulesXML xmlObj) {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
|
||||
try {
|
||||
// If site, then write out, otherwise save it as site.
|
||||
if (priorityRulesLocFile.getContext().getLocalizationLevel()
|
||||
.equals(LocalizationLevel.SITE)) {
|
||||
marshaller.marshal(xmlObj, priorityRulesLocFile.getFile());
|
||||
return priorityRulesLocFile.save();
|
||||
} else {
|
||||
LocalizationContext context = pm.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
|
||||
LocalizationFile priorityRulesLocFile = pm.getLocalizationFile(context,
|
||||
this.PRIORITY_RULE_FILE);
|
||||
|
||||
try {
|
||||
priorityRulesLocFile = pm.getLocalizationFile(context,
|
||||
this.PRIORITY_RULE_FILE);
|
||||
addPriorityRulesFileObserver();
|
||||
marshaller.marshal(xmlObj, priorityRulesLocFile.getFile());
|
||||
priorityRulesLocFile.save();
|
||||
return true;
|
||||
return priorityRulesLocFile.save();
|
||||
}
|
||||
} catch (JAXBException e) {
|
||||
statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
|
||||
} catch (LocalizationOpFailedException e) {
|
||||
|
@ -231,15 +256,22 @@ public class SystemRuleManager {
|
|||
public boolean saveLatencyRules(LatencyRulesXML xmlObj) {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
|
||||
try {
|
||||
// If site, then write out, otherwise save it as site.
|
||||
if (latencyRulesLocFile.getContext().getLocalizationLevel()
|
||||
.equals(LocalizationLevel.SITE)) {
|
||||
marshaller.marshal(xmlObj, latencyRulesLocFile.getFile());
|
||||
return latencyRulesLocFile.save();
|
||||
} else {
|
||||
LocalizationContext context = pm.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
|
||||
LocalizationFile latencyRulesLocFile = pm.getLocalizationFile(context,
|
||||
this.LATENCY_RULE_FILE);
|
||||
|
||||
try {
|
||||
latencyRulesLocFile = pm.getLocalizationFile(context,
|
||||
this.LATENCY_RULE_FILE);
|
||||
addLatencyRulesFileObserver();
|
||||
marshaller.marshal(xmlObj, latencyRulesLocFile.getFile());
|
||||
latencyRulesLocFile.save();
|
||||
return true;
|
||||
return latencyRulesLocFile.save();
|
||||
}
|
||||
} catch (JAXBException e) {
|
||||
statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
|
||||
} catch (LocalizationOpFailedException e) {
|
||||
|
@ -256,7 +288,7 @@ public class SystemRuleManager {
|
|||
* the rule name to delete
|
||||
*/
|
||||
public void deleteLatencyRule(String ruleName) {
|
||||
LatencyRulesXML latencyRules = getLatencyRules();
|
||||
LatencyRulesXML latencyRules = getLatencyRules(false);
|
||||
|
||||
for (LatencyRuleXML rule : latencyRules.getRules()) {
|
||||
if (rule.getRuleName().equals(ruleName)) {
|
||||
|
@ -274,7 +306,7 @@ public class SystemRuleManager {
|
|||
* the rule name to delete
|
||||
*/
|
||||
public void deletePriorityRule(String ruleName) {
|
||||
PriorityRulesXML priorityRules = getPriorityRules();
|
||||
PriorityRulesXML priorityRules = getPriorityRules(false);
|
||||
|
||||
for (PriorityRuleXML rule : priorityRules.getRules()) {
|
||||
if (rule.getRuleName().equals(ruleName)) {
|
||||
|
@ -293,7 +325,7 @@ public class SystemRuleManager {
|
|||
* @return true if updated
|
||||
*/
|
||||
public boolean updateRule(LatencyRuleXML rule) {
|
||||
LatencyRulesXML rulesXml = getLatencyRules();
|
||||
LatencyRulesXML rulesXml = getLatencyRules(false);
|
||||
boolean saved = rulesXml.updateRule(rule);
|
||||
if (saved) {
|
||||
return saveLatencyRules(rulesXml);
|
||||
|
@ -310,7 +342,7 @@ public class SystemRuleManager {
|
|||
* @return true if updated
|
||||
*/
|
||||
public boolean updateRule(PriorityRuleXML rule) {
|
||||
PriorityRulesXML rulesXml = getPriorityRules();
|
||||
PriorityRulesXML rulesXml = getPriorityRules(false);
|
||||
boolean saved = rulesXml.updateRule(rule);
|
||||
if (saved) {
|
||||
saved = savePriorityRules(rulesXml);
|
||||
|
@ -331,7 +363,7 @@ public class SystemRuleManager {
|
|||
* @return true if updated
|
||||
*/
|
||||
public boolean saveRule(PriorityRuleXML rule) {
|
||||
PriorityRulesXML rulesXml = getPriorityRules();
|
||||
PriorityRulesXML rulesXml = getPriorityRules(false);
|
||||
boolean saved = rulesXml.addRule(rule);
|
||||
if (saved) {
|
||||
saved = savePriorityRules(rulesXml);
|
||||
|
@ -352,7 +384,7 @@ public class SystemRuleManager {
|
|||
* @return true if updated
|
||||
*/
|
||||
public boolean saveRule(LatencyRuleXML rule) {
|
||||
LatencyRulesXML rulesXml = getLatencyRules();
|
||||
LatencyRulesXML rulesXml = getLatencyRules(false);
|
||||
boolean saved = rulesXml.addRule(rule);
|
||||
if (saved) {
|
||||
saved = saveLatencyRules(rulesXml);
|
||||
|
@ -368,19 +400,23 @@ public class SystemRuleManager {
|
|||
/**
|
||||
* Get the latency rules.
|
||||
*
|
||||
* @param reread
|
||||
* true to reread the file from disk
|
||||
*
|
||||
* @return The latency rules xml object
|
||||
*/
|
||||
private LatencyRulesXML getLatencyRules() {
|
||||
LocalizationFile lfile = getRules(this.LATENCY_RULE_FILE);
|
||||
|
||||
LatencyRulesXML latencyRules = new LatencyRulesXML();
|
||||
if (lfile != null && lfile.exists()) {
|
||||
private LatencyRulesXML getLatencyRules(boolean reread) {
|
||||
if (latencyRules == null || reread) {
|
||||
if (this.latencyRulesLocFile != null
|
||||
&& latencyRulesLocFile.exists()) {
|
||||
try {
|
||||
latencyRules = (LatencyRulesXML) unmarshaller.unmarshal(lfile
|
||||
.getFile());
|
||||
latencyRules = (LatencyRulesXML) unmarshaller
|
||||
.unmarshal(latencyRulesLocFile.getFile());
|
||||
} catch (JAXBException e) {
|
||||
statusHandler
|
||||
.handle(Priority.ERROR, e.getLocalizedMessage(), e);
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
e.getLocalizedMessage(), e);
|
||||
latencyRules = new LatencyRulesXML();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,34 +426,26 @@ public class SystemRuleManager {
|
|||
/**
|
||||
* Get the priority rules
|
||||
*
|
||||
* @param reread
|
||||
* true to reread the file from disk
|
||||
*
|
||||
* @return The priority rules xml object
|
||||
*/
|
||||
private PriorityRulesXML getPriorityRules() {
|
||||
LocalizationFile lfile = getRules(this.PRIORITY_RULE_FILE);
|
||||
|
||||
PriorityRulesXML priorityRules = new PriorityRulesXML();
|
||||
if (lfile != null && lfile.exists()) {
|
||||
private PriorityRulesXML getPriorityRules(boolean reread) {
|
||||
if (priorityRules == null || reread)
|
||||
if (this.priorityRulesLocFile != null
|
||||
&& priorityRulesLocFile.exists()) {
|
||||
try {
|
||||
priorityRules = (PriorityRulesXML) unmarshaller.unmarshal(lfile
|
||||
.getFile());
|
||||
priorityRules = (PriorityRulesXML) unmarshaller
|
||||
.unmarshal(priorityRulesLocFile.getFile());
|
||||
} catch (JAXBException e) {
|
||||
statusHandler
|
||||
.handle(Priority.ERROR, e.getLocalizedMessage(), e);
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
e.getLocalizedMessage(), e);
|
||||
priorityRules = new PriorityRulesXML();
|
||||
}
|
||||
}
|
||||
return priorityRules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rules files
|
||||
*
|
||||
* @param name
|
||||
* Rules file name to get
|
||||
* @return The localization file
|
||||
*/
|
||||
private LocalizationFile getRules(String name) {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
return pm.getStaticLocalizationFile(name);
|
||||
return priorityRules;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -442,7 +470,7 @@ public class SystemRuleManager {
|
|||
* @return
|
||||
*/
|
||||
public int getLatency(Subscription sub, Set<Integer> cycleTimes) {
|
||||
LatencyRulesXML rulesXml = this.getLatencyRules();
|
||||
LatencyRulesXML rulesXml = this.getLatencyRules(false);
|
||||
int latency = 999;
|
||||
boolean found = false;
|
||||
for (LatencyRuleXML rule : rulesXml.getRules()) {
|
||||
|
@ -471,7 +499,7 @@ public class SystemRuleManager {
|
|||
* @return
|
||||
*/
|
||||
public int getPriority(Subscription sub, Set<Integer> cycleTimes) {
|
||||
PriorityRulesXML rulesXml = this.getPriorityRules();
|
||||
PriorityRulesXML rulesXml = this.getPriorityRules(false);
|
||||
int priority = 3;
|
||||
boolean found = false;
|
||||
for (PriorityRuleXML rule : rulesXml.getRules()) {
|
||||
|
@ -546,4 +574,87 @@ public class SystemRuleManager {
|
|||
return getInstance().bandwidthService
|
||||
.setBandwidthForNetworkInKilobytes(network, bandwidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the latency rules file.
|
||||
*/
|
||||
private void loadLatencyRules() {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
this.latencyRulesLocFile = pm
|
||||
.getStaticLocalizationFile(this.LATENCY_RULE_FILE);
|
||||
addLatencyRulesFileObserver();
|
||||
getLatencyRules(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the priority rules file.
|
||||
*/
|
||||
private void loadPriorityRules() {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
this.priorityRulesLocFile = pm
|
||||
.getStaticLocalizationFile(this.PRIORITY_RULE_FILE);
|
||||
addPriorityRulesFileObserver();
|
||||
getPriorityRules(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a file observer to the latency rules file to get notified when the
|
||||
* file changes.
|
||||
*/
|
||||
private void addLatencyRulesFileObserver() {
|
||||
latencyRulesLocFile
|
||||
.addFileUpdatedObserver(new ILocalizationFileObserver() {
|
||||
@Override
|
||||
public void fileUpdated(FileUpdatedMessage message) {
|
||||
loadLatencyRules();
|
||||
fireUpdates();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a file observer to the priority rules file to get notified when the
|
||||
* file changes.
|
||||
*/
|
||||
private void addPriorityRulesFileObserver() {
|
||||
priorityRulesLocFile
|
||||
.addFileUpdatedObserver(new ILocalizationFileObserver() {
|
||||
@Override
|
||||
public void fileUpdated(FileUpdatedMessage message) {
|
||||
loadPriorityRules();
|
||||
fireUpdates();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the listeners the files changed.
|
||||
*/
|
||||
private void fireUpdates() {
|
||||
for (IRulesUpdateListener listener : listeners) {
|
||||
listener.update();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register as a listener for rules file changes.
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
public void registerAsListener(IRulesUpdateListener listener) {
|
||||
if (!listeners.contains(listener)) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister as a listener for rules files changed.
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
public void deregisterAsListener(IRulesUpdateListener listener) {
|
||||
if (listeners.contains(listener)) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,8 @@ import com.raytheon.viz.ui.widgets.duallist.ButtonImages.ButtonImage;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 3, 2012 728 mpduff Initial creation
|
||||
* Oct 03, 2012 728 mpduff Initial creation.
|
||||
* Jan 18, 2013 1386 mpduff Change menu text.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -315,7 +316,7 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
|
|||
fileMenuItem.setMenu(fileMenu);
|
||||
|
||||
saveMI = new MenuItem(fileMenu, SWT.NONE);
|
||||
saveMI.setText("&Save\tCtrl+S");
|
||||
saveMI.setText("&Save Graph Image\tCtrl+S");
|
||||
saveMI.setAccelerator(SWT.CTRL + 'S');
|
||||
saveMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
|
|
23
deltaScripts/13.2.1/aggregateRecordGroupingLength.sh
Normal file
23
deltaScripts/13.2.1/aggregateRecordGroupingLength.sh
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
SQL_SCRIPT="increaseAggregateRecordGroupingLength.sql"
|
||||
|
||||
# ensure that the sql script is present
|
||||
if [ ! -f ${SQL_SCRIPT} ]; then
|
||||
echo "ERROR: the required sql script - ${SQL_SCRIPT} was not found."
|
||||
echo "FATAL: the update has failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "INFO: update started - increasing the size of the aggregate.grouping column"
|
||||
|
||||
# run the update
|
||||
/awips2/psql/bin/psql -U awips -d metadata -f ${SQL_SCRIPT}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "FATAL: the update has failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "INFO: the update has completed successfully!"
|
||||
|
||||
exit 0
|
23
deltaScripts/13.2.1/convertAggregateRecordGroupToXml.sh
Normal file
23
deltaScripts/13.2.1/convertAggregateRecordGroupToXml.sh
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
SQL_SCRIPT="convertAggregateRecordGroupToXml.sql"
|
||||
|
||||
# ensure that the sql script is present
|
||||
if [ ! -f ${SQL_SCRIPT} ]; then
|
||||
echo "ERROR: the required sql script - ${SQL_SCRIPT} was not found."
|
||||
echo "FATAL: the update has failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "INFO: update started - converting the aggregate.grouping column to xml"
|
||||
|
||||
# run the update
|
||||
/awips2/psql/bin/psql -U awips -d metadata -f ${SQL_SCRIPT}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "FATAL: the update has failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "INFO: the update has completed successfully!"
|
||||
|
||||
exit 0
|
38
deltaScripts/13.2.1/convertAggregateRecordGroupToXml.sql
Normal file
38
deltaScripts/13.2.1/convertAggregateRecordGroupToXml.sql
Normal file
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* 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.
|
||||
**/
|
||||
\set ON_ERROR_STOP 1
|
||||
\connect metadata;
|
||||
|
||||
-- Start a transaction
|
||||
BEGIN;
|
||||
|
||||
-- Temporarily replace dashes in pluginName rows with @@@
|
||||
update events.aggregate set grouping = regexp_replace(grouping, 'pluginName:(.*?)-(.*)', E'pluginName:\\1@@@\\2', 'g');
|
||||
|
||||
-- Convert to XML format
|
||||
update events.aggregate set grouping = regexp_replace(grouping, ':', '" value="', 'g');
|
||||
update events.aggregate set grouping = regexp_replace(grouping, '-', '"/><group name="', 'g');
|
||||
update events.aggregate set grouping = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><stat><group name="' || grouping || '"/></stat>';
|
||||
|
||||
-- Restore dashes from @@@
|
||||
update events.aggregate set grouping = regexp_replace(grouping, '<group name="(.*?)" value="(.*?)@@@(.*?)"', E'<group name="\\1" value="\\2-\\3"', 'g');
|
||||
|
||||
-- Commit the transaction
|
||||
END;
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* 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.
|
||||
**/
|
||||
\set ON_ERROR_STOP 1
|
||||
\connect metadata;
|
||||
ALTER TABLE events.aggregate ALTER COLUMN grouping TYPE varchar(1024);
|
|
@ -0,0 +1,80 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
#
|
||||
# Provides Java implementations of common smart utility functions
|
||||
# to boost performance.
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 01/14/13 njensen Initial Creation.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
import jep
|
||||
from com.raytheon.uf.common.dataplugin.gfe.util import SmartUtils as JavaSmartUtils
|
||||
import numpy
|
||||
|
||||
|
||||
def __getMaskIndiciesForJava(mask):
|
||||
flatMask = mask.flat #flatten the array
|
||||
flatIndicies = numpy.nonzero(flatMask) # get the indicies of the set cells
|
||||
ysize = mask.shape[1]
|
||||
indexes = []
|
||||
# convert the flat incicies to the x, y indicies
|
||||
for i in flatIndicies:
|
||||
indexes.append((i / ysize, i % ysize))
|
||||
|
||||
# Make two new jarrays to hold the final coordinate tuples
|
||||
size = len(indexes[0][0])
|
||||
xcoords = jep.jarray(size, jep.JINT_ID)
|
||||
ycoords = jep.jarray(size, jep.JINT_ID)
|
||||
|
||||
#===================================================================
|
||||
# Convert the coordinates from a tuple of numpy arrays to a list of
|
||||
# coordinate tuples
|
||||
|
||||
for index in xrange(size):
|
||||
try:
|
||||
x = indexes[0][0][index]
|
||||
y = indexes[0][1][index]
|
||||
xcoords[index] = int(x)
|
||||
ycoords[index] = int(y)
|
||||
except Exception, e:
|
||||
print e
|
||||
|
||||
return xcoords, ycoords
|
||||
|
||||
|
||||
def fillEditArea(grid, fillMask, borderMask):
|
||||
editPointsX, editPointsY = __getMaskIndiciesForJava(fillMask)
|
||||
borderPointsX, borderPointsY = __getMaskIndiciesForJava(borderMask)
|
||||
|
||||
gridObj = JavaSmartUtils.fillEditArea(grid, grid.shape[1], grid.shape[0], \
|
||||
editPointsY, editPointsX, borderPointsY, borderPointsX)
|
||||
|
||||
retObj = gridObj.__numpy__[0]
|
||||
return retObj
|
||||
|
||||
|
|
@ -593,19 +593,19 @@ class GribDecoder():
|
|||
|
||||
# Special case handling for specific PDS Templates
|
||||
if pdsTemplateNumber == 1 or pdsTemplateNumber == 11:
|
||||
typeEnsemble = Integer(pdsTemplate[15])
|
||||
perturbationNumber = Integer(pdsTemplate[16])
|
||||
typeEnsemble = Integer(pdsTemplate[15]).intValue()
|
||||
perturbationNumber = Integer(pdsTemplate[16]).intValue()
|
||||
pdsFields['numForecasts'] = Integer(pdsTemplate[17])
|
||||
if(typeEnsemble == 0):
|
||||
pdsFields['ensembleId'] = "ctlh" + perturbationNumber;
|
||||
pdsFields['ensembleId'] = "ctlh" + str(perturbationNumber);
|
||||
elif(typeEnsemble == 1):
|
||||
pdsFields['ensembleId'] = "ctll" + perturbationNumber;
|
||||
pdsFields['ensembleId'] = "ctll" + str(perturbationNumber);
|
||||
elif(typeEnsemble == 2):
|
||||
pdsFields['ensembleId'] = "n" + perturbationNumber;
|
||||
pdsFields['ensembleId'] = "n" + str(perturbationNumber);
|
||||
elif(typeEnsemble == 3):
|
||||
pdsFields['ensembleId'] = "p" + perturbationNumber;
|
||||
pdsFields['ensembleId'] = "p" + str(perturbationNumber);
|
||||
else:
|
||||
pdsFields['ensembleId'] = typeEnsemble + "." + perturbationNumber;
|
||||
pdsFields['ensembleId'] = str(typeEnsemble) + "." + str(perturbationNumber);
|
||||
|
||||
if pdsTemplateNumber == 11:
|
||||
endTime = GregorianCalendar(pdsTemplate[18], pdsTemplate[19] - 1, pdsTemplate[20], pdsTemplate[21], pdsTemplate[22], pdsTemplate[23])
|
||||
|
|
|
@ -22,6 +22,7 @@ package com.raytheon.edex.plugin.radar;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -95,6 +96,30 @@ public class RadarDecoder extends AbstractDecoder {
|
|||
private static final IUFStatusHandler theHandler = UFStatus
|
||||
.getHandler(RadarDecoder.class);
|
||||
|
||||
// radar server sends messages from edex to cave, handle that here
|
||||
private final String EDEX = "EDEX";
|
||||
|
||||
/*
|
||||
* Constants having to do with certain products
|
||||
*/
|
||||
|
||||
private final List<String> LEVEL_TWO_IDENTS = new ArrayList<String>(
|
||||
Arrays.asList("ARCH", "AR2V"));
|
||||
|
||||
private final String NOUS = "NOUS";
|
||||
|
||||
private final int USER_ALERT_MESSAGE = 73;
|
||||
|
||||
private final int FREE_TEXT_MESSAGE = 75;
|
||||
|
||||
private final int USER_SELECT_ACCUM = 173;
|
||||
|
||||
private final int CLUTTER_FILTER_CONTROL = 34;
|
||||
|
||||
/*
|
||||
* End constants
|
||||
*/
|
||||
|
||||
private String traceId = "";
|
||||
|
||||
private RadarInfoDict infoDict;
|
||||
|
@ -103,9 +128,6 @@ public class RadarDecoder extends AbstractDecoder {
|
|||
|
||||
private final String RADAR = "RADAR";
|
||||
|
||||
// radar server sends messages from edex to cave, handle that here
|
||||
private final String EDEX = "EDEX";
|
||||
|
||||
public RadarDecoder() throws DecoderException {
|
||||
|
||||
String dir = "";
|
||||
|
@ -146,11 +168,11 @@ public class RadarDecoder extends AbstractDecoder {
|
|||
String arch = new String(messageData, 0, 4);
|
||||
try {
|
||||
// for level2 data, this does not happen very often
|
||||
if ("ARCH".equals(arch) || "AR2V".equals(arch)) {
|
||||
if (LEVEL_TWO_IDENTS.contains(arch)) {
|
||||
decodeLevelTwoData(messageData, recordList);
|
||||
}
|
||||
// for free text messages, which come in with the following wmo
|
||||
else if ("NOUS".equals(arch)) {
|
||||
else if (NOUS.equals(arch)) {
|
||||
decodeFreeTextMessage(messageData, headers);
|
||||
} else {
|
||||
if (headers.get("header") != null) {
|
||||
|
@ -208,24 +230,19 @@ public class RadarDecoder extends AbstractDecoder {
|
|||
|
||||
// -- some product specific decode functionality --
|
||||
// the general status message product
|
||||
if (l3Radar.getMessageCode() == 2) {
|
||||
if (l3Radar.getMessageCode() == l3Radar.GSM_MESSAGE) {
|
||||
record.setGsmMessage(l3Radar.getGsmBlock().getMessage());
|
||||
record.setPrimaryElevationAngle(0.0);
|
||||
record.setTrueElevationAngle(0.0f);
|
||||
handleRadarStatus(record);
|
||||
}
|
||||
// the product request response product
|
||||
else if (l3Radar.getMessageCode() == 3) {
|
||||
else if (l3Radar.getMessageCode() == l3Radar.PRODUCT_REQUEST_RESPONSE_MESSAGE) {
|
||||
// do nothing with this, it will get excessive otherwise!
|
||||
// EDEXUtil.sendMessageAlertViz(Priority.VERBOSE,
|
||||
// RadarConstants.PLUGIN_ID, EDEX, RADAR,
|
||||
// record.getIcao()
|
||||
// + ": Response Request Message Received",
|
||||
// l3Radar.getRequestResponseMessage(), null);
|
||||
return new PluginDataObject[0];
|
||||
}
|
||||
// the user alert message product
|
||||
else if (l3Radar.getMessageCode() == 73) {
|
||||
else if (l3Radar.getMessageCode() == USER_ALERT_MESSAGE) {
|
||||
EDEXUtil.sendMessageAlertViz(Priority.VERBOSE,
|
||||
RadarConstants.PLUGIN_ID, EDEX, RADAR,
|
||||
record.getIcao() + ": User Alert Message Received",
|
||||
|
@ -233,21 +250,19 @@ public class RadarDecoder extends AbstractDecoder {
|
|||
return new PluginDataObject[0];
|
||||
}
|
||||
// handle the other case for free text message
|
||||
else if (l3Radar.getMessageCode() == 75) {
|
||||
else if (l3Radar.getMessageCode() == FREE_TEXT_MESSAGE) {
|
||||
// product already stored to the text database, so just send
|
||||
// to alertviz
|
||||
EDEXUtil.sendMessageAlertViz(
|
||||
Priority.SIGNIFICANT,
|
||||
RadarConstants.PLUGIN_ID,
|
||||
EDEX,
|
||||
RADAR,
|
||||
String formattedMsg = l3Radar.getTabularBlock().toString()
|
||||
.replace("Page 1\n\t", "");
|
||||
EDEXUtil.sendMessageAlertViz(Priority.SIGNIFICANT,
|
||||
RadarConstants.PLUGIN_ID, EDEX, RADAR,
|
||||
record.getIcao() + ": Free Text Message Received",
|
||||
l3Radar.getTabularBlock().toString()
|
||||
.replace("Page 1\n\t", ""), null);
|
||||
formattedMsg, null);
|
||||
return new PluginDataObject[0];
|
||||
}
|
||||
// the alert adaptations parameters product
|
||||
else if (l3Radar.getMessageCode() == 6) {
|
||||
else if (l3Radar.getMessageCode() == l3Radar.ALERT_ADAPTATION_PARAMETERS) {
|
||||
record.setAapMessage(l3Radar.getAapMessage());
|
||||
record.setPrimaryElevationAngle(0.0);
|
||||
record.setTrueElevationAngle(0.0f);
|
||||
|
@ -261,7 +276,7 @@ public class RadarDecoder extends AbstractDecoder {
|
|||
l3Radar.getAapMessage().toString(), null);
|
||||
}
|
||||
// the alert message product
|
||||
else if (l3Radar.getMessageCode() == 9) {
|
||||
else if (l3Radar.getMessageCode() == l3Radar.ALERT_MESSAGE) {
|
||||
record.setPrimaryElevationAngle(0.0);
|
||||
record.setTrueElevationAngle(0.0f);
|
||||
AlertMessage msg = l3Radar.getAlertMessage();
|
||||
|
@ -291,6 +306,8 @@ public class RadarDecoder extends AbstractDecoder {
|
|||
record.setOperationalMode(l3Radar.getOperationalMode());
|
||||
|
||||
record.setElevationNumber(l3Radar.getElevationNumber());
|
||||
// some products don't have real elevation angles, 0 is a
|
||||
// default value
|
||||
if (record.getElevationNumber() == 0) {
|
||||
record.setTrueElevationAngle(0f);
|
||||
} else {
|
||||
|
@ -320,13 +337,13 @@ public class RadarDecoder extends AbstractDecoder {
|
|||
}
|
||||
|
||||
// code specific for clutter filter control
|
||||
if (record.getProductCode() == 34) {
|
||||
if (record.getProductCode() == CLUTTER_FILTER_CONTROL) {
|
||||
int segment = ((int) (Math.log(l3Radar
|
||||
.getProductDependentValue(0)) / Math.log(2)));
|
||||
record.setLayer((double) segment);
|
||||
}
|
||||
// code specific for user select accum
|
||||
else if (record.getProductCode() == 173) {
|
||||
else if (record.getProductCode() == USER_SELECT_ACCUM) {
|
||||
int layer = 0; // Default to zero
|
||||
|
||||
int timeSpan = l3Radar.getProductDependentValue(1);
|
||||
|
@ -491,7 +508,8 @@ public class RadarDecoder extends AbstractDecoder {
|
|||
|
||||
String[] splits = temp.split(" ");
|
||||
AFOSProductId afos = new AFOSProductId(
|
||||
RadarTextProductUtil.createAfosId(75, splits[1].substring(1)));
|
||||
RadarTextProductUtil.createAfosId(FREE_TEXT_MESSAGE,
|
||||
splits[1].substring(1)));
|
||||
|
||||
// store the product to the text database
|
||||
Calendar cal = (TimeTools.allowArchive() ? header.getHeaderDate()
|
||||
|
@ -510,7 +528,9 @@ public class RadarDecoder extends AbstractDecoder {
|
|||
record.setPluginName("radar");
|
||||
record.constructDataURI();
|
||||
record.setInsertTime(TimeTools.getSystemCalendar());
|
||||
if (record.getProductCode() == 2) {
|
||||
// for GSM, we want all the messages as they have the possibility of
|
||||
// being different
|
||||
if (record.getProductCode() == Level3BaseRadar.GSM_MESSAGE) {
|
||||
record.setOverwriteAllowed(true);
|
||||
} else {
|
||||
record.setOverwriteAllowed(false);
|
||||
|
@ -669,7 +689,8 @@ public class RadarDecoder extends AbstractDecoder {
|
|||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
theHandler.handle(Priority.ERROR,
|
||||
"Unable to query for the radar station", e);
|
||||
}
|
||||
|
||||
return station;
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -178,6 +179,21 @@ public class Level3BaseRadar {
|
|||
|
||||
private RadarInfoDict dict = null;
|
||||
|
||||
private final List<Integer> SPECIAL_PRODS = new ArrayList<Integer>(
|
||||
Arrays.asList(73, 62, 75, 77, 82));
|
||||
|
||||
public static final int GSM_MESSAGE = 2;
|
||||
|
||||
public final int PRODUCT_REQUEST_RESPONSE_MESSAGE = 3;
|
||||
|
||||
public final int ALERT_ADAPTATION_PARAMETERS = 6;
|
||||
|
||||
public final int PRODUCT_LIST = 8;
|
||||
|
||||
public final int RADAR_CODED_MESSAGE = 74;
|
||||
|
||||
public final int ALERT_MESSAGE = 9;
|
||||
|
||||
/**
|
||||
* This baseradar constructor accepts a radar file contained within a
|
||||
* java.io.File object.
|
||||
|
@ -251,16 +267,16 @@ public class Level3BaseRadar {
|
|||
this.parseRadarHeader();
|
||||
|
||||
// Handle the message contents
|
||||
if (this.theMessageCode == 6) {
|
||||
if (this.theMessageCode == ALERT_ADAPTATION_PARAMETERS) {
|
||||
// Alert Adaptation Params
|
||||
this.parseAAP();
|
||||
} else if (this.theMessageCode == 3) {
|
||||
} else if (this.theMessageCode == PRODUCT_REQUEST_RESPONSE_MESSAGE) {
|
||||
this.parseRequestResponse();
|
||||
} else if (this.theMessageCode == 8) {
|
||||
} else if (this.theMessageCode == PRODUCT_LIST) {
|
||||
this.parseProductList(headers);
|
||||
} else if (this.theMessageCode == 2) {
|
||||
} else if (this.theMessageCode == GSM_MESSAGE) {
|
||||
this.parseGeneralStatusMessage();
|
||||
} else if (this.theMessageCode == 9) {
|
||||
} else if (this.theMessageCode == ALERT_MESSAGE) {
|
||||
this.parseAlertMessage(headers);
|
||||
} else {
|
||||
this.parseRadarMessage(headers);
|
||||
|
@ -593,8 +609,13 @@ public class Level3BaseRadar {
|
|||
byte[] buf = new byte[lineLen];
|
||||
theRadarData.readFully(buf);
|
||||
String temp = new String(buf);
|
||||
// PSM is found in all products that have useful Site Adaptation
|
||||
// Parameters. For this reason, we are dropping every other set of
|
||||
// Site Adaptation Parameters.
|
||||
if (temp.contains("PSM")) {
|
||||
temp = temp.substring(temp.indexOf("PSM"));
|
||||
} else {
|
||||
temp = "";
|
||||
}
|
||||
return temp;
|
||||
} else {
|
||||
|
@ -795,15 +816,13 @@ public class Level3BaseRadar {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.theProductCode == 73 || this.theProductCode == 62
|
||||
|| this.theProductCode == 75 || this.theProductCode == 77
|
||||
|| this.theProductCode == 82) {
|
||||
if (SPECIAL_PRODS.contains(this.theProductCode)) {
|
||||
// The first offset will be to the tabular block
|
||||
tabularBlock = readStandaloneTabular(symbologyBlockOffset);
|
||||
// The second offset will be to a symbology block with no header
|
||||
symbologyBlock = readPseudoSymbologyBlock(graphicBlockOffset);
|
||||
// tabularBlock.getPages().toString();
|
||||
} else if (this.theProductCode == 74) {
|
||||
} else if (this.theProductCode == RADAR_CODED_MESSAGE) {
|
||||
tabularBlock = readRadarCodedMessage(symbologyBlockOffset);
|
||||
} else {
|
||||
symbologyBlock = readSymbologyBlock(symbologyBlockOffset);
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<latencyRules>
|
||||
<latencyRule>
|
||||
<rule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="latencyRuleXML">
|
||||
<ruleField>Dataset Frequency</ruleField>
|
||||
<ruleName>Hourly-Products</ruleName>
|
||||
<ruleOperator><=</ruleOperator>
|
||||
<ruleUnit>Hrs</ruleUnit>
|
||||
<ruleValue>1</ruleValue>
|
||||
<latency>40</latency>
|
||||
</latencyRule>
|
||||
<latencyRule>
|
||||
</rule>
|
||||
<rule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="latencyRuleXML">
|
||||
<ruleField>Dataset Frequency</ruleField>
|
||||
<ruleName>MultiHour-Products</ruleName>
|
||||
<ruleOperator>></ruleOperator>
|
||||
<ruleUnit>Hrs</ruleUnit>
|
||||
<ruleValue>1</ruleValue>
|
||||
<latency>115</latency>
|
||||
</latencyRule>
|
||||
</rule>
|
||||
</latencyRules>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<priorityRules>
|
||||
|
||||
</priorityRules>
|
|
@ -17,4 +17,5 @@ Require-Bundle: javax.persistence;bundle-version="1.0.0",
|
|||
com.raytheon.uf.common.event;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.time;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.stats;bundle-version="1.0.0"
|
||||
com.raytheon.uf.common.stats;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.uf.common.datadelivery.event.notification;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
@ -35,6 +36,7 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 20, 2012 1157 mpduff Initial creation
|
||||
* Jan 17, 2013 1501 djohnson Allow a response to specify the subscription handler.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -85,4 +87,11 @@ public abstract class BaseSubscriptionNotificationResponse<T extends Subscriptio
|
|||
this.subscription = subscription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subscription handler that corresponds to the subscription type
|
||||
* for this notification.
|
||||
*
|
||||
* @return the subscription handler
|
||||
*/
|
||||
public abstract IBaseSubscriptionHandler<T> getSubscriptionHandler();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
package com.raytheon.uf.common.datadelivery.event.notification;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
|
||||
/**
|
||||
|
@ -32,6 +34,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 20, 2012 mpduff Initial creation
|
||||
* Jan 17, 2013 1501 djohnson Allow a response to specify the subscription handler.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -42,4 +45,12 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
public class PendingSubscriptionNotificationResponse extends
|
||||
BaseSubscriptionNotificationResponse<InitialPendingSubscription> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public IBaseSubscriptionHandler<InitialPendingSubscription> getSubscriptionHandler() {
|
||||
return DataDeliveryHandlers.getPendingSubscriptionHandler();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
package com.raytheon.uf.common.datadelivery.event.notification;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
|
||||
/**
|
||||
|
@ -33,6 +35,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 25, 2012 mpduff Initial creation.
|
||||
* Aug 21, 2012 712 mpduff Add a Subscription Object.
|
||||
* Jan 17, 2013 1501 djohnson Allow a response to specify the subscription handler.
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
|
@ -41,4 +44,12 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
@DynamicSerialize
|
||||
public class SubscriptionNotificationResponse extends
|
||||
BaseSubscriptionNotificationResponse<Subscription>{
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public IBaseSubscriptionHandler<Subscription> getSubscriptionHandler() {
|
||||
return DataDeliveryHandlers.getSubscriptionHandler();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
* 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.dataplugin.gfe.util;
|
||||
|
||||
import jep.INumpyable;
|
||||
|
||||
import com.raytheon.uf.common.python.PythonNumpyFloatArray;
|
||||
|
||||
/**
|
||||
* Java port of python utility functions. Ported to Java to boost performance to
|
||||
* surpass python's poor looping performance.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 11, 2013 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SmartUtils {
|
||||
|
||||
/**
|
||||
* Define a method to fill the specified edit area. Ported from python.
|
||||
*
|
||||
* @param grid
|
||||
* @param gridNx
|
||||
* @param gridNy
|
||||
* @param editPointsX
|
||||
* @param editPointsY
|
||||
* @param borderPointsX
|
||||
* @param borderPointsY
|
||||
* @return
|
||||
*/
|
||||
public static INumpyable fillEditArea(float[] grid, int gridNx, int gridNy,
|
||||
int[] editPointsX, int[] editPointsY, int[] borderPointsX,
|
||||
int[] borderPointsY) {
|
||||
// edit points and border points are a list of (x,y) indices
|
||||
int[] e = new int[2];
|
||||
int[] b = new int[2];
|
||||
|
||||
for (int i = 0; i < editPointsX.length; i++) {
|
||||
e[0] = editPointsX[i];
|
||||
e[1] = editPointsY[i];
|
||||
double numSum = 0.0;
|
||||
double denomSum = 0.0;
|
||||
|
||||
for (int k = 0; k < borderPointsX.length; k++) {
|
||||
b[0] = borderPointsX[k];
|
||||
b[1] = borderPointsY[k];
|
||||
|
||||
// points in the same row, column or diagonal
|
||||
int xdiff = e[0] - b[0];
|
||||
int ydiff = e[1] - b[1];
|
||||
int absXdiff = (xdiff < 0) ? -xdiff : xdiff;
|
||||
int absYdiff = (ydiff < 0) ? -ydiff : ydiff;
|
||||
if (e[0] == b[0] || e[1] == b[1] || absXdiff == absYdiff) {
|
||||
|
||||
double xdist = xdiff;
|
||||
double ydist = ydiff;
|
||||
|
||||
// calculate the distance to the border point
|
||||
double dist = Math.sqrt(xdist * xdist + ydist * ydist);
|
||||
|
||||
// value = grid[b[0], b[1]]
|
||||
float value = grid[b[0] + (gridNx * b[1])];
|
||||
|
||||
// Accumulate the distance-weighted average
|
||||
numSum = numSum + value / dist;
|
||||
denomSum = denomSum + 1 / dist;
|
||||
}
|
||||
}
|
||||
|
||||
int eIndex = e[0] + (gridNx * e[1]);
|
||||
if (denomSum > 0.0f) {
|
||||
// grid[e[0], e[1]] = numSum / denomSum;
|
||||
grid[eIndex] = (float) (numSum / denomSum);
|
||||
} else {
|
||||
// grid[e[0], e[1]] = 0.0;
|
||||
grid[eIndex] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
// Return completed grid
|
||||
return new PythonNumpyFloatArray(grid, gridNx, gridNy);
|
||||
}
|
||||
}
|
|
@ -29,6 +29,8 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import com.raytheon.uf.common.localization.FileLocker.Type;
|
||||
import com.raytheon.uf.common.localization.ILocalizationAdapter.ListResponse;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
|
@ -80,6 +82,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* This was added as part of an effort to improve
|
||||
* localization performance but caused updated
|
||||
* files on the server not to be retrieved.
|
||||
* Jan 17, 2013 1412 djohnson Add jaxbMarshal.
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
|
@ -635,6 +638,25 @@ public final class LocalizationFile implements Comparable<LocalizationFile> {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marshal the specified object into this file.
|
||||
*
|
||||
* @param obj
|
||||
* the object to marshal
|
||||
*
|
||||
* @param jaxbManager
|
||||
* the jaxbManager
|
||||
*/
|
||||
public void jaxbMarshal(Object obj, JAXBManager jaxbManager) throws LocalizationException{
|
||||
try {
|
||||
String xml = jaxbManager.marshalToXml(obj);
|
||||
write(xml.getBytes());
|
||||
} catch (JAXBException e) {
|
||||
throw new LocalizationException(
|
||||
"Unable to marshal the object to the file.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return context + IPathManager.SEPARATOR + path;
|
||||
|
|
|
@ -10,7 +10,8 @@ Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.2",
|
|||
com.raytheon.uf.common.auth;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.status;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.localization;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174"
|
||||
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
|
||||
org.apache.commons.lang;bundle-version="2.3.0"
|
||||
Export-Package: com.raytheon.uf.common.plugin.nwsauth,
|
||||
com.raytheon.uf.common.plugin.nwsauth.exception,
|
||||
com.raytheon.uf.common.plugin.nwsauth.user,
|
||||
|
|
|
@ -302,4 +302,21 @@ public class NwsRoleData implements ISerializableObject {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Application:").append(this.getApplication()).append("\n\n");
|
||||
sb.append("Users:\n").append(this.getUserList()).append("\n\n");
|
||||
sb.append("Permissions:\n").append(this.getPermissionList())
|
||||
.append("\n\n");
|
||||
sb.append("Roles:\n").append(this.getRoleList()).append("\n\n");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,4 +94,16 @@ public class PermissionXML implements ISerializableObject {
|
|||
public void setDescription(String description) {
|
||||
this.description = (description == null) ? null : description.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("id:").append(this.getId());
|
||||
sb.append("\ndescription:").append(this.getDescription());
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,4 +117,19 @@ public class RoleXML implements ISerializableObject {
|
|||
public void addPermission(String permission) {
|
||||
this.permissionList.add(permission);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("roleId:").append(this.getRoleId());
|
||||
sb.append("\nroleDescription:").append(this.getRoleDescription());
|
||||
sb.append("\npermissionList:").append(this.getPermissionList());
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ import javax.xml.bind.annotation.XmlAttribute;
|
|||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
import com.raytheon.uf.common.auth.user.IAuthenticationData;
|
||||
import com.raytheon.uf.common.auth.user.IUser;
|
||||
import com.raytheon.uf.common.auth.user.IUserId;
|
||||
|
@ -66,6 +69,17 @@ public class UserXML implements IUser, ISerializableObject {
|
|||
@XmlElements({ @XmlElement(name = "userRole", type = String.class) })
|
||||
private List<String> roleList = new ArrayList<String>();
|
||||
|
||||
public UserXML() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userId
|
||||
*/
|
||||
public UserXML(String userId) {
|
||||
setUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the userId
|
||||
*/
|
||||
|
@ -129,6 +143,30 @@ public class UserXML implements IUser, ISerializableObject {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof UserXML) {
|
||||
UserXML that = (UserXML) obj;
|
||||
|
||||
EqualsBuilder builder = new EqualsBuilder();
|
||||
builder.append(this.getUserId(), that.getUserId());
|
||||
return builder.isEquals();
|
||||
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append(this.getUserId()).toHashCode();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -136,17 +174,10 @@ public class UserXML implements IUser, ISerializableObject {
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
final String nl = "\n";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(this.getUserId()).append(nl);
|
||||
|
||||
for (String role : this.roleList) {
|
||||
sb.append(" ").append(role).append(nl);
|
||||
}
|
||||
|
||||
for (String perm : permissionList) {
|
||||
sb.append(" ").append(perm).append(nl);
|
||||
}
|
||||
sb.append("userId:").append(this.getUserId());
|
||||
sb.append("\nroles:").append(this.getRoleList());
|
||||
sb.append("\npermissions:").append(this.getPermissionList());
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 21, 2012 jsanchez Initial creation
|
||||
* Nov 12, 2012 dhladky Updates some things for stats
|
||||
* Jan 15, 2013 1487 djohnson Increase length of grouping to 1024.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -56,7 +57,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
public class AggregateRecord extends PersistableDataObject {
|
||||
public class AggregateRecord extends PersistableDataObject<Integer> {
|
||||
private static final long serialVersionUID = -4553588456131256014L;
|
||||
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
|
@ -77,6 +78,7 @@ public class AggregateRecord extends PersistableDataObject {
|
|||
private String eventType;
|
||||
|
||||
@DynamicSerializeElement
|
||||
@Column(length = 1024)
|
||||
private String grouping;
|
||||
|
||||
@Column(nullable = false)
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Contains a grouping for statistics.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 15, 2013 1487 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class StatsGrouping {
|
||||
|
||||
@XmlAttribute(required = true)
|
||||
private String name;
|
||||
|
||||
@XmlAttribute(required = true)
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public StatsGrouping() {
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param name
|
||||
* @param value
|
||||
*/
|
||||
public StatsGrouping(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value
|
||||
* the value to set
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -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.common.stats;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Contains a list of groupings for statistics.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 15, 2013 1487 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlRootElement(name = "stat")
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class StatsGroupingColumn {
|
||||
|
||||
@XmlElement
|
||||
private List<StatsGrouping> group = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* @return the group
|
||||
*/
|
||||
public List<StatsGrouping> getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param group
|
||||
* the group to set
|
||||
*/
|
||||
public void setGroup(List<StatsGrouping> group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link StatsGroupingColumn} to hold the specified
|
||||
* {@link StatsGrouping} instances.
|
||||
*
|
||||
* @param statsGroupings
|
||||
* the groupings
|
||||
* @return the column
|
||||
*/
|
||||
public static StatsGroupingColumn withGroupings(
|
||||
StatsGrouping... statsGroupings) {
|
||||
StatsGroupingColumn column = new StatsGroupingColumn();
|
||||
|
||||
for (StatsGrouping grouping : statsGroupings) {
|
||||
column.group.add(grouping);
|
||||
}
|
||||
|
||||
return column;
|
||||
}
|
||||
}
|
|
@ -18,4 +18,5 @@ Require-Bundle: com.google.guava;bundle-version="1.0.0",
|
|||
org.springframework;bundle-version="2.5.6",
|
||||
com.raytheon.uf.common.event;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.datadelivery.registry;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.registry.event;bundle-version="1.0.0"
|
||||
com.raytheon.uf.common.registry.event;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0"
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.raytheon.uf.common.datadelivery.event.notification.BaseSubscriptionNo
|
|||
import com.raytheon.uf.common.datadelivery.event.notification.BaseSubscriptionNotificationResponse;
|
||||
import com.raytheon.uf.common.datadelivery.event.notification.NotificationRecord;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.IBaseSubscriptionHandler;
|
||||
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -44,13 +45,15 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
* Aug 31, 2012 1128 mpduff Set priority and category from request.
|
||||
* Sep 06, 2012 687 mpduff Send a SubscriptionNotificationResponse object.
|
||||
* Sep 24, 2012 1157 mpduff Changed to use BaseSubscriptionNotificationRequest.
|
||||
* Jan 17, 2013 1501 djohnson If a subscription is still in the registry, use it for the notification response.
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SubscriptionNotificationHandler<T extends Subscription> extends AbstractHandler implements
|
||||
public class SubscriptionNotificationHandler<T extends Subscription> extends
|
||||
AbstractHandler implements
|
||||
IRequestHandler<BaseSubscriptionNotificationRequest<T>> {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
|
@ -87,9 +90,21 @@ public class SubscriptionNotificationHandler<T extends Subscription> extends Abs
|
|||
|
||||
storeAndSend(record, uri);
|
||||
|
||||
BaseSubscriptionNotificationResponse<T> response = request.getResponse();
|
||||
BaseSubscriptionNotificationResponse<T> response = request
|
||||
.getResponse();
|
||||
response.setMessage(request.getMessage());
|
||||
response.setSubscription(request.getSubscription());
|
||||
|
||||
final IBaseSubscriptionHandler<T> subscriptionHandler = response
|
||||
.getSubscriptionHandler();
|
||||
final T requestSubscription = request.getSubscription();
|
||||
final T registryVersion = subscriptionHandler
|
||||
.getByName(requestSubscription.getName());
|
||||
|
||||
// If the subscription is still in the registry, use that version which
|
||||
// will reflect any updates that have occurred since the notification
|
||||
// was sent, otherwise pass along the one provided with the request
|
||||
response.setSubscription((registryVersion != null) ? registryVersion
|
||||
: requestSubscription);
|
||||
|
||||
send(response, uri);
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 26, 2011 snaples Initial creation
|
||||
* Jan 10, 2013 1448 bgonzale Added app context check in processArealQpe().
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -209,6 +210,9 @@ public class ArealQpeGenSrv {
|
|||
private SimpleDateFormat fdf = new SimpleDateFormat("yyyyMMddHH");
|
||||
|
||||
public Object processArealQpe() {
|
||||
if (!AppsDefaults.getInstance().setAppContext(this)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check to see if we need to run
|
||||
String gen = appsDefaults.getToken("mpe_generate_areal_qpe");
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.raytheon.uf.common.datastorage.DataStoreFactory;
|
|||
import com.raytheon.uf.common.datastorage.IDataStore;
|
||||
import com.raytheon.uf.common.datastorage.StorageException;
|
||||
import com.raytheon.uf.common.hydro.spatial.HRAP;
|
||||
import com.raytheon.uf.common.ohd.AppsDefaults;
|
||||
import com.raytheon.uf.edex.core.EdexException;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
|
@ -52,6 +53,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 06, 2011 5951 jnjanga Initial creation
|
||||
* Jan 10, 2013 1448 bgonzale Added app context check in runOnSchedule().
|
||||
* Jan 18, 2013 1469 bkowal Removed the hdf5 data directory.
|
||||
*
|
||||
* </pre>
|
||||
|
@ -212,6 +214,9 @@ public class MpeLightningSrv {
|
|||
* @throws EdexException
|
||||
*/
|
||||
public void runOnSchedule() throws EdexException {
|
||||
if (!AppsDefaults.getInstance().setAppContext(this)) {
|
||||
return;
|
||||
}
|
||||
QueryResultRow[] rows = getMostRecentStrikes();
|
||||
ifhsInsertMostRecentStrikes(rows);
|
||||
}
|
||||
|
|
|
@ -55,8 +55,6 @@ import com.raytheon.uf.edex.core.props.PropertiesFactory;
|
|||
import com.raytheon.uf.edex.dat.utils.FreezingLevel;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
public class MpeRUCFreezingLevel {
|
||||
|
||||
/**
|
||||
* MPE RUC calculator
|
||||
*
|
||||
|
@ -66,12 +64,14 @@ public class MpeRUCFreezingLevel {
|
|||
* ------------ -------- --------- --------------------------
|
||||
* Nov 19, 2011 dhladky Initial Creation.
|
||||
* Oct 09, 2012 15168 wkwock Fix incorrect values.
|
||||
* Jan 10, 2013 1448 bgonzale Made methods that are used internally private.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
public class MpeRUCFreezingLevel {
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(MpeRUCFreezingLevel.class);
|
||||
|
@ -441,7 +441,7 @@ public class MpeRUCFreezingLevel {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public String getAbsoluteTempFileName(int forecastHour, String modelName) {
|
||||
private String getAbsoluteTempFileName(int forecastHour, String modelName) {
|
||||
return modelOutputFilePath + File.separatorChar + modelName
|
||||
+ forecastHour + "zFreezingLevel" + ".bin";
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ public class MpeRUCFreezingLevel {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public String getAbsoluteOutFileName(Date date, String site) {
|
||||
private String getAbsoluteOutFileName(Date date, String site) {
|
||||
return modelOutputFilePath + File.separatorChar + "freezing_1_" + site
|
||||
+ "_point_" + getFormattedDate(date);
|
||||
}
|
||||
|
@ -461,7 +461,7 @@ public class MpeRUCFreezingLevel {
|
|||
*
|
||||
* @param FreezingLevelXML
|
||||
*/
|
||||
public void writeFreezingLevelTemp(FreezingLevelXML freezingLevel,
|
||||
private void writeFreezingLevelTemp(FreezingLevelXML freezingLevel,
|
||||
String modelName) {
|
||||
|
||||
try {
|
||||
|
|
|
@ -11,7 +11,8 @@ Require-Bundle: com.raytheon.uf.edex.auth;bundle-version="1.12.2",
|
|||
com.raytheon.uf.common.status;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.localization,
|
||||
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.useradmin;bundle-version="1.0.0"
|
||||
com.raytheon.uf.common.useradmin;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.time;bundle-version="1.12.1174"
|
||||
Import-Package: com.raytheon.uf.common.localization,
|
||||
com.raytheon.uf.common.serialization,
|
||||
com.raytheon.uf.common.status,
|
||||
|
|
|
@ -19,9 +19,11 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.plugin.nwsauth;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
|
@ -40,6 +42,7 @@ import com.raytheon.uf.common.serialization.JAXBManager;
|
|||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
|
||||
/**
|
||||
* Uses localization data to determine role/permissions. Intentionally
|
||||
|
@ -52,6 +55,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 09, 2013 1412 djohnson Moved file writing from viz plugin to server-side.
|
||||
* Jan 17, 2013 1412 djohnson Check files for having been modified each time data is requested,
|
||||
* in case they were written by another member of the cluster.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -69,14 +74,22 @@ class FileManager {
|
|||
|
||||
private final String ROLE_DIR = "roles";
|
||||
|
||||
private final Map<String, NwsRoleData> roleDataMap = new HashMap<String, NwsRoleData>();
|
||||
private final AtomicLong lastReadTime = new AtomicLong(-1L);
|
||||
|
||||
/**
|
||||
* Application name -> Role Data.
|
||||
*/
|
||||
private final ConcurrentMap<String, NwsRoleData> roleDataMap = new ConcurrentHashMap<String, NwsRoleData>();
|
||||
|
||||
/**
|
||||
* Application name -> LocalizationFile map.
|
||||
*/
|
||||
private final Map<String, LocalizationFile> roleFileMap = new HashMap<String, LocalizationFile>();
|
||||
private final ConcurrentMap<String, LocalizationFile> roleFileMap = new ConcurrentHashMap<String, LocalizationFile>();
|
||||
|
||||
private FileManager() {
|
||||
/**
|
||||
* Package-level visibility so tests can create new instances.
|
||||
*/
|
||||
FileManager() {
|
||||
readXML();
|
||||
}
|
||||
|
||||
|
@ -117,8 +130,43 @@ class FileManager {
|
|||
|
||||
private void readXML() {
|
||||
try {
|
||||
getJaxbManager();
|
||||
LocalizationFile[] roleFiles = getUserRoleLocalizationFiles();
|
||||
boolean needToReadFiles = false;
|
||||
for (LocalizationFile lf : roleFiles) {
|
||||
final long fileLastModified = lf.getFile().lastModified();
|
||||
final long lastTimeFilesWereRead = lastReadTime.get();
|
||||
|
||||
if (fileLastModified > lastTimeFilesWereRead) {
|
||||
needToReadFiles = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (needToReadFiles) {
|
||||
for (LocalizationFile lf : roleFiles) {
|
||||
final long fileLastModified = lf.getFile().lastModified();
|
||||
final long lastTimeFilesWereRead = lastReadTime.get();
|
||||
|
||||
if (fileLastModified < lastTimeFilesWereRead) {
|
||||
continue;
|
||||
}
|
||||
NwsRoleData roleData = lf.jaxbUnmarshal(NwsRoleData.class,
|
||||
getJaxbManager());
|
||||
|
||||
if (roleData != null) {
|
||||
final String application = roleData.getApplication();
|
||||
this.roleDataMap.put(application, roleData);
|
||||
this.roleFileMap.put(application, lf);
|
||||
}
|
||||
}
|
||||
}
|
||||
lastReadTime.set(TimeUtil.currentTimeMillis());
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private LocalizationFile[] getUserRoleLocalizationFiles() {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext[] contexts = new LocalizationContext[2];
|
||||
contexts[0] = pm.getContext(LocalizationType.COMMON_STATIC,
|
||||
|
@ -127,19 +175,7 @@ class FileManager {
|
|||
LocalizationLevel.SITE);
|
||||
LocalizationFile[] roleFiles = pm.listFiles(contexts, ROLE_DIR,
|
||||
new String[] { ".xml" }, false, true);
|
||||
|
||||
for (LocalizationFile lf : roleFiles) {
|
||||
NwsRoleData roleData = lf.jaxbUnmarshal(NwsRoleData.class,
|
||||
getJaxbManager());
|
||||
|
||||
if (roleData != null) {
|
||||
this.roleDataMap.put(roleData.getApplication(), roleData);
|
||||
this.roleFileMap.put(roleData.getApplication(), lf);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
}
|
||||
return roleFiles;
|
||||
}
|
||||
|
||||
private JAXBManager getJaxbManager() throws JAXBException {
|
||||
|
@ -154,13 +190,15 @@ class FileManager {
|
|||
* @return
|
||||
*/
|
||||
public Map<String, NwsRoleData> getRoleDataMap() {
|
||||
readXML();
|
||||
return roleDataMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param roleDataWithChanges
|
||||
*/
|
||||
public void writeApplicationRoleData(Map<String, NwsRoleData> roleDataWithChanges) {
|
||||
public void writeApplicationRoleData(
|
||||
Map<String, NwsRoleData> roleDataWithChanges) {
|
||||
for (Entry<String, NwsRoleData> entry : roleDataWithChanges.entrySet()) {
|
||||
final String application = entry.getKey();
|
||||
roleDataMap.put(application, entry.getValue());
|
||||
|
|
|
@ -89,6 +89,8 @@
|
|||
<permission id="com.raytheon.localization.site/common_static/roles">
|
||||
</permission>
|
||||
|
||||
<permission id="com.raytheon.localization.site/common_static/datadelivery"/>
|
||||
|
||||
<user userId="ALL">
|
||||
<userPermission>com.raytheon.localization.site/common_static/purge</userPermission>
|
||||
<userPermission>com.raytheon.localization.site/cave_static/colormaps</userPermission>
|
||||
|
@ -119,6 +121,7 @@
|
|||
<userPermission>com.raytheon.localization.site/common_static/radar/rmr/rmrAvailableRequests.xml</userPermission>
|
||||
<userPermission>com.raytheon.localization.site/common_static/shef</userPermission>
|
||||
<userPermission>com.raytheon.localization.site/common_static/roles</userPermission>
|
||||
<userPermission>com.raytheon.localization.site/common_static/datadelivery</userPermission>
|
||||
</user>
|
||||
</nwsRoleData>
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.stats;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
@ -28,11 +30,17 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.raytheon.uf.common.event.Event;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
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;
|
||||
import com.raytheon.uf.common.stats.StatsRecord;
|
||||
import com.raytheon.uf.common.stats.xml.StatisticsAggregate;
|
||||
import com.raytheon.uf.common.stats.xml.StatisticsEvent;
|
||||
|
@ -61,6 +69,7 @@ import com.raytheon.uf.edex.stats.util.ConfigLoader;
|
|||
* Nov 07, 2012 1317 mpduff Updated Configuration Files.
|
||||
* Nov 28, 2012 1350 rjpeter Simplied aggregation and added aggregation with current db aggregate records.
|
||||
* Jan 07, 2013 1451 djohnson Use newGmtCalendar().
|
||||
* Jan 15, 2013 1487 djohnson Use xml for the grouping information on an {@link AggregateRecord}.
|
||||
* </pre>
|
||||
*
|
||||
* @author jsanchez
|
||||
|
@ -70,6 +79,17 @@ public class AggregateManager {
|
|||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(AggregateManager.class);
|
||||
|
||||
private static final Object[] EMPTY_OBJ_ARR = new Object[0];
|
||||
|
||||
private static final JAXBManager JAXB_MANAGER;
|
||||
static {
|
||||
try {
|
||||
JAXB_MANAGER = new JAXBManager(StatsGroupingColumn.class);
|
||||
} catch (JAXBException e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/** In minutes */
|
||||
private int bucketInterval;
|
||||
|
||||
|
@ -255,8 +275,6 @@ public class AggregateManager {
|
|||
Map<TimeRange, Multimap<String, Event>> rval = new HashMap<TimeRange, Multimap<String, Event>>();
|
||||
TimeRange timeRange = null;
|
||||
Multimap<String, Event> eventsByGroup = null;
|
||||
final Object[] EMPTY_OBJ_ARR = new Object[0];
|
||||
StringBuilder group = new StringBuilder();
|
||||
|
||||
for (StatsRecord record : records) {
|
||||
if ((timeRange == null)
|
||||
|
@ -275,30 +293,11 @@ public class AggregateManager {
|
|||
Event event = SerializationUtil.transformFromThrift(
|
||||
Event.class, record.getEvent());
|
||||
|
||||
// determine group
|
||||
boolean addDelim = false;
|
||||
Iterator<Method> gMethodIter = statEvent.getGroupByMethods()
|
||||
.iterator();
|
||||
Iterator<StatisticsGroup> gFieldNameIter = statEvent
|
||||
.getGroupList().iterator();
|
||||
group.setLength(0);
|
||||
|
||||
while (gMethodIter.hasNext() && gFieldNameIter.hasNext()) {
|
||||
Method m = gMethodIter.next();
|
||||
String field = gFieldNameIter.next().getName();
|
||||
String gVal = String
|
||||
.valueOf(m.invoke(event, EMPTY_OBJ_ARR));
|
||||
|
||||
if (addDelim) {
|
||||
group.append('-');
|
||||
} else {
|
||||
addDelim = true;
|
||||
String groupAsString = determineGroupRepresentationForEvent(
|
||||
statEvent, event);
|
||||
if (groupAsString != null) {
|
||||
eventsByGroup.put(groupAsString, event);
|
||||
}
|
||||
|
||||
group.append(field).append(':').append(gVal);
|
||||
}
|
||||
|
||||
eventsByGroup.put(group.toString(), event);
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.error("Error processing event. Aggregation may be inaccurate. ",
|
||||
|
@ -309,6 +308,30 @@ public class AggregateManager {
|
|||
return rval;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static String determineGroupRepresentationForEvent(
|
||||
StatisticsEvent statEvent, Event event)
|
||||
throws IllegalAccessException, InvocationTargetException,
|
||||
JAXBException {
|
||||
Iterator<Method> gMethodIter = statEvent.getGroupByMethods().iterator();
|
||||
Iterator<StatisticsGroup> gFieldNameIter = statEvent.getGroupList()
|
||||
.iterator();
|
||||
List<StatsGrouping> groupings = new ArrayList<StatsGrouping>();
|
||||
|
||||
while (gMethodIter.hasNext() && gFieldNameIter.hasNext()) {
|
||||
Method m = gMethodIter.next();
|
||||
String field = gFieldNameIter.next().getName();
|
||||
String gVal = String.valueOf(m.invoke(event, EMPTY_OBJ_ARR));
|
||||
|
||||
groupings.add(new StatsGrouping(field, gVal));
|
||||
}
|
||||
|
||||
StatsGroupingColumn column = new StatsGroupingColumn();
|
||||
column.setGroup(groupings);
|
||||
|
||||
return JAXB_MANAGER.marshalToXml(column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the bucket interval is a valid value. If value is invalid then
|
||||
* value will be set to default value.
|
||||
|
|
|
@ -27,13 +27,18 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
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;
|
||||
import com.raytheon.uf.common.stats.data.GraphData;
|
||||
import com.raytheon.uf.common.stats.data.StatsBin;
|
||||
import com.raytheon.uf.common.stats.data.StatsData;
|
||||
|
@ -44,6 +49,7 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.util.CollectionUtil;
|
||||
|
||||
/**
|
||||
* Accumulates the statistics data.
|
||||
|
@ -55,6 +61,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 15, 2012 728 mpduff Initial creation
|
||||
* Jan 15, 2013 1487 djohnson Use xml for the grouping information on an {@link AggregateRecord}.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -63,15 +70,21 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
|||
*/
|
||||
|
||||
public class StatsDataAccumulator {
|
||||
private static final Pattern COLON_PATTERN = Pattern.compile(":");
|
||||
|
||||
private static final Pattern DASH_PATTERN = Pattern.compile("-");
|
||||
|
||||
private static final String COLON = ":";
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(StatsDataAccumulator.class);
|
||||
|
||||
private static final String COLON = ":";
|
||||
|
||||
private static final JAXBManager JAXB_MANAGER;
|
||||
static {
|
||||
try {
|
||||
JAXB_MANAGER = new JAXBManager(StatsGroupingColumn.class);
|
||||
} catch (JAXBException e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/** List of records */
|
||||
private AggregateRecord[] records;
|
||||
|
||||
|
@ -122,23 +135,22 @@ public class StatsDataAccumulator {
|
|||
@VisibleForTesting
|
||||
public void setupGroupings() {
|
||||
for (AggregateRecord aggRec : records) {
|
||||
String grouping = aggRec.getGrouping();
|
||||
String[] groupString = DASH_PATTERN.split(grouping);
|
||||
String group;
|
||||
String member;
|
||||
for (String grp : groupString) {
|
||||
String[] parts = COLON_PATTERN.split(grp);
|
||||
group = parts[0];
|
||||
member = parts[1];
|
||||
if (!groupMemberMap.containsKey(group)) {
|
||||
groupMemberMap.put(group, new TreeSet<String>());
|
||||
}
|
||||
StatsGroupingColumn columnValue = unmarshalGroupingColumnFromRecord(aggRec);
|
||||
|
||||
groupMemberMap.get(group).add(member);
|
||||
final List<StatsGrouping> groups = columnValue.getGroup();
|
||||
if (CollectionUtil.isNullOrEmpty(groups)) {
|
||||
continue;
|
||||
}
|
||||
for (StatsGrouping group : groups) {
|
||||
final String groupName = group.getName();
|
||||
if (!groupMemberMap.containsKey(groupName)) {
|
||||
groupMemberMap.put(groupName, Sets.<String> newTreeSet());
|
||||
}
|
||||
groupMemberMap.get(groupName).add(group.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
groups = new ArrayList<String>(groupMemberMap.keySet());
|
||||
groups = Lists.newArrayList(groupMemberMap.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -202,21 +214,25 @@ public class StatsDataAccumulator {
|
|||
if (record.getEventType().equals(eventType)
|
||||
&& record.getField().equals(dataType)) {
|
||||
|
||||
StatsGroupingColumn columnValue = unmarshalGroupingColumnFromRecord(record);
|
||||
|
||||
final List<StatsGrouping> columnValueGroups = columnValue
|
||||
.getGroup();
|
||||
if (CollectionUtil.isNullOrEmpty(columnValueGroups)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Have a matching record
|
||||
for (String key : keySequenceMap.keySet()) {
|
||||
keySequenceMap.put(key, "");
|
||||
}
|
||||
String[] groupings = DASH_PATTERN.split(record.getGrouping());
|
||||
|
||||
for (String grouping : groupings) {
|
||||
String[] parts = COLON_PATTERN.split(grouping);
|
||||
String group = parts[0];
|
||||
String groupMember = parts[1];
|
||||
for (StatsGrouping group : columnValueGroups) {
|
||||
|
||||
for (String key : keySequenceMap.keySet()) {
|
||||
if (group.equals(key)) {
|
||||
if (group.getName().equals(key)) {
|
||||
keySequenceMap.put(key, keySequenceMap.get(key)
|
||||
.concat(groupMember + COLON));
|
||||
.concat(group.getValue() + COLON));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -242,6 +258,29 @@ public class StatsDataAccumulator {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshals the {@link StatsGroupingColumn} from the
|
||||
* {@link AggregateRecord}.
|
||||
*
|
||||
* @param record
|
||||
* the aggregate record
|
||||
* @return the unmarshalled column, or an empty column if unable to
|
||||
* unmarshal
|
||||
*/
|
||||
private static StatsGroupingColumn unmarshalGroupingColumnFromRecord(
|
||||
AggregateRecord record) {
|
||||
String groupingXmlAsString = record.getGrouping();
|
||||
try {
|
||||
return (StatsGroupingColumn) JAXB_MANAGER
|
||||
.unmarshalFromXml(groupingXmlAsString);
|
||||
} catch (JAXBException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to unmarshal stats grouping column, returning empty record, xml:\n"
|
||||
+ groupingXmlAsString, e);
|
||||
return new StatsGroupingColumn();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gather the data together in each bin.
|
||||
*
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.raytheon.uf.common.event.Event;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
|
@ -57,6 +58,7 @@ import com.raytheon.uf.common.util.ReflectionUtil;
|
|||
* Aug 21, 2012 jsanchez Updated error handling and validated config files.
|
||||
* Nov 07, 2012 1317 mpduff Update config files.
|
||||
* Nov 29, 2012 1350 rjpeter Updated to static, fixed localization, increased validation.
|
||||
* Jan 15, 2013 1487 djohnson Make validate() static and public, so it can be run independently.
|
||||
* </pre>
|
||||
*
|
||||
* @author jsanchez
|
||||
|
@ -158,7 +160,8 @@ public class ConfigLoader {
|
|||
*
|
||||
* @param config
|
||||
*/
|
||||
private void validate(Map<String, StatisticsEvent> eventMap,
|
||||
@VisibleForTesting
|
||||
public static void validate(Map<String, StatisticsEvent> eventMap,
|
||||
StatisticsConfig config) {
|
||||
for (Iterator<StatisticsEvent> iter = config.getEvents().iterator(); iter
|
||||
.hasNext();) {
|
||||
|
|
|
@ -42,18 +42,10 @@ echo "------------------------------ " >> $LOGFILE
|
|||
Dte=`date -u `
|
||||
echo Starting alarm_whfs at $Dte >> $LOGFILE
|
||||
|
||||
Dte=`date -u`
|
||||
echo Invoking roc_checker at $Dte >> $LOGFILE
|
||||
|
||||
$WHFS_LOCAL_BIN_DIR/run_roc_checker
|
||||
|
||||
# TODO re-enabled report_alarm if needed
|
||||
$WHFS_LOCAL_BIN_DIR/run_report_alarm
|
||||
|
||||
#Dte=`date -u`
|
||||
#echo Invoking report_alarm at $Dte >> $LOGFILE
|
||||
|
||||
#$WHFS_LOCAL_BIN_DIR/run_report_alarm
|
||||
|
||||
#Dte=`date -u `
|
||||
#echo Completed alarm_whfs at $Dte >> $LOGFILE
|
||||
Dte=`date -u `
|
||||
echo Completed alarm_whfs at $Dte >> $LOGFILE
|
||||
|
||||
|
|
|
@ -67,5 +67,6 @@
|
|||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.stats"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.edex.stats"/>
|
||||
<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 kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
com.raytheon.uf.common.datadelivery.retrieval.util.NullXmlWriter
|
|
@ -1 +0,0 @@
|
|||
com.raytheon.uf.common.datadelivery.retrieval.util.NullXmlWriter
|
|
@ -40,6 +40,7 @@ import com.raytheon.uf.common.util.FileUtil;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 18, 2012 740 djohnson Initial creation
|
||||
* Oct 23, 2012 1286 djohnson Change to find more localization files.
|
||||
* Jan 16, 2013 1487 djohnson Avoid adding new localization files to baseline utility directories.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -131,21 +132,44 @@ public class TestPathManager extends PathManager {
|
|||
}
|
||||
|
||||
if (foundFile == null
|
||||
|| !foundFile.exists()
|
||||
|| foundFile.getAbsolutePath().startsWith(
|
||||
savedLocalizationFileDir.getAbsolutePath())) {
|
||||
return foundFile;
|
||||
}
|
||||
// Make a copy in the savedFile folder, this way if any
|
||||
// modifications are performed we don't mess with the file in
|
||||
// the baseline
|
||||
|
||||
File savedFile = createTestIsolatedVersionOfLocalizationFile(
|
||||
context, fileName, foundFile);
|
||||
return savedFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a test isolated version of the localization file. Allows the
|
||||
* file to be written to, and changes to be read back, without affecting
|
||||
* the baselined version of the file.
|
||||
*
|
||||
* @param context
|
||||
* the context
|
||||
* @param fileName
|
||||
* the file path
|
||||
* @param baselinedVersion
|
||||
* the file reference
|
||||
* @return
|
||||
*/
|
||||
private File createTestIsolatedVersionOfLocalizationFile(
|
||||
LocalizationContext context, String fileName, File baselinedVersion) {
|
||||
File savedFileBaseDir = new File(savedLocalizationFileDir,
|
||||
context.toPath());
|
||||
File savedFile = new File(savedFileBaseDir, fileName);
|
||||
savedFile.getParentFile().mkdirs();
|
||||
|
||||
try {
|
||||
FileUtil.copyFile(foundFile, savedFile);
|
||||
if (baselinedVersion.exists()) {
|
||||
if (baselinedVersion.isDirectory()) {
|
||||
FileUtil.copyDirectory(baselinedVersion, savedFile);
|
||||
} else {
|
||||
FileUtil.copyFile(baselinedVersion, savedFile);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
/**
|
||||
* 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.edex.plugin.nwsauth;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.plugin.nwsauth.xml.NwsRoleData;
|
||||
import com.raytheon.uf.common.plugin.nwsauth.xml.UserXML;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.time.util.TimeUtilTest;
|
||||
|
||||
/**
|
||||
* Test {@link FileManager}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 17, 2013 1412 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class FileManagerTest {
|
||||
private static JAXBManager jaxbManager;
|
||||
|
||||
private final UserXML someUser = new UserXML("someUser");
|
||||
|
||||
private FileManager manager;
|
||||
|
||||
@BeforeClass
|
||||
public static void classSetup() throws JAXBException {
|
||||
jaxbManager = new JAXBManager(NwsRoleData.class);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
TimeUtilTest.freezeTime();
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
manager = new FileManager();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
TimeUtilTest.resumeTime();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fileNewerOnDiskIsReadBeforeResponse()
|
||||
throws LocalizationException {
|
||||
|
||||
addUserToUserAdminFile();
|
||||
|
||||
verifyUserIsFoundWhenRoleDataRetrieved();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fileOlderOnDiskIsNotReadBeforeResponse()
|
||||
throws LocalizationException {
|
||||
|
||||
addUserToUserAdminFile();
|
||||
setUserAdminFileModifiedTimeToOneSecondAgo();
|
||||
|
||||
verifyUserIsNotFoundWhenRoleDataRetrieved();
|
||||
}
|
||||
|
||||
private void verifyUserIsFoundWhenRoleDataRetrieved() {
|
||||
final Map<String, NwsRoleData> roleDataMap = manager.getRoleDataMap();
|
||||
assertTrue(
|
||||
"Did not find the user added to the role data map!",
|
||||
roleDataMap.get("TestUserRoles").getUserList()
|
||||
.contains(someUser));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param someUser
|
||||
*/
|
||||
private void verifyUserIsNotFoundWhenRoleDataRetrieved() {
|
||||
final Map<String, NwsRoleData> roleDataMap = manager.getRoleDataMap();
|
||||
assertFalse(
|
||||
"Should not have found the user added to the role data map!",
|
||||
roleDataMap.get("TestUserRoles").getUserList()
|
||||
.contains(someUser));
|
||||
|
||||
}
|
||||
|
||||
private void addUserToUserAdminFile() throws LocalizationException {
|
||||
final LocalizationFile file = getTestUserAdminRolesLocalizationFile();
|
||||
NwsRoleData roleData = file.jaxbUnmarshal(NwsRoleData.class,
|
||||
jaxbManager);
|
||||
|
||||
roleData.getUserList().add(someUser);
|
||||
file.jaxbMarshal(roleData, jaxbManager);
|
||||
file.save();
|
||||
// The file was written out 1 second after we last read it
|
||||
file.getFile().setLastModified(
|
||||
TimeUtil.currentTimeMillis() + TimeUtil.MILLIS_PER_SECOND);
|
||||
}
|
||||
|
||||
private void setUserAdminFileModifiedTimeToOneSecondAgo() {
|
||||
// The file was written out 1 second before we last read it
|
||||
getTestUserAdminRolesLocalizationFile().getFile().setLastModified(
|
||||
TimeUtil.currentTimeMillis() - TimeUtil.MILLIS_PER_SECOND);
|
||||
}
|
||||
|
||||
private LocalizationFile getTestUserAdminRolesLocalizationFile() {
|
||||
IPathManager pathManager = PathManagerFactory.getPathManager();
|
||||
final LocalizationFile file = pathManager.getLocalizationFile(
|
||||
new LocalizationContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.SITE, "OAX"),
|
||||
"roles/testUserAdminRoles.xml");
|
||||
return file;
|
||||
}
|
||||
|
||||
}
|
116
tests/unit/com/raytheon/uf/edex/stats/AggregateManagerTest.java
Normal file
116
tests/unit/com/raytheon/uf/edex/stats/AggregateManagerTest.java
Normal file
|
@ -0,0 +1,116 @@
|
|||
/**
|
||||
* 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.edex.stats;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.stats.StatsGrouping;
|
||||
import com.raytheon.uf.common.stats.StatsGroupingColumn;
|
||||
import com.raytheon.uf.common.stats.xml.StatisticsConfig;
|
||||
import com.raytheon.uf.common.stats.xml.StatisticsEvent;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.raytheon.uf.edex.stats.util.ConfigLoader;
|
||||
|
||||
/**
|
||||
* Test {@link AggregateManager}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 15, 2013 1487 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class AggregateManagerTest {
|
||||
private static JAXBManager jaxbManager;
|
||||
|
||||
@BeforeClass
|
||||
public static void classSetUp() throws JAXBException {
|
||||
jaxbManager = new JAXBManager(StatisticsConfig.class,
|
||||
StatsGroupingColumn.class);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeterminingGroupForEvent() throws Exception {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
final LocalizationFile lf = pm.getLocalizationFile(
|
||||
new LocalizationContext(LocalizationType.EDEX_STATIC,
|
||||
LocalizationLevel.BASE), FileUtil.join("stats",
|
||||
"mockStats.xml"));
|
||||
|
||||
final StatisticsConfig statisticsConfig = lf.jaxbUnmarshal(
|
||||
StatisticsConfig.class, jaxbManager);
|
||||
|
||||
ConfigLoader.validate(Maps.<String, StatisticsEvent> newHashMap(),
|
||||
statisticsConfig);
|
||||
|
||||
MockEvent mockEvent = new MockEvent();
|
||||
mockEvent.setPluginName("somePlugin");
|
||||
mockEvent.setFileName("someFileName");
|
||||
mockEvent.setProcessingTime(1000L);
|
||||
mockEvent.setProcessingLatency(500L);
|
||||
|
||||
List<StatsGrouping> groupList = new ArrayList<StatsGrouping>();
|
||||
groupList.add(new StatsGrouping("pluginName", "somePlugin"));
|
||||
groupList.add(new StatsGrouping("fileName", "someFileName"));
|
||||
StatsGroupingColumn column = new StatsGroupingColumn();
|
||||
column.setGroup(groupList);
|
||||
|
||||
final String expectedGroupRepresentation = jaxbManager
|
||||
.marshalToXml(column);
|
||||
final String actualGroupRepresentation = AggregateManager.determineGroupRepresentationForEvent(
|
||||
statisticsConfig.getEvents().iterator().next(), mockEvent);
|
||||
assertThat(actualGroupRepresentation,
|
||||
is(equalTo(expectedGroupRepresentation)));
|
||||
}
|
||||
|
||||
}
|
169
tests/unit/com/raytheon/uf/edex/stats/MockEvent.java
Normal file
169
tests/unit/com/raytheon/uf/edex/stats/MockEvent.java
Normal file
|
@ -0,0 +1,169 @@
|
|||
/**
|
||||
* 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.edex.stats;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.stats.ProcessEvent;
|
||||
import com.raytheon.uf.common.stats.StatisticsEvent;
|
||||
|
||||
/**
|
||||
* Mock event based from {@link ProcessEvent}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 15, 2013 1487 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class MockEvent extends StatisticsEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Map<String, String> FIELD_UNIT_MAP;
|
||||
static {
|
||||
Map<String, String> m = new HashMap<String, String>();
|
||||
m.put("processingLatency", "ms");
|
||||
m.put("processingTime", "ms");
|
||||
FIELD_UNIT_MAP = Collections.unmodifiableMap(m);
|
||||
}
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String message;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String pluginName;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String fileName;
|
||||
|
||||
/*
|
||||
* Processing time in milliseconds
|
||||
*/
|
||||
@DynamicSerializeElement
|
||||
private long processingTime;
|
||||
|
||||
/*
|
||||
* Processing latency in milliseconds
|
||||
*/
|
||||
@DynamicSerializeElement
|
||||
private long processingLatency;
|
||||
|
||||
public MockEvent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, String> getFieldUnitMap() {
|
||||
return FIELD_UNIT_MAP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fileName
|
||||
*/
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pluginName
|
||||
*/
|
||||
public String getPluginName() {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the processingLatency in milliseconds
|
||||
*/
|
||||
public long getProcessingLatency() {
|
||||
return processingLatency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the processingTime in milliseconds
|
||||
*/
|
||||
public long getProcessingTime() {
|
||||
return processingTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileName
|
||||
* the fileName to set
|
||||
*/
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* the message to set
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pluginName
|
||||
* the pluginName to set
|
||||
*/
|
||||
public void setPluginName(String pluginName) {
|
||||
this.pluginName = pluginName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param processingLatency
|
||||
* the processingLatency in milliseconds to set
|
||||
*/
|
||||
public void setProcessingLatency(long processingLatency) {
|
||||
this.processingLatency = processingLatency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param processingTime
|
||||
* the processingTime in milliseconds to set
|
||||
*/
|
||||
public void setProcessingTime(long processingTime) {
|
||||
this.processingTime = processingTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " : " + getMessage();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +1,82 @@
|
|||
/**
|
||||
* 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.edex.stats.data;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.raytheon.uf.common.datadelivery.event.retrieval.DataRetrievalEvent;
|
||||
import com.raytheon.uf.common.datadelivery.event.retrieval.SubscriptionRetrievalEvent;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.stats.AggregateRecord;
|
||||
import com.raytheon.uf.common.stats.StatsGrouping;
|
||||
import com.raytheon.uf.common.stats.StatsGroupingColumn;
|
||||
import com.raytheon.uf.common.stats.data.StatsData;
|
||||
import com.raytheon.uf.common.stats.util.UnitUtils;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* Test {@link StatsDataAccumulator}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 15, 2013 1487 djohnson Use XML for grouping column.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class StatsDataAccumulatorTest {
|
||||
|
||||
private static final JAXBManager JAXB_MANAGER;
|
||||
static {
|
||||
try {
|
||||
JAXB_MANAGER = new JAXBManager(StatsGroupingColumn.class);
|
||||
} catch (JAXBException e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateBinsCalculatesCorrectly() {
|
||||
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
c.set(Calendar.MILLISECOND, 0);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
c.set(Calendar.MINUTE, 0);
|
||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||
c.set(Calendar.DAY_OF_MONTH, 1);
|
||||
c.set(Calendar.MONTH, 0);
|
||||
long start = c.getTimeInMillis();
|
||||
|
||||
c.add(Calendar.DAY_OF_MONTH, 1);
|
||||
long end = c.getTimeInMillis();
|
||||
|
||||
TimeRange tr = new TimeRange(start, end);
|
||||
TimeRange tr = new TimeRange(0L, TimeUtil.MILLIS_PER_DAY);
|
||||
StatsDataAccumulator acc = new StatsDataAccumulator();
|
||||
acc.setTimeRange(tr);
|
||||
acc.setTimeStep(5);
|
||||
|
@ -41,7 +85,8 @@ public class StatsDataAccumulatorTest {
|
|||
|
||||
int expectedBinCount = 288; // 5 minute bins 12 per hour, * 24
|
||||
int actualBinCount = acc.bins.keySet().size();
|
||||
assertEquals("Bin Counts do not match", expectedBinCount, actualBinCount);
|
||||
assertEquals("Bin Counts do not match", expectedBinCount,
|
||||
actualBinCount);
|
||||
|
||||
int count = 0;
|
||||
for (long bin : acc.bins.keySet()) {
|
||||
|
@ -51,7 +96,7 @@ public class StatsDataAccumulatorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSetupGroupings() {
|
||||
public void testSetupGroupings() throws JAXBException {
|
||||
List<AggregateRecord> recordList = getTestRecords();
|
||||
StatsDataAccumulator acc = new StatsDataAccumulator();
|
||||
acc.setRecords(recordList.toArray(new AggregateRecord[recordList.size()]));
|
||||
|
@ -62,33 +107,39 @@ public class StatsDataAccumulatorTest {
|
|||
expectedGroups.add("provider");
|
||||
expectedGroups.add("plugin");
|
||||
|
||||
List<String> expectedGroupMembers = new ArrayList<String>();
|
||||
expectedGroupMembers.add("nomads");
|
||||
expectedGroupMembers.add("madis");
|
||||
expectedGroupMembers.add("owner0");
|
||||
expectedGroupMembers.add("owner1");
|
||||
expectedGroupMembers.add("owner2");
|
||||
expectedGroupMembers.add("owner3");
|
||||
expectedGroupMembers.add("owner4");
|
||||
expectedGroupMembers.add("grid");
|
||||
List<String> expectedPlugins = Arrays.asList("grid");
|
||||
List<String> expectedProviders = Arrays.asList("nomads", "madis");
|
||||
List<String> expectedOwners = Arrays.asList("owner0", "owner1",
|
||||
"owner2", "owner3", "owner4");
|
||||
|
||||
Map<String, List<String>> expectedGroupsToValues = Maps.newHashMap();
|
||||
expectedGroupsToValues.put("provider", expectedProviders);
|
||||
expectedGroupsToValues.put("plugin", expectedPlugins);
|
||||
expectedGroupsToValues.put("owner", expectedOwners);
|
||||
|
||||
// Check the groups
|
||||
for (String group : acc.groups) {
|
||||
assertTrue(expectedGroups.contains(group));
|
||||
for (String expected : expectedGroups) {
|
||||
assertTrue("Did not find group [" + expected
|
||||
+ "] in the group collection!",
|
||||
acc.groups.contains(expected));
|
||||
}
|
||||
|
||||
// Check the group members
|
||||
for (String key: acc.groupMemberMap.keySet()) {
|
||||
for (String member: acc.groupMemberMap.get(key)) {
|
||||
assertTrue(expectedGroupMembers.contains(member));
|
||||
final Map<String, Set<String>> groupMemberMap = acc.groupMemberMap;
|
||||
for (Entry<String, List<String>> entry : expectedGroupsToValues
|
||||
.entrySet()) {
|
||||
final String groupName = entry.getKey();
|
||||
final Set<String> setToCheck = groupMemberMap.get(groupName);
|
||||
for (String member : entry.getValue()) {
|
||||
assertTrue("Did not find entry [" + member + "] for group ["
|
||||
+ groupName + "]!", setToCheck.contains(member));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateStatsDataMapCreation() {
|
||||
String eventType = "com.raytheon.uf.common.datadelivery.event.retrieval.DataRetrievalEvent";
|
||||
public void testCreateStatsDataMapCreation() throws JAXBException {
|
||||
String eventType = DataRetrievalEvent.class.getName();
|
||||
String dataType = "bytes";
|
||||
String displayUnit = "MB";
|
||||
|
||||
|
@ -116,54 +167,54 @@ public class StatsDataAccumulatorTest {
|
|||
expectedSet.add("owner3:madis");
|
||||
expectedSet.add("owner4:madis");
|
||||
|
||||
for (String key : acc.statsDataMap.keySet()) {
|
||||
assertTrue(expectedSet.contains(key));
|
||||
final Map<String, StatsData> statsDataMap = acc.statsDataMap;
|
||||
for (String expected : expectedSet) {
|
||||
assertTrue("Did not find expected value (" + expected
|
||||
+ "] as key in the statsDataMap!",
|
||||
statsDataMap.containsKey(expected));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Build the Aggregate records
|
||||
private List<AggregateRecord> getTestRecords() {
|
||||
private List<AggregateRecord> getTestRecords() throws JAXBException {
|
||||
String plugin = "plugin";
|
||||
String provider = "provider";
|
||||
String nomads = "nomads";
|
||||
String madis = "madis";
|
||||
String owner = "owner";
|
||||
String grid = "grid";
|
||||
String dash = "-";
|
||||
String colon = ":";
|
||||
|
||||
List<String> groupings = new ArrayList<String>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
groupings.add(plugin + colon + grid + dash + owner + colon + owner + i);
|
||||
List<StatsGroupingColumn> groupingColumns = new ArrayList<StatsGroupingColumn>();
|
||||
for (int i = 0; i < 15; i++) {
|
||||
groupingColumns.add(StatsGroupingColumn.withGroupings(
|
||||
new StatsGrouping(plugin, grid), new StatsGrouping(owner,
|
||||
owner + i)));
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
groupings.add(plugin + colon + grid + dash + owner + colon + owner + i);
|
||||
groupingColumns.add(StatsGroupingColumn.withGroupings(
|
||||
new StatsGrouping(provider, nomads), new StatsGrouping(
|
||||
owner, owner + i)));
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
groupings.add(plugin + colon + grid + dash + owner + colon + owner + i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
groupings.add(provider + colon + nomads + dash + owner + colon + owner + i);
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
groupings.add(provider + colon + madis + dash + owner + colon + owner + i);
|
||||
groupingColumns.add(StatsGroupingColumn.withGroupings(
|
||||
new StatsGrouping(provider, madis), new StatsGrouping(
|
||||
owner, owner + i)));
|
||||
}
|
||||
|
||||
List<AggregateRecord> records = new ArrayList<AggregateRecord>();
|
||||
|
||||
for (String group : groupings) {
|
||||
for (StatsGroupingColumn group : groupingColumns) {
|
||||
AggregateRecord r = new AggregateRecord();
|
||||
|
||||
if (group.contains("provider")) {
|
||||
r.setEventType("com.raytheon.uf.common.datadelivery.event.retrieval.DataRetrievalEvent");
|
||||
if ("provider".equals(group.getGroup().iterator().next().getName())) {
|
||||
r.setEventType(DataRetrievalEvent.class.getName());
|
||||
r.setField("bytes");
|
||||
} else {
|
||||
r.setEventType("com.raytheon.uf.common.datadelivery.event.retrieval.SubscriptionRetrievalEvent");
|
||||
r.setEventType(SubscriptionRetrievalEvent.class.getName());
|
||||
r.setField("numRecords");
|
||||
}
|
||||
r.setGrouping(group);
|
||||
r.setGrouping(JAXB_MANAGER.marshalToXml(group));
|
||||
records.add(r);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<nwsRoleData xmlns:ns2="group">
|
||||
<!-- AWIPS 2 User Admin Roles/Permissions file -->
|
||||
<application>TestUserRoles</application>
|
||||
<permission id="awips.user.admin">
|
||||
<description>
|
||||
This permission allows the user to access and edit AWIPS 2 User Administration
|
||||
</description>
|
||||
</permission>
|
||||
|
||||
<user userId="ALL">
|
||||
<userPermission>awips.user.admin</userPermission>
|
||||
</user>
|
||||
</nwsRoleData>
|
12
tests/utility/edex_static/base/stats/mockStats.xml
Normal file
12
tests/utility/edex_static/base/stats/mockStats.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<statisticsConfig>
|
||||
<!-- Event Type should be fully qualified name of stat event -->
|
||||
<statisticsEvent type="com.raytheon.uf.edex.stats.MockEvent"
|
||||
displayName="Mock Events" category="Mock Events">
|
||||
<statisticsGroup name="pluginName" displayName="Data Type" />
|
||||
<statisticsGroup name="fileName" displayName="File Name" />
|
||||
<statisticsAggregate field="processingTime"
|
||||
displayName="Processing Time" displayUnit="ms" />
|
||||
<statisticsAggregate field="processingLatency"
|
||||
displayName="Processing Latency" displayUnit="ms" />
|
||||
</statisticsEvent>
|
||||
</statisticsConfig>
|
Loading…
Add table
Reference in a new issue