From 41e429a3595a58e47bb5bb8ce50e5922c4876a8d Mon Sep 17 00:00:00 2001 From: Nathan Bowler Date: Thu, 14 Apr 2016 09:34:14 -0400 Subject: [PATCH 1/8] Omaha #5537 Fix typo on UI Change-Id: I4c09cbbf46577ba0e45b49bb26ce4f8b9c72adac Former-commit-id: 47797cef7bda683fad653e87a0f4b4e113323fe9 --- .../volumebrowser/fields/planview-timeseries/sfc2d/pwpf.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cave/com.raytheon.viz.volumebrowser/localization/menus/volumebrowser/fields/planview-timeseries/sfc2d/pwpf.xml b/cave/com.raytheon.viz.volumebrowser/localization/menus/volumebrowser/fields/planview-timeseries/sfc2d/pwpf.xml index f9a11184a9..03cf715da1 100644 --- a/cave/com.raytheon.viz.volumebrowser/localization/menus/volumebrowser/fields/planview-timeseries/sfc2d/pwpf.xml +++ b/cave/com.raytheon.viz.volumebrowser/localization/menus/volumebrowser/fields/planview-timeseries/sfc2d/pwpf.xml @@ -19,7 +19,7 @@ further_licensing_information. --> - + From c3303aa1d61d9fc475c08eedd11c2c46f95e5fae Mon Sep 17 00:00:00 2001 From: David Gillingham Date: Thu, 14 Apr 2016 10:48:59 -0500 Subject: [PATCH 2/8] Omaha #5575 - Merge IFPClient changes to support sendWfoMessage. Change-Id: Ia378f3378a2f64feda5d87fd412938e3a4f2bc2a Former-commit-id: 0c527e9c161a3d6dd4769dc986cd49f7f5cfa964 --- .../src/com/raytheon/uf/common/gfe/ifpclient/IFPClient.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/edexOsgi/com.raytheon.uf.common.gfe.ifpclient/src/com/raytheon/uf/common/gfe/ifpclient/IFPClient.java b/edexOsgi/com.raytheon.uf.common.gfe.ifpclient/src/com/raytheon/uf/common/gfe/ifpclient/IFPClient.java index 1b68f12f0a..7691dbe217 100644 --- a/edexOsgi/com.raytheon.uf.common.gfe.ifpclient/src/com/raytheon/uf/common/gfe/ifpclient/IFPClient.java +++ b/edexOsgi/com.raytheon.uf.common.gfe.ifpclient/src/com/raytheon/uf/common/gfe/ifpclient/IFPClient.java @@ -67,6 +67,7 @@ import com.raytheon.uf.common.dataplugin.gfe.request.IscRequestQueryRequest.IscQ import com.raytheon.uf.common.dataplugin.gfe.request.LockChangeRequest; import com.raytheon.uf.common.dataplugin.gfe.request.SaveGfeGridRequest; import com.raytheon.uf.common.dataplugin.gfe.request.SendIscGridRequest; +import com.raytheon.uf.common.dataplugin.gfe.request.SendWFOMessageRequest; import com.raytheon.uf.common.dataplugin.gfe.sample.SampleData; import com.raytheon.uf.common.dataplugin.gfe.sample.SampleId; import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable; @@ -1102,6 +1103,11 @@ public class IFPClient { return (ServerResponse) makeRequest(request); } + public ServerResponse sendWFOMessage(List wfos, String message) { + SendWFOMessageRequest request = new SendWFOMessageRequest(wfos, message); + return makeRequest(request); + } + /** * To get a "legacy-style" (prior to A2 release 16.2.2) IFPClient * implementation. Instead of returning ServerResponse objects, the From 91153289270f316da6d62aa584495852541c34a4 Mon Sep 17 00:00:00 2001 From: Mark Peters Date: Thu, 14 Apr 2016 13:13:44 -0500 Subject: [PATCH 3/8] Omaha #4946 Fix duplicate files listed in delete confirmation dialog Change-Id: I50b9b1992c9478370284bf4cf2542c87fd5874d6 Former-commit-id: 7b3e4ad1407ae3944168b4a7dd2eee883205177e --- .../localization/perspective/view/FileTreeView.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/FileTreeView.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/FileTreeView.java index 8fa092ac17..bde604c55e 100644 --- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/FileTreeView.java +++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/FileTreeView.java @@ -150,6 +150,7 @@ import com.raytheon.uf.viz.localization.service.ILocalizationService; * Jan 11, 2016 5242 kbisanz Replaced calls to deprecated LocalizationFile methods * Jan 15, 2016 5242 kbisanz Replaced LocalizationFile with * ILocalizationFile where possible + * Apr 14, 2016 4946 mapeters Fix duplicate files listed in delete confirmation dialog * * * @@ -921,9 +922,13 @@ public class FileTreeView extends ViewPart implements IPartListener2, } if (toDelete.size() > 0) { - Collections.sort(toDelete, new FileTreeFileComparator()); - mgr.add(new DeleteAction(getSite().getPage(), toDelete - .toArray(new LocalizationFile[toDelete.size()]))); + // Duplicates occur if both a dir and its contents are selected + LocalizationFile[] toDeleteWithoutDuplicates = new HashSet<>( + toDelete).toArray(new LocalizationFile[0]); + Arrays.sort(toDeleteWithoutDuplicates, + new FileTreeFileComparator()); + mgr.add(new DeleteAction(getSite().getPage(), + toDeleteWithoutDuplicates)); mgr.add(new Separator()); } } From 3d1bee45323a4d0c9fed1ec243d42c9bd76f6ba8 Mon Sep 17 00:00:00 2001 From: Tom Gurney Date: Tue, 8 Mar 2016 12:01:44 -0600 Subject: [PATCH 4/8] Omaha #5345 - Store SLP values as Pa, not hPa Also update existing sea level pressure values stored in hdf5 files. (cherry picked from commit b733a89e8a6a2804bab9faaeee72496d8a65fba1 [formerly 73606213c72ba86a2a0f96232b1d1471fb6bd1c4]) Change-Id: I6924acf4fbe3fba7057f69306d582fc5c368812e Former-commit-id: a9f91757e4a9cc994b24c025d20aa63433e7c2f7 --- .../localization/plotModels/stdObsDesign.svg | 2 +- .../TO56/DR5345/_update_metar_slp_values.py | 34 +++++++++++++++++++ .../TO56/DR5345/update_metar_slp_values.sh | 21 ++++++++++++ .../edex/plugin/obs/metar/MetarDecoder.java | 5 +++ 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100755 deltaScripts/TO56/DR5345/_update_metar_slp_values.py create mode 100755 deltaScripts/TO56/DR5345/update_metar_slp_values.sh diff --git a/cave/com.raytheon.viz.pointdata/localization/plotModels/stdObsDesign.svg b/cave/com.raytheon.viz.pointdata/localization/plotModels/stdObsDesign.svg index d2ae2be2c3..41448295a3 100644 --- a/cave/com.raytheon.viz.pointdata/localization/plotModels/stdObsDesign.svg +++ b/cave/com.raytheon.viz.pointdata/localization/plotModels/stdObsDesign.svg @@ -87,7 +87,7 @@ plotDelegate = ObsPlotDelegate() 018 59 75 - 018 + 018 0 0 59 diff --git a/deltaScripts/TO56/DR5345/_update_metar_slp_values.py b/deltaScripts/TO56/DR5345/_update_metar_slp_values.py new file mode 100755 index 0000000000..7d05f5826a --- /dev/null +++ b/deltaScripts/TO56/DR5345/_update_metar_slp_values.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python2 + +# #5345 +# Convert sea level pressure from hPa to Pa in an hdf5 file +# Do nothing if all values are already in Pa + +import sys +import h5py + +def main(): + if len(sys.argv) != 2: + print "usage: {} filename.h5".format(sys.argv[0]) + sys.exit(1) + + didstuff = False + try: + with h5py.File(sys.argv[1], 'r+') as f: + if 'seaLevelPress' in f: + for i, data in enumerate(f['seaLevelPress']): + if data > 0 and data < 1999: + f['seaLevelPress'][i] = data * 100.0 + didstuff = True + except Exception as e: + print "ERROR: " + str(sys.exc_info()[0]) + ": " + str(e) + sys.exit(1) + + if didstuff: + print "INFO: {}: updated".format(sys.argv[1]) + else: + print "INFO: {}: no update needed".format(sys.argv[1]) + + +if __name__ == "__main__": + main() diff --git a/deltaScripts/TO56/DR5345/update_metar_slp_values.sh b/deltaScripts/TO56/DR5345/update_metar_slp_values.sh new file mode 100755 index 0000000000..94741b725c --- /dev/null +++ b/deltaScripts/TO56/DR5345/update_metar_slp_values.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# #5345 +# Convert sea level pressure from hPa to Pa in all h5 files + +TARGET=/awips2/edex/data/hdf5/obs +THIS_LOCATION=$(dirname $0) +success=0 + +for item in $(find $TARGET -type f -name "*.h5"); do + $THIS_LOCATION/_update_metar_slp_values.py $item + if [[ $? -ne 0 ]]; then + success=1 + fi +done + +if [[ success -eq 0 ]]; then + echo INFO: No errors reported. +else + echo "ERROR: There was a problem with one or more updates; see above." +fi diff --git a/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarDecoder.java b/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarDecoder.java index 8db285746b..bd03f5dcd8 100644 --- a/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarDecoder.java @@ -26,6 +26,8 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.measure.unit.SI; + import com.raytheon.edex.esb.Headers; import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.plugin.obs.metar.util.VisibilityParser; @@ -90,6 +92,7 @@ import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; * Jul 13, 2015 4389 skorolev Added correction of invalid (NUL) characters in the message. * Nov 01, 2015 DR 14741 MPorricelli Modified WIND_VAR_DIR_EXP pattern to prevent its matching * some RVR strings + * Mar 08, 2016 5345 tgurney Convert sea level pressure from hPa to Pa * * * @@ -720,6 +723,8 @@ public class MetarDecoder { // nothing } if (slp != null) { + slp = (float) SI.HECTO(SI.PASCAL) + .getConverterTo(SI.PASCAL).convert(slp); record.setSeaLevelPress(slp); } } From 50d18a8cc7edb36abcb183d5169fead4a69749eb Mon Sep 17 00:00:00 2001 From: David Lovely Date: Mon, 18 Apr 2016 11:16:56 -0500 Subject: [PATCH 5/8] Omaha #5466 Moved Hazard Services and Data Delivery spec files to WA Repos. Former-commit-id: 4cd107834d217e823fc9ae51abed01270222cdba --- .../Installer.edex-component/README.txt | 1 - .../Installer.edex-datadelivery/README.txt | 1 - .../component.spec | 144 ----------------- .../datadelivery.patch0 | 147 ------------------ .../scripts/init.d/edexServiceList | 5 - .../Installer.edex-hazards/README.txt | 1 - .../Installer.edex-hazards/component.spec | 141 ----------------- .../Installer.edex-hazards/hazards.patch0 | 82 ---------- rpms/awips2.edex/deploy.builder/build.sh | 46 +----- rpms/awips2.edex/generatePatchFiles.sh | 6 - 10 files changed, 3 insertions(+), 571 deletions(-) delete mode 100644 rpms/awips2.edex/Installer.edex-component/README.txt delete mode 100644 rpms/awips2.edex/Installer.edex-datadelivery/README.txt delete mode 100644 rpms/awips2.edex/Installer.edex-datadelivery/component.spec delete mode 100644 rpms/awips2.edex/Installer.edex-datadelivery/datadelivery.patch0 delete mode 100644 rpms/awips2.edex/Installer.edex-datadelivery/scripts/init.d/edexServiceList delete mode 100644 rpms/awips2.edex/Installer.edex-hazards/README.txt delete mode 100644 rpms/awips2.edex/Installer.edex-hazards/component.spec delete mode 100644 rpms/awips2.edex/Installer.edex-hazards/hazards.patch0 delete mode 100644 rpms/awips2.edex/generatePatchFiles.sh diff --git a/rpms/awips2.edex/Installer.edex-component/README.txt b/rpms/awips2.edex/Installer.edex-component/README.txt deleted file mode 100644 index c03b95dd01..0000000000 --- a/rpms/awips2.edex/Installer.edex-component/README.txt +++ /dev/null @@ -1 +0,0 @@ -After updating the edex-component spec file, run generatePatchFiles.sh from the parent folder and commit any changed patch0 files that are updated. diff --git a/rpms/awips2.edex/Installer.edex-datadelivery/README.txt b/rpms/awips2.edex/Installer.edex-datadelivery/README.txt deleted file mode 100644 index b395413dbf..0000000000 --- a/rpms/awips2.edex/Installer.edex-datadelivery/README.txt +++ /dev/null @@ -1 +0,0 @@ -To update the Data Delivery installer, modify the component.spec file. Then, run generatePatchFiles.sh from the parent folder. diff --git a/rpms/awips2.edex/Installer.edex-datadelivery/component.spec b/rpms/awips2.edex/Installer.edex-datadelivery/component.spec deleted file mode 100644 index d8d94dcca7..0000000000 --- a/rpms/awips2.edex/Installer.edex-datadelivery/component.spec +++ /dev/null @@ -1,144 +0,0 @@ -# -# AWIPS II Edex "component" spec file -# -%define __prelink_undo_cmd %{nil} -# Turn off the brp-python-bytecompile script -%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') -%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-java-repack-jars[[:space:]].*$!!g') - -Name: awips2-edex-datadelivery -Summary: awips2-edex-datadelivery Installation -Version: %{_component_version} -Release: %{_component_release} -Group: AWIPSII -BuildRoot: %{_build_root} -URL: N/A -License: N/A -Distribution: N/A -Vendor: Raytheon -Packager: %{_build_site} - -provides: awips2-edex-datadelivery -requires: awips2 -requires: awips2-edex-base -requires: awips2-python -requires: awips2-java -requires: awips2-psql - -%description -AWIPS II Edex - Installs AWIPS II Edex Plugins. - -%prep -# Verify That The User Has Specified A BuildRoot. -if [ "%{_build_root}" = "" ] -then - echo "ERROR: The RPM Build Root has not been specified." - exit 1 -fi - -if [ -d %{_build_root} ]; then - rm -rf %{_build_root} -fi - -%build - -%install -mkdir -p %{_build_root} -if [ $? -ne 0 ]; then - exit 1 -fi -# prepare the init.d directory path -mkdir -p %{_build_root}/etc/init.d -if [ $? -ne 0 ]; then - exit 1 -fi - -unzip %{_baseline_workspace}/build.edex/edex/dist/edex-datadelivery.zip \ - -d %{_build_root} -if [ $? -ne 0 ]; then - exit 1 -fi - -# include the init.d script -INSTALLER_RPM="%{_baseline_workspace}/rpms" -EDEX_DATADELIVERY="${INSTALLER_RPM}/awips2.edex/Installer.edex-datadelivery" -cp -v ${EDEX_DATADELIVERY}/scripts/init.d/* \ - %{_build_root}/etc/init.d -if [ $? -ne 0 ]; then - exit 1 -fi -# rename the script to prevent naming conflicts during installation -pushd . > /dev/null 2>&1 -cd %{_build_root}/etc/init.d -mv edexServiceList edexServiceList-datadelivery -popd > /dev/null 2>&1 - -#add central registry script -mkdir -p %{_build_root}/awips2/edex/bin/ -if [ $? -ne 0 ]; then - exit 1 -fi - -cp -v %{_baseline_workspace}/deploy.edex-Data_Delivery/esb/bin/centralRegistryProviderCredentials.sh %{_build_root}/awips2/edex/bin/ -if [ $? -ne 0 ]; then - exit 1 -fi - -#create a list of all files packaged for /awips2/edex/data/utility -UTILITY=/awips2/edex/data/utility -if [ -d %{_build_root}/$UTILITY ]; then - cd %{_build_root}/$UTILITY - find . -type f > %{_build_root}/awips2/edex/util_filelist.%{name}.txt -fi - -%pre -%post -# replace the service list script with the datadelivery service list script -if [ -f /etc/init.d/edexServiceList ]; then - mv /etc/init.d/edexServiceList /etc/init.d/edexServiceList.orig - if [ $? -ne 0 ]; then - exit 1 - fi -fi -cp /etc/init.d/edexServiceList-datadelivery /etc/init.d/edexServiceList -if [ $? -ne 0 ]; then - exit 1 -fi - -#change date stamp of utility files -UTILITY=/awips2/edex/data/utility -UTIL_FILENAME=/awips2/edex/util_filelist.%{name}.txt -if [ -d $UTILITY ] && [ -f $UTIL_FILENAME ]; then - while read fileName - do - touch "$UTILITY/$fileName" - done < $UTIL_FILENAME - rm -f $UTIL_FILENAME -fi - -%preun -if [ "${1}" = "1" ]; then - exit 0 -fi -# restore the original service list script with the datadelivery service list script -if [ -f /etc/init.d/edexServiceList.orig ]; then - mv /etc/init.d/edexServiceList.orig /etc/init.d/edexServiceList - if [ $? -ne 0 ]; then - exit 1 - fi -fi - -%postun - -%clean -rm -rf ${RPM_BUILD_ROOT} - -%files -%defattr(644,awips,fxalpha,755) -%dir /awips2 -%dir /awips2/edex -/awips2/edex/* -%dir /awips2/edex/bin -%attr(744, -, -) /awips2/edex/bin/centralRegistryProviderCredentials.sh - -%attr(744,root,root) /etc/init.d/* diff --git a/rpms/awips2.edex/Installer.edex-datadelivery/datadelivery.patch0 b/rpms/awips2.edex/Installer.edex-datadelivery/datadelivery.patch0 deleted file mode 100644 index 8b3a2c8152..0000000000 --- a/rpms/awips2.edex/Installer.edex-datadelivery/datadelivery.patch0 +++ /dev/null @@ -1,147 +0,0 @@ -*** Installer.edex-component/component.spec 2015-12-01 15:13:59.047022621 -0600 ---- Installer.edex-datadelivery/component.spec 2015-12-01 15:13:59.048022609 -0600 -*************** -*** 6,13 **** - %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') - %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-java-repack-jars[[:space:]].*$!!g') - -! Name: awips2-%{_component_name} -! Summary: awips2-%{_component_name} Installation - Version: %{_component_version} - Release: %{_component_release} - Group: AWIPSII ---- 6,13 ---- - %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') - %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-java-repack-jars[[:space:]].*$!!g') - -! Name: awips2-edex-datadelivery -! Summary: awips2-edex-datadelivery Installation - Version: %{_component_version} - Release: %{_component_release} - Group: AWIPSII -*************** -*** 18,24 **** - Vendor: Raytheon - Packager: %{_build_site} - -! provides: awips2-%{_component_name} - requires: awips2 - requires: awips2-edex-base - requires: awips2-python ---- 18,24 ---- - Vendor: Raytheon - Packager: %{_build_site} - -! provides: awips2-edex-datadelivery - requires: awips2 - requires: awips2-edex-base - requires: awips2-python -*************** -*** 47,56 **** - if [ $? -ne 0 ]; then - exit 1 - fi - -! unzip %{_baseline_workspace}/build.edex/edex/dist/%{_component_name}.zip \ - -d %{_build_root} - - if [ $? -ne 0 ]; then - exit 1 - fi ---- 47,85 ---- - if [ $? -ne 0 ]; then - exit 1 - fi -+ # prepare the init.d directory path -+ mkdir -p %{_build_root}/etc/init.d -+ if [ $? -ne 0 ]; then -+ exit 1 -+ fi - -! unzip %{_baseline_workspace}/build.edex/edex/dist/edex-datadelivery.zip \ - -d %{_build_root} -+ if [ $? -ne 0 ]; then -+ exit 1 -+ fi - -+ # include the init.d script -+ INSTALLER_RPM="%{_baseline_workspace}/rpms" -+ EDEX_DATADELIVERY="${INSTALLER_RPM}/awips2.edex/Installer.edex-datadelivery" -+ cp -v ${EDEX_DATADELIVERY}/scripts/init.d/* \ -+ %{_build_root}/etc/init.d -+ if [ $? -ne 0 ]; then -+ exit 1 -+ fi -+ # rename the script to prevent naming conflicts during installation -+ pushd . > /dev/null 2>&1 -+ cd %{_build_root}/etc/init.d -+ mv edexServiceList edexServiceList-datadelivery -+ popd > /dev/null 2>&1 -+ -+ #add central registry script -+ mkdir -p %{_build_root}/awips2/edex/bin/ -+ if [ $? -ne 0 ]; then -+ exit 1 -+ fi -+ -+ cp -v %{_baseline_workspace}/deploy.edex-Data_Delivery/esb/bin/centralRegistryProviderCredentials.sh %{_build_root}/awips2/edex/bin/ - if [ $? -ne 0 ]; then - exit 1 - fi -*************** -*** 64,70 **** - - %pre - %post -! - - #change date stamp of utility files - UTILITY=/awips2/edex/data/utility ---- 93,109 ---- - - %pre - %post -! # replace the service list script with the datadelivery service list script -! if [ -f /etc/init.d/edexServiceList ]; then -! mv /etc/init.d/edexServiceList /etc/init.d/edexServiceList.orig -! if [ $? -ne 0 ]; then -! exit 1 -! fi -! fi -! cp /etc/init.d/edexServiceList-datadelivery /etc/init.d/edexServiceList -! if [ $? -ne 0 ]; then -! exit 1 -! fi - - #change date stamp of utility files - UTILITY=/awips2/edex/data/utility -*************** -*** 78,83 **** ---- 117,133 ---- - fi - - %preun -+ if [ "${1}" = "1" ]; then -+ exit 0 -+ fi -+ # restore the original service list script with the datadelivery service list script -+ if [ -f /etc/init.d/edexServiceList.orig ]; then -+ mv /etc/init.d/edexServiceList.orig /etc/init.d/edexServiceList -+ if [ $? -ne 0 ]; then -+ exit 1 -+ fi -+ fi -+ - %postun - - %clean -*************** -*** 88,90 **** ---- 138,144 ---- - %dir /awips2 - %dir /awips2/edex - /awips2/edex/* -+ %dir /awips2/edex/bin -+ %attr(744, -, -) /awips2/edex/bin/centralRegistryProviderCredentials.sh -+ -+ %attr(744,root,root) /etc/init.d/* diff --git a/rpms/awips2.edex/Installer.edex-datadelivery/scripts/init.d/edexServiceList b/rpms/awips2.edex/Installer.edex-datadelivery/scripts/init.d/edexServiceList deleted file mode 100644 index e5aa013a8f..0000000000 --- a/rpms/awips2.edex/Installer.edex-datadelivery/scripts/init.d/edexServiceList +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# Default Services to start -export SERVICES=('registry') - diff --git a/rpms/awips2.edex/Installer.edex-hazards/README.txt b/rpms/awips2.edex/Installer.edex-hazards/README.txt deleted file mode 100644 index c8fe836b7b..0000000000 --- a/rpms/awips2.edex/Installer.edex-hazards/README.txt +++ /dev/null @@ -1 +0,0 @@ -To update the Hazard Services installer, modify the component.spec file. Then, run generatePatchFiles.sh from the parent folder. diff --git a/rpms/awips2.edex/Installer.edex-hazards/component.spec b/rpms/awips2.edex/Installer.edex-hazards/component.spec deleted file mode 100644 index 7fc631c52a..0000000000 --- a/rpms/awips2.edex/Installer.edex-hazards/component.spec +++ /dev/null @@ -1,141 +0,0 @@ -# -# AWIPS II EDEX Hazard Services spec file -# -%define __prelink_undo_cmd %{nil} -# Turn off the brp-python-bytecompile script -%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') -%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-java-repack-jars[[:space:]].*$!!g') - -Name: awips2-%{_component_name} -Summary: awips2-%{_component_name} Installation -Version: %{_component_version} -Release: %{_component_release} -Group: AWIPSII -BuildRoot: %{_build_root} -URL: N/A -License: N/A -Distribution: N/A -Vendor: Raytheon -Packager: %{_build_site} - -provides: awips2-%{_component_name} -requires: awips2 -requires: awips2-edex-base -requires: awips2-python -requires: awips2-java -requires: awips2-psql - -%description -AWIPS II Edex - Installs AWIPS II Edex Plugins. - -%prep -# Verify That The User Has Specified A BuildRoot. -if [ "%{_build_root}" = "" ] -then - echo "ERROR: The RPM Build Root has not been specified." - exit 1 -fi - -if [ -d %{_build_root} ]; then - rm -rf %{_build_root} -fi - -%build - -%install -mkdir -p %{_build_root} -if [ $? -ne 0 ]; then - exit 1 -fi - -unzip %{_baseline_workspace}/build.edex/edex/dist/%{_component_name}.zip \ - -d %{_build_root} - -if [ $? -ne 0 ]; then - exit 1 -fi - -#create the edex scripts dir -EDEX_SCRIPTS_DIR=%{_build_root}/awips2/edex/scripts/ -if [ ! -d $EDEX_SCRIPTS_DIR ]; then - mkdir -p $EDEX_SCRIPTS_DIR - - if [ $? -ne 0 ]; then - exit 1 - fi -fi - - -# verify HazardServices directory exists and copy in files -HS_NAME=HazardServices -TOOLS_HS_DIR=%{_baseline_workspace}/tools/$HS_NAME -if [ -d $TOOLS_HS_DIR ]; then - - cp -Rv $TOOLS_HS_DIR $EDEX_SCRIPTS_DIR - if [ $? -ne 0 ]; then - exit 1 - fi - -fi - -# HazardServices dir may not be available, as tools/HazardServices may not exist -# if not available, create the directory for other scripts -if [ ! -d $EDEX_SCRIPTS_DIR/$HS_NAME ]; then - mkdir -p $EDEX_SCRIPTS_DIR/$HS_NAME - - if [ $? -ne 0 ]; then - exit 1 - fi -fi - -#copy in specific files for HS -if [ -d $EDEX_SCRIPTS_DIR/$HS_NAME ]; then - - cp -v %{_baseline_workspace}/tools/parseWarngenTemplate.py $EDEX_SCRIPTS_DIR/$HS_NAME - if [ $? -ne 0 ]; then - exit 1 - fi - - cp -v %{_baseline_workspace}/tools/ingestshapefiles.sh $EDEX_SCRIPTS_DIR/$HS_NAME - if [ $? -ne 0 ]; then - exit 1 - fi - -fi - -#create a list of all files packaged for /awips2/edex/data/utility -UTILITY=/awips2/edex/data/utility -if [ -d %{_build_root}/$UTILITY ]; then - cd %{_build_root}/$UTILITY - find . -type f > %{_build_root}/awips2/edex/util_filelist.%{name}.txt -fi - -%pre -%post - - -#change date stamp of utility files -UTILITY=/awips2/edex/data/utility -UTIL_FILENAME=/awips2/edex/util_filelist.%{name}.txt -if [ -d $UTILITY ] && [ -f $UTIL_FILENAME ]; then - while read fileName - do - touch "$UTILITY/$fileName" - done < $UTIL_FILENAME - rm -f $UTIL_FILENAME -fi - -%preun -%postun - -%clean -rm -rf ${RPM_BUILD_ROOT} - -%files -%defattr(644,awips,fxalpha,755) -%dir /awips2 -%dir /awips2/edex -%dir /awips2/edex/conf -/awips2/edex/* -%defattr(755,awips,fxalpha,-) -/awips2/edex/scripts/* diff --git a/rpms/awips2.edex/Installer.edex-hazards/hazards.patch0 b/rpms/awips2.edex/Installer.edex-hazards/hazards.patch0 deleted file mode 100644 index 32744b6427..0000000000 --- a/rpms/awips2.edex/Installer.edex-hazards/hazards.patch0 +++ /dev/null @@ -1,82 +0,0 @@ -*** Installer.edex-component/component.spec 2015-12-01 15:13:59.047022621 -0600 ---- Installer.edex-hazards/component.spec 2015-12-01 15:13:59.054022541 -0600 -*************** -*** 1,5 **** - # -! # AWIPS II Edex "component" spec file - # - %define __prelink_undo_cmd %{nil} - # Turn off the brp-python-bytecompile script ---- 1,5 ---- - # -! # AWIPS II EDEX Hazard Services spec file - # - %define __prelink_undo_cmd %{nil} - # Turn off the brp-python-bytecompile script -*************** -*** 55,60 **** ---- 55,108 ---- - exit 1 - fi - -+ #create the edex scripts dir -+ EDEX_SCRIPTS_DIR=%{_build_root}/awips2/edex/scripts/ -+ if [ ! -d $EDEX_SCRIPTS_DIR ]; then -+ mkdir -p $EDEX_SCRIPTS_DIR -+ -+ if [ $? -ne 0 ]; then -+ exit 1 -+ fi -+ fi -+ -+ -+ # verify HazardServices directory exists and copy in files -+ HS_NAME=HazardServices -+ TOOLS_HS_DIR=%{_baseline_workspace}/tools/$HS_NAME -+ if [ -d $TOOLS_HS_DIR ]; then -+ -+ cp -Rv $TOOLS_HS_DIR $EDEX_SCRIPTS_DIR -+ if [ $? -ne 0 ]; then -+ exit 1 -+ fi -+ -+ fi -+ -+ # HazardServices dir may not be available, as tools/HazardServices may not exist -+ # if not available, create the directory for other scripts -+ if [ ! -d $EDEX_SCRIPTS_DIR/$HS_NAME ]; then -+ mkdir -p $EDEX_SCRIPTS_DIR/$HS_NAME -+ -+ if [ $? -ne 0 ]; then -+ exit 1 -+ fi -+ fi -+ -+ #copy in specific files for HS -+ if [ -d $EDEX_SCRIPTS_DIR/$HS_NAME ]; then -+ -+ cp -v %{_baseline_workspace}/tools/parseWarngenTemplate.py $EDEX_SCRIPTS_DIR/$HS_NAME -+ if [ $? -ne 0 ]; then -+ exit 1 -+ fi -+ -+ cp -v %{_baseline_workspace}/tools/ingestshapefiles.sh $EDEX_SCRIPTS_DIR/$HS_NAME -+ if [ $? -ne 0 ]; then -+ exit 1 -+ fi -+ -+ fi -+ - #create a list of all files packaged for /awips2/edex/data/utility - UTILITY=/awips2/edex/data/utility - if [ -d %{_build_root}/$UTILITY ]; then -*************** -*** 87,90 **** ---- 135,141 ---- - %defattr(644,awips,fxalpha,755) - %dir /awips2 - %dir /awips2/edex -+ %dir /awips2/edex/conf - /awips2/edex/* -+ %defattr(755,awips,fxalpha,-) -+ /awips2/edex/scripts/* diff --git a/rpms/awips2.edex/deploy.builder/build.sh b/rpms/awips2.edex/deploy.builder/build.sh index 47fa56b4af..d2dddda38b 100644 --- a/rpms/awips2.edex/deploy.builder/build.sh +++ b/rpms/awips2.edex/deploy.builder/build.sh @@ -56,26 +56,6 @@ if [ ! "${architecture}" = "x86_64" ]; then exit 1 fi -function patchSpecification() -{ - # copy the standard rpm feature specification into the - # component's project directory - cp -v Installer.edex-component/component.spec \ - Installer.${COMPONENT_NAME}/component.spec - if [ $? -ne 0 ]; then - exit 1 - fi - - # apply the specification patch - pushd . > /dev/null 2>&1 - cd Installer.${COMPONENT_NAME} - patch -p1 -i *.patch0 - if [ $? -ne 0 ]; then - exit 1 - fi - popd > /dev/null 2>&1 -} - function buildRPM() { # Arguments: @@ -129,36 +109,16 @@ cd ../ buildRPM "Installer.edex" buildRPM "Installer.edex-configuration" -# build the edex-hazards component -export COMPONENT_NAME="edex-hazards" -# Workaround until #5466 is resolved. -if [ -f ${DIST}/${COMPONENT_NAME}.zip ]; then - patchSpecification - buildRPM "Installer.edex-hazards" -fi -unset COMPONENT_NAME - DIST="${WORKSPACE}/build.edex/edex/dist" for edex_zip in `cd ${DIST}; ls -1;`; do edex_component=`python -c "zipFile='${edex_zip}'; componentName=zipFile.replace('.zip',''); print componentName;"` - - #Data Delivery and Hazard Services components are built separately - if [ ! "${edex_component}" = "edex-datadelivery" ] && - [ ! "${edex_component}" = "common-base" ] && - [ ! "${edex_component}" = "edex-hazards" ]; then + + # Check if component is in the ignore file, do not build an RPM if so. + if ! grep -Fxq "${edex_component}" ${WORKSPACE}/build.edex/component.ignore.txt; then export COMPONENT_NAME="${edex_component}" buildRPM "Installer.edex-component" unset COMPONENT_NAME fi done -# build the edex-datadelivery rpm -export COMPONENT_NAME="edex-datadelivery" -# Workaround until #5466 is resolved. -if [ -f ${DIST}/${COMPONENT_NAME}.zip ]; then - patchSpecification - buildRPM "Installer.edex-datadelivery" -fi -unset COMPONENT_NAME - diff --git a/rpms/awips2.edex/generatePatchFiles.sh b/rpms/awips2.edex/generatePatchFiles.sh deleted file mode 100644 index f67159906a..0000000000 --- a/rpms/awips2.edex/generatePatchFiles.sh +++ /dev/null @@ -1,6 +0,0 @@ -#hazard services -diff -crb Installer.edex-component/component.spec Installer.edex-hazards/component.spec > Installer.edex-hazards/hazards.patch0 - -#data delivery -diff -crb Installer.edex-component/component.spec Installer.edex-datadelivery/component.spec > Installer.edex-datadelivery/datadelivery.patch0 - From 85c854aa4e1c9c1803edeff8113a26535c1d1d62 Mon Sep 17 00:00:00 2001 From: Tim Jensen Date: Fri, 15 Apr 2016 14:54:38 -0500 Subject: [PATCH 6/8] Omaha #5182 - Changed processorMap population to be done during processing instead of up front. Change-Id: I22fbc67c57b3dae66c04026a6b88bb3dbca51e27 Former-commit-id: 76b1244537e8f3f9926ada57e3daec5dd25decb1 --- .../GribPostProcessor.java | 164 ++++++++++-------- .../PostProcessedModel.java | 26 ++- 2 files changed, 113 insertions(+), 77 deletions(-) diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/GribPostProcessor.java b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/GribPostProcessor.java index cd6ca8960f..9a805ff905 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/GribPostProcessor.java +++ b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/GribPostProcessor.java @@ -23,11 +23,14 @@ package com.raytheon.edex.plugin.grib.decoderpostprocessors; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.regex.Matcher; import javax.xml.bind.JAXBException; @@ -35,7 +38,6 @@ import org.apache.camel.Headers; import com.raytheon.edex.plugin.grib.decoderpostprocessors.DecoderPostProcessor.PostProcessorType; import com.raytheon.edex.plugin.grib.exception.GribException; -import com.raytheon.edex.plugin.grib.util.GribModelLookup; import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.annotations.DataURIUtil; import com.raytheon.uf.common.dataplugin.grid.GridRecord; @@ -54,11 +56,11 @@ import com.raytheon.uf.common.status.UFStatus; /** * An implementation to modify a grib record after the initial grid decoding if * necessary - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date          Ticket#  Engineer    Description
  * ------------- -------- ----------- --------------------------
  * Aug 30, 2010  5875     bphillip    Initial Creation
@@ -72,9 +74,11 @@ import com.raytheon.uf.common.status.UFStatus;
  * Oct 14, 2015  4627     nabowle     Load post processor mappings at each
  *                                    localization level as available, appending
  *                                    only new processors.
- *
+ * Apr 15, 2016  5182     tjensen     Changed processorMap population to be done
+ *                                       during processing instead of up front.
+ * 
  * 
- * + * * @author bphillip * @version 1 */ @@ -88,13 +92,15 @@ public class GribPostProcessor { private static GribPostProcessor instance; /** The map containing the currently registered grib post processors */ - private Map> processorMap; + private Map> processorMap = new ConcurrentHashMap<>(); - private Map knownProcessors = new HashMap<>(); + private final Map knownProcessors = new HashMap<>();; + + private List postProcessedModels; /** * Gets the singleton instance of GribPostProcessor - * + * * @return The singleton instance of GribPostProcessor */ public static synchronized GribPostProcessor getInstance() { @@ -113,7 +119,7 @@ public class GribPostProcessor { /** * Processes the GribRecords to determine if they need post processing - * + * * @param records * The records to examine * @return The GribRecords including any new records created during the post @@ -122,7 +128,7 @@ public class GribPostProcessor { */ public GridRecord[] process(GridRecord[] records) throws GribException { synchronized (this) { - if (this.processorMap == null) { + if (this.postProcessedModels == null) { initProcessorMap(); } } @@ -131,10 +137,22 @@ public class GribPostProcessor { GridRecord[] results = null; List additionalGrids = null; for (int i = 0; i < records.length; i++) { - // Check the map to see if this grib record is part of a model for - // which post processing is necessary - processors = processorMap.get(records[i].getDatasetId()); - if (processors != null) { + String modelName = records[i].getDatasetId(); + + /* + * If we don't already have a entry in the map, check to see if we + * need to add one. + */ + if (processorMap.get(modelName) == null) { + lookupModelProcessors(modelName); + } + + /* + * Check the map to see if this grib record is part of a model for + * which post processing is necessary + */ + processors = processorMap.get(modelName); + if (processors != null && !processors.isEmpty()) { for (DecoderPostProcessor processor : processors) { // Post processing is not necessary, so we continue if (processor == null @@ -172,7 +190,7 @@ public class GribPostProcessor { /** * Processes the GridRecords to determine if they need post processing - * + * * @param notif * A notification of datauri's that have been persisted. * @return Only grid records created by the post processors. The records @@ -244,7 +262,7 @@ public class GribPostProcessor { /** * Registers the DecoderPostProcessor classes for the supplied * fully-qualified classnames. - * + * * @param fqClassNames * The list of fully-qualified classnames to register. */ @@ -288,16 +306,14 @@ public class GribPostProcessor { } /** - * Initializes the processor map. Starting at base working to site, the - * localization files will be unmarshalled if present and new processors - * will be appended to the list of processors for a model. If a processor - * has already been configured for a model, it will not be added again. - * - * It's assumed that every processor will have already been registered under - * its simple name, or is fully qualified. - * - * Other than the first initialization, the processor map will only be - * changed if the new value is not an empty map. + * Initializes the list of postProcessedModels and the processor map. + * Starting at base working to site, the localization files will be + * unmarshalled if present and new processors will be appended to the list + * of processors for a model. If a processor has already been configured for + * a model, it will not be added again. + * + * The processor map is initially empty, but will be populated as records + * are processed to prevent repeated lookup for the same model. */ private synchronized void initProcessorMap() { IPathManager pathMgr = PathManagerFactory.getPathManager(); @@ -310,7 +326,7 @@ public class GribPostProcessor { .getTieredLocalizationFile(LocalizationType.EDEX_STATIC, "/grib/postProcessModels/postProcessedModels.xml"); PostProcessedModelSet ppModelSet; - List postProcessedModels = new ArrayList<>(); + postProcessedModels = new ArrayList<>(); Map idMap = new HashMap<>(); for (LocalizationLevel level : levels) { processorFile = files.get(level); @@ -339,7 +355,8 @@ public class GribPostProcessor { Integer idx = idMap.get(ppModel.getId()); if (idx == null) { postProcessedModels.add(ppModel); - idMap.put(ppModel.getId(), postProcessedModels.size() - 1); + idMap.put(ppModel.getId(), + postProcessedModels.size() - 1); } else { postProcessedModels.remove(idx.intValue()); postProcessedModels.add(idx.intValue(), ppModel); @@ -355,64 +372,69 @@ public class GribPostProcessor { } /* - * Iterate over post processed models. Determine which models apply to + * Initialize processorMap to an empty map. Map will be populated as + * records are processed. + */ + this.processorMap.clear(); + } + + /** + * For a given model name, determine if the model applies for each post + * processor. If so, update the processor map for this model to prevent + * repeated lookup for this model. + * + * @param modelName + */ + private synchronized void lookupModelProcessors(String modelName) { + /* + * Iterate over post processed models. Determine if model applies to * each post processor if a regex is present */ String knownProc; String classToLoad; - List processorInstances; - Set modelNames = GribModelLookup.getInstance().getModelNames(); - Map> newMap = new HashMap<>(); + Matcher m; + List processorInstances = new ArrayList<>(); for (PostProcessedModel ppModel : postProcessedModels) { if (ppModel.getModelName() == null) { continue; } - for (String modelName : modelNames) { - if (modelName.matches(ppModel.getModelName())) { - processorInstances = newMap.get(modelName); - if (processorInstances == null) { - processorInstances = new ArrayList(); - newMap.put(modelName, processorInstances); + m = ppModel.getModelNamePattern().matcher(modelName); + if (m.matches()) { + for (String processor : ppModel.getProcessors()) { + knownProc = this.knownProcessors.get(processor); + if (knownProc != null) { + classToLoad = knownProc; + } else { + classToLoad = processor; } - for (String processor : ppModel.getProcessors()) { - knownProc = this.knownProcessors.get(processor); - if (knownProc != null) { - classToLoad = knownProc; - } else { - classToLoad = processor; - } - - try { - boolean alreadyConfigured = false; - for (DecoderPostProcessor instance : processorInstances) { - if (classToLoad.equals(instance.getClass() - .getName())) { - alreadyConfigured = true; - statusHandler.debug(classToLoad - + " is already configured for " - + modelName + "."); - break; - } + try { + boolean alreadyConfigured = false; + for (DecoderPostProcessor instance : processorInstances) { + if (classToLoad.equals(instance.getClass() + .getName())) { + alreadyConfigured = true; + statusHandler.debug(classToLoad + + " is already configured for " + + modelName + "."); + break; } - if (!alreadyConfigured) { - processorInstances - .add((DecoderPostProcessor) Class - .forName(classToLoad) - .newInstance()); - } - } catch (Exception e) { - statusHandler.fatal( - "Error instantiating grib post processor for " - + processor, e); } + if (!alreadyConfigured) { + processorInstances.add((DecoderPostProcessor) Class + .forName(classToLoad).newInstance()); + } + } catch (Exception e) { + statusHandler.fatal( + "Error instantiating grib post processor for " + + processor, e); } } } } - - if (this.processorMap == null || !newMap.isEmpty()) { - this.processorMap = newMap; + if (processorInstances.isEmpty()) { + processorInstances = Collections.emptyList(); } + processorMap.put(modelName, processorInstances); } } diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/PostProcessedModel.java b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/PostProcessedModel.java index db04da5412..c1320ae7ec 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/PostProcessedModel.java +++ b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/decoderpostprocessors/PostProcessedModel.java @@ -21,6 +21,7 @@ package com.raytheon.edex.plugin.grib.decoderpostprocessors; import java.util.ArrayList; import java.util.List; +import java.util.regex.Pattern; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -30,20 +31,21 @@ import javax.xml.bind.annotation.XmlRootElement; /** * A container class to hold which post processors apply to a grib model - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date          Ticket#  Engineer    Description
  * ------------- -------- ----------- --------------------------
  * Jul 24, 2012  949      bphillip    Initial Creation
  * Oct 15, 2013  2473     bsteffen    Remove deprecated ISerializableObject.
  * Oct 14, 2015  4627     nabowle     Add id attribute.
- *
- *
+ * Apr 18, 2016  5182     tjensen     Optimized to store modelNamePattern
+ * 
+ * 
  * 
- * + * * @author bphillip * @version 1 */ @@ -70,6 +72,11 @@ public class PostProcessedModel { @XmlElement(name = "processorName") private List processors; + /** + * Stores the regex pattern so it only needs to be calculated once. + */ + private Pattern modelNamePattern; + public PostProcessedModel() { } @@ -80,6 +87,7 @@ public class PostProcessedModel { public void setModelName(String modelName) { this.modelName = modelName; + this.modelNamePattern = Pattern.compile(modelName); } /** @@ -122,4 +130,10 @@ public class PostProcessedModel { return buf.toString(); } + public Pattern getModelNamePattern() { + if (modelName != null && modelNamePattern == null) { + modelNamePattern = Pattern.compile(modelName); + } + return modelNamePattern; + } } From 0ffd97f7d39d40a35b1d8820de698bb9ff43c2e5 Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Mon, 18 Apr 2016 14:22:16 -0500 Subject: [PATCH 7/8] Omaha #5539 Fix GFE issues with Wx/Discretes with more than 128 Wx types Change-Id: I8c66fdcbc8925c23863d6d1e0a8ec5fce67f87c8 Former-commit-id: 81a57e1d4d2062bfcf8acdcc92fbbab062fa9cbf --- .../gfe/userPython/utilities/SmartScript.py | 7 +- .../gfe/core/griddata/DiscreteGridData.java | 3 +- .../viz/gfe/core/internal/ISCDataAccess.java | 5 +- .../com/raytheon/viz/gfe/core/parm/Parm.java | 11 +- .../viz/gfe/interpolation/DiscreteInterp.java | 15 +- .../edex/plugin/gfe/ifpAG/ASCIIGrid.java | 17 ++- .../server/handler/GetPointDataHandler.java | 7 +- .../edex_static/base/gfe/isc/ifpnetCDF.py | 21 +-- .../edex_static/base/gfe/isc/mergeGrid.py | 45 +++++- .../dataplugin/gfe/grid/Grid2DByte.java | 37 ++--- .../gfe/slice/WeatherGridSlice.java | 137 ++++++++++-------- 11 files changed, 190 insertions(+), 115 deletions(-) diff --git a/cave/com.raytheon.viz.gfe/localization/gfe/userPython/utilities/SmartScript.py b/cave/com.raytheon.viz.gfe/localization/gfe/userPython/utilities/SmartScript.py index b7dd5efa6d..175258851a 100644 --- a/cave/com.raytheon.viz.gfe/localization/gfe/userPython/utilities/SmartScript.py +++ b/cave/com.raytheon.viz.gfe/localization/gfe/userPython/utilities/SmartScript.py @@ -78,7 +78,8 @@ # Sep 11, 2015 4858 dgilling Remove notification processing from publishElements. # Jan 20, 2016 4751 randerso Fix type of mask returned from getComposite() to work with numpy 1.9.2 # Jan 28, 2016 5129 dgilling Support changes to IFPClient. -# 02/22/2016 5374 randerso Added support for sendWFOMessage +# Feb 22, 2016 5374 randerso Added support for sendWFOMessage +# Apr 05, 2016 5539 randerso Added exception when attempting create more than 256 Wx keys # ######################################################################## import types, string, time, sys @@ -2198,6 +2199,10 @@ class SmartScript(BaseTool.BaseTool): for str in keys: if sortedUglyStr == self.sortUglyStr(str): return keys.index(str) + + if len(keys) >= 256: + raise IndexError("Attempt to create more than 256 Wx keys") + keys.append(uglyStr) return len(keys) - 1 diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/DiscreteGridData.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/DiscreteGridData.java index 95bc1a1c6e..b6c11e8385 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/DiscreteGridData.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/DiscreteGridData.java @@ -72,6 +72,7 @@ import com.vividsolutions.jts.geom.MultiPolygon; * 02/19/2013 1637 randerso Added throws declarations to translateDataFrom * 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys() * Apr 23, 2015 4259 njensen Removed unused INumpyable + * Apr 04, 2016 5539 randerso Fix unsigned byte issues * * * @@ -918,7 +919,7 @@ public class DiscreteGridData extends AbstractGridData { for (int j = 0; j < dim.y; j++) { if (points.get(i, j) == 1) { DiscreteKey combined = DiscreteKey.combine( - key.get(values.get(i, j)), + key.get(0xFF & values.get(i, j)), doGetDiscreteValue(i, j)); grid.set(i, j, lookupKeyValue(combined)); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ISCDataAccess.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ISCDataAccess.java index 746d4fc6a6..a0fcd22626 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ISCDataAccess.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ISCDataAccess.java @@ -76,6 +76,7 @@ import com.vividsolutions.jts.geom.Coordinate; * 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys() * 09/01/2014 3572 randerso Removed ourSiteMap as it was unused and the only * thing that used Grid2DBoolean + * 04/04/2016 5539 randerso Fix unsigned byte issues * * * @@ -462,7 +463,7 @@ public class ISCDataAccess implements IISCDataAccess { for (int i = 0; i < siteMask.getXdim(); i++) { if (siteMask.getAsBoolean(i, j)) { byte index = lookupKeyValue(keyIndexMap, - iscKey[iscGrid.get(i, j)]); + iscKey[0xFF & iscGrid.get(i, j)]); slice.getWeatherGrid().set(i, j, index); } } @@ -551,7 +552,7 @@ public class ISCDataAccess implements IISCDataAccess { for (int i = 0; i < siteMask.getXdim(); i++) { if (siteMask.getAsBoolean(i, j)) { byte index = lookupKeyValue(keyIndexMap, - iscKey[iscGrid.get(i, j)]); + iscKey[0xFF & iscGrid.get(i, j)]); slice.getDiscreteGrid().set(i, j, index); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/Parm.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/Parm.java index d4f220b606..9675628544 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/Parm.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/Parm.java @@ -191,6 +191,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Sep 10, 2015 #4782 randerso Converted inParmEdit to ReentrantLock to force * updates to be run consecutively. * Cleaned up TODOs, FIXMEs and deprecations. + * Apr 04, 2016 #5539 randerso Fix unsigned byte issues * * * @@ -2161,10 +2162,9 @@ public abstract class Parm implements Comparable { .getGridSlice()).getKeys(); Grid2DByte grid1 = ((WeatherGridSlice) grids[k] .getGridSlice()).getWeatherGrid(); - WeatherKey tmpKey = key1[grid1.get(i, j)]; + WeatherKey tmpKey = key1[0xFF & grid1.get(i, j)]; WeatherSubKey gpkeys[] = tmpKey.getSubKeys().toArray( new WeatherSubKey[tmpKey.getSubKeys().size()]); - // key1[grid1(i, j)].subKeys(); for (int m = 0; m < gpkeys.length; m++) { int index = subKeys.indexOf(gpkeys[m]); if (index == -1) { @@ -2236,8 +2236,7 @@ public abstract class Parm implements Comparable { .getGridSlice()).getKeys(); Grid2DByte grid1 = ((DiscreteGridSlice) grids[k] .getGridSlice()).getDiscreteGrid(); - // TextString kv = key1[grid1(i, j)].keyAsString(); - DiscreteKey kv = key1[grid1.get(i, j)]; + DiscreteKey kv = key1[0xFF & grid1.get(i, j)]; // add it to the dictionary MutableInteger cnt = values.get(kv); if (cnt == null) { @@ -3706,7 +3705,7 @@ public abstract class Parm implements Comparable { .getGridSlice()); WeatherKey[] key1 = slice.getKeys(); Grid2DByte grid1 = slice.getWeatherGrid(); - WeatherKey key1ij = key1[grid1.get(i, j)]; + WeatherKey key1ij = key1[0xFF & grid1.get(i, j)]; subkeys.addAll(key1ij.getSubKeys()); } @@ -3760,7 +3759,7 @@ public abstract class Parm implements Comparable { .getGridSlice()).getKeys(); Grid2DByte grid1 = ((DiscreteGridSlice) grids[k] .getGridSlice()).getDiscreteGrid(); - DiscreteKey dkv = key1[grid1.get(i, j)]; + DiscreteKey dkv = key1[0xFF & grid1.get(i, j)]; String dks = dkv.toString(); // add it to the dictionary Integer count = values.get(dks); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/interpolation/DiscreteInterp.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/interpolation/DiscreteInterp.java index 3f279aacca..d197e250ba 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/interpolation/DiscreteInterp.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/interpolation/DiscreteInterp.java @@ -121,10 +121,11 @@ import com.raytheon.viz.gfe.Activator; * *
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * Jun 2, 2008		#1161	randerso	Initial creation
- * Oct 31, 2013     #2508   randerso    Change to use DiscreteGridSlice.getKeys()
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun  2, 2008  #1161     randerso    Initial creation
+ * Oct 31, 2013  #2508     randerso    Change to use DiscreteGridSlice.getKeys()
+ * Apr 04, 2016  #5539     randerso    Fix unsigned byte issues
  * 
  * 
* @@ -479,7 +480,7 @@ public class DiscreteInterp extends Interp { // input byte index grids, but with values for the weatherKeys // in _allKeys. - byte index; + int index; DiscreteKey key; // For every grid point in the grids, load the new working grids @@ -488,7 +489,7 @@ public class DiscreteInterp extends Interp { for (i = 0; i < _xDim; i++) { for (j = 0; j < _yDim; j++) { // get the index value from the actual first input grid of bytes - index = grid1.get(i, j); + index = 0xFF & grid1.get(i, j); // Can save a lot of processing here if index=0 // ALWAYS means "no weather": the workGrid1 and 2 values @@ -508,7 +509,7 @@ public class DiscreteInterp extends Interp { // get the index value from the actual second input grid of // bytes - index = grid2.get(i, j); + index = 0xFF & grid2.get(i, j); // get its key key = keys2[index]; // find this key in the new list, and save the corresponding diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/ifpAG/ASCIIGrid.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/ifpAG/ASCIIGrid.java index 90c300cd9f..c10314e9eb 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/ifpAG/ASCIIGrid.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/ifpAG/ASCIIGrid.java @@ -75,12 +75,13 @@ import com.vividsolutions.jts.geom.Coordinate; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Apr 13, 2011 #8393 dgilling Initial creation - * 02/19/13 #1637 randerso Added exception handling for Discrete and Weather - * 10/31/2013 #2508 randerso Change to use DiscreteGridSlice.getKeys() - * 04/22/2014 #3050 randerso Allow exceptions to propagate to caller from readASCIIGridData - * Jan 14, 2016 #5237 tgurney Allow outputAsciiGridData to take - * OutputStream as well as File + * Apr 13, 2011 #8393 dgilling Initial creation + * 02/19/13 #1637 randerso Added exception handling for Discrete and Weather + * 10/31/2013 #2508 randerso Change to use DiscreteGridSlice.getKeys() + * 04/22/2014 #3050 randerso Allow exceptions to propagate to caller from readASCIIGridData + * 01/14/2016 #5237 tgurney Allow outputAsciiGridData to take + * OutputStream as well as File + * 04/04/2016 #5539 randerso Fixed unsigned byte issues * * * @@ -341,7 +342,7 @@ public class ASCIIGrid { WeatherGridSlice weather = (WeatherGridSlice) gs; for (int i = weather.getWeatherGrid().getYdim() - 1; i >= 0; i--) { for (int j = 0; j < weather.getWeatherGrid().getXdim(); j++) { - String key = weather.getKeys()[weather + String key = weather.getKeys()[0xFF & weather .getWeatherGrid().get(j, i)].toString(); printStream.println(key); } @@ -352,7 +353,7 @@ public class ASCIIGrid { for (int i = discrete.getDiscreteGrid().getYdim() - 1; i >= 0; i--) { for (int j = 0; j < discrete.getDiscreteGrid() .getXdim(); j++) { - String key = discrete.getKeys()[discrete + String key = discrete.getKeys()[0xFF & discrete .getDiscreteGrid().get(j, i)].toString(); printStream.println(key); } diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/GetPointDataHandler.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/GetPointDataHandler.java index f0b6568ab3..881c6774e6 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/GetPointDataHandler.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/GetPointDataHandler.java @@ -35,8 +35,8 @@ import javax.measure.unit.Unit; import com.raytheon.edex.plugin.gfe.server.IFPServer; import com.raytheon.edex.plugin.gfe.server.database.GridDatabase; import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; -import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo.GridType; import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation; +import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo.GridType; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; import com.raytheon.uf.common.dataplugin.gfe.point.GFEPointDataContainer; import com.raytheon.uf.common.dataplugin.gfe.point.GFEPointDataContainers; @@ -70,6 +70,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Jun 13, 2013 #2044 randerso Refactored to use IFPServer * Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys() * Apr 23, 2014 #3006 randerso Restructured code to work with multi-hour grids + * Apr 04, 2016 #5539 randerso Fixed unsigned byte issues * * * @@ -209,7 +210,7 @@ public class GetPointDataHandler extends BaseGfeRequestHandler implements byte discreteValue = discreteSlice .getDiscreteGrid().get(x, y); String discreteKey = discreteSlice - .getKeys()[discreteValue] + .getKeys()[0xFF & discreteValue] .toString(); type = Type.STRING; view.setData(param, type, unit, discreteKey); @@ -218,7 +219,7 @@ public class GetPointDataHandler extends BaseGfeRequestHandler implements WeatherGridSlice weatherSlice = (WeatherGridSlice) slice; byte wxValue = weatherSlice .getWeatherGrid().get(x, y); - String wxKey = weatherSlice.getKeys()[wxValue] + String wxKey = weatherSlice.getKeys()[0xFF & wxValue] .toString(); type = Type.STRING; view.setData(param, type, unit, wxKey); diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/ifpnetCDF.py b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/ifpnetCDF.py index d01ea1a26e..a2620efc39 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/ifpnetCDF.py +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/ifpnetCDF.py @@ -41,6 +41,8 @@ # 05/13/2015 4427 dgilling Add siteIdOverride field. # 08/06/2015 4718 dgilling Optimize casting when using where with # NumPy 1.9. +# 04/07/2016 5539 randerso Reversed order of parameters/return value in collapseKey +# to match order of Wx/Discrete tuple # ## @@ -924,21 +926,20 @@ def storeVectorWE(we, trList, file, timeRange, ###-------------------------------------------------------------------------### # Collapse key and bytes. (for discrete and weather) -### Returns tuple of (updated key, updated grid) -def collapseKey(keys, grid): +### Returns tuple of (updated grid, updated key) +def collapseKey(grid, keys): #make list of unique indexes in the grid flatGrid = grid.flat - used = [] + used = numpy.zeros((len(keys)), dtype=numpy.bool) for n in range(flatGrid.__array__().shape[0]): - if flatGrid[n] not in used: - used.append(flatGrid[n]) + used[0xFF & flatGrid[n]] = True #make reverse map map = [] newKeys = [] j = 0 for i in range(len(keys)): - if i in used: + if used[i]: map.append(j) newKeys.append(keys[i]) j = j + 1 @@ -948,10 +949,10 @@ def collapseKey(keys, grid): # modify the data newGrid = grid for k in range(len(map)): - mask = numpy.equal(k, grid) + mask = numpy.equal(numpy.int8(k), grid) newGrid = numpy.where(mask, numpy.int8(map[k]), newGrid).astype(numpy.int8) - return (newKeys, newGrid) + return (newGrid, newKeys) ###-------------------------------------------------------------------------### # Stores the specified Weather WE in the netCDF file whose grids fall within @@ -987,7 +988,7 @@ def storeWeatherWE(we, trList, file, timeRange, databaseID, invMask, clipArea, s # Process the weather keys so we store only what is necessary for g in range(byteCube.shape[0]): - (keyList[g], byteCube[g]) = collapseKey(keyList[g], byteCube[g]) + (byteCube[g], keyList[g]) = collapseKey(byteCube[g], keyList[g]) # Mask the values fillValue = -127 @@ -1072,7 +1073,7 @@ def storeDiscreteWE(we, trList, file, timeRange, databaseID, invMask, clipArea, # Process the discrete keys so we store only what is necessary for g in range(byteCube.shape[0]): - (keyList[g], byteCube[g]) = collapseKey(keyList[g], byteCube[g]) + (byteCube[g], keyList[g]) = collapseKey(byteCube[g], keyList[g]) # Mask the values fillValue = -127 diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/mergeGrid.py b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/mergeGrid.py index 6ddf7a8b9b..031c9f0664 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/mergeGrid.py +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/isc/mergeGrid.py @@ -39,7 +39,7 @@ import LogStream, fcntl # 11/05/13 2517 randerso Improve memory utilization # 08/06/2015 4718 dgilling Optimize casting when using where with # NumPy 1.9. -# +# 04/07/2016 5539 randerso Fixed issues with Wx/Discretes with large number of keys # # @@ -79,6 +79,9 @@ class MergeGrid: index = keyMap.index(key) return index except: + if (len(keyMap) >= 256): + raise IndexError("Attempt to create more than 256 Wx keys") + keyMap.append(key) return len(keyMap) - 1 @@ -186,6 +189,36 @@ class MergeGrid: return (magGrid, dirGrid) + ###-------------------------------------------------------------------------### + # Collapse key and bytes. (for discrete and weather) + ### Returns tuple of (updated grid, updated key) + def __collapseKey(self, grid, keys): + #make list of unique indexes in the grid + flatGrid = grid.flat + used = numpy.zeros((len(keys)), dtype=numpy.bool) + for n in range(flatGrid.__array__().shape[0]): + used[0xFF & flatGrid[n]] = True + + #make reverse map + map = [] + newKeys = [] + j = 0 + for i in range(len(keys)): + if used[i]: + map.append(j) + newKeys.append(keys[i]) + j = j + 1 + else: + map.append(-1) + + # modify the data + newGrid = grid + for k in range(len(map)): + mask = numpy.equal(numpy.int8(k), grid) + newGrid = numpy.where(mask, numpy.int8(map[k]), newGrid).astype(numpy.int8) + + return (newGrid, newKeys) + #--------------------------------------------------------------------- # merge weather grid # @@ -208,6 +241,11 @@ class MergeGrid: noWxGrid = numpy.empty_like(gridA[0]) noWxGrid.fill(self.__findKey(noWx, noWxKeys)) gridB = (noWxGrid, noWxKeys) + else: + # clear out the masked area in gridB and collapse gridB's keys + grid, keys = gridB + grid[mask]= self.__findKey(noWx, keys) + gridB = self.__collapseKey(grid, keys) (commonkey, remapG, dbG) = self.__commonizeKey(gridA, gridB) mergedGrid = numpy.where(mask, remapG, dbG) return (mergedGrid, commonkey) @@ -242,6 +280,11 @@ class MergeGrid: noGrid = numpy.empty_like(gridA[0]) noGrid.fill(self.__findKey(noKey, noKeys)) gridB = (noGrid, noKeys) + else: + # clear out the masked area in gridB and collapse gridB's keys + grid, keys = gridB + grid[mask] = self.__findKey(noKey, keys) + gridB = self.__collapseKey(grid, keys) (commonkey, remapG, dbG) = \ self.__commonizeKey(gridA, gridB) diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/grid/Grid2DByte.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/grid/Grid2DByte.java index 567a702292..53b5a3e4ed 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/grid/Grid2DByte.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/grid/Grid2DByte.java @@ -42,6 +42,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Oct 22, 2008 1624 wdougherty Speed up translate method * Sep 01, 2014 3572 randerso Changed getNumpy to use getBytes() * Apr 23, 2015 4259 njensen Updated for new JEP API + * Apr 04, 2016 5539 randerso Fixed toString method to handle unsigned bytes * * * @@ -103,7 +104,7 @@ public class Grid2DByte implements IGrid2D, Cloneable { */ public Grid2DByte(int xDim, int yDim, byte[] data) { this(xDim, yDim); - if (xDim * yDim != data.length) { + if ((xDim * yDim) != data.length) { throw new IllegalArgumentException( "Dimensions do not match data length (" + xDim + "," + yDim + ") " + data.length); @@ -122,7 +123,7 @@ public class Grid2DByte implements IGrid2D, Cloneable { * ByteBuffer of initialization data */ public Grid2DByte(int xDim, int yDim, ByteBuffer data) { - if (xDim * yDim != data.limit()) { + if ((xDim * yDim) != data.limit()) { throw new IllegalArgumentException( "Dimensions do not match data length (" + xDim + "," + yDim + ") " + data.limit()); @@ -165,7 +166,7 @@ public class Grid2DByte implements IGrid2D, Cloneable { if (!isValid(xDim, yDim)) { throw new IllegalArgumentException("Dimensions not valid"); } - return buffer.get(yDim * this.xdim + xDim); + return buffer.get((yDim * this.xdim) + xDim); } /** @@ -180,7 +181,7 @@ public class Grid2DByte implements IGrid2D, Cloneable { if (!isValid(xDim, yDim)) { throw new IllegalArgumentException("Dimensions not valid"); } - buffer.put(yDim * this.xdim + xDim, aValue); + buffer.put((yDim * this.xdim) + xDim, aValue); } public void set(int xDim, int yDim, int aValue) { @@ -205,7 +206,7 @@ public class Grid2DByte implements IGrid2D, Cloneable { @Override public boolean isValid(int x, int y) { - return (x < xdim && y < ydim && x >= 0 && y >= 0); + return ((x < xdim) && (y < ydim) && (x >= 0) && (y >= 0)); } /** @@ -224,7 +225,7 @@ public class Grid2DByte implements IGrid2D, Cloneable { * y coordinate to clear */ public void clear(int x, int y) { - buffer.put(y * xdim + x, (byte) 0); + buffer.put((y * xdim) + x, (byte) 0); } /** @@ -241,7 +242,7 @@ public class Grid2DByte implements IGrid2D, Cloneable { // make another Grid2DByte Grid2DByte rVal = new Grid2DByte(this.xdim, this.ydim, (byte) 0); - if (Math.abs(deltaCoord.x) < xdim && Math.abs(deltaCoord.y) < ydim) { + if ((Math.abs(deltaCoord.x) < xdim) && (Math.abs(deltaCoord.y) < ydim)) { // Find iteration limits for X int fromXStart; int toXStart; @@ -275,8 +276,8 @@ public class Grid2DByte implements IGrid2D, Cloneable { byte[] toA = rVal.getBuffer().array(); // Calculate from/to array offsets of the first point. - int fromOffset = fromYStart * xdim + fromXStart; - int toOffset = toYStart * xdim + toXStart; + int fromOffset = (fromYStart * xdim) + fromXStart; + int toOffset = (toYStart * xdim) + toXStart; // For each row, copy cols bytes of data. // Then update offsets for next row. @@ -328,9 +329,9 @@ public class Grid2DByte implements IGrid2D, Cloneable { @Override public Grid2DByte subGrid(int minX, int minY, int maxX, int maxY) { - Grid2DByte rVal = new Grid2DByte(maxX + 1 - minX, maxY + 1 - minY); - for (int y = minY; y < maxY + 1; y++) { - for (int x = minX; x < maxX + 1; x++) { + Grid2DByte rVal = new Grid2DByte((maxX + 1) - minX, (maxY + 1) - minY); + for (int y = minY; y < (maxY + 1); y++) { + for (int x = minX; x < (maxX + 1); x++) { rVal.buffer.put(this.get(x, y)); } } @@ -345,7 +346,8 @@ public class Grid2DByte implements IGrid2D, Cloneable { Grid2DByte rhsGrid2DByte = (Grid2DByte) rhs; - if (this.xdim != rhsGrid2DByte.xdim || this.ydim != rhsGrid2DByte.ydim) { + if ((this.xdim != rhsGrid2DByte.xdim) + || (this.ydim != rhsGrid2DByte.ydim)) { return false; } @@ -374,9 +376,10 @@ public class Grid2DByte implements IGrid2D, Cloneable { Grid2DByte sourceGrid2DByte = (Grid2DByte) sourceGrid; - if (this.xdim != sourceGrid2DByte.xdim || this.xdim != maskGrid.xdim - || this.ydim != sourceGrid2DByte.ydim - || this.ydim != maskGrid.ydim) { + if ((this.xdim != sourceGrid2DByte.xdim) + || (this.xdim != maskGrid.xdim) + || (this.ydim != sourceGrid2DByte.ydim) + || (this.ydim != maskGrid.ydim)) { throw new IllegalArgumentException( "This grid, the input grid, and the input mask grid must have equal dimensions"); } @@ -407,7 +410,7 @@ public class Grid2DByte implements IGrid2D, Cloneable { rVal += xdim + "X" + ydim + "\n[\n"; for (int y = 0; y < ydim; y++) { for (int x = 0; x < xdim; x++) { - rVal += this.get(x, y) + (x + 1 == xdim ? "" : ","); + rVal += (0xFF & this.get(x, y)) + ((x + 1) == xdim ? "" : ","); } rVal += "\n"; } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/WeatherGridSlice.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/WeatherGridSlice.java index f531e35b81..6e0fa5bdd7 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/WeatherGridSlice.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/WeatherGridSlice.java @@ -53,13 +53,14 @@ import com.raytheon.uf.common.time.TimeRange; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 15, 2011 randerso Initial creation - * Jan 30, 2013 15719 jdynina Allowed more than 128 char wx string - * Aug 13, 2013 1571 randerso Removed toString to stop it from hanging the - * debugger when trying to display the grid - * Oct 29, 2013 2476 njensen Updated getNumpy() and added getKeyList() - * Apr 23, 2015 4259 njensen Updated for new JEP API - * Nov 03, 2015 5061 randerso Fixed null pointer in equals() + * Mar 15, 2011 randerso Initial creation + * Jan 30, 2013 15719 jdynina Allowed more than 128 char wx string + * Aug 13, 2013 1571 randerso Removed toString to stop it from hanging the + * debugger when trying to display the grid + * Oct 29, 2013 2476 njensen Updated getNumpy() and added getKeyList() + * Apr 23, 2015 4259 njensen Updated for new JEP API + * Nov 03, 2015 5061 randerso Fixed null pointer in equals() + * Apr 05, 2016 5539 randerso Cleaned up collapse method * * * @@ -645,63 +646,81 @@ public class WeatherGridSlice extends AbstractGridSlice { return; } - // make a histogram, indicating what is and what isn't - // used in the weather keys - boolean[] used = new boolean[keys.length]; - int[] invMapping = new int[keys.length]; - for (int i = 0; i < used.length; i++) { - invMapping[i] = i; - used[i] = false; - } - - // process the grid - for (int i = 0; i < weatherGrid.getXdim(); i++) { - for (int j = 0; j < weatherGrid.getYdim(); j++) { - used[0xFF & weatherGrid.get(i, j)] = true; - } - } // indicate used - - // clear the invmapping if not used - for (int i = 0; i < used.length; i++) { - if (!used[i]) { - invMapping[i] = -1; - } - } - - // eliminate duplicate keys - int nk = 0; - List tmpKeys = new ArrayList(); - for (int i = 0; i < used.length; i++) { - if (used[i]) { - tmpKeys.add(keys[i]); - invMapping[i] = nk; - for (int j = i + 1; j < used.length; j++) { - if (keys[i].equals(keys[j])) { - invMapping[j] = nk; // key index - used[j] = false; // to prevent reprocessing - } + try { + int max = 0; + for (byte b : weatherGrid.getBytes()) { + int unsigned = 0xFF & b; + if (unsigned > max) { + max = unsigned; } - nk++; } - } - WeatherKey[] newKeys = tmpKeys.toArray(new WeatherKey[tmpKeys.size()]); - // anything to do? - if (Arrays.equals(newKeys, keys)) { - return; - } - - // now remap the data - for (int i = 0; i < weatherGrid.getXdim(); i++) { - for (int j = 0; j < weatherGrid.getYdim(); j++) { - weatherGrid.set(i, j, - (byte) invMapping[0xFF & weatherGrid.get(i, j)]); + if (max >= keys.length) { + throw new IndexOutOfBoundsException("Grid contains index (" + + max + ") > keys.length (" + keys.length + ")"); } - } - // store the grid - setWeatherGrid(weatherGrid); - keys = newKeys; + // make a histogram, indicating what is and what isn't + // used in the weather keys + boolean[] used = new boolean[keys.length]; + int[] invMapping = new int[keys.length]; + for (int i = 0; i < used.length; i++) { + invMapping[i] = i; + used[i] = false; + } + + // process the grid + for (int i = 0; i < weatherGrid.getXdim(); i++) { + for (int j = 0; j < weatherGrid.getYdim(); j++) { + used[0xFF & weatherGrid.get(i, j)] = true; // indicate used + } + } + + // clear the invmapping if not used + for (int i = 0; i < used.length; i++) { + if (!used[i]) { + invMapping[i] = -1; + } + } + + // eliminate duplicate keys + int nk = 0; + List tmpKeys = new ArrayList(); + for (int i = 0; i < used.length; i++) { + if (used[i]) { + tmpKeys.add(keys[i]); + invMapping[i] = nk; + for (int j = i + 1; j < used.length; j++) { + if (keys[i].equals(keys[j])) { + invMapping[j] = nk; // key index + used[j] = false; // to prevent reprocessing + } + } + nk++; + } + } + WeatherKey[] newKeys = tmpKeys.toArray(new WeatherKey[tmpKeys + .size()]); + + // anything to do? + if (Arrays.equals(newKeys, keys)) { + return; + } + + // now remap the data + for (int i = 0; i < weatherGrid.getXdim(); i++) { + for (int j = 0; j < weatherGrid.getYdim(); j++) { + weatherGrid.set(i, j, + (byte) invMapping[0xFF & weatherGrid.get(i, j)]); + } + } + // store the grid + setWeatherGrid(weatherGrid); + keys = newKeys; + } catch (IndexOutOfBoundsException e) { + statusHandler.error(e.getLocalizedMessage(), e); + throw e; + } } @Override From 495b45f62883669a6707fb777a35655e71eed439 Mon Sep 17 00:00:00 2001 From: David Gillingham Date: Thu, 14 Apr 2016 13:43:29 -0500 Subject: [PATCH 8/8] Omaha #5578 - Ensure GFE text formatter varDict GUI always pop up before formatter executes. Change-Id: I3090623b98ebb75fd5288cfb44a73a8abbad50e3 Former-commit-id: a2d5522c3aca41ed5366db533e81993102a3cd66 --- .../formatterlauncher/ProductAreaComp.java | 49 ++++++----- .../viz/gfe/textformatter/FormatterUtil.java | 67 ++++++++++----- .../viz/gfe/textformatter/TextFormatter.java | 34 +------- .../gfe/textformatter/TextProductManager.java | 35 ++++++++ .../TextProductVarDictExecutor.java | 82 +++++++++++++++++++ 5 files changed, 196 insertions(+), 71 deletions(-) create mode 100644 cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextProductVarDictExecutor.java diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/ProductAreaComp.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/ProductAreaComp.java index 624450c8c4..f0bddd7200 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/ProductAreaComp.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/ProductAreaComp.java @@ -35,9 +35,9 @@ import org.eclipse.swt.widgets.ProgressBar; import org.eclipse.swt.widgets.TabFolder; import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; -import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.viz.core.VizApp; import com.raytheon.viz.gfe.Activator; import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.dialogs.FormatterLauncherDialog; @@ -47,7 +47,6 @@ import com.raytheon.viz.gfe.tasks.TaskManager; import com.raytheon.viz.gfe.textformatter.FormatterUtil; import com.raytheon.viz.gfe.textformatter.TextProductFinishListener; import com.raytheon.viz.gfe.textformatter.TextProductManager; -import com.raytheon.viz.ui.simulatedtime.SimulatedTimeProhibitedOpException; /** * Composite containing the product area and its controls. @@ -62,7 +61,7 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeProhibitedOpException; * 2 SEP 2011 10654 gzhou Delete running/pending task and close tab. * 23 MAY 2012 14859 ryu Select VTEC formatting in practice mode * based on VTECMessageType setting. - * 10 AUG 2012 15178 mli Add autoWrite and autoStore capability + * 10 AUG 2012 15178 mli Add autoWrite and autoStore capability * 26 SEP 2012 15423 ryu Fix product correction in practice mode * 15 MAY 2013 1842 dgilling Change constructor signature to accept a * DataManager instance. @@ -79,7 +78,8 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeProhibitedOpException; * based on the pil of the product rather than the disply name. * 18 FEB 2016 13033 yteng Improve error message for bad characters in text formatter * definitions. - * + * 14 APR 2016 5578 dgilling Support changes to FormatterUtil.runFormatterScript. + * * * * @author lvenable @@ -399,28 +399,29 @@ public class ProductAreaComp extends Composite implements String pil = ""; try { pil = (String) textProductMgr - .getDefinitionValue(productName, "pil"); + .getDefinitionValue(productName, + "pil"); } catch (ClassCastException e) { - statusHandler.error("Invalid pil value: " - + textProductMgr - .getDefinitionValue(productName, "pil"), e); + statusHandler.error( + "Invalid pil value: " + + textProductMgr + .getDefinitionValue( + productName, + "pil"), e); } if (pil != null) { pil = pil.substring(0, 3); - vtecMode = textProductMgr.getVtecMessageType(pil); + vtecMode = textProductMgr + .getVtecMessageType(pil); } } // Get the source database zoneCombiner.applyZoneCombo(); - try { - FormatterUtil.runFormatterScript(dataMgr, - textProductMgr, productName, - dbId.toString(), vtecMode, - ProductAreaComp.this); - } catch (SimulatedTimeProhibitedOpException e) { - statusHandler.error(e.getLocalizedMessage(), e); - } + FormatterUtil.runFormatterScript(dataMgr, + textProductMgr, productName, + dbId.toString(), vtecMode, + ProductAreaComp.this); } } } @@ -663,8 +664,18 @@ public class ProductAreaComp extends Composite implements } @Override - public void textProductQueued(ConfigData.ProductStateEnum state) { - productTabCB.setTabState(state, productName); + public void textProductQueued(final ConfigData.ProductStateEnum state) { + if (isTabClosed) { + return; + } + + VizApp.runSyncIfWorkbench(new Runnable() { + + @Override + public void run() { + productTabCB.setTabState(state, productName); + } + }); } @Override diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/FormatterUtil.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/FormatterUtil.java index 1b90fc4112..e1313bc711 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/FormatterUtil.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/FormatterUtil.java @@ -23,7 +23,14 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.TimeZone; +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 com.raytheon.uf.common.activetable.ActiveTableMode; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.time.SimulatedTime; import com.raytheon.uf.common.time.TimeRange; import com.raytheon.viz.core.mode.CAVEMode; @@ -52,6 +59,8 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeProhibitedOpException; * Aug 26, 2015 4804 dgilling Add methods so SmartScript can run formatters. * Sep 15, 2015 4858 dgilling Disable store/transmit in DRT mode. * Oct 01, 2015 4888 dgilling Fix javadoc for exceptions. + * Apr 14, 2016 5578 dgilling Ensure formatters launched interactively + * ask for varDict before execution. * * * @@ -61,6 +70,9 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeProhibitedOpException; public class FormatterUtil { + private static final IUFStatusHandler statusHandler = UFStatus + .getHandler(FormatterUtil.class); + public static final String[] VTEC_MODES = { "Normal: NoVTEC", "Normal: O-Vtec", "Normal: E-Vtec", "Normal: X-Vtec", "Test: NoVTEC", "Test: T-Vtec" }; @@ -85,20 +97,43 @@ public class FormatterUtil { * VTEC mode * @param finish * listener to fire when formatter finishes generating product - * @throws SimulatedTimeProhibitedOperationException + * */ - public static void runFormatterScript(DataManager dataMgr, - TextProductManager productMgr, String productName, String dbId, - String vtecMode, TextProductFinishListener finish) - throws SimulatedTimeProhibitedOpException { - String activeTable = getActiveTableName(dataMgr); - int testMode = getTestMode(dataMgr, vtecMode); - String shortVtec = getVTECModeCode(vtecMode); - String name = productMgr.getModuleName(productName); - String time = getDRTString(); + public static void runFormatterScript(final DataManager dataMgr, + final TextProductManager productMgr, final String productName, + final String dbId, final String vtecMode, + final TextProductFinishListener finish) { + /* + * we wrap this inside an eclipse Job so that we aren't blocking the UI + * thread by waiting for the varDict result. Waiting on the varDict on + * the UI thread would cause a deadlock because ValuesDialog requires + * use of VizApp.runAsync. + */ + Job runFormatterJob = new Job("Running product formatter") { - runFormatterScript(name, shortVtec, dbId, activeTable, time, testMode, - finish, dataMgr); + @Override + protected IStatus run(IProgressMonitor monitor) { + String activeTable = getActiveTableName(dataMgr); + int testMode = getTestMode(dataMgr, vtecMode); + String shortVtec = getVTECModeCode(vtecMode); + String name = productMgr.getModuleName(productName); + String time = getDRTString(); + String varDict = dataMgr.getTextProductMgr().obtainVarDictSelections(name, + dataMgr, dbId); + + try { + runFormatterScript(name, shortVtec, dbId, varDict, + activeTable, time, testMode, finish, dataMgr); + } catch (Exception e) { + statusHandler.error(String.format( + "Error running text formatter %s", productName), e); + } + + return Status.OK_STATUS; + } + }; + runFormatterJob.setSystem(true); + runFormatterJob.schedule(); } /** @@ -134,14 +169,6 @@ public class FormatterUtil { testMode, listener, dataMgr); } - public static void runFormatterScript(String name, String vtecMode, - String databaseID, String vtecActiveTable, String drtTime, - int testMode, TextProductFinishListener finish, DataManager dataMgr) - throws SimulatedTimeProhibitedOpException { - runFormatterScript(name, vtecMode, databaseID, null, vtecActiveTable, - drtTime, testMode, finish, dataMgr); - } - public static void runFormatterScript(String name, String vtecMode, String databaseID, String varDict, String vtecActiveTable, String drtTime, int testMode, TextProductFinishListener finish, diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextFormatter.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextFormatter.java index 0fd4e97e0a..6295b26ed9 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextFormatter.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextFormatter.java @@ -25,10 +25,6 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; -import jep.JepException; - -import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; -import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil; import com.raytheon.uf.common.status.IPerformanceStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.PerformanceStatus; @@ -37,7 +33,6 @@ import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.SimulatedTime; 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.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.dialogs.formatterlauncher.ConfigData; import com.raytheon.viz.gfe.dialogs.formatterlauncher.ConfigData.ProductStateEnum; @@ -65,6 +60,7 @@ import com.raytheon.viz.gfe.tasks.AbstractGfeTask; * Aug 26, 2015 #4804 dgilling Support ability to run TextFormatters * from SmartScript. * Dec 08, 2015 #5129 dgilling Pass IFPClient to getVarDict. + * Apr 14, 2016 #5578 dgilling Remove getVarDict. * * * @@ -166,9 +162,7 @@ public class TextFormatter extends AbstractGfeTask { argMap.put(ArgDictConstants.VTEC_MODE, vtecMode); argMap.put(ArgDictConstants.VTEC_ACTIVE_TABLE, vtecActiveTable); argMap.put("drtTime", drtTime); - if (!StringUtil.isEmptyString(varDict)) { - argMap.put(ArgDictConstants.CMDLINE_VARDICT, varDict); - } + argMap.put(ArgDictConstants.CMDLINE_VARDICT, varDict); listener = finish; this.state = ConfigData.ProductStateEnum.Queued; @@ -187,14 +181,6 @@ public class TextFormatter extends AbstractGfeTask { String productName = (String) argMap .get(ArgDictConstants.FORECAST_LIST); - String issuedBy = dataMgr.getTextProductMgr().getIssuedBy(); - String dbId = (String) argMap.get(ArgDictConstants.DATABASE_ID); - - if (!argMap.containsKey(ArgDictConstants.CMDLINE_VARDICT)) { - String varDict = getVarDict(productName, dataMgr, dbId, - issuedBy, script); - argMap.put(ArgDictConstants.CMDLINE_VARDICT, varDict); - } String varDict = (String) argMap .get(ArgDictConstants.CMDLINE_VARDICT); @@ -282,22 +268,6 @@ public class TextFormatter extends AbstractGfeTask { return sb.toString(); } - private String getVarDict(String productName, DataManager dataManager, - String dbId, String issuedBy, FormatterScript script) - throws JepException { - Map map = new HashMap(5, 1f); - map.put("paths", GfePyIncludeUtil.getTextProductsIncludePath()); - map.put("dspName", - dataManager.getTextProductMgr().getDisplayName(productName)); - map.put("dataMgr", dataManager); - map.put("ifpClient", dataManager.getClient().getPythonClient()); - map.put("issuedBy", issuedBy); - map.put("dataSource", new DatabaseID(dbId).getModelName()); - - String varDict = (String) script.execute("getVarDict", map); - return varDict; - } - @Override public void cleanUp() { super.cleanUp(); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextProductManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextProductManager.java index a6c422211a..809a63cb6b 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextProductManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextProductManager.java @@ -42,6 +42,7 @@ import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.core.localization.LocalizationManager; +import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.core.IAsyncStartupObjectListener; /** @@ -62,6 +63,7 @@ import com.raytheon.viz.gfe.core.IAsyncStartupObjectListener; * Jul 30, 2015 4263 dgilling Major refactor so this object can be initialized off * UI thread. * Dec 14, 2015 4816 dgilling Support refactored PythonJobCoordinator API. + * Apr 14, 2016 5578 dgilling Add getVarDict. * * * @@ -263,6 +265,39 @@ public class TextProductManager implements ILocalizationFileObserver { return productDef; } + /** + * Returns the varDict for the given text formatter. In GFE, the varDict is + * a Map (or dict) containing the user's selections from an optional popup + * dialog that can appear before executing a formatter. + *

+ * To retrieve the varDict this will require a call into Jep (specifically + * FormatterRunner.py's getVarDict method) to retrieve the varDict. + * Depending on whether or not the formatter script defines the global + * variable variableList, this may cause an instance of ValuesDialog to + * display. + *

+ * Do NOT call this function from the UI thread of CAVE or it will deadlock + * the application. + * + * @param productName + * @param dataManager + * @param dbId + * @return + */ + public String obtainVarDictSelections(String productName, DataManager dataManager, + String dbId) { + String varDict = null; + try { + varDict = jobCoordinator.submitJob( + new TextProductVarDictExecutor(getDisplayName(productName), + dataManager, issuedBy, dbId)).get(); + } catch (Exception e) { + statusHandler.error(String.format( + "Error retrieving varDict for product %s", productName), e); + } + return varDict; + } + public String getVtecMessageType(String productCategory) { String vtec = productDefaultVtecCoding.get(productCategory); if (vtec == null) { diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextProductVarDictExecutor.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextProductVarDictExecutor.java new file mode 100644 index 0000000000..d0ad0ad118 --- /dev/null +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextProductVarDictExecutor.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.viz.gfe.textformatter; + +import java.util.HashMap; +import java.util.Map; + +import jep.JepException; + +import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; +import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil; +import com.raytheon.uf.common.python.concurrent.IPythonExecutor; +import com.raytheon.viz.gfe.core.DataManager; + +/** + * Executor object to get the user's selections from the formatter's + * ValuesDialog. + * + *

+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 14, 2016  #5578     dgilling     Initial creation
+ * 
+ * 
+ * + * @author dgilling + * @version 1.0 + */ + +public final class TextProductVarDictExecutor implements + IPythonExecutor { + + private final String displayName; + + private final DataManager dataMgr; + + private final String issuedBy; + + private final DatabaseID dbID; + + public TextProductVarDictExecutor(String displayName, DataManager dataMgr, + String issuedBy, String dbID) { + this.displayName = displayName; + this.dataMgr = dataMgr; + this.issuedBy = issuedBy; + this.dbID = new DatabaseID(dbID); + } + + @Override + public String execute(FormatterScript script) throws JepException { + Map map = new HashMap(5, 1f); + map.put("paths", GfePyIncludeUtil.getTextProductsIncludePath()); + map.put("dspName", displayName); + map.put("dataMgr", dataMgr); + map.put("ifpClient", dataMgr.getClient().getPythonClient()); + map.put("issuedBy", issuedBy); + map.put("dataSource", dbID.getModelName()); + + String varDict = (String) script.execute("getVarDict", map); + return varDict; + } +}