diff --git a/cave/com.raytheon.uf.viz.dat.feature/feature.xml b/cave/com.raytheon.uf.viz.dat.feature/feature.xml index 7e473721cb..c1696c082b 100644 --- a/cave/com.raytheon.uf.viz.dat.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.dat.feature/feature.xml @@ -169,4 +169,10 @@ version="0.0.0" unpack="false"/> + + diff --git a/cave/com.raytheon.uf.viz.hpe/.classpath b/cave/com.raytheon.uf.viz.hpe/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/cave/com.raytheon.uf.viz.hpe/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/cave/com.raytheon.uf.viz.hpe/.project b/cave/com.raytheon.uf.viz.hpe/.project new file mode 100644 index 0000000000..52f6993c01 --- /dev/null +++ b/cave/com.raytheon.uf.viz.hpe/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.viz.hpe + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/cave/com.raytheon.uf.viz.hpe/.settings/org.eclipse.jdt.core.prefs b/cave/com.raytheon.uf.viz.hpe/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..8000cd6ca6 --- /dev/null +++ b/cave/com.raytheon.uf.viz.hpe/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/cave/com.raytheon.uf.viz.hpe/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.hpe/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..0957b34c04 --- /dev/null +++ b/cave/com.raytheon.uf.viz.hpe/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Hpe +Bundle-SymbolicName: com.raytheon.uf.viz.hpe; singleton:=true +Bundle-Version: 1.14.0.qualifier +Bundle-Vendor: RAYTHEON +Require-Bundle: org.eclipse.core.runtime, + com.raytheon.uf.common.dataplugin.shef;bundle-version="1.12.1174", + com.raytheon.uf.common.plugin.hpe;bundle-version="1.0.0", + com.raytheon.uf.common.status;bundle-version="1.12.1174", + com.raytheon.uf.common.time;bundle-version="1.12.1174", + com.raytheon.uf.common.util;bundle-version="1.14.0", + com.raytheon.uf.viz.core;bundle-version="1.14.2", + com.raytheon.viz.hydrocommon;bundle-version="1.12.1174", + com.raytheon.viz.ui;bundle-version="1.14.0", + com.raytheon.uf.viz.monitor.ffmp;bundle-version="1.12.1174", + com.raytheon.viz.grid;bundle-version="1.14.0", + com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174", + com.raytheon.uf.common.geospatial;bundle-version="1.14.0", + com.raytheon.uf.viz.core.rsc;bundle-version="1.0.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy diff --git a/cave/com.raytheon.uf.viz.hpe/build.properties b/cave/com.raytheon.uf.viz.hpe/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/cave/com.raytheon.uf.viz.hpe/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/cave/com.raytheon.uf.viz.hpe/plugin.xml b/cave/com.raytheon.uf.viz.hpe/plugin.xml new file mode 100644 index 0000000000..488e536235 --- /dev/null +++ b/cave/com.raytheon.uf.viz.hpe/plugin.xml @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/D2DHpeDisplayCustomizer.java b/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/D2DHpeDisplayCustomizer.java new file mode 100644 index 0000000000..e13442a35d --- /dev/null +++ b/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/D2DHpeDisplayCustomizer.java @@ -0,0 +1,265 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.hpe; + +import java.util.ArrayList; +import java.util.List; + +import com.raytheon.uf.common.dataplugin.grid.GridRecord; +import com.raytheon.uf.viz.core.drawables.IDescriptor; +import com.raytheon.uf.viz.core.drawables.IRenderableDisplay; +import com.raytheon.uf.viz.core.drawables.ResourcePair; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.rsc.AbstractVizResource; +import com.raytheon.uf.viz.core.rsc.AbstractVizResource.ResourceStatus; +import com.raytheon.uf.viz.core.rsc.IInitListener; +import com.raytheon.uf.viz.core.rsc.IResourceDataChanged; +import com.raytheon.uf.viz.core.rsc.ResourceList; +import com.raytheon.uf.viz.core.rsc.ResourceList.AddListener; +import com.raytheon.uf.viz.core.rsc.ResourceList.RemoveListener; +import com.raytheon.uf.viz.hpe.rsc.HpeLabelResourceData; +import com.raytheon.uf.viz.hpe.util.HpeUtils; +import com.raytheon.viz.grid.rsc.general.D2DGridResource; +import com.raytheon.viz.ui.perspectives.IRenderableDisplayCustomizer; + +/** + * This class listens to existing resources and adds the HPE "legend" text as + * needed. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 5, 2014     3026    mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class D2DHpeDisplayCustomizer implements IRenderableDisplayCustomizer { + + /** List of listeners we have for renderable displays */ + private final List listeners = new ArrayList(); + + @Override + public void customizeDisplay(IRenderableDisplay display) { + boolean add = true; + for (D2DHpeResourceListener listener : listeners) { + if (display == listener.getDisplay()) { + add = false; + break; + } + } + + if (add) { + listeners.add(new D2DHpeResourceListener(display)); + } + } + + @Override + public void uncustomizeDisplay(IRenderableDisplay display) { + D2DHpeResourceListener toRemove = null; + for (D2DHpeResourceListener listener : listeners) { + if (listener.getDisplay() == display) { + toRemove = listener; + break; + } + } + if (toRemove != null) { + toRemove.dispose(); + listeners.remove(toRemove); + } + } + + private static class D2DHpeResourceListener implements AddListener, + RemoveListener, IInitListener { + + private final IRenderableDisplay display; + + private boolean resourcesAdded = false; + + private ResourcePair hpeResourcePair; + + public D2DHpeResourceListener(IRenderableDisplay display) { + this.display = display; + IDescriptor descriptor = display.getDescriptor(); + ResourceList list = descriptor.getResourceList(); + if (hasCompatibleResource(list)) { + addResources(descriptor); + } + list.addPostAddListener(this); + list.addPostRemoveListener(this); + } + + public void dispose() { + ResourceList list = display.getDescriptor().getResourceList(); + list.removePostAddListener(this); + list.removePostRemoveListener(this); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.core.rsc.ResourceList.RemoveListener#notifyRemove + * (com.raytheon.uf.viz.core.drawables.ResourcePair) + */ + @Override + public synchronized void notifyRemove(ResourcePair rp) + throws VizException { + if (resourcesAdded) { + if (rp.getResource() != null) { + rp.getResource().unregisterListener(this); + } + if (isCompatibleResource(rp)) { + IDescriptor descriptor = display.getDescriptor(); + if (hasCompatibleResource(descriptor.getResourceList()) == false) { + removeResources(descriptor); + } + } + } + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.core.rsc.ResourceList.AddListener#notifyAdd(com + * .raytheon .uf.viz.core.drawables.ResourcePair) + */ + @Override + public synchronized void notifyAdd(ResourcePair rp) throws VizException { + if (!resourcesAdded) { + AbstractVizResource rsc = rp.getResource(); + if (rsc != null) { + rsc.registerListener(this); + if (rsc.getStatus() == ResourceStatus.INITIALIZED + && isCompatibleResource(rp)) { + addResources(display.getDescriptor()); + } + } + } + } + + private boolean hasCompatibleResource(ResourceList list) { + for (ResourcePair rp : list) { + if (isCompatibleResource(rp)) { + return true; + } + } + return false; + } + + private boolean isCompatibleResource(ResourcePair rp) { + AbstractVizResource resource = rp.getResource(); + if (resource != null) { + if (resource instanceof D2DGridResource) { + D2DGridResource rsc = (D2DGridResource) resource; + return HpeUtils.isHpe(rsc.getCurrentGridRecord()); + } + } + return false; + } + + private synchronized void addResources(IDescriptor descriptor) { + if (!resourcesAdded) { + ResourceList list = descriptor.getResourceList(); + hpeResourcePair = constructHpeLabelResource(); + list.add(hpeResourcePair); + + list.instantiateResources(descriptor, true); + resourcesAdded = true; + + // add hpe resource as a listener + for (ResourcePair rp : list) { + AbstractVizResource resource = rp.getResource(); + if (resource != null) { + if (resource instanceof D2DGridResource) { + D2DGridResource rsc = (D2DGridResource) resource; + rsc.getResourceData().addChangeListener( + (IResourceDataChanged) hpeResourcePair + .getResource()); + return; + } + } + } + } + } + + private synchronized void removeResources(IDescriptor descriptor) { + if (resourcesAdded) { + if (hpeResourcePair != null) { + ResourceList list = descriptor.getResourceList(); + list.remove(hpeResourcePair); + for (ResourcePair rp : list) { + AbstractVizResource resource = rp.getResource(); + if (resource != null) { + if (resource instanceof D2DGridResource) { + D2DGridResource rsc = (D2DGridResource) resource; + rsc.getResourceData().removeChangeListener( + (IResourceDataChanged) hpeResourcePair + .getResource()); + } + } + } + + hpeResourcePair = null; + } + resourcesAdded = false; + } + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.core.rsc.IInitListener#inited(com.raytheon.uf + * .viz.core.rsc.AbstractVizResource) + */ + @Override + public synchronized void inited(AbstractVizResource rsc) { + if (rsc instanceof D2DGridResource) { + GridRecord gridRec = ((D2DGridResource) rsc) + .getCurrentGridRecord(); + if (!resourcesAdded && HpeUtils.isHpe(gridRec)) { + addResources(rsc.getDescriptor()); + } + } + } + + /** + * Get the IRenderableDisplay + * + * @return the display + */ + public IRenderableDisplay getDisplay() { + return display; + } + } + + private static ResourcePair constructHpeLabelResource() { + return ResourcePair + .constructSystemResourcePair(new HpeLabelResourceData()); + } +} diff --git a/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/rsc/HpeLabelResource.java b/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/rsc/HpeLabelResource.java new file mode 100644 index 0000000000..1d89badae1 --- /dev/null +++ b/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/rsc/HpeLabelResource.java @@ -0,0 +1,225 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.hpe.rsc; + +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.swt.graphics.RGB; + +import com.raytheon.uf.common.dataplugin.grid.GridRecord; +import com.raytheon.uf.common.plugin.hpe.request.HpeLabelDataRequest; +import com.raytheon.uf.common.plugin.hpe.request.HpeLabelDataResponse; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.time.DataTime; +import com.raytheon.uf.viz.core.DrawableString; +import com.raytheon.uf.viz.core.IGraphicsTarget; +import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; +import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment; +import com.raytheon.uf.viz.core.drawables.IFont; +import com.raytheon.uf.viz.core.drawables.PaintProperties; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.map.MapDescriptor; +import com.raytheon.uf.viz.core.requests.ThriftClient; +import com.raytheon.uf.viz.core.rsc.AbstractVizResource; +import com.raytheon.uf.viz.core.rsc.IResourceDataChanged; +import com.raytheon.uf.viz.core.rsc.LoadProperties; +import com.raytheon.uf.viz.core.rsc.ResourceList; +import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; +import com.raytheon.uf.viz.core.rsc.capabilities.MagnificationCapability; +import com.raytheon.uf.viz.hpe.util.HpeUtils; +import com.raytheon.viz.grid.rsc.general.D2DGridResource; + +/** + * A resource to display HPE label text in the upper left corner of the display + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 5, 2014    3026     mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class HpeLabelResource extends + AbstractVizResource implements + IResourceDataChanged { + + private final IUFStatusHandler logger = UFStatus + .getHandler(HpeLabelResource.class); + + private final Map hpeTextCache = Collections + .synchronizedMap(new HashMap()); + + private DrawableString drawableString = null; + + private IFont font = null; + + private final HpeSourceDataJob dataJob = new HpeSourceDataJob(); + + protected HpeLabelResource(HpeLabelResourceData resourceData, + LoadProperties loadProperties) { + super(resourceData, loadProperties); + } + + @Override + public void resourceChanged(ChangeType type, Object object) { + if (type == ChangeType.DATA_REMOVE) { + if (object instanceof DataTime) { + hpeTextCache.remove(((DataTime) object).getRefTime()); + } + } + } + + @Override + protected void disposeInternal() { + if (font != null) { + font.dispose(); + } + } + + @Override + protected void paintInternal(IGraphicsTarget target, + PaintProperties paintProps) throws VizException { + ResourceList rscList = this.descriptor.getResourceList(); + if (rscList != null) { + StringBuilder sb = new StringBuilder(); + + // Find all D2DGridResources + List list = rscList + .getResourcesByTypeAsType(D2DGridResource.class); + if (!list.isEmpty()) { + double[] pixel = paintProps.getView().getDisplayCoords( + new double[] { 125, 50 }, target); + RGB color = getCapability(ColorableCapability.class).getColor(); + for (D2DGridResource rsc : list) { + GridRecord currentGridRec = rsc.getCurrentGridRecord(); + color = rsc.getCapability(ColorableCapability.class) + .getColor(); + if (HpeUtils.isHpe(currentGridRec)) { + // this is HPE so display the bias information + String text = getText(currentGridRec.getDataTime() + .getRefTime(), currentGridRec.getSecondaryId()); + if (text != null) { + sb.append(text); + } + } + } + + if (sb.length() > 0) { + drawableString.setText(sb.toString(), color); + drawableString.setCoordinates(pixel[0], pixel[1]); + target.drawStrings(drawableString); + } + } + } + } + + @Override + protected void initInternal(IGraphicsTarget target) throws VizException { + if (font == null) { + font = target.initializeFont("Dialog", 11, null); + } + font.setMagnification(getCapability(MagnificationCapability.class) + .getMagnification().floatValue()); + + drawableString = new DrawableString("", getCapability( + ColorableCapability.class).getColor()); + drawableString.font = font; + drawableString.horizontalAlignment = HorizontalAlignment.CENTER; + drawableString.verticallAlignment = VerticalAlignment.MIDDLE; + } + + private String getText(Date date, String productId) { + String text = hpeTextCache.get(date); + if (text == null) { + dataJob.scheduleRetrieval(date, productId); + } + + return text; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.core.rsc.AbstractVizResource#resourceDataChanged( + * com.raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType, + * java.lang.Object) + */ + @Override + protected void resourceDataChanged(ChangeType type, Object updateObject) { + super.resourceDataChanged(type, updateObject); + } + + private class HpeSourceDataJob extends Job { + private volatile String productId; + + private volatile Date date; + + public HpeSourceDataJob() { + super("Get HPE Source"); + } + + protected void scheduleRetrieval(Date date, String productId) { + this.productId = productId; + this.date = date; + if (this.getState() == Job.RUNNING + || this.getState() == Job.SLEEPING + || this.getState() == Job.WAITING) { + return; + } + this.schedule(); + } + + @Override + protected IStatus run(IProgressMonitor monitor) { + // Request the text from edex + try { + HpeLabelDataRequest req = new HpeLabelDataRequest(productId, + date); + HpeLabelDataResponse response = (HpeLabelDataResponse) ThriftClient + .sendRequest(req); + Map data = response.getData(); + for (Date d : data.keySet()) { + hpeTextCache.put(d, data.get(d)); + } + } catch (VizException e) { + statusHandler.error(e.getLocalizedMessage(), e); + } + + return Status.OK_STATUS; + } + } +} diff --git a/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/rsc/HpeLabelResourceData.java b/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/rsc/HpeLabelResourceData.java new file mode 100644 index 0000000000..d660dd27a7 --- /dev/null +++ b/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/rsc/HpeLabelResourceData.java @@ -0,0 +1,71 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.hpe.rsc; + +import com.raytheon.uf.viz.core.drawables.IDescriptor; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.rsc.AbstractResourceData; +import com.raytheon.uf.viz.core.rsc.AbstractVizResource; +import com.raytheon.uf.viz.core.rsc.LoadProperties; + +/** + * Resource data object for the HpeLabelResource. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 5, 2014      3026   mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class HpeLabelResourceData extends AbstractResourceData { + + @Override + public AbstractVizResource construct(LoadProperties loadProperties, + IDescriptor descriptor) throws VizException { + HpeLabelResource rsc = new HpeLabelResource(this, loadProperties); + addChangeListener(rsc); + return rsc; + } + + @Override + public void update(Object updateData) { + // No op + + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || (!(obj instanceof HpeLabelResourceData))) { + return false; + } + return false; + } +} diff --git a/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/util/HpeUtils.java b/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/util/HpeUtils.java new file mode 100644 index 0000000000..7d38180a93 --- /dev/null +++ b/cave/com.raytheon.uf.viz.hpe/src/com/raytheon/uf/viz/hpe/util/HpeUtils.java @@ -0,0 +1,69 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.hpe.util; + +import com.raytheon.uf.common.dataplugin.grid.GridRecord; +import com.raytheon.uf.common.dataplugin.grid.dataset.DatasetInfo; +import com.raytheon.uf.common.dataplugin.grid.dataset.DatasetInfoLookup; + +/** + * HPE Utilities + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 6, 2014     3026    mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class HpeUtils { + private static final String HPE = "HPE"; + + /** + * Determine if this title represents an HPE model. + * + * @param gridRecord + * The gridRecord to check + * @return true if model is HPE, false otherwise + * + */ + public static boolean isHpe(GridRecord gridRecord) { + String title = null; + if (gridRecord != null) { + DatasetInfo info = DatasetInfoLookup.getInstance().getInfo( + gridRecord.getDatasetId()); + if (info != null) { + title = info.getTitle(); + } + } + + if (title == null) { + return false; + } + return HPE.equals(title); + } +} diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.monitor.ffmp/META-INF/MANIFEST.MF index 05f56b95ed..dcbff667ab 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/META-INF/MANIFEST.MF @@ -27,7 +27,8 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.common.event;bundle-version="1.0.0", com.raytheon.uf.common.dataaccess;bundle-version="1.0.0", com.raytheon.uf.common.colormap;bundle-version="1.12.1174", - com.raytheon.uf.common.style;bundle-version="1.0.0" + com.raytheon.uf.common.style;bundle-version="1.0.0", + com.raytheon.uf.common.plugin.hpe;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Import-Package: com.raytheon.uf.common.pointdata diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java index c778f99e98..f826d1408f 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java @@ -22,6 +22,7 @@ package com.raytheon.uf.viz.monitor.ffmp.ui.rsc; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -77,6 +78,8 @@ import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager; import com.raytheon.uf.common.monitor.xml.DomainXML; import com.raytheon.uf.common.monitor.xml.ProductXML; import com.raytheon.uf.common.monitor.xml.SourceXML; +import com.raytheon.uf.common.plugin.hpe.request.HpeLabelDataRequest; +import com.raytheon.uf.common.plugin.hpe.request.HpeLabelDataResponse; import com.raytheon.uf.common.status.IPerformanceStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.PerformanceStatus; @@ -85,6 +88,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.util.ITimer; import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.common.util.StringUtil; import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IDisplayPaneContainer; @@ -105,6 +109,7 @@ import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormapShadedShapeExten import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormapShadedShapeExtension.IColormapShadedShape; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.MapDescriptor; +import com.raytheon.uf.viz.core.requests.ThriftClient; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.IInputHandler; import com.raytheon.uf.viz.core.rsc.IResourceDataChanged; @@ -176,6 +181,7 @@ import com.vividsolutions.jts.geom.Point; * Jan 21, 2014 DR 15874 gzhang Use getValue() for QPFSCAN independent. * Feb 19, 2014 2819 randerso Removed unnecessary .clone() call * Mar 3, 2014 2804 mschenke Set back up clipping pane + * May 05, 2014 3026 mpduff Display Hpe bias source. * * * @author dhladky @@ -187,7 +193,7 @@ public class FFMPResource extends IResourceDataChanged, IFFMPResourceListener, FFMPListener { /** Status handler */ - private static final IUFStatusHandler statusHandler = UFStatus + private final IUFStatusHandler statusHandler = UFStatus .getHandler(FFMPResource.class); /** Performance log statement prefix */ @@ -241,6 +247,9 @@ public class FFMPResource extends /** expansion of the window **/ private static final double EXPANSION_FACTOR = 1.0; + /** HPE Constant */ + private static final String HPE = "HPE"; + /** the stream cross hatched area **/ private IWireframeShape streamOutlineShape = null; @@ -412,6 +421,16 @@ public class FFMPResource extends /** Restore Table flag */ private boolean restoreTable = false; + /** HPE bias source legend cache */ + private final Map hpeLegendMap = Collections + .synchronizedMap(new HashMap()); + + /** Flag denoting data as HPE */ + private boolean isHpe; + + /** The job to get the HPE bias source info */ + private final HpeSourceDataJob dataJob = new HpeSourceDataJob(); + /** * FFMP resource * @@ -496,6 +515,12 @@ public class FFMPResource extends statusHandler.handle(Priority.PROBLEM, "Error updating record", ve); } + } else if (type.equals(ChangeType.DATA_REMOVE)) { + PluginDataObject[] pdos = (PluginDataObject[]) object; + for (PluginDataObject pdo : pdos) { + FFMPRecord ffmpRec = (FFMPRecord) pdo; + hpeLegendMap.remove(ffmpRec.getDataTime().getRefTime()); + } } } @@ -798,9 +823,10 @@ public class FFMPResource extends } else { switch (field) { case QPF: { - value = getBasin(key, field, recentTime, aggregate).getValue(recentTime);// DR 15874 - //.getAverageValue(recentTime, - //getQpfSourceExpiration()); + value = getBasin(key, field, recentTime, aggregate) + .getValue(recentTime);// DR 15874 + // .getAverageValue(recentTime, + // getQpfSourceExpiration()); break; } case GUIDANCE: { @@ -814,7 +840,7 @@ public class FFMPResource extends } } } catch (Exception e) { - e.printStackTrace(); + statusHandler.error("Problem getting basin value", e); } return value; } @@ -883,8 +909,8 @@ public class FFMPResource extends if (source.getSourceType().equals( FFMPSourceConfigurationManager.SOURCE_TYPE.GUIDANCE .getSourceType())) { - prefix.append(source.getDisplayName() + " " - + source.getDurationHour() + " HR"); + prefix.append(source.getDisplayName()).append(" ") + .append(source.getDurationHour()).append(" HR"); } else { prefix.append(source.getDisplayName()); } @@ -914,6 +940,8 @@ public class FFMPResource extends /** * Gets the record currently used * + * @param recentTime + * * @return FFMPCacheRecord */ public FFMPRecord getRateRecord(Date recentTime) { @@ -924,7 +952,8 @@ public class FFMPResource extends getDataKey(), getPrimarySource(), recentTime, false); isNewRate = false; } catch (Exception e) { - e.printStackTrace(); + statusHandler.error("Error retrieving the current rate record", + e); } } return rateRecord; @@ -944,9 +973,8 @@ public class FFMPResource extends isNewQpe = false; } } catch (Exception e) { - e.printStackTrace(); + statusHandler.error("Error retrieving the current QPE record", e); } - // System.out.println("FFMPResource.getQPERecord(): " + getTableTime()); return qpeRecord; } @@ -979,7 +1007,7 @@ public class FFMPResource extends } } catch (Exception e) { - e.printStackTrace(); + statusHandler.error("Error retrieving the current guid record", e); } return guidRecord; @@ -1008,7 +1036,7 @@ public class FFMPResource extends isNewQpf = false; } } catch (Exception e) { - e.printStackTrace(); + statusHandler.error("Error retrieving the current QPF record", e); } return qpfRecord; @@ -1029,7 +1057,8 @@ public class FFMPResource extends } } catch (Exception e) { - e.printStackTrace(); + statusHandler.error("Error retrieving the current virtual record", + e); } return virtualRecord; @@ -1039,6 +1068,8 @@ public class FFMPResource extends * General get record call * * @param pfield + * @param recentTime + * * @return FFMPCacheRecord */ public FFMPRecord getRecord(FIELDS pfield, Date recentTime) { @@ -1155,18 +1186,17 @@ public class FFMPResource extends @Override public void run() { - if (/* this. */font == null) { - /* this. */font = target.initializeFont("Dialog", 11, null); + if (font == null) { + font = target.initializeFont("Dialog", 11, null); } font.setMagnification(getCapability( MagnificationCapability.class).getMagnification() .floatValue()); - if (/* this. */xfont == null) { + if (xfont == null) { IFont.Style[] styles = new IFont.Style[] { IFont.Style.BOLD }; - /* this. */xfont = target.initializeFont("Monospace", 12, - styles); + xfont = target.initializeFont("Monospace", 12, styles); } xfont.setMagnification(getCapability( @@ -1189,6 +1219,9 @@ public class FFMPResource extends basinLocatorString.textStyle = TextStyle.BLANKED; } }); + + // Set flag for HPE data + isHpe = resourceData.siteKey.equalsIgnoreCase(HPE); } /** @@ -1427,13 +1460,24 @@ public class FFMPResource extends PaintProperties paintProps) throws VizException { double[] pixel = paintProps.getView().getDisplayCoords( new double[] { 110, 50 }, target); - + StringBuilder sb = new StringBuilder(); if (isAutoRefresh || isQuery) { - fieldDescString.setText("FFMP " + df.format(getTime()) + " hour " - + FFMPRecord.getFieldLongDescription(getField()), - getCapability(ColorableCapability.class).getColor()); + sb.append("FFMP ").append(df.format(getTime())).append(" hour ") + .append(FFMPRecord.getFieldLongDescription(getField())); } + // Paint the HPE bias source text if HPE + if (isHpe) { + String text = getText(paintTime.getRefTime(), + qpeRecord.getMetaData()); + if (text != null) { + sb.append(StringUtil.NEWLINE); + sb.append(text); + } + } + + fieldDescString.setText(sb.toString(), + getCapability(ColorableCapability.class).getColor()); fieldDescString.setCoordinates(pixel[0], pixel[1]); target.drawStrings(fieldDescString); } @@ -4081,4 +4125,52 @@ public class FFMPResource extends return dataTimes; } + private String getText(Date date, String productId) { + String text = hpeLegendMap.get(date); + if (text == null) { + dataJob.scheduleRetrieval(date, productId); + } + + return text; + } + + private class HpeSourceDataJob extends Job { + private volatile String productId; + + private volatile Date date; + + public HpeSourceDataJob() { + super("Get HPE Source"); + } + + protected void scheduleRetrieval(Date date, String productId) { + this.productId = productId; + this.date = date; + if (this.getState() == Job.RUNNING + || this.getState() == Job.SLEEPING + || this.getState() == Job.WAITING) { + return; + } + this.schedule(); + } + + @Override + protected IStatus run(IProgressMonitor monitor) { + // Request the text from edex + try { + HpeLabelDataRequest req = new HpeLabelDataRequest(productId, + date); + HpeLabelDataResponse response = (HpeLabelDataResponse) ThriftClient + .sendRequest(req); + Map data = response.getData(); + for (Date d : data.keySet()) { + hpeLegendMap.put(d, data.get(d)); + } + } catch (VizException e) { + statusHandler.error(e.getLocalizedMessage(), e); + } + + return Status.OK_STATUS; + } + } } diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/general/GridResource.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/general/GridResource.java index 73cd259f94..bed96f158d 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/general/GridResource.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/general/GridResource.java @@ -28,12 +28,12 @@ import javax.measure.unit.Unit; import org.geotools.coverage.grid.GeneralGridGeometry; -import com.raytheon.uf.common.inventory.exception.DataCubeException; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.grid.GridRecord; import com.raytheon.uf.common.dataplugin.grid.util.GridStyleUtil; import com.raytheon.uf.common.datastorage.records.FloatDataRecord; import com.raytheon.uf.common.datastorage.records.IDataRecord; +import com.raytheon.uf.common.inventory.exception.DataCubeException; import com.raytheon.uf.common.style.ParamLevelMatchCriteria; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.viz.core.exception.VizException; @@ -54,6 +54,7 @@ import com.raytheon.uf.viz.datacube.DataCubeContainer; * Mar 09, 2011 bsteffen Initial creation * Sep 24, 2013 2404 bclement match criteria built using GridStyleUtil * Jan 14, 2014 2661 bsteffen Switch vectors to u,v only. + * May 05, 2014 3026 mpduff Made getCurrentGribRecord() public * * * @@ -150,7 +151,7 @@ public class GridResource extends + record.getParameter().getName(); } - protected GridRecord getCurrentGridRecord() { + public GridRecord getCurrentGridRecord() { List pdos = getCurrentPluginDataObjects(); if (pdos == null || pdos.isEmpty()) { return null; diff --git a/cave/com.raytheon.viz.hydro.feature/feature.xml b/cave/com.raytheon.viz.hydro.feature/feature.xml index a0fab3939d..678974858a 100644 --- a/cave/com.raytheon.viz.hydro.feature/feature.xml +++ b/cave/com.raytheon.viz.hydro.feature/feature.xml @@ -130,4 +130,11 @@ version="0.0.0" unpack="false"/> + + diff --git a/deltaScripts/14.3.1/DR3026/addMetadataColumnFFMP.sh b/deltaScripts/14.3.1/DR3026/addMetadataColumnFFMP.sh new file mode 100644 index 0000000000..76ea698a49 --- /dev/null +++ b/deltaScripts/14.3.1/DR3026/addMetadataColumnFFMP.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# DR 3026 - Add metadata column to FFMP database + +PSQL="/awips2/psql/bin/psql" + +echo "INFO: Adding column metadata to table ffmp" + +${PSQL} -U awips -d metadata -c "ALTER TABLE ffmp ADD COLUMN metadata varchar(255);" + +if [ $? -ne 0 ]; then + echo "ERROR: Failed to add column metadata to table ffmp" + echo "FATAL: The update has failed." + exit 1 +fi + +echo "INFO: column metadata added successfully" diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java index 3e07637fbe..1afaa5a5f0 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java @@ -90,6 +90,7 @@ import com.raytheon.uf.common.time.util.ImmutableDate; * Jul 15, 2013 2184 dhladky Remove all HUC's for storage except ALL * Aug 30, 2013 2298 rjpeter Make getPluginName abstract * Oct 14, 2013 2361 njensen Removed XML annotations + * May 01, 2014 3026 mpduff Added metadata column. * * * @@ -131,6 +132,10 @@ public class FFMPRecord extends PersistablePluginDataObject implements @DynamicSerializeElement private String siteKey; + @Column(length = 255) + @DynamicSerializeElement + private String metaData; + @Transient private FFMPBasinData basins = new FFMPBasinData();; @@ -600,6 +605,21 @@ public class FFMPRecord extends PersistablePluginDataObject implements return isRate; } + /** + * @return the metaData + */ + public String getMetaData() { + return metaData; + } + + /** + * @param metaData + * the metaData to set + */ + public void setMetaData(String metaData) { + this.metaData = metaData; + } + /** * Purges out old data * diff --git a/edexOsgi/com.raytheon.uf.common.ohd/utility/common_static/base/hydro/Apps_defaults b/edexOsgi/com.raytheon.uf.common.ohd/utility/common_static/base/hydro/Apps_defaults index 59d708ef3b..819a0815db 100644 --- a/edexOsgi/com.raytheon.uf.common.ohd/utility/common_static/base/hydro/Apps_defaults +++ b/edexOsgi/com.raytheon.uf.common.ohd/utility/common_static/base/hydro/Apps_defaults @@ -127,6 +127,7 @@ #10/03/12 - Added token section for script execution #02/12/2014 - Added token for default display to replace field in rwprefs table #02/18/14 - Added section for run_report_alarm service configuration. +#05/05/2014 - #3026 added hpe_grib_input_dir token # ============================================================================== @@ -1123,6 +1124,7 @@ dhr_dirname1 : $(data_archive_root)/radar # first part of directo dhr_dirname2 : DHR/layer0/res1/level256 # second part of directory name # containing DHR products for # associated or dial in radar + dhr_grid_dir : $(pproc_local_data)/dhr_decoded # decoded DHR radar grids dhr_error_dir : $(pproc_local_data)/dhr_error # DHR error files @@ -1149,6 +1151,7 @@ dsp_error_dir : $(pproc_local_data)/dsp_error # DSP error files dsp_arch_dir : $(pproc_local_data)/dsp_archive # DSP archives +hpe_grib_input_dir : $(EDEX_HOME)/data/local/hpegrib hpe_generate_list : DHRMOSAIC,BDHRMOSAIC,ERMOSAIC,LSATPRE,EBMOSAIC hpe_qpe_fieldtype : ERMOSAIC # field type to be saved as qpe diff --git a/edexOsgi/com.raytheon.uf.common.plugin.hpe/.classpath b/edexOsgi/com.raytheon.uf.common.plugin.hpe/.classpath new file mode 100644 index 0000000000..098194ca4b --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.hpe/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.common.plugin.hpe/.project b/edexOsgi/com.raytheon.uf.common.plugin.hpe/.project new file mode 100644 index 0000000000..d621d2b9da --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.hpe/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.common.plugin.hpe + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edexOsgi/com.raytheon.uf.common.plugin.hpe/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.common.plugin.hpe/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..c537b63063 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.hpe/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/edexOsgi/com.raytheon.uf.common.plugin.hpe/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.plugin.hpe/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..980394b25f --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.hpe/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Hpe +Bundle-SymbolicName: com.raytheon.uf.common.plugin.hpe +Bundle-Version: 1.14.3.qualifier +Bundle-Vendor: RAYTHEON +Require-Bundle: org.eclipse.core.runtime, + com.raytheon.uf.common.util;bundle-version="1.14.0", + com.raytheon.uf.common.status;bundle-version="1.12.1174", + com.raytheon.uf.common.time;bundle-version="1.12.1174", + javax.persistence;bundle-version="1.0.0", + com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", + com.raytheon.uf.common.serialization;bundle-version="1.12.1174" +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Export-Package: com.raytheon.uf.common.plugin.hpe.data, + com.raytheon.uf.common.plugin.hpe.request diff --git a/edexOsgi/com.raytheon.uf.common.plugin.hpe/build.properties b/edexOsgi/com.raytheon.uf.common.plugin.hpe/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.hpe/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/edexOsgi/com.raytheon.uf.common.plugin.hpe/src/com/raytheon/uf/common/plugin/hpe/data/BiasDynRecord.java b/edexOsgi/com.raytheon.uf.common.plugin.hpe/src/com/raytheon/uf/common/plugin/hpe/data/BiasDynRecord.java new file mode 100644 index 0000000000..3d7a407d5c --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.hpe/src/com/raytheon/uf/common/plugin/hpe/data/BiasDynRecord.java @@ -0,0 +1,204 @@ +/** + * 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.plugin.hpe.data; + +import java.util.Date; + +import com.raytheon.uf.common.util.StringUtil; + +/** + * Data structure holding data from the RWBiasDyn and the DAABiasDyn tables. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 26, 2014    3026    mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class BiasDynRecord { + /** Radar ID */ + private String radarId; + + /** Office ID */ + private String officeId; + + /** Observation time */ + private Date obsTime; + + /** MemspanIndex */ + private float memspanIndex; + + /** Number pairs */ + private double numPairs; + + /** Sum of Gages */ + private float sumGages; + + /** Sum of radars */ + private float sumRadars; + + private float bias; + + /** + * @return the radarId + */ + public String getRadarId() { + return radarId; + } + + /** + * @param radarId + * the radarId to set + */ + public void setRadarId(String radarId) { + this.radarId = radarId; + } + + /** + * @return the officeId + */ + public String getOfficeId() { + return officeId; + } + + /** + * @param officeId + * the officeId to set + */ + public void setOfficeId(String officeId) { + this.officeId = officeId; + } + + /** + * @return the obsTime + */ + public Date getObsTime() { + return obsTime; + } + + /** + * @param obsTime + * the obsTime to set + */ + public void setObsTime(Date obsTime) { + this.obsTime = obsTime; + } + + /** + * @return the memspanIndex + */ + public float getMemspanIndex() { + return memspanIndex; + } + + /** + * @param memspanIndex + * the memspanIndex to set + */ + public void setMemspanIndex(float memspanIndex) { + this.memspanIndex = memspanIndex; + } + + /** + * @return the numPairs + */ + public double getNumPairs() { + return numPairs; + } + + /** + * @param numPairs + * the numPairs to set + */ + public void setNumPairs(double numPairs) { + this.numPairs = numPairs; + } + + /** + * @return the sumGages + */ + public float getSumGages() { + return sumGages; + } + + /** + * @param sumGages + * the sumGages to set + */ + public void setSumGages(float sumGages) { + this.sumGages = sumGages; + } + + /** + * @return the sumRadars + */ + public float getSumRadars() { + return sumRadars; + } + + /** + * @param sumRadars + * the sumRadars to set + */ + public void setSumRadars(float sumRadars) { + this.sumRadars = sumRadars; + } + + /** + * @return the bias + */ + public float getBias() { + return bias; + } + + /** + * @param bias + * the bias to set + */ + public void setBias(float bias) { + this.bias = bias; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Bias: ").append(this.bias).append(StringUtil.NEWLINE); + sb.append("MemSpanIndex: ").append(this.memspanIndex) + .append(StringUtil.NEWLINE); + sb.append("NumPairs: ").append(this.numPairs) + .append(StringUtil.NEWLINE); + sb.append("OfficeId: ").append(this.officeId) + .append(StringUtil.NEWLINE); + sb.append("RadarId: ").append(this.radarId).append(StringUtil.NEWLINE); + sb.append("sumGages: ").append(this.sumGages) + .append(StringUtil.NEWLINE); + sb.append("sumRadars: ").append(this.sumRadars); + + return sb.toString(); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.plugin.hpe/src/com/raytheon/uf/common/plugin/hpe/request/HpeLabelDataRequest.java b/edexOsgi/com.raytheon.uf.common.plugin.hpe/src/com/raytheon/uf/common/plugin/hpe/request/HpeLabelDataRequest.java new file mode 100644 index 0000000000..21825000e4 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.hpe/src/com/raytheon/uf/common/plugin/hpe/request/HpeLabelDataRequest.java @@ -0,0 +1,120 @@ +/** + * 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.plugin.hpe.request; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; +import com.raytheon.uf.common.serialization.comm.IServerRequest; + +/** + * HPE bias source request object. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 23, 2014   3026     mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ +@DynamicSerialize +public class HpeLabelDataRequest implements IServerRequest { + + /** HPE Product name */ + @DynamicSerializeElement + private String productName; + + /** HPE list of dates */ + @DynamicSerializeElement + private List dateList; + + /** + * Constructor. + */ + public HpeLabelDataRequest() { + + } + + /** + * Constructor. + * + * @param productName + * The Hpe product name + * @param dateList + * List of times for the product + */ + public HpeLabelDataRequest(String productName, List dateList) { + this.productName = productName; + this.dateList = dateList; + } + + /** + * Constructor. + * + * @param productName + * The Hpe product name + * @param date + * Date of the product + */ + public HpeLabelDataRequest(String productName, Date date) { + this.productName = productName; + dateList = new ArrayList(1); + dateList.add(date); + } + + /** + * @return the productName + */ + public String getProductName() { + return productName; + } + + /** + * @param productName + * the productName to set + */ + public void setProductName(String productName) { + this.productName = productName; + } + + /** + * @return the dateList + */ + public List getDateList() { + return dateList; + } + + /** + * @param dateList + * the dateList to set + */ + public void setDateList(List dateList) { + this.dateList = dateList; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.plugin.hpe/src/com/raytheon/uf/common/plugin/hpe/request/HpeLabelDataResponse.java b/edexOsgi/com.raytheon.uf.common.plugin.hpe/src/com/raytheon/uf/common/plugin/hpe/request/HpeLabelDataResponse.java new file mode 100644 index 0000000000..4a9fb1028a --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.plugin.hpe/src/com/raytheon/uf/common/plugin/hpe/request/HpeLabelDataResponse.java @@ -0,0 +1,65 @@ +/** + * 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.plugin.hpe.request; + +import java.util.Date; +import java.util.Map; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * HPE bias source response object. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 23, 2014    3026    mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ +@DynamicSerialize +public class HpeLabelDataResponse { + + /** Map of Dates->bias source text */ + @DynamicSerializeElement + private Map data; + + /** + * @return the data + */ + public Map getData() { + return data; + } + + /** + * @param data + * the data to set + */ + public void setData(Map data) { + this.data = data; + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.dataplugins.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.dataplugins.feature/feature.xml index 62015e6f02..46b70f5435 100644 --- a/edexOsgi/com.raytheon.uf.edex.dataplugins.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.edex.dataplugins.feature/feature.xml @@ -381,4 +381,17 @@ version="0.0.0" unpack="false"/> + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/META-INF/MANIFEST.MF index a14e28f88a..e54447274f 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/META-INF/MANIFEST.MF @@ -19,7 +19,8 @@ Require-Bundle: com.raytheon.uf.edex.cpgsrv;bundle-version="1.11.7";resolution:= com.raytheon.uf.common.status;bundle-version="1.12.1174", com.raytheon.uf.common.event;bundle-version="1.0.0", com.raytheon.uf.edex.event;bundle-version="1.0.0", - com.raytheon.uf.common.stats;bundle-version="1.0.0" + com.raytheon.uf.common.stats;bundle-version="1.0.0", + com.raytheon.uf.edex.plugin.hpe;bundle-version="1.14.0" Import-Package: com.raytheon.uf.common.dataplugin.grid, com.raytheon.uf.common.ohd, com.raytheon.uf.common.status, diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/common/FFMPProcessor.java b/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/common/FFMPProcessor.java index a841b1d811..d315b4d954 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/common/FFMPProcessor.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/common/FFMPProcessor.java @@ -102,6 +102,7 @@ import com.vividsolutions.jts.geom.Polygon; * Jul 15, 2013 2184 dhladky Remove all HUC's for storage except ALL * 09/03/2013 DR 13083 G. Zhang Added a fix in processRADAR(ArrayList). * 03 April 2014 2940 dhladky Better error message for bad configurations. + * Apr 15, 2014 3026 mpduff Set the xmrg filename into the metadata column. * * @author dhladky * @version 1 @@ -262,6 +263,7 @@ public class FFMPProcessor { xmrg = (XmrgFile) config.getSourceData( source.getSourceName()).get(dataKey); xmrgData = getXMRGData(); + ffmpRec.setMetaData(xmrg.getFile().getName()); } catch (Exception e) { fireBadConfigMessage(type, e); return; diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/.classpath b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/.project b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/.project new file mode 100644 index 0000000000..57c93e109e --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.edex.plugin.hpe + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..8000cd6ca6 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..afff97de3b --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/META-INF/MANIFEST.MF @@ -0,0 +1,18 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Hpe Grib Preprocessor +Bundle-SymbolicName: com.raytheon.uf.edex.plugin.hpe +Bundle-Version: 1.14.0.qualifier +Bundle-Vendor: RAYTHEON +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Require-Bundle: com.raytheon.uf.common.status;bundle-version="1.12.1174", + com.raytheon.uf.edex.database;bundle-version="1.0.0", + com.raytheon.uf.common.time;bundle-version="1.12.1174", + com.google.guava;bundle-version="11.0.2", + com.raytheon.uf.common.util;bundle-version="1.14.0", + org.apache.camel;bundle-version="2.11.2", + com.raytheon.uf.common.plugin.hpe;bundle-version="1.0.0", + com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", + com.raytheon.uf.common.serialization;bundle-version="1.12.1174", + com.raytheon.edex.common;bundle-version="1.12.1174" diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/build.properties b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/build.properties new file mode 100644 index 0000000000..5791d48d5f --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + res/ diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/res/spring/hpe-file-endpoint.xml b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/res/spring/hpe-file-endpoint.xml new file mode 100644 index 0000000000..78fb11a3e6 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/res/spring/hpe-file-endpoint.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + java.lang.Throwable + + + + + + + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/res/spring/hpe-request.xml b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/res/spring/hpe-request.xml new file mode 100644 index 0000000000..05916c959d --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/res/spring/hpe-request.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/handler/HpeLabelDataHandler.java b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/handler/HpeLabelDataHandler.java new file mode 100644 index 0000000000..5f6709cf64 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/handler/HpeLabelDataHandler.java @@ -0,0 +1,86 @@ +/** + * 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.hpe.handler; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import com.raytheon.uf.common.plugin.hpe.request.HpeLabelDataRequest; +import com.raytheon.uf.common.plugin.hpe.request.HpeLabelDataResponse; +import com.raytheon.uf.common.serialization.comm.IRequestHandler; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.edex.plugin.hpe.util.HpeDataAccessor; +import com.raytheon.uf.edex.plugin.hpe.util.HpeLabelGenerator; + +/** + * HPE bias source label request handler. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 23, 2014    3026    mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class HpeLabelDataHandler implements + IRequestHandler { + /** Status handler */ + private static final IUFStatusHandler statusHandler = UFStatus + .getHandler(HpeLabelDataHandler.class); + + @Override + public Object handleRequest(HpeLabelDataRequest request) throws Exception { + return getData(request); + } + + private HpeLabelDataResponse getData(HpeLabelDataRequest request) { + // Generate the label string, put in response and send back + HpeLabelDataResponse response = new HpeLabelDataResponse(); + Map labelMap = new HashMap(); + try { + for (Date d : request.getDateList()) { + String label = generateHpeLabel(request.getProductName(), d); + labelMap.put(d, label); + } + + response.setData(labelMap); + } catch (Exception e) { + statusHandler.error(e.getMessage(), e); + } + return response; + } + + private String generateHpeLabel(String productName, Date date) + throws Exception { + HpeDataAccessor dataAccessor = new HpeDataAccessor(); + HpeLabelGenerator generator = new HpeLabelGenerator(dataAccessor); + String text = generator.getHpeLabel(date, productName); + return text; + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/process/HpeGribFileNameProcessor.java b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/process/HpeGribFileNameProcessor.java new file mode 100644 index 0000000000..800a5c8898 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/process/HpeGribFileNameProcessor.java @@ -0,0 +1,62 @@ +/** + * 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.hpe.process; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.camel.Exchange; +import org.apache.camel.Processor; + +/** + * Processor for HPE grib files. Adds the filename without the extension as the + * secondaryId. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 21, 2014    3026    mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class HpeGribFileNameProcessor implements Processor { + /** Filename pattern to match for HPE grib files */ + private static final Pattern FILENAME_PATTERN = Pattern + .compile("^([A-Za-z]*MOSAIC[0-9]*z)\\.grib$"); + + @Override + public void process(Exchange exchange) throws Exception { + String fileName = (String) exchange.getIn().getHeader( + "CamelFileNameOnly"); + Matcher matcher = FILENAME_PATTERN.matcher(fileName); + if (matcher.matches()) { + // Take the text before the last "." + String productName = matcher.group(1); + exchange.getIn().setHeader("secondaryid", productName); + } + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/util/HpeDataAccessor.java b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/util/HpeDataAccessor.java new file mode 100644 index 0000000000..7974098139 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/util/HpeDataAccessor.java @@ -0,0 +1,244 @@ +/** + * 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.hpe.util; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.SortedMap; +import java.util.TimeZone; +import java.util.TreeMap; + +import com.raytheon.edex.site.SiteUtil; +import com.raytheon.uf.common.plugin.hpe.data.BiasDynRecord; +import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.edex.database.dao.CoreDao; +import com.raytheon.uf.edex.database.dao.DaoConfig; +import com.raytheon.uf.edex.plugin.hpe.util.HpeEnums.HpeDataSource; + +/** + * HPE database access utility class. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 26, 2014    3026    mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class HpeDataAccessor { + private static final String IHFS = "ihfs"; + + private static final String POSTGRES_DATE_STRING = "yyyy-MM-dd HH:mm:ss"; + + private static final String HPE_RADAR_QUERY = "select distinct(radid) from "; + + /** + * Full query string for HpeRadarResult table + */ + public static final String FULL_HPE_RADAR_RESULT_QUERY = "select hpe_productname, producttime, " + + "num_radar_avail, bias_source, radar_data_source from hperadarresult"; + + /** + * Database date string format + */ + private final ThreadLocal sdf = TimeUtil + .buildThreadLocalSimpleDateFormat(POSTGRES_DATE_STRING, + TimeZone.getTimeZone("GMT")); + + /** The data access object */ + private final CoreDao dao; + + /** + * Constructor. + */ + public HpeDataAccessor() { + dao = new CoreDao(DaoConfig.forDatabase(IHFS)); + } + + /** + * Get a map of radar id->BiasDynRecords + * + * @param recdate + * @param productName + * @return BiasDynRecords + * @throws Exception + */ + public SortedMap> getBiasDynRecords( + Date recdate, String productName) throws Exception { + SortedMap> dataMap = new TreeMap>(); + + HpeRadarResult hpeResult = getHpeRadarResult(recdate, productName); + + HpeDataSource source = hpeResult.getRadarDataSource(); + + String table = null; + if (source == HpeDataSource.S) { + table = "RWBiasDyn"; + } else if (source == HpeDataSource.D) { + table = "DAABiasDyn"; + } else { + throw new Exception( + "Invalid bias source defined in HPERadarResult table: " + + source); + } + + String office = SiteUtil.getSite(); + StringBuilder query = new StringBuilder("select radid, office_id, "); + query.append("obstime, memspan_ind, numpairs, sumgag, sumrad, bias"); + query.append(" from ").append(table); + query.append(" where office_id ").append(" = '").append(office) + .append("'"); + query.append(" and obstime = '").append(sdf.get().format(recdate)); + query.append("'").append(" order by radid asc, memspan_ind asc"); + + Object[] results = dao.executeSQLQuery(query.toString()); + for (Object result : results) { + if (result instanceof Object[]) { + Object[] oa = (Object[]) result; + BiasDynRecord rec = new BiasDynRecord(); + rec.setRadarId((String) oa[0]); + rec.setOfficeId((String) oa[1]); + rec.setObsTime((Date) oa[2]); + rec.setMemspanIndex((Integer) oa[3]); + rec.setNumPairs((Float) oa[4]); + rec.setSumGages((Float) oa[5]); + rec.setSumRadars((Float) oa[6]); + rec.setBias((Float) oa[7]); + + if (!dataMap.containsKey(rec.getOfficeId())) { + dataMap.put(rec.getOfficeId(), + new ArrayList()); + } + + dataMap.get(rec.getRadarId()).add(rec); + } else { + throw new Exception( + "Unexpected return type from bias query, expected Object[], got " + + result.getClass().getName()); + } + } + + return dataMap; + } + + /** + * Get the hpeRadarResult entry for this product. + * + * @param date + * date of the product + * @param productName + * name of the product + * @return record object + * @throws Exception + */ + public HpeRadarResult getHpeRadarResult(Date date, String productName) + throws Exception { + HpeRadarResult hpeResult = new HpeRadarResult(); + try { + String where = " where producttime = '" + sdf.get().format(date) + + "' and hpe_productname = '" + productName + "'"; + + Object[] results = dao.executeSQLQuery(FULL_HPE_RADAR_RESULT_QUERY + + where); + if (results != null && results.length == 5) { + hpeResult.setHpeProductName((String) results[0]); + hpeResult.setProductTime((Date) results[1]); + + if (results[2] != null) { + hpeResult.setNumRadarAvailable((Integer) results[2]); + } + + if (results[3] != null) { + hpeResult.setBiasSource((String) results[3]); + } + + if (results[4] != null) { + hpeResult.setRadarDataSource((String) results[4]); + } + } + } catch (Exception e) { + throw new Exception("Error querying the IHFS hperadarresult table", + e); + } + + return hpeResult; + } + + /** + * Get the nPairBiasSelect value. + * + * @return the nPairBiasSelect value + * @throws Exception + */ + public int getNPairBiasSelect() throws Exception { + try { + Object[] results = dao + .executeSQLQuery("select npair_bias_select from RWBiasStat"); + if (results != null && results.length == 1) { + return (Integer) results[0]; + } + } catch (Exception e) { + throw new Exception("Error querying the IHFS hperadarresult table", + e); + } + + return 0; + } + + /** + * Get a list of HPE radars for the current time. + * + * @param date + * The obstime + * @param table + * The table to query + * @return List of radars + * @throws Exception + */ + public List getHpeRadars(Date date, String table) throws Exception { + StringBuilder query = new StringBuilder(HPE_RADAR_QUERY); + query.append(table).append(" where obstime = '"); + query.append(sdf.get().format(date)).append("' order by radid"); + + List radarList; + + try { + Object[] results = dao.executeSQLQuery(query.toString()); + radarList = new ArrayList(results.length); + for (Object o : results) { + radarList.add((String) o); + } + + return radarList; + } catch (Exception e) { + throw new Exception("Error querying the IHFS hperadarresult table", + e); + } + } +} \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/util/HpeEnums.java b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/util/HpeEnums.java new file mode 100644 index 0000000000..63b32a0d51 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/util/HpeEnums.java @@ -0,0 +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.plugin.hpe.util; + +/** + * HPE Enumerations. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 23, 2014    3026    mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class HpeEnums { + /** + * HPE Data Source + * + *
+     * S for single pol 
+     * D for dual pol
+     * 
+ */ + public enum HpeDataSource { + S, D + } + + /** + * HPE Bias Source. + */ + public enum HpeBiasSource { + RFC_MEAN_BIAS("RCF MEAN BIAS"), SITE_MEAN_BIAS("SITE MEAN BIAS"), SITE_LOCAL_BIAS( + "SITE LOCAL BIAS"), NO_BIAS("NO BIAS"); + + private final String biasSource; + + HpeBiasSource(String biasSource) { + this.biasSource = biasSource; + } + + public String getBiasSource() { + return biasSource; + } + + public static HpeBiasSource fromString(String source) { + if (source != null) { + for (HpeBiasSource h : HpeBiasSource.values()) { + if (source.equalsIgnoreCase(h.getBiasSource())) { + return h; + } + } + } + + throw new IllegalArgumentException( + "No souce found for HpeBiasSource value: " + source); + } + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/util/HpeLabelGenerator.java b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/util/HpeLabelGenerator.java new file mode 100644 index 0000000000..08a9c32672 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/util/HpeLabelGenerator.java @@ -0,0 +1,183 @@ +/** + * 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.hpe.util; + +import java.text.DecimalFormat; +import java.util.Date; +import java.util.List; +import java.util.SortedMap; + +import com.raytheon.uf.common.plugin.hpe.data.BiasDynRecord; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.util.StringUtil; +import com.raytheon.uf.edex.plugin.hpe.util.HpeEnums.HpeBiasSource; +import com.raytheon.uf.edex.plugin.hpe.util.HpeEnums.HpeDataSource; + +/** + * HPE label generator. Creates labels based on the HPE bias source data. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 26, 2014   3026     mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class HpeLabelGenerator { + private static final IUFStatusHandler statusHandler = UFStatus + .getHandler(HpeLabelGenerator.class); + + /** + * 2 decimal place formatter + */ + private final ThreadLocal twoDeciamalFormatter = new ThreadLocal() { + + @Override + protected DecimalFormat initialValue() { + DecimalFormat format = new DecimalFormat("0.00"); + return format; + } + }; + + private static String SLASH = "/"; + + private static String SPACE = " "; + + private static String Y = "Y"; + + private static String N = "N"; + + private final HpeDataAccessor dataAccessor; + + /** + * Constructor. + * + * @param dataAccessor + */ + public HpeLabelGenerator(HpeDataAccessor dataAccessor) { + this.dataAccessor = dataAccessor; + } + + /** + * Get the HPE label string. + * + * @param recDate + * The date of the record + * @param productName + * The name of the HPE product + * + * @return the label + * @throws Exception + */ + public String getHpeLabel(Date recDate, String productName) + throws Exception { + HpeRadarResult hpeResult = dataAccessor.getHpeRadarResult(recDate, + productName); + + if (hpeResult == null || hpeResult.isEmpty()) { + return "No HPE bias source data"; + } + + HpeDataSource source = hpeResult.getRadarDataSource(); + HpeBiasSource biasSource = hpeResult.getBiasSource(); + + // Site->BiasDynRecord list + SortedMap> dataMap = dataAccessor + .getBiasDynRecords(recDate, productName); + + StringBuilder label = new StringBuilder("Dual-Pol Source: "); + + // Label if single or dual + if (source == HpeDataSource.S) { + label.append(N); + } else if (source == HpeDataSource.D) { + label.append(Y); + } + + label.append(StringUtil.NEWLINE); + + // Add bias value + if (biasSource == HpeBiasSource.SITE_MEAN_BIAS) { + label.append("Bias Source: "); + label.append(System.getProperty("AW_SITE_IDENTIFIER")); + } else if (biasSource == HpeBiasSource.RFC_MEAN_BIAS) { + label.append("Bias Source: RFC"); + } else if (biasSource == HpeBiasSource.SITE_LOCAL_BIAS) { + label.append(System.getProperty("AW_SITE_IDENTIFIER")).append( + " Local Bias "); + return label.toString().trim(); + } else { + label.append("Bias Source: none"); + return label.toString().trim(); + } + + label.append(StringUtil.NEWLINE).append(SPACE); + + // Process each radar to get it's part of the label + for (String radar : dataMap.keySet()) { + String labelEntry = getLabelEntry(radar, dataMap.get(radar)); + label.append(labelEntry).append(SPACE); + } + + return label.toString().trim(); + } + + /** + * Get the label entry for the radar. + * + * @param radar + * radar id + * @param records + * BiasDynRecord objects + * @return the label for this radar + * @throws Exception + */ + private String getLabelEntry(String radar, List records) + throws Exception { + StringBuilder sb = new StringBuilder("k"); + sb.append(radar.toLowerCase()).append(SPACE); + final int npairBiasSelect = dataAccessor.getNPairBiasSelect(); + + // process the records + if (!records.isEmpty()) { + for (BiasDynRecord rec : records) { + if (rec.getNumPairs() > npairBiasSelect) { + String bias = twoDeciamalFormatter.get().format( + rec.getBias()); + sb.append(bias).append(SLASH) + .append((int) rec.getNumPairs()); + sb.append(StringUtil.NEWLINE); + + return sb.toString(); + } + } + } + + return sb.toString(); + } +} \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/util/HpeRadarResult.java b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/util/HpeRadarResult.java new file mode 100644 index 0000000000..1efd32d79c --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.hpe/src/com/raytheon/uf/edex/plugin/hpe/util/HpeRadarResult.java @@ -0,0 +1,181 @@ +/** + * 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.hpe.util; + +import java.util.Date; + +import com.raytheon.uf.edex.plugin.hpe.util.HpeEnums.HpeBiasSource; +import com.raytheon.uf.edex.plugin.hpe.util.HpeEnums.HpeDataSource; + +/** + * HpeRadarResult table data object. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 26, 2014    3026    mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class HpeRadarResult { + + private String hpeProductName; + + private Date productTime; + + private int numRadarAvailable; + + private String biasSource; + + private String radarDataSource; + + /** + * Default constructor. + */ + public HpeRadarResult() { + + } + + /** + * @return the hpeProductName + */ + public String getHpeProductName() { + return hpeProductName; + } + + /** + * @param hpeProductName + * the hpeProductName to set + */ + public void setHpeProductName(String hpeProductName) { + this.hpeProductName = hpeProductName; + } + + /** + * @return the productTime + */ + public Date getProductTime() { + return productTime; + } + + /** + * @param productTime + * the productTime to set + */ + public void setProductTime(Date productTime) { + this.productTime = productTime; + } + + /** + * @return the numRadarAvailable + */ + public int getNumRadarAvailable() { + return numRadarAvailable; + } + + /** + * @param numRadarAvailable + * the numRadarAvailable to set + */ + public void setNumRadarAvailable(int numRadarAvailable) { + this.numRadarAvailable = numRadarAvailable; + } + + /** + * @return the biasSource + */ + public String getBiasSourceString() { + return biasSource; + } + + /** + * @return the biasSource + */ + public HpeBiasSource getBiasSource() { + return HpeBiasSource.fromString(biasSource); + } + + /** + * @param biasSource + * the biasSource to set + */ + public void setBiasSource(String biasSource) { + this.biasSource = biasSource; + } + + /** + * @return the radarDataSource String value + */ + public String getRadarDataSourceString() { + return radarDataSource; + } + + /** + * @return the radarDataSource + */ + public HpeDataSource getRadarDataSource() { + return Enum.valueOf(HpeDataSource.class, radarDataSource); + } + + /** + * @param radarDataSource + * the radarDataSource to set + */ + public void setRadarDataSource(String radarDataSource) { + this.radarDataSource = radarDataSource; + } + + /** + * Determine if this is an empty data object. + * + * @return true if empty object, false if populated with data + */ + public boolean isEmpty() { + if (biasSource != null && biasSource.length() > 0) { + return false; + } + + if (hpeProductName != null && hpeProductName.length() > 0) { + return false; + } + + if (numRadarAvailable > 0) { + return false; + } + + if (productTime != null) { + return false; + } + + if (radarDataSource != null && radarDataSource.length() > 0) { + return false; + } + + // Empty file + return true; + } +} \ No newline at end of file diff --git a/nativeLib/files.native/awipsShare/hydroapps/precip_proc/bin/process_hpe_grib_files b/nativeLib/files.native/awipsShare/hydroapps/precip_proc/bin/process_hpe_grib_files index 5303433502..be04b650a4 100755 --- a/nativeLib/files.native/awipsShare/hydroapps/precip_proc/bin/process_hpe_grib_files +++ b/nativeLib/files.native/awipsShare/hydroapps/precip_proc/bin/process_hpe_grib_files @@ -150,7 +150,7 @@ then new_string=`date -u +%d%H%M%S` new_file_name=ZETA98_${out_file%.*}_$new_string.grib - INPUT_DIR=$(get_apps_defaults d2d_input_dir) + INPUT_DIR=$(get_apps_defaults hpe_grib_input_dir) echo Copy grib file $HPE_DHRMOSAIC_GRIB_DIR/$out_file >> $griblog echo to $HPE_DHRMOSAIC_GRIB_DIR/gribfile.tmp >> $griblog @@ -183,7 +183,7 @@ then new_string=`date -u +%d%H%M%S` new_file_name=ZETA98_${out_file%.*}_$new_string.grib - INPUT_DIR=$(get_apps_defaults d2d_input_dir) + INPUT_DIR=$(get_apps_defaults hpe_grib_input_dir) echo Copy grib file $HPE_BDHRMOSAIC_GRIB_DIR/$out_file >> $griblog echo to $HPE_BDHRMOSAIC_GRIB_DIR/gribfile.tmp >> $griblog @@ -216,7 +216,7 @@ then new_string=`date -u +%d%H%M%S` new_file_name=ZETA98_${out_file%.*}_$new_string.grib - INPUT_DIR=$(get_apps_defaults d2d_input_dir) + INPUT_DIR=$(get_apps_defaults hpe_grib_input_dir) echo Copy grib file $HPE_EBMOSAIC_GRIB_DIR/$out_file >> $griblog echo to $HPE_EBMOSAIC_GRIB_DIR/gribfile.tmp >> $griblog @@ -249,7 +249,7 @@ then new_string=`date -u +%d%H%M%S` new_file_name=ZETA98_${out_file%.*}_$new_string.grib - INPUT_DIR=$(get_apps_defaults d2d_input_dir) + INPUT_DIR=$(get_apps_defaults hpe_grib_input_dir) echo Copy grib file $HPE_ERMOSAIC_GRIB_DIR/$out_file >> $griblog echo to $HPE_ERMOSAIC_GRIB_DIR/gribfile.tmp >> $griblog diff --git a/tests/.classpath b/tests/.classpath index a9b0fefae7..79e64062c1 100644 --- a/tests/.classpath +++ b/tests/.classpath @@ -163,5 +163,7 @@ + + diff --git a/tests/manual/com/raytheon/uf/edex/plugin/hpe/util/HpeLabelGeneratorTest.java b/tests/manual/com/raytheon/uf/edex/plugin/hpe/util/HpeLabelGeneratorTest.java new file mode 100644 index 0000000000..6f22553d9b --- /dev/null +++ b/tests/manual/com/raytheon/uf/edex/plugin/hpe/util/HpeLabelGeneratorTest.java @@ -0,0 +1,364 @@ +/** + * 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.hpe.util; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; +import java.util.SortedMap; +import java.util.TreeMap; + +import org.junit.Before; +import org.junit.Test; + +import com.raytheon.uf.common.plugin.hpe.data.BiasDynRecord; +import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.edex.plugin.hpe.util.HpeEnums.HpeBiasSource; + +/** + * Test class for HpeLabelGenerator.java. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 26, 2014    3026    mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class HpeLabelGeneratorTest { + + private final HpeDataAccessor dataAccessor = mock(HpeDataAccessor.class); + + private final Calendar cal = TimeUtil.newGmtCalendar(); + + private final String SINGLE_POL_TABLE = "RWBiasDyn"; + + private final String DUAL_POL_TABLE = "DAABiasDyn"; + + private final String productName = "ERMOSAICM60201403051225z"; + + private final SortedMap> meanDataMap = new TreeMap>(); + + private final SortedMap> localDataMap = new TreeMap>(); + + @Before + public void setup() throws Exception { + setCalendar(); + createBiasDynRecords(); + List radarList = getRadarList(); + System.setProperty("AW_SITE_IDENTIFIER", "OAX"); + when(dataAccessor.getNPairBiasSelect()).thenReturn(10); + when(dataAccessor.getHpeRadars(cal.getTime(), SINGLE_POL_TABLE)) + .thenReturn(radarList); + when(dataAccessor.getHpeRadars(cal.getTime(), DUAL_POL_TABLE)) + .thenReturn(radarList); + } + + // Single pol tests + @Test + public void testLabelCreationForSinglePolSiteMeanBias() throws Exception { + // Set up run specific data + HpeRadarResult siteMeanBiasSingle = new HpeRadarResult(); + siteMeanBiasSingle.setHpeProductName(productName); + siteMeanBiasSingle.setProductTime(cal.getTime()); + siteMeanBiasSingle.setBiasSource(HpeBiasSource.SITE_MEAN_BIAS + .getBiasSource()); + siteMeanBiasSingle.setNumRadarAvailable(8); + siteMeanBiasSingle.setRadarDataSource("S"); + + when(dataAccessor.getHpeRadarResult(cal.getTime(), productName)) + .thenReturn(siteMeanBiasSingle); + + when(dataAccessor.getBiasDynRecords(cal.getTime(), productName)) + .thenReturn(meanDataMap); + + // Run the code + HpeLabelGenerator labelGen = new HpeLabelGenerator(dataAccessor); + String label = labelGen.getHpeLabel(cal.getTime(), productName); + + System.out.println(""); + System.out.println("Single Pol Site Mean Bias"); + System.out.println(label); + } + + @Test + public void testLabelCreationForSinglePolRfcMeanBias() throws Exception { + // Set up run specific data + HpeRadarResult rfcMeanBiasSingle = new HpeRadarResult(); + rfcMeanBiasSingle.setHpeProductName(productName); + rfcMeanBiasSingle.setProductTime(cal.getTime()); + rfcMeanBiasSingle.setBiasSource(HpeBiasSource.RFC_MEAN_BIAS + .getBiasSource()); + rfcMeanBiasSingle.setNumRadarAvailable(8); + rfcMeanBiasSingle.setRadarDataSource("S"); + + when(dataAccessor.getHpeRadarResult(cal.getTime(), productName)) + .thenReturn(rfcMeanBiasSingle); + + when(dataAccessor.getBiasDynRecords(cal.getTime(), productName)) + .thenReturn(meanDataMap); + + // Run the code + HpeLabelGenerator labelGen = new HpeLabelGenerator(dataAccessor); + String label; + label = labelGen.getHpeLabel(cal.getTime(), productName); + + System.out.println(""); + System.out.println("Single Pol RFC Mean Bias"); + System.out.println(label); + } + + @Test + public void testLabelCreationForSinglePolLocalBias() throws Exception { + // Set up run specific data + HpeRadarResult rfcLocalBiasSingle = new HpeRadarResult(); + rfcLocalBiasSingle.setHpeProductName(productName); + rfcLocalBiasSingle.setProductTime(cal.getTime()); + rfcLocalBiasSingle.setBiasSource(HpeBiasSource.SITE_LOCAL_BIAS + .getBiasSource()); + rfcLocalBiasSingle.setNumRadarAvailable(8); + rfcLocalBiasSingle.setRadarDataSource("S"); + + when(dataAccessor.getHpeRadarResult(cal.getTime(), productName)) + .thenReturn(rfcLocalBiasSingle); + + when(dataAccessor.getBiasDynRecords(cal.getTime(), productName)) + .thenReturn(localDataMap); + + // Run the code + HpeLabelGenerator labelGen = new HpeLabelGenerator(dataAccessor); + String label = labelGen.getHpeLabel(cal.getTime(), productName); + + System.out.println(""); + System.out.println("Single Pol Local Site Bias"); + System.out.println(label); + } + + @Test + public void testLabelCreationForSinglePolNoBias() throws Exception { + // Set up run specific data + HpeRadarResult rfcLocalBiasSingle = new HpeRadarResult(); + rfcLocalBiasSingle.setHpeProductName(productName); + rfcLocalBiasSingle.setProductTime(cal.getTime()); + rfcLocalBiasSingle.setBiasSource(HpeBiasSource.NO_BIAS.getBiasSource()); + rfcLocalBiasSingle.setNumRadarAvailable(8); + rfcLocalBiasSingle.setRadarDataSource("S"); + + when(dataAccessor.getHpeRadarResult(cal.getTime(), productName)) + .thenReturn(rfcLocalBiasSingle); + + when(dataAccessor.getBiasDynRecords(cal.getTime(), productName)) + .thenReturn(localDataMap); + + // Run the code + HpeLabelGenerator labelGen = new HpeLabelGenerator(dataAccessor); + String label = labelGen.getHpeLabel(cal.getTime(), productName); + + System.out.println(""); + System.out.println("Single Pol No Bias"); + System.out.println(label); + } + + // Dual pol tests + @Test + public void testLabelCreationForDualPolSiteMeanBias() throws Exception { + // Set up run specific data + HpeRadarResult siteMeanBiasSingle = new HpeRadarResult(); + siteMeanBiasSingle.setHpeProductName(productName); + siteMeanBiasSingle.setProductTime(cal.getTime()); + siteMeanBiasSingle.setBiasSource(HpeBiasSource.SITE_MEAN_BIAS + .getBiasSource()); + siteMeanBiasSingle.setNumRadarAvailable(8); + siteMeanBiasSingle.setRadarDataSource("D"); + + when(dataAccessor.getHpeRadarResult(cal.getTime(), productName)) + .thenReturn(siteMeanBiasSingle); + + when(dataAccessor.getBiasDynRecords(cal.getTime(), productName)) + .thenReturn(meanDataMap); + + // Run the code + HpeLabelGenerator labelGen = new HpeLabelGenerator(dataAccessor); + String label = labelGen.getHpeLabel(cal.getTime(), productName); + + System.out.println(""); + System.out.println("Dual Pol Site Mean Bias"); + System.out.println(label); + } + + @Test + public void testLabelCreationForDualPolRfcMeanBias() throws Exception { + // Set up run specific data + HpeRadarResult rfcMeanBiasSingle = new HpeRadarResult(); + rfcMeanBiasSingle.setHpeProductName(productName); + rfcMeanBiasSingle.setProductTime(cal.getTime()); + rfcMeanBiasSingle.setBiasSource(HpeBiasSource.RFC_MEAN_BIAS + .getBiasSource()); + rfcMeanBiasSingle.setNumRadarAvailable(8); + rfcMeanBiasSingle.setRadarDataSource("D"); + + when(dataAccessor.getHpeRadarResult(cal.getTime(), productName)) + .thenReturn(rfcMeanBiasSingle); + + when(dataAccessor.getBiasDynRecords(cal.getTime(), productName)) + .thenReturn(meanDataMap); + + // Run the code + HpeLabelGenerator labelGen = new HpeLabelGenerator(dataAccessor); + String label = labelGen.getHpeLabel(cal.getTime(), productName); + + System.out.println(""); + System.out.println("Dual Pol RFC Mean Bias"); + System.out.println(label); + } + + @Test + public void testLabelCreationForDualPolLocalBias() throws Exception { + // Set up run specific data + HpeRadarResult rfcLocalBiasSingle = new HpeRadarResult(); + rfcLocalBiasSingle.setHpeProductName(productName); + rfcLocalBiasSingle.setProductTime(cal.getTime()); + rfcLocalBiasSingle.setBiasSource(HpeBiasSource.SITE_LOCAL_BIAS + .getBiasSource()); + rfcLocalBiasSingle.setNumRadarAvailable(8); + rfcLocalBiasSingle.setRadarDataSource("D"); + + when(dataAccessor.getHpeRadarResult(cal.getTime(), productName)) + .thenReturn(rfcLocalBiasSingle); + + when(dataAccessor.getBiasDynRecords(cal.getTime(), productName)) + .thenReturn(localDataMap); + + // Run the code + HpeLabelGenerator labelGen = new HpeLabelGenerator(dataAccessor); + String label = labelGen.getHpeLabel(cal.getTime(), productName); + + System.out.println(""); + System.out.println("Dual Pol Local Site Bias"); + System.out.println(label); + } + + @Test + public void testLabelCreationForDualPolNoBias() throws Exception { + // Set up run specific data + HpeRadarResult rfcLocalBiasSingle = new HpeRadarResult(); + rfcLocalBiasSingle.setHpeProductName(productName); + rfcLocalBiasSingle.setProductTime(cal.getTime()); + rfcLocalBiasSingle.setBiasSource(HpeBiasSource.NO_BIAS.getBiasSource()); + rfcLocalBiasSingle.setNumRadarAvailable(8); + rfcLocalBiasSingle.setRadarDataSource("D"); + + when(dataAccessor.getHpeRadarResult(cal.getTime(), productName)) + .thenReturn(rfcLocalBiasSingle); + + when(dataAccessor.getBiasDynRecords(cal.getTime(), productName)) + .thenReturn(localDataMap); + + // Run the code + HpeLabelGenerator labelGen = new HpeLabelGenerator(dataAccessor); + String label = labelGen.getHpeLabel(cal.getTime(), productName); + + System.out.println(""); + System.out.println("Dual Pol No Bias"); + System.out.println(label); + } + + private void setCalendar() { + cal.set(Calendar.YEAR, 2014); + cal.set(Calendar.MONTH, 3); + cal.set(Calendar.DAY_OF_MONTH, 5); + cal.set(Calendar.HOUR, 12); + cal.set(Calendar.MINUTE, 25); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + } + + private List getRadarList() { + List radarList = new ArrayList(); + radarList.add("ABR"); + radarList.add("DMX"); + radarList.add("EAX"); + radarList.add("FSD"); + radarList.add("LNX"); + radarList.add("OAX"); + radarList.add("TWX"); + radarList.add("UEX"); + + return radarList; + } + + private void createBiasDynRecords() { + List radarList = getRadarList(); + + float[] memSpanIdx = new float[] { 0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, + 6.0f, 7.0f, 8.0f, 9.0f }; + + double[] numPairs = new double[] { 0, 1.8534577634678e-36, + 3.9062266222742e-18, 5.102510849233e-12, 4.0175370594682e-07, + 0.0018974485809437, 7.045055608027, 40.795505532567, + 74.1231615108, 102.99244442947 }; + + float[] sumGages = new float[] { 0.381f, 0.384065f, 0.387877f, + 0.389836f, 0.391715f, 0.393323f, 0.539044f, 1.08328f, 1.15115f, + 1.16888f }; + + float[] sumRadars = new float[] { 1.21662f, 1.09099f, 1.03442f, + 1.01281f, 0.99475f, 0.980855f, 0.949928f, 0.990251f, 0.977503f, + 0.9625f }; + + float[] bias = new float[] { 0.313163f, 0.352033f, 0.37497f, 0.384905f, + 0.393782f, 0.401f, 0.567458f, 1.09394f, 1.17764f, 1.21442f }; + + // Create mean bias data + for (String radar : radarList) { + meanDataMap.put(radar, new ArrayList()); + } + + for (String radar : radarList) { + for (int i = 0; i < memSpanIdx.length; i++) { + BiasDynRecord r = new BiasDynRecord(); + r.setBias(bias[i]); + r.setMemspanIndex(memSpanIdx[i]); + r.setNumPairs(numPairs[i]); + r.setObsTime(cal.getTime()); + r.setOfficeId("OAX"); + r.setRadarId(radar); + r.setSumGages(sumGages[i]); + r.setSumRadars(sumRadars[i]); + meanDataMap.get(radar).add(r); + } + } + + // Create local bias data - local/no bias do not have bias data + for (String radar : radarList) { + localDataMap.put(radar, new ArrayList()); + } + } +}