From 3ad2195c50fbd2e533515554f7f4c1d3d82331ca Mon Sep 17 00:00:00 2001 From: Brad Gonzales Date: Fri, 18 Oct 2013 17:46:04 -0500 Subject: [PATCH 01/15] Issue #2267 Refactored SbnSimulator into the sbnSimulator that runs on the wfo boxes and a centralSbnSimulator that runs on the centralRegistry box. Amend: Added excludes to sbnSimulator modes. Updated FileUtil.listPaths to close the stream and use a LinkedList. Added additional logging to SbnSimulator. Change-Id: I89ff7d4afdd18ba51b8fd4812bb0b871ffc6d3af Former-commit-id: 5145ec3dfe9bc7990f75a4dab079149811c21bfc [formerly bd7e5d8940d286063ba7c91676827afe2016d5b0] [formerly 5145ec3dfe9bc7990f75a4dab079149811c21bfc [formerly bd7e5d8940d286063ba7c91676827afe2016d5b0] [formerly f7a635ebef6180bc478c2c9cc897542dafbb3620 [formerly f9e593974811896dec76c512c2a76b5769c7a68a]]] Former-commit-id: f7a635ebef6180bc478c2c9cc897542dafbb3620 Former-commit-id: 88a20aeae1478980801a222125c0f0daed264de8 [formerly c36cbae57773fd8f825a7976e50c81ac47feda1c] Former-commit-id: 9215426279ff47eb06a3372d84c35bb9dd1e7b2e --- edexOsgi/build.edex/esb/conf/modes.xml | 9 ++- .../com/raytheon/uf/common/util/FileUtil.java | 39 +++++++++++ .../uf/common/util/file/FilenameFilters.java | 36 ++++++++++- .../META-INF/MANIFEST.MF | 1 + .../res/spring/sbn-simulator-ncf.xml | 30 +++++++++ ...bn-simulator.xml => sbn-simulator-wfo.xml} | 0 .../bandwidth/sbn/SbnSimulator.java | 63 ++++++++++++++++-- .../bandwidth/sbn/SbnSimulatorTest.java | 64 +++++++++++++------ 8 files changed, 213 insertions(+), 29 deletions(-) create mode 100644 edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/res/spring/sbn-simulator-ncf.xml rename edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/res/spring/{sbn-simulator.xml => sbn-simulator-wfo.xml} (100%) diff --git a/edexOsgi/build.edex/esb/conf/modes.xml b/edexOsgi/build.edex/esb/conf/modes.xml index 456ea966f5..b78be04e4c 100644 --- a/edexOsgi/build.edex/esb/conf/modes.xml +++ b/edexOsgi/build.edex/esb/conf/modes.xml @@ -305,9 +305,16 @@ .*datadelivery-ncf.* - .*sbn-simulator.* + .*sbn-simulator-wfo.* event-common.xml eventbus-common.xml + .*sbn-simulator-ncf.* + + + .*sbn-simulator-ncf.* + event-common.xml + eventbus-common.xml + .*sbn-simulator-wfo.* grib-decode.xml diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java index f8def3954c..dedcb82118 100644 --- a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java @@ -31,7 +31,13 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.channels.FileChannel; +import java.nio.file.DirectoryStream; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; @@ -59,6 +65,7 @@ import java.util.zip.GZIPOutputStream; * Mar 11, 2013 1645 djohnson Added file modification watcher. * Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List. * May 16, 2013 1966 rferrel Add sizeOfDirectory and listDirFiles method. + * Oct 18, 2013 2267 bgonzale Add listPaths method. * * * @@ -925,4 +932,36 @@ public class FileUtil { return size; } + /** + * List files/directories that match a FileFilter. + * + * @param directory + * @param filter + * @param recurse + * @return + * @throws IOException + */ + public static List listPaths(File directory, + DirectoryStream.Filter filter, boolean recurse) + throws IOException { + // List of files / directories + List files = new LinkedList(); + + // Get files / directories in the directory accepted by the filter. + Path dirPath = FileSystems.getDefault().getPath( + directory.getAbsolutePath()); + DirectoryStream stream = null; + try { + stream = Files.newDirectoryStream(dirPath, filter); + for (final Iterator it = stream.iterator(); it.hasNext();) { + files.add(it.next()); + } + } finally { + if (stream != null) { + stream.close(); + } + } + return files; + } + } diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/file/FilenameFilters.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/file/FilenameFilters.java index 6aa5abac44..6b329459c8 100644 --- a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/file/FilenameFilters.java +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/file/FilenameFilters.java @@ -21,6 +21,10 @@ package com.raytheon.uf.common.util.file; import java.io.File; import java.io.FilenameFilter; +import java.io.IOException; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; /** * Consolidates common filename filters. @@ -32,6 +36,7 @@ import java.io.FilenameFilter; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Mar 14, 2013 1794 djohnson Initial creation + * Oct 18, 2013 2267 bgonzale Added Path filters. * * * @@ -154,7 +159,7 @@ public final class FilenameFilters { }; /** - * Accepts directories. + * Accepts files. */ public static final FilenameFilter ACCEPT_FILES = new FilenameFilter() { @Override @@ -162,6 +167,35 @@ public final class FilenameFilters { return new File(dir.getPath(), name).isFile(); } }; + + /** + * Accepts files. + */ + public static final FilenameFilter ACCEPT_VISIBLE_FILES = new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + File tmp = new File(dir.getPath(), name); + return tmp.isFile() && !tmp.isHidden(); + } + }; + + /** + * Accepts Path directories. + */ + public static final DirectoryStream.Filter ACCEPT_PATH_DIRECTORIES = new DirectoryStream.Filter() { + public boolean accept(Path path) throws IOException { + return (Files.isDirectory(path)); + } + }; + + /** + * Accepts Path files. + */ + public static final DirectoryStream.Filter ACCEPT_PATH_FILES = new DirectoryStream.Filter() { + public boolean accept(Path path) throws IOException { + return (Files.isRegularFile(path)); + } + }; /** * Returns a {@link FilenameFilter} that matches the specified file diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/META-INF/MANIFEST.MF index 34d0b4ebe8..123d1e0365 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/META-INF/MANIFEST.MF @@ -17,3 +17,4 @@ Require-Bundle: com.raytheon.uf.common.datadelivery.bandwidth;bundle-version="1. com.google.guava;bundle-version="1.0.0", com.raytheon.uf.edex.core;bundle-version="1.12.1174", com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0" +Import-Package: com.raytheon.edex.site diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/res/spring/sbn-simulator-ncf.xml b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/res/spring/sbn-simulator-ncf.xml new file mode 100644 index 0000000000..2697d372c8 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/res/spring/sbn-simulator-ncf.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + java.lang.Throwable + + + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/res/spring/sbn-simulator.xml b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/res/spring/sbn-simulator-wfo.xml similarity index 100% rename from edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/res/spring/sbn-simulator.xml rename to edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/res/spring/sbn-simulator-wfo.xml diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/src/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulator.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/src/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulator.java index 7f5c099f46..02b7017252 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/src/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulator.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/src/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulator.java @@ -21,9 +21,13 @@ package com.raytheon.uf.edex.datadelivery.bandwidth.sbn; import java.io.File; import java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.util.List; import com.google.common.annotations.VisibleForTesting; +import com.raytheon.edex.site.SiteUtil; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.util.FileUtil; @@ -41,6 +45,7 @@ import com.raytheon.uf.edex.core.EDEXUtil; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Mar 14, 2013 1648 djohnson Initial creation + * Oct 18, 2013 2267 bgonzale Added distribution to and check in site specific directories. * * * @@ -84,6 +89,10 @@ public class SbnSimulator { private final File directoryToScan; + private final File sitesDirectory; + + private final File localSiteDirectory; + private final IFileProcessor fileProcessor; /** @@ -91,7 +100,7 @@ public class SbnSimulator { */ public SbnSimulator() { this(new File(System.getProperty("sbn.retrieval.transfer.directory")), - new CopyFileToManualIngest()); + new CopyFileToManualIngest(), SiteUtil.getSite()); } /** @@ -100,9 +109,12 @@ public class SbnSimulator { * @param fileProcessor */ @VisibleForTesting - SbnSimulator(File scanDirectory, IFileProcessor fileProcessor) { + SbnSimulator(File scanDirectory, IFileProcessor fileProcessor, String site) { this.fileProcessor = fileProcessor; this.directoryToScan = scanDirectory; + this.sitesDirectory = new File(directoryToScan, "sbnSimulator"); + this.localSiteDirectory = new File(sitesDirectory, site); + this.localSiteDirectory.mkdirs(); } /** @@ -111,11 +123,11 @@ public class SbnSimulator { * @throws IOException */ public void checkForSbnData() throws IOException { - final List files = FileUtil.listFiles(directoryToScan, - FilenameFilters.ACCEPT_FILES, false); + final List files = FileUtil.listFiles(localSiteDirectory, + FilenameFilters.ACCEPT_VISIBLE_FILES, false); - statusHandler - .info("Found [" + files.size() + "] files from the SBN..."); + statusHandler.info("Found [" + files.size() + "] files for " + + SiteUtil.getSite() + " from the SBN..."); for (File file : files) { @@ -131,4 +143,43 @@ public class SbnSimulator { } } + /** + * Distribute to the site directories. Enables all site client registries to + * ingest shared data. + * + * @throws IOException + */ + public void distributeToSiteDirs() throws IOException { + final List undistributedFiles = FileUtil.listPaths( + directoryToScan, + FilenameFilters.ACCEPT_PATH_FILES, false); + // get list of site dirs + final List sites = FileUtil.listPaths(sitesDirectory, + FilenameFilters.ACCEPT_PATH_DIRECTORIES, false); + + statusHandler.info("Found [" + undistributedFiles.size() + "] files to distribute..."); + + // distribute to site specific directories + for (Path file : undistributedFiles) { + statusHandler.info("Distributing file [" + file + "]"); + for (Path siteDir : sites) { + Path dest = FileSystems.getDefault().getPath( + siteDir.toString(), file.getFileName().toString()); + Path hiddenDest = FileSystems.getDefault() + .getPath(siteDir.toString(), + "." + file.getFileName().toString()); + + // move to site sbn directory as hidden + java.nio.file.Files.copy(file, hiddenDest, + StandardCopyOption.REPLACE_EXISTING); + // rename dest to un-hidden + java.nio.file.Files.move(hiddenDest, dest, + StandardCopyOption.ATOMIC_MOVE); + statusHandler.info("===> to file [" + dest + "]"); + } + // delete source file + java.nio.file.Files.delete(file); + } + } + } diff --git a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulatorTest.java b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulatorTest.java index dd9234e02e..aa87aa0ccf 100644 --- a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulatorTest.java +++ b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulatorTest.java @@ -19,8 +19,6 @@ **/ package com.raytheon.uf.edex.datadelivery.bandwidth.sbn; -import static com.raytheon.uf.common.util.Matchers.hasNoFiles; -import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; @@ -31,10 +29,13 @@ import static org.mockito.Mockito.verifyZeroInteractions; import java.io.File; import java.io.IOException; +import junit.framework.Assert; + import org.junit.Test; import com.raytheon.uf.common.util.FileUtil; import com.raytheon.uf.common.util.TestUtil; +import com.raytheon.uf.common.util.file.FilenameFilters; import com.raytheon.uf.edex.datadelivery.bandwidth.sbn.SbnSimulator.IFileProcessor; /** @@ -47,6 +48,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.sbn.SbnSimulator.IFileProcess * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Mar 18, 2013 1648 djohnson Initial creation + * Oct 18, 2013 2267 bgonzale Updated tests to work with sbnSimulator reading from site specific dirs. * * * @@ -55,26 +57,31 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.sbn.SbnSimulator.IFileProcess */ public class SbnSimulatorTest { + private final static String SITE = "OAX"; private final File testDir = TestUtil .setupTestClassDir(SbnSimulatorTest.class); private final IFileProcessor fileProcessor = mock(IFileProcessor.class); private final SbnSimulator simulator = new SbnSimulator(testDir, - fileProcessor); + fileProcessor, SITE); @Test public void processesEachFileInDirectory() throws IOException { - File fileOne = new File(testDir, "fileOne.txt"); - File fileTwo = new File(testDir, "fileTwo.txt"); + SbnSimulator simAAA = new SbnSimulator(testDir, fileProcessor, "AAA"); + SbnSimulator simBBB = new SbnSimulator(testDir, fileProcessor, "BBB"); - FileUtil.bytes2File("fileOne".getBytes(), fileOne); - FileUtil.bytes2File("fileTwo".getBytes(), fileTwo); + File fileOneExpectedResult = createTestFileGetExpected(testDir, + "fileOne.txt", SITE); + File fileTwoExpectedResult = createTestFileGetExpected(testDir, + "fileTwo.txt", "BBB"); simulator.checkForSbnData(); + simAAA.checkForSbnData(); + simBBB.checkForSbnData(); - verify(fileProcessor).processFile(fileOne); - verify(fileProcessor).processFile(fileTwo); + verify(fileProcessor).processFile(fileOneExpectedResult); + verify(fileProcessor).processFile(fileTwoExpectedResult); } @Test @@ -86,32 +93,34 @@ public class SbnSimulatorTest { @Test public void fileInDirectoryProcessedOnlyOnce() throws IOException { - File fileOne = new File(testDir, "fileOne.txt"); - - FileUtil.bytes2File("fileOne".getBytes(), fileOne); + File fileOneExpectedResult = createTestFileGetExpected(testDir, + "fileOne.txt", SITE); simulator.checkForSbnData(); - verify(fileProcessor, times(1)).processFile(fileOne); + verify(fileProcessor, times(1)).processFile(fileOneExpectedResult); } @Test public void fileInDirectoryIsDeleted() throws IOException { - File fileOne = new File(testDir, "fileOne.txt"); - - FileUtil.bytes2File("fileOne".getBytes(), fileOne); + createTestFileGetExpected(testDir, "fileOne.txt", SITE); simulator.checkForSbnData(); - assertThat(testDir, hasNoFiles()); + int fileCount = FileUtil.listFiles(testDir, + FilenameFilters.ACCEPT_FILES, true).size(); + + Assert.assertEquals( + "Found unexpected files in the processing directory.", 0, + fileCount); } @Test public void errorOnOneFileDoesNotStopTheOthers() throws IOException { - FileUtil.bytes2File("fileOne".getBytes(), new File(testDir, - "fileOne.txt")); - FileUtil.bytes2File("fileTwo".getBytes(), new File(testDir, - "fileTwo.txt")); + File fileOneExpectedResult = createTestFileGetExpected(testDir, + "fileOne.txt", "AA1"); + File fileTwoExpectedResult = createTestFileGetExpected(testDir, + "fileTwo.txt", "AA2"); doThrow(new IOException()).when(fileProcessor).processFile( any(File.class)); @@ -120,4 +129,17 @@ public class SbnSimulatorTest { verify(fileProcessor, times(2)).processFile(any(File.class)); } + + private File createTestFileGetExpected(File dir, String name, String site) + throws IOException { + File file = new File(dir, name); + File fileExpectedResult = new File(dir, "sbnSimulator/" + site + + File.separator + name); + + FileUtil.bytes2File(name.getBytes(), file); + simulator.distributeToSiteDirs(); + return fileExpectedResult; + } + + } From 627dd4f2db8ba7ca17982833b26daf9fbad05e31 Mon Sep 17 00:00:00 2001 From: Dave Hladky Date: Thu, 24 Oct 2013 09:32:41 -0500 Subject: [PATCH 02/15] Issue #2469 Refined deletion of adhoc subs. Former-commit-id: e02868bf2a8317b3b0ca27da69678979c5e44840 [formerly 988bb90523b267f29aa14c1cae8b3311943e8a6e] [formerly e02868bf2a8317b3b0ca27da69678979c5e44840 [formerly 988bb90523b267f29aa14c1cae8b3311943e8a6e] [formerly 6b5543501a12badcd497c5c975eec2f067fb8812 [formerly f8d93b233f32623864f86edf822b77b68aa5e0a0]]] Former-commit-id: 6b5543501a12badcd497c5c975eec2f067fb8812 Former-commit-id: 05c2ce9bc32f5db0e354e276fa4755182afeb535 [formerly 14ea0393a17fcbddfe45396a8d835b610063db1e] Former-commit-id: c552f899e3c4ada4a77ca101b386e386dcba7677 --- .../adhoc/AdhocSubscriptionCleaner.java | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/adhoc/AdhocSubscriptionCleaner.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/adhoc/AdhocSubscriptionCleaner.java index 361d628c67..2c173784c7 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/adhoc/AdhocSubscriptionCleaner.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/adhoc/AdhocSubscriptionCleaner.java @@ -52,6 +52,7 @@ import com.raytheon.uf.edex.database.purge.PurgeRuleSet; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Oct 11, 2013 2460 dhladky Initial creation + * Oct 23, 2013 2469 dhladky Refined the time check and accommodation for lack of purge rules. * * * @@ -63,6 +64,8 @@ public class AdhocSubscriptionCleaner { private static final IUFStatusHandler statusHandler = UFStatus .getHandler(AdhocSubscriptionCleaner.class); + + private static final String DEFAULT_RULE = "00-12:00:00"; public AdhocSubscriptionCleaner() { @@ -150,17 +153,29 @@ public class AdhocSubscriptionCleaner { if (purgeRuleSet != null) { List rules = purgeRuleSet.getRules(); + // if no rules exist, create a default, 12 hours + if (rules.isEmpty()) { + rules = new ArrayList(); + PurgeRule rule = new PurgeRule(); + rule.setPeriod(DEFAULT_RULE); + rules.add(rule); + } // Go over all of the purge rules for each sub - for (PurgeRule rule: rules) { - // use current system date/time - long timeCheck = TimeUtil.newDate().getTime(); - Date expireDate = new Date(timeCheck + rule.getPeriodInMillis()); - - // check rule against creation time of this sub - if (adhoc.getTime().getEnd().before(expireDate)) { - if (!subsToDelete.contains(adhoc)) { - subsToDelete.add(adhoc); + for (PurgeRule rule : rules) { + // use a valid rule + if (rule.getPeriodInMillis() != 0) { + // use current system date/time + Date compareTime = TimeUtil.newDate(); + Date expireDate = new Date(adhoc.getTime() + .getStart().getTime() + + rule.getPeriodInMillis()); + + if (expireDate.before(compareTime)) { + if (!subsToDelete.contains(adhoc)) { + subsToDelete.add(adhoc); + break; + } } } } From 9cc9dc3e9c40d9778e9a41d884d2db84a67743eb Mon Sep 17 00:00:00 2001 From: Benjamin Phillippe Date: Wed, 23 Oct 2013 16:15:13 -0500 Subject: [PATCH 03/15] Issue #2385 Fixed subscription backup web service. Restored subscriptions are now scheduled in the bandwidth manager Change-Id: I7e0e98517ff7d2213957004c6a94e38cf7063cce Former-commit-id: 127b5a3b70a926ffad17bc62fe980a025fe874b5 [formerly be09ba9fcfaebcc9e621b21c5d02f3e1608e75db] [formerly 127b5a3b70a926ffad17bc62fe980a025fe874b5 [formerly be09ba9fcfaebcc9e621b21c5d02f3e1608e75db] [formerly 0905d6ffdd900d323b7ce351f7044a19b189a04f [formerly 40fec1c49a0a4aa2ecb4afdf4cf225e6359efd28]]] Former-commit-id: 0905d6ffdd900d323b7ce351f7044a19b189a04f Former-commit-id: a169585a0a6dc28825afbd5ede5718fe9f0d0e0c [formerly 041ce0780379994ce534bf03fd6de231446ede42] Former-commit-id: d938f481972fa4d29443cae13a341716501e3eb2 --- .../rest/IRegistryDataAccessService.java | 15 +-- .../res/spring/bandwidth-datadelivery.xml | 17 +++- .../bandwidth/BandwidthManager.java | 97 +++++++++++-------- .../bandwidth/EdexBandwidthManager.java | 47 +++++---- .../bandwidth/IBandwidthManager.java | 7 +- .../META-INF/MANIFEST.MF | 3 +- .../rest/RegistryDataAccessService.java | 84 ++++++++++++---- 7 files changed, 170 insertions(+), 100 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/services/rest/IRegistryDataAccessService.java b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/services/rest/IRegistryDataAccessService.java index 03af0aff27..8234045d26 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/services/rest/IRegistryDataAccessService.java +++ b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/services/rest/IRegistryDataAccessService.java @@ -22,7 +22,6 @@ package com.raytheon.uf.common.registry.services.rest; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; -import javax.xml.bind.JAXBException; import com.raytheon.uf.common.registry.RegistryException; import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResponse; @@ -40,6 +39,7 @@ import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResp * 7/29/2013 2191 bphillip Initial implementation * 9/20/2013 2385 bphillip Added subscription backup functions * 10/8/2013 1682 bphillip Added rest functions for use with the query web interface + * 10/23/2013 2385 bphillip restoreSubscriptions throws JAXBException * * * @author bphillip @@ -111,25 +111,20 @@ public interface IRegistryDataAccessService { * @param subscriptionName * The subscription to be backed up * @return Status message about whether the backup was successful - * @throws JAXBException - * If marshalling/unmarshalling errors are encountered */ @GET @Path(DATA_ACCESS_PATH_PREFIX + "backupSubscription/{subscriptionName}") public String backupSubscription( - @PathParam("subscriptionName") String subscriptionName) - throws JAXBException; + @PathParam("subscriptionName") String subscriptionName); /** * Backs up all subscriptions currently in the registry * * @return Status message about whether the backup was successful - * @throws JAXBException - * If marshalling/unmarshalling errors are encountered */ @GET @Path(DATA_ACCESS_PATH_PREFIX + "backupAllSubscriptions/") - public String backupAllSubscriptions() throws JAXBException; + public String backupAllSubscriptions(); /** * Restores the specified subscription @@ -137,13 +132,11 @@ public interface IRegistryDataAccessService { * @param subscriptionName * The name of the subscription to restore * @return Status message about whether the backup was successful - * @throws JAXBException */ @GET @Path(DATA_ACCESS_PATH_PREFIX + "restoreSubscription/{subscriptionName}") public String restoreSubscription( - @PathParam("subscriptionName") String subscriptionName) - throws JAXBException; + @PathParam("subscriptionName") String subscriptionName); /** * Restores any subscriptions that were previously backed up diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/res/spring/bandwidth-datadelivery.xml b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/res/spring/bandwidth-datadelivery.xml index cdce5e7807..ae6fa98860 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/res/spring/bandwidth-datadelivery.xml +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/res/spring/bandwidth-datadelivery.xml @@ -1,7 +1,8 @@ - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> + @@ -86,5 +87,15 @@ + + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java index c3968aee66..7ae9e3be38 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java @@ -122,14 +122,15 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException; * case for no matching dataset metadata for an * adhoc subscription. * Sept 25, 2013 1797 dhladky separated time from gridded time + * 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc * * * @author dhladky * @version 1.0 */ -public abstract class BandwidthManager extends - AbstractPrivilegedRequestHandler> implements - IBandwidthManager { +public abstract class BandwidthManager + extends AbstractPrivilegedRequestHandler> + implements IBandwidthManager { protected static final IUFStatusHandler statusHandler = UFStatus .getHandler(BandwidthManager.class); @@ -141,7 +142,7 @@ public abstract class BandwidthManager exten private BandwidthInitializer initializer; - protected final BandwidthDaoUtil bandwidthDaoUtil; + protected final BandwidthDaoUtil bandwidthDaoUtil; private final IBandwidthDbInit dbInit; @@ -154,8 +155,9 @@ public abstract class BandwidthManager exten final RetrievalManager retrievalManager; public BandwidthManager(IBandwidthDbInit dbInit, - IBandwidthDao bandwidthDao, RetrievalManager retrievalManager, - BandwidthDaoUtil bandwidthDaoUtil) { + IBandwidthDao bandwidthDao, + RetrievalManager retrievalManager, + BandwidthDaoUtil bandwidthDaoUtil) { this.dbInit = dbInit; this.bandwidthDao = bandwidthDao; this.retrievalManager = retrievalManager; @@ -244,8 +246,8 @@ public abstract class BandwidthManager exten return unscheduled; } - protected List schedule(Subscription subscription, - BandwidthSubscription dao) { + protected List schedule( + Subscription subscription, BandwidthSubscription dao) { Calendar retrievalTime = dao.getBaseReferenceTime(); // Retrieve all the current subscriptions by provider, dataset name and @@ -440,7 +442,8 @@ public abstract class BandwidthManager exten * @return */ @Override - public List schedule(AdhocSubscription subscription) { + public List scheduleAdhoc( + AdhocSubscription subscription) { List subscriptions = new ArrayList(); Calendar now = BandwidthUtil.now(); @@ -453,8 +456,7 @@ public abstract class BandwidthManager exten * and time. */ AdhocSubscription subscriptionUpdated = bandwidthDaoUtil - .setAdhocMostRecentUrlAndTime( - subscription, true); + .setAdhocMostRecentUrlAndTime(subscription, true); if (subscriptionUpdated != null) { subscription = subscriptionUpdated; } @@ -558,7 +560,8 @@ public abstract class BandwidthManager exten * the subscription * @return the list of unscheduled subscriptions */ - private List handlePoint(Subscription subscription) { + private List handlePoint( + Subscription subscription) { return schedule(subscription, ((PointTime) subscription.getTime()).getInterval()); } @@ -570,8 +573,10 @@ public abstract class BandwidthManager exten * the subscription * @return the list of unscheduled subscriptions */ - private List handleGridded(Subscription subscription) { - final List cycles = ((GriddedTime)subscription.getTime()).getCycleTimes(); + private List handleGridded( + Subscription subscription) { + final List cycles = ((GriddedTime) subscription.getTime()) + .getCycleTimes(); final boolean subscribedToCycles = !CollectionUtil .isNullOrEmpty(cycles); final boolean useMostRecentDataSetUpdate = !subscribedToCycles; @@ -599,7 +604,7 @@ public abstract class BandwidthManager exten + "No adhoc requested.", subscription.getName())); } else { - unscheduled = schedule(adhoc); + unscheduled = scheduleAdhoc(adhoc); } } else { statusHandler @@ -614,10 +619,11 @@ public abstract class BandwidthManager exten * @return */ @Override - public List adhocSubscription(AdhocSubscription adhoc) { + public List adhocSubscription( + AdhocSubscription adhoc) { statusHandler.info("Scheduling adhoc subscription [" + adhoc.getName() + "]"); - return schedule(adhoc); + return scheduleAdhoc(adhoc); } /** @@ -660,7 +666,8 @@ public abstract class BandwidthManager exten * {@inheritDoc} */ @Override - public Object handleRequest(IBandwidthRequest request) throws Exception { + public Object handleRequest(IBandwidthRequest request) + throws Exception { ITimer timer = TimeUtil.getTimer(); timer.start(); @@ -670,7 +677,8 @@ public abstract class BandwidthManager exten final Network requestNetwork = request.getNetwork(); final int bandwidth = request.getBandwidth(); - final List> subscriptions = request.getSubscriptions(); + final List> subscriptions = request + .getSubscriptions(); final RequestType requestType = request.getRequestType(); switch (requestType) { case GET_ESTIMATED_COMPLETION: @@ -797,7 +805,8 @@ public abstract class BandwidthManager exten * @throws SerializationException */ protected abstract Set scheduleSbnSubscriptions( - List> subscriptions) throws SerializationException; + List> subscriptions) + throws SerializationException; /** * Proposes scheduling a list of subscriptions. @@ -808,7 +817,8 @@ public abstract class BandwidthManager exten * @throws SerializationException */ protected ProposeScheduleResponse proposeScheduleSubscriptions( - List> subscriptions) throws SerializationException { + List> subscriptions) + throws SerializationException { final ProposeScheduleResponse proposeResponse = proposeSchedule(subscriptions); Set subscriptionsUnscheduled = proposeResponse .getUnscheduledSubscriptions(); @@ -907,7 +917,8 @@ public abstract class BandwidthManager exten * @return the set of subscription names unscheduled * @throws SerializationException */ - protected Set scheduleSubscriptions(List> subscriptions) + protected Set scheduleSubscriptions( + List> subscriptions) throws SerializationException { Set unscheduledSubscriptions = new TreeSet(); @@ -993,7 +1004,8 @@ public abstract class BandwidthManager exten * @throws SerializationException */ private ProposeScheduleResponse proposeSchedule( - List> subscriptions) throws SerializationException { + List> subscriptions) + throws SerializationException { BandwidthMap copyOfCurrentMap = BandwidthMap .load(EdexBandwidthContextFactory.getBandwidthMapConfig()); @@ -1100,7 +1112,8 @@ public abstract class BandwidthManager exten * @throws SerializationException */ @VisibleForTesting - BandwidthManager startProposedBandwidthManager(BandwidthMap bandwidthMap) { + BandwidthManager startProposedBandwidthManager( + BandwidthMap bandwidthMap) { InMemoryBandwidthContextFactory .setInMemoryBandwidthConfigFile(bandwidthMap); @@ -1137,8 +1150,8 @@ public abstract class BandwidthManager exten * @param type * @return the reference to the bandwidth manager */ - private BandwidthManager startBandwidthManager(final String[] springFiles, - boolean close, String type) { + private BandwidthManager startBandwidthManager( + final String[] springFiles, boolean close, String type) { ITimer timer = TimeUtil.getTimer(); timer.start(); @@ -1146,8 +1159,8 @@ public abstract class BandwidthManager exten try { ctx = new ClassPathXmlApplicationContext(springFiles, EDEXUtil.getSpringContext()); - final BandwidthManager bwManager = ctx.getBean("bandwidthManager", - BandwidthManager.class); + final BandwidthManager bwManager = ctx.getBean( + "bandwidthManager", BandwidthManager.class); try { bwManager.initializer.executeAfterRegistryInit(); return bwManager; @@ -1218,11 +1231,11 @@ public abstract class BandwidthManager exten /** * {@inheritDoc} */ - public List copyState(BandwidthManager copyFrom) { + public List copyState(BandwidthManager copyFrom) { IPerformanceTimer timer = TimeUtil.getPerformanceTimer(); timer.start(); List unscheduled = Collections.emptyList(); - IBandwidthDao fromDao = copyFrom.bandwidthDao; + IBandwidthDao fromDao = copyFrom.bandwidthDao; final boolean proposingBandwidthChange = retrievalManager .isProposingBandwidthChanges(copyFrom.retrievalManager); @@ -1239,10 +1252,10 @@ public abstract class BandwidthManager exten subscriptionNames.add(subscription.getName()); } - Set> actualSubscriptions = Sets.newHashSet(); + Set> actualSubscriptions = Sets.newHashSet(); for (String subName : subscriptionNames) { try { - Subscription actualSubscription = DataDeliveryHandlers + Subscription actualSubscription = DataDeliveryHandlers .getSubscriptionHandler().getByName(subName); actualSubscriptions.add(actualSubscription); } catch (RegistryHandlerException e) { @@ -1332,7 +1345,8 @@ public abstract class BandwidthManager exten * the subscription * @return the required dataset size */ - private long determineRequiredDataSetSize(final Subscription subscription) { + private long determineRequiredDataSetSize( + final Subscription subscription) { return determineRequiredValue(subscription, new FindSubscriptionRequiredDataSetSize()); } @@ -1430,7 +1444,8 @@ public abstract class BandwidthManager exten * the subscription * @return true if able to be cleanly scheduled, false otherwise */ - private boolean isSchedulableWithoutConflict(final Subscription subscription) { + private boolean isSchedulableWithoutConflict( + final Subscription subscription) { BandwidthMap copyOfCurrentMap = BandwidthMap .load(EdexBandwidthContextFactory.getBandwidthMapConfig()); @@ -1455,22 +1470,24 @@ public abstract class BandwidthManager exten * Provide implementation specific shutdown. */ protected abstract void shutdownInternal(); - + /** * Special handling for Gridded Times with cycles and time indicies + * * @param subTime * @param dataSetMetaDataTime * @return */ - protected static Time handleCyclesAndSequences(Time subTime, Time dataSetMetaDataTime) { - + protected static Time handleCyclesAndSequences(Time subTime, + Time dataSetMetaDataTime) { + if (subTime instanceof GriddedTime) { - GriddedTime time = (GriddedTime)subTime; - GriddedTime dsmTime = (GriddedTime)dataSetMetaDataTime; + GriddedTime time = (GriddedTime) subTime; + GriddedTime dsmTime = (GriddedTime) dataSetMetaDataTime; dsmTime.setSelectedTimeIndices(time.getSelectedTimeIndices()); dsmTime.setCycleTimes(time.getCycleTimes()); } - + return dataSetMetaDataTime; } } diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/EdexBandwidthManager.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/EdexBandwidthManager.java index 138fa918c8..b953de7833 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/EdexBandwidthManager.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/EdexBandwidthManager.java @@ -96,13 +96,15 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil; * Add throws to updatePointDataSetMetaData. * Oct 1 2013 1797 dhladky Time and GriddedTime separation * Oct 10, 2013 1797 bgonzale Refactored registry Time objects. + * 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc * * * * @author djohnson * @version 1.0 */ -public abstract class EdexBandwidthManager extends BandwidthManager { +public abstract class EdexBandwidthManager + extends BandwidthManager { private static final Pattern RAP_PATTERN = Pattern .compile(".*rap_f\\d\\d$"); @@ -135,8 +137,9 @@ public abstract class EdexBandwidthManager e * @param bandwidthDaoUtil */ public EdexBandwidthManager(IBandwidthDbInit dbInit, - IBandwidthDao bandwidthDao, RetrievalManager retrievalManager, - BandwidthDaoUtil bandwidthDaoUtil, + IBandwidthDao bandwidthDao, + RetrievalManager retrievalManager, + BandwidthDaoUtil bandwidthDaoUtil, IDataSetMetaDataHandler dataSetMetaDataHandler, ISubscriptionHandler subscriptionHandler) { super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil); @@ -393,11 +396,11 @@ public abstract class EdexBandwidthManager e GriddedDataSetMetaData dataSetMetaData) throws ParseException { // Daily/Hourly/Monthly datasets if (dataSetMetaData.getCycle() == GriddedDataSetMetaData.NO_CYCLE) { - updateDataSetMetaDataWithoutCycle((DataSetMetaData)dataSetMetaData); + updateDataSetMetaDataWithoutCycle((DataSetMetaData) dataSetMetaData); } // Regular cycle containing datasets else { - updateDataSetMetaDataWithCycle((DataSetMetaData)dataSetMetaData); + updateDataSetMetaDataWithCycle((DataSetMetaData) dataSetMetaData); } } @@ -465,7 +468,7 @@ public abstract class EdexBandwidthManager e try { // Update the retrieval times on the subscription object // which goes through the retrieval process - final SubscriptionRetrievalAttributes subscriptionRetrievalAttributes = bandwidthDao + final SubscriptionRetrievalAttributes subscriptionRetrievalAttributes = bandwidthDao .getSubscriptionRetrievalAttributes(retrieval); final Subscription subscription = subscriptionRetrievalAttributes .getSubscription(); @@ -480,7 +483,8 @@ public abstract class EdexBandwidthManager e subTime.setRequestStart(earliestRetrievalDataTime); subTime.setRequestEnd(latestRetrievalDataTime); subTime.setTimes(time.getTimes()); - subscriptionRetrievalAttributes.setSubscription(subscription); + subscriptionRetrievalAttributes + .setSubscription(subscription); bandwidthDao.update(subscriptionRetrievalAttributes); @@ -533,13 +537,14 @@ public abstract class EdexBandwidthManager e dataSetMetaData.getUrl())); // Create an adhoc for each one, and schedule it - for (Subscription subscription : subscriptions) { + for (Subscription subscription : subscriptions) { @SuppressWarnings("unchecked") - Subscription sub = updateSubscriptionWithDataSetMetaData( + Subscription sub = updateSubscriptionWithDataSetMetaData( subscription, dataSetMetaData); if (sub instanceof SiteSubscription) { - schedule(new AdhocSubscription((SiteSubscription) sub)); + scheduleAdhoc(new AdhocSubscription( + (SiteSubscription) sub)); } else { statusHandler .warn("Unable to create adhoc queries for shared subscriptions at this point. This functionality should be added in the future..."); @@ -583,10 +588,10 @@ public abstract class EdexBandwidthManager e // SubscriptionRetrieval with the current DataSetMetaData // URL and time Object - SubscriptionRetrievalAttributes attributes = bandwidthDao + SubscriptionRetrievalAttributes attributes = bandwidthDao .getSubscriptionRetrievalAttributes(retrieval); - Subscription sub; + Subscription sub; try { sub = updateSubscriptionWithDataSetMetaData( attributes.getSubscription(), dataSetMetaData); @@ -608,12 +613,12 @@ public abstract class EdexBandwidthManager e bandwidthDaoUtil.update(retrieval); - statusHandler - .info(String.format("Updated retrieval [%s] for " + statusHandler.info(String.format( + "Updated retrieval [%s] for " + "subscription [%s] to use " + "url [%s] and " - + "base reference time [%s]", retrieval - .getIdentifier(), sub.getName(), + + "base reference time [%s]", + retrieval.getIdentifier(), sub.getName(), dataSetMetaData.getUrl(), BandwidthUtil.format(sub.getTime().getStart()))); } @@ -647,14 +652,14 @@ public abstract class EdexBandwidthManager e } } - Set> subscriptions = new HashSet>(); + Set> subscriptions = new HashSet>(); for (SubscriptionRetrieval retrieval : retrievals) { try { - final SubscriptionRetrievalAttributes sra = bandwidthDao + final SubscriptionRetrievalAttributes sra = bandwidthDao .getSubscriptionRetrievalAttributes(retrieval); if (sra != null) { @SuppressWarnings("unchecked") - Subscription sub = sra.getSubscription(); + Subscription sub = sra.getSubscription(); if (sub != null) { subscriptions.add(sub); } @@ -666,7 +671,7 @@ public abstract class EdexBandwidthManager e } } - for (Subscription subscription : subscriptions) { + for (Subscription subscription : subscriptions) { subscription.setUnscheduled(true); subscriptionUpdated(subscription); } @@ -700,7 +705,7 @@ public abstract class EdexBandwidthManager e * reinitialize operation. */ private void bandwidthMapConfigurationUpdated() { - IBandwidthRequest request = new IBandwidthRequest(); + IBandwidthRequest request = new IBandwidthRequest(); request.setRequestType(RequestType.REINITIALIZE); try { diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/IBandwidthManager.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/IBandwidthManager.java index aeacbaa41b..11e708c7c2 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/IBandwidthManager.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/IBandwidthManager.java @@ -41,6 +41,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.interfaces.ISubscriptionAggre * ------------ ---------- ----------- -------------------------- * Oct 30, 2012 1286 djohnson Initial creation * Jul 10, 2013 2106 djohnson Remove EDEX instance specific methods. + * 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc * * * @@ -66,7 +67,7 @@ public interface IBandwidthManager { * @param b * @return */ - List schedule(AdhocSubscription subscription); + List scheduleAdhoc(AdhocSubscription subscription); /** * When a Subscription is updated in the Registry, update the retrieval plan @@ -76,8 +77,8 @@ public interface IBandwidthManager { * @return * @throws SerializationException */ - List subscriptionUpdated(Subscription subscription) - throws SerializationException; + List subscriptionUpdated( + Subscription subscription) throws SerializationException; /** * diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/META-INF/MANIFEST.MF index b867831290..1a9b10b1ff 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/META-INF/MANIFEST.MF @@ -34,7 +34,8 @@ Require-Bundle: com.raytheon.uf.common.registry.schemas.ebxml;bundle-version="1. com.raytheon.uf.common.datadelivery.request;bundle-version="1.0.0", javax.mail;bundle-version="1.0.0", org.apache.commons.validator;bundle-version="1.2.0", - com.sun.xml.bind;bundle-version="1.0.0" + com.sun.xml.bind;bundle-version="1.0.0", + org.reflections;bundle-version="0.9.9" Export-Package: com.raytheon.uf.edex.registry.ebxml.acp, com.raytheon.uf.edex.registry.ebxml.dao, com.raytheon.uf.edex.registry.ebxml.exception, diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/rest/RegistryDataAccessService.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/rest/RegistryDataAccessService.java index 3c5b4067b8..09ffd01fb7 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/rest/RegistryDataAccessService.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/rest/RegistryDataAccessService.java @@ -21,12 +21,14 @@ package com.raytheon.uf.edex.registry.ebxml.services.rest; import java.io.File; import java.util.List; +import java.util.Set; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.xml.bind.JAXB; import javax.xml.bind.JAXBException; +import javax.xml.bind.annotation.XmlRootElement; import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager; import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException; @@ -40,21 +42,29 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SubscriptionType; +import org.reflections.Reflections; +import org.reflections.scanners.TypeAnnotationsScanner; +import org.reflections.util.ClasspathHelper; +import org.reflections.util.ConfigurationBuilder; import org.springframework.transaction.annotation.Transactional; import com.raytheon.uf.common.registry.RegistryException; import com.raytheon.uf.common.registry.services.rest.IRegistryDataAccessService; import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResponse; +import com.raytheon.uf.common.serialization.JAXBManager; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.util.CollectionUtil; import com.raytheon.uf.common.util.StringUtil; +import com.raytheon.uf.edex.core.EDEXUtil; +import com.raytheon.uf.edex.core.EdexException; import com.raytheon.uf.edex.registry.ebxml.dao.QueryDefinitionDao; import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao; /** * - * Implementation of the registry data access service interface + * Implementation of the registry data access service interface
+ * TODO: This class really needs to be moved to a data delivery specific plugin * *
  * 
@@ -66,6 +76,7 @@ import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao;
  * 9/20/2013    2385        bphillip    Added subscription backup functions
  * 10/2/2013    2385        bphillip    Fixed subscription backup queries
  * 10/8/2013    1682        bphillip    Added query queries
+ * 10/23/2013   2385        bphillip    Restored subscriptions are now scheduled in the bandwidth manager
  * 
* * @author bphillip @@ -91,6 +102,8 @@ public class RegistryDataAccessService implements IRegistryDataAccessService { + "where obj.objectType like '%SiteSubscription' " + "OR obj.objectType like '%SharedSubscription' order by obj.id asc"; + private static final JAXBManager subscriptionJaxbManager = initJaxbManager(); + /** Data access object for registry objects */ private RegistryObjectDao registryObjectDao; @@ -234,8 +247,7 @@ public class RegistryDataAccessService implements IRegistryDataAccessService { @GET @Path(DATA_ACCESS_PATH_PREFIX + "backupSubscription/{subscriptionName}") public String backupSubscription( - @PathParam("subscriptionName") String subscriptionName) - throws JAXBException { + @PathParam("subscriptionName") String subscriptionName) { StringBuilder response = new StringBuilder(); List result = registryObjectDao.executeHQLQuery( GET_SINGLE_SUBSCRIPTIONS_QUERY, "id", subscriptionName); @@ -277,7 +289,7 @@ public class RegistryDataAccessService implements IRegistryDataAccessService { @Override @GET @Path(DATA_ACCESS_PATH_PREFIX + "backupAllSubscriptions/") - public String backupAllSubscriptions() throws JAXBException { + public String backupAllSubscriptions() { StringBuilder response = new StringBuilder(); List subs = registryObjectDao .executeHQLQuery(GET_SUBSCRIPTIONS_QUERY); @@ -300,16 +312,32 @@ public class RegistryDataAccessService implements IRegistryDataAccessService { @GET @Path(DATA_ACCESS_PATH_PREFIX + "restoreSubscription/{subscriptionName}") public String restoreSubscription( - @PathParam("subscriptionName") String subscriptionName) - throws JAXBException { + @PathParam("subscriptionName") String subscriptionName) { StringBuilder response = new StringBuilder(); File subscriptionFile = new File(SUBSCRIPTION_BACKUP_DIR + File.separator + subscriptionName); if (subscriptionFile.exists()) { SubmitObjectsRequest submitRequest = JAXB.unmarshal( subscriptionFile, SubmitObjectsRequest.class); + String subscriptionXML = submitRequest.getRegistryObjects().get(0) + .getSlotByName("content").getSlotValue().getValue(); + try { + Object subObj = subscriptionJaxbManager + .unmarshalFromXml(subscriptionXML); + EDEXUtil.getMessageProducer().sendSync("scheduleSubscription", + subObj); lcm.submitObjects(submitRequest); + subscriptionFile.delete(); + response.append( + "Subscription successfully restored from file [") + .append(subscriptionFile).append("]
"); + } catch (EdexException e1) { + statusHandler.error("Error submitting subscription", e1); + response.append("Subscription from file [") + .append(subscriptionFile) + .append("] failed to be restored: ") + .append(e1.getLocalizedMessage()).append("
"); } catch (MsgRegistryException e) { response.append("Error restoring subscription from file [") .append(subscriptionFile).append("] ") @@ -317,10 +345,13 @@ public class RegistryDataAccessService implements IRegistryDataAccessService { statusHandler.error("Error restoring subscription from file [" + subscriptionFile + "]", e); return response.toString(); + } catch (JAXBException e) { + response.append("Error restoring subscription from file [") + .append(subscriptionFile).append("] ") + .append(e.getMessage()).append("
"); + statusHandler.error("Error restoring subscription from file [" + + subscriptionFile + "]", e); } - subscriptionFile.delete(); - response.append("Subscription successfully restored from file [") - .append(subscriptionFile).append("]
"); } else { response.append("No backup file exists for subscription[") .append(subscriptionName).append("]
"); @@ -345,18 +376,7 @@ public class RegistryDataAccessService implements IRegistryDataAccessService { response.append("No subscriptions found to restore
"); } else { for (File subscription : filesToRestore) { - - try { - response.append(restoreSubscription(subscription - .getName())); - } catch (JAXBException e) { - statusHandler.error("Error restoring subscription [" - + subscription + "]", e); - response.append("Error restoring subscription [") - .append(subscription).append("] ") - .append(e.getMessage()).append("
"); - continue; - } + response.append(restoreSubscription(subscription.getName())); } } } else { @@ -394,6 +414,28 @@ public class RegistryDataAccessService implements IRegistryDataAccessService { return response.toString(); } + /** + * Initializes the JAXBManager for datadelivery classes. + * + * @return JAXBManager for datadelivery classes + */ + private static JAXBManager initJaxbManager() { + ConfigurationBuilder cb = new ConfigurationBuilder(); + cb.addUrls(ClasspathHelper + .forPackage("com.raytheon.uf.common.datadelivery.registry")); + cb.setScanners(new TypeAnnotationsScanner()); + Reflections reflecs = cb.build(); + Set> classes = reflecs + .getTypesAnnotatedWith(XmlRootElement.class); + try { + return new JAXBManager( + classes.toArray(new Class[classes.size()])); + } catch (JAXBException e) { + throw new RuntimeException( + "Error initializing subscription jaxb Manager!", e); + } + } + public void setRegistryObjectDao(RegistryObjectDao registryObjectDao) { this.registryObjectDao = registryObjectDao; } From 819cb0bcb7295010ef5d6354c9c7d7477a544f0f Mon Sep 17 00:00:00 2001 From: Bryan Kowal Date: Mon, 28 Oct 2013 14:50:00 -0500 Subject: [PATCH 04/15] Issue #2500 - the list of web applications to deploy is no longer hard-coded in deploy-install. Former-commit-id: df575b7be14b3c7e1cd65239379de179995e7307 [formerly a6d7822698b85dac7e5b27440a90c605146183f2] [formerly df575b7be14b3c7e1cd65239379de179995e7307 [formerly a6d7822698b85dac7e5b27440a90c605146183f2] [formerly cda8d04831ef8200ef235469ff611d9ee8eff1f2 [formerly 06a166ef6c963585eb65da223610a21665f9545a]]] Former-commit-id: cda8d04831ef8200ef235469ff611d9ee8eff1f2 Former-commit-id: 27d2e337694e8139030830d8a8f0984db2d5ab83 [formerly cc0f6832c9e2ba548775550687d42d7279b0e0fa] Former-commit-id: 2615ad732437c96f324d86fd86aa6c1d43e75524 --- .../build.edex/deploy-common/deploy-esb.xml | 18 ----------------- .../build.edex/deploy-common/deploy-web.xml | 20 +++++++++---------- .../deploy-common/plugin-methods.xml | 15 ++++++++++++++ edexOsgi/build.edex/edex/customAssembly.xml | 15 ++++++++++++++ edexOsgi/build.edex/edex/customTargets.xml | 13 ++++++++++++ edexOsgi/build.edex/edex/developer.properties | 2 -- .../build.edex/properties/edex.properties | 1 - edexOsgi/com.raytheon.edex.uengine/web.deploy | 1 + .../web.deploy | 1 + .../web.deploy | 1 + 10 files changed, 55 insertions(+), 32 deletions(-) create mode 100644 edexOsgi/com.raytheon.edex.uengine/web.deploy create mode 100644 edexOsgi/com.raytheon.uf.edex.registry.ebxml/web.deploy create mode 100644 ncep/gov.noaa.nws.ncep.edex.purgeutil/web.deploy diff --git a/edexOsgi/build.edex/deploy-common/deploy-esb.xml b/edexOsgi/build.edex/deploy-common/deploy-esb.xml index 968f6c0dc3..f257cadbeb 100644 --- a/edexOsgi/build.edex/deploy-common/deploy-esb.xml +++ b/edexOsgi/build.edex/deploy-common/deploy-esb.xml @@ -17,12 +17,6 @@ - - - - - - @@ -96,18 +90,6 @@ includes="**/*" type="both" /> - - - - - - diff --git a/edexOsgi/build.edex/deploy-common/deploy-web.xml b/edexOsgi/build.edex/deploy-common/deploy-web.xml index a3ca610d2d..b02f4529b5 100644 --- a/edexOsgi/build.edex/deploy-common/deploy-web.xml +++ b/edexOsgi/build.edex/deploy-common/deploy-web.xml @@ -10,11 +10,9 @@ + - - - + - - - + + + - @@ -56,9 +54,9 @@ - - + + \ No newline at end of file diff --git a/edexOsgi/build.edex/deploy-common/plugin-methods.xml b/edexOsgi/build.edex/deploy-common/plugin-methods.xml index b4324105a8..4c48c76a60 100644 --- a/edexOsgi/build.edex/deploy-common/plugin-methods.xml +++ b/edexOsgi/build.edex/deploy-common/plugin-methods.xml @@ -1,4 +1,6 @@ + + @@ -101,6 +103,19 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/build.edex/edex/customTargets.xml b/edexOsgi/build.edex/edex/customTargets.xml index 803bb4f140..241389e465 100644 --- a/edexOsgi/build.edex/edex/customTargets.xml +++ b/edexOsgi/build.edex/edex/customTargets.xml @@ -156,6 +156,19 @@ + + + + + + + + + + + + diff --git a/edexOsgi/build.edex/edex/developer.properties b/edexOsgi/build.edex/edex/developer.properties index 28ec5525e9..6edc5f2745 100644 --- a/edexOsgi/build.edex/edex/developer.properties +++ b/edexOsgi/build.edex/edex/developer.properties @@ -9,8 +9,6 @@ wa.to.deploy= deploy.python=true # deploy build.edex/esb/data deploy.data=true -# deploy the web applications -deploy.web=true # deploy GFESuite deploy.gfesuite=true # use esb.overwrite to overwrite files during esb deployment regardless diff --git a/edexOsgi/build.edex/properties/edex.properties b/edexOsgi/build.edex/properties/edex.properties index 75bce66529..4d619951f0 100644 --- a/edexOsgi/build.edex/properties/edex.properties +++ b/edexOsgi/build.edex/properties/edex.properties @@ -4,6 +4,5 @@ esbDir=${install.dir}/../edex feature=../com.raytheon.edex.feature.uframe/feature.xml working.dir=edex/tmp/plugins -deploy.web=true deploy.data=true svcbudir=${install.dir}/../GFESuite diff --git a/edexOsgi/com.raytheon.edex.uengine/web.deploy b/edexOsgi/com.raytheon.edex.uengine/web.deploy new file mode 100644 index 0000000000..ccc4140465 --- /dev/null +++ b/edexOsgi/com.raytheon.edex.uengine/web.deploy @@ -0,0 +1 @@ +war.name=uEngineWeb \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web.deploy b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web.deploy new file mode 100644 index 0000000000..32b20478ab --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/web.deploy @@ -0,0 +1 @@ +war.name=registryEbxml \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.edex.purgeutil/web.deploy b/ncep/gov.noaa.nws.ncep.edex.purgeutil/web.deploy new file mode 100644 index 0000000000..e4fb53999d --- /dev/null +++ b/ncep/gov.noaa.nws.ncep.edex.purgeutil/web.deploy @@ -0,0 +1 @@ +war.name=purgeWeb \ No newline at end of file From f7f75c86da3a21ecdca1cd7b3e0dab65a421a28b Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Tue, 29 Oct 2013 10:58:54 -0500 Subject: [PATCH 05/15] Issue #2489 Fix SfcObs NPE. Former-commit-id: 59d8afc6391d4c3c6359d743b9d8be782593e6bc [formerly f9ee49fac59705e7fe87dfbfaa235435807ab222] [formerly 59d8afc6391d4c3c6359d743b9d8be782593e6bc [formerly f9ee49fac59705e7fe87dfbfaa235435807ab222] [formerly ddf506ceacd800a322aa4c1deaafa4958f5eb3c6 [formerly 3013c7d2bbf38ab9c27491eb3cade83eaafc35aa]]] Former-commit-id: ddf506ceacd800a322aa4c1deaafa4958f5eb3c6 Former-commit-id: 32427d8b3d3398c2c07eb2a6b8f3c2a21af81121 [formerly ca5a125829194fc0d9236c1caacc9bf1b5d19e20] Former-commit-id: bab495ab35381dd7c141799fe17570bf771bf911 --- .../edex/plugin/sfcobs/common/SfcObsPart.java | 10 +++++++--- .../plugin/sfcobs/common/SfcObsSubMessage.java | 18 +++++++++++++++--- .../sfcobs/decoder/AbstractSfcObsDecoder.java | 10 +++++----- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/common/SfcObsPart.java b/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/common/SfcObsPart.java index c935ff6a81..61b885a8b4 100644 --- a/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/common/SfcObsPart.java +++ b/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/common/SfcObsPart.java @@ -36,9 +36,10 @@ import java.util.Map; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * 20070925 391 jkorman Initial Coding. + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Sep 25, 2007 391 jkorman Initial Coding. + * Oct 29, 2013 2489 bsteffen Add NAVTEX_END_PART * * * @@ -70,6 +71,9 @@ public class SfcObsPart { public static final SfcObsPart MAROB_PART = new SfcObsPart("MAROB",true); + public static final SfcObsPart NAVTEX_END_PART = new SfcObsPart("NNNN", + true); + private static final Map OBS_TYPE_MAP = new HashMap(); static { OBS_TYPE_MAP.put(AAXX_PART.partValue, AAXX_PART); diff --git a/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/common/SfcObsSubMessage.java b/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/common/SfcObsSubMessage.java index 7f0ffb56ce..0a1cbf0c61 100644 --- a/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/common/SfcObsSubMessage.java +++ b/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/common/SfcObsSubMessage.java @@ -31,9 +31,10 @@ import java.util.List; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * 20070925 391 jkorman Initial Coding. + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Sep 25, 2007 391 jkorman Initial Coding. + * Oct 29, 2013 2489 bsteffen Add checks for NAVTEX_END_PART * * * @@ -136,6 +137,17 @@ public class SfcObsSubMessage { // just throw it away. } else if (SfcObsPart.ME_PART.equals(part)) { break; + } else if (SfcObsPart.NAVTEX_END_PART.equals(part)) { + /* + * NNNN is an end of message token for some of the sbn + * data(NAVTEX generated data) and it is not a valid + * observation. If NNNN is the only part in the report then + * it will be ignored completely(dataWritten will be false). + * If there is other parts before or after NNNN then it will + * be included in the report. + */ + sb.append(" "); + sb.append(part.getPartValue()); } else { sb.append(" "); sb.append(part.getPartValue()); diff --git a/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/decoder/AbstractSfcObsDecoder.java b/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/decoder/AbstractSfcObsDecoder.java index 85d4bfe0e6..020b3d2498 100644 --- a/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/decoder/AbstractSfcObsDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/decoder/AbstractSfcObsDecoder.java @@ -34,11 +34,11 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; * *
  * 
- * SOFTWARE HISTORY
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Oct 19, 2007  391      jkorman     Initial Coding.
+ * Oct 29, 2013  2489     bsteffen    Add null check to matchElement.
  * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 20071019            391 jkorman     Initial coding.
  * 
* * @author jkorman @@ -166,7 +166,7 @@ public abstract class AbstractSfcObsDecoder implements ISfcObsDecoder { */ public static final boolean matchElement(String element, String pattern) { boolean matches = false; - if (pattern != null) { + if (pattern != null && element != null) { Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(element); matches = m.find(); From fba7e48970299f60030c11549a26ca330de2f828 Mon Sep 17 00:00:00 2001 From: Bryan Kowal Date: Tue, 29 Oct 2013 11:42:21 -0500 Subject: [PATCH 06/15] Issue #2268 - fix CAVE installation error Former-commit-id: 203c5d7288f77981a8fae258611a5beea586ff51 [formerly 7772aca092513dbe7fa9103142eb3521dea713ac] [formerly 203c5d7288f77981a8fae258611a5beea586ff51 [formerly 7772aca092513dbe7fa9103142eb3521dea713ac] [formerly 5bc115c56c620da805814edc4f982222441ca29c [formerly b36df9f89f1c58b1d1a14d05796d656bdeb2d20d]]] Former-commit-id: 5bc115c56c620da805814edc4f982222441ca29c Former-commit-id: a89499f3992dff546b2841309a36c8e777e6aed9 [formerly a34d7b254fb47327f1b37afd142872a4acae2cd3] Former-commit-id: 893a2cf3343eb8fa7483ab983968c85d3ab6148b --- rpms/awips2.core/Installer.version/component.spec | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/rpms/awips2.core/Installer.version/component.spec b/rpms/awips2.core/Installer.version/component.spec index 18a955da80..714dbe03d3 100644 --- a/rpms/awips2.core/Installer.version/component.spec +++ b/rpms/awips2.core/Installer.version/component.spec @@ -102,7 +102,6 @@ function padEdexBannerLine() function updateCAVEVersion() { - local BUILD_XML="/awips2/cave/build.xml" local TMP_PRODUCTS_DIR="/awips2/cave/.tmp/products" if [ -d ${TMP_PRODUCTS_DIR} ]; then @@ -111,21 +110,10 @@ function updateCAVEVersion() mkdir -p ${TMP_PRODUCTS_DIR} mv ${AWIPS_PRODUCT_JAR} ${TMP_PRODUCTS_DIR} AWIPS_PRODUCT_JAR=`ls -1 ${TMP_PRODUCTS_DIR}/*` - - touch ${BUILD_XML} - echo "" > ${BUILD_XML} - echo " " >> ${BUILD_XML} - echo " " >> ${BUILD_XML} - echo "" >> ${BUILD_XML} - cd /awips2/cave # Need to use awips2-java export PATH=/awips2/java/bin:${PATH} export JAVA_HOME="/awips2/java/jre" - - su awips -c './cave -application org.eclipse.ant.core.antRunner -nosplash' \ - > /dev/null 2>&1 - rm -f ${BUILD_XML} # Update the version information. cd ${TMP_PRODUCTS_DIR} From 0d562b64fdad1cae3a6f5d2a26277c20511adb70 Mon Sep 17 00:00:00 2001 From: Dave Hladky Date: Tue, 29 Oct 2013 12:20:53 -0500 Subject: [PATCH 07/15] Issue #2361 Harvester JAXB fixed up Former-commit-id: 1deca134879f3f0f1c77fa738fa056c8d297c208 [formerly 70d2ad2cdc2ecd7129c3a405463c1a2e08a93f72] [formerly 1deca134879f3f0f1c77fa738fa056c8d297c208 [formerly 70d2ad2cdc2ecd7129c3a405463c1a2e08a93f72] [formerly bcfa7d7a8fe239358d4b88fe5652241bb0103aff [formerly 6d9af3f0f470cfe5a566789c59a90fe05e516aa2]]] Former-commit-id: bcfa7d7a8fe239358d4b88fe5652241bb0103aff Former-commit-id: 1a889e84b19bc319b70648d6fd8913302d31b3a0 [formerly c5137923c07a2fc5e729484790cd724167aaf6b7] Former-commit-id: 64a9973089f2978e7abb56383b486a6ad50d1ce9 --- .../HarvesterConfigurationManager.java | 29 +++++-- .../harvester/HarvesterJaxbManager.java | 82 +++++++++++++++++++ .../harvester/CrawlMetaDataHandler.java | 12 ++- .../harvester/crawler/CrawlLauncher.java | 10 +-- .../harvester/crawler/Crawler.java | 5 +- .../crawler/FileCommunicationStrategy.java | 4 +- .../crawler/MainSequenceCrawlLauncher.java | 7 +- .../harvester/crawler/SeedCrawlLauncher.java | 7 +- 8 files changed, 129 insertions(+), 27 deletions(-) create mode 100644 edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterJaxbManager.java diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java b/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java index 087146e295..174c2f7f64 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java @@ -1,5 +1,25 @@ package com.raytheon.uf.common.datadelivery.harvester; +/** + * 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. + **/ + import java.util.Arrays; import java.util.List; @@ -7,7 +27,6 @@ import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.serialization.SerializationException; -import com.raytheon.uf.common.serialization.SingleTypeJAXBManager; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -22,6 +41,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * ------------ ---------- ----------- -------------------------- * --/--/---- dhladky Initial creation * Oct 23, 2013 2361 njensen Use JAXBManager for XML + * Oct 28, 2013 2361 dhladky Fixed up JAXBManager. * * * @@ -33,9 +53,6 @@ public class HarvesterConfigurationManager { private static final IUFStatusHandler statusHandler = UFStatus .getHandler(HarvesterConfigurationManager.class); - private static final SingleTypeJAXBManager jaxb = SingleTypeJAXBManager - .createWithoutException(HarvesterConfig.class); - /** * Gets site and base level configs for harvesters * @@ -63,7 +80,7 @@ public class HarvesterConfigurationManager { for (LocalizationFile lf : getLocalizedFiles()) { try { - config = jaxb.unmarshalFromXmlFile(lf.getFile()); + config = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, lf.getFile()); } catch (SerializationException e) { statusHandler.handle(Priority.ERROR, "Can't deserialize harvester config at " @@ -94,7 +111,7 @@ public class HarvesterConfigurationManager { for (LocalizationFile lf : getLocalizedFiles()) { try { - config = jaxb.unmarshalFromXmlFile(lf.getFile()); + config = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, lf.getFile()); } catch (SerializationException e) { statusHandler.handle(Priority.ERROR, "Can't deserialize harvester config at " diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterJaxbManager.java b/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterJaxbManager.java new file mode 100644 index 0000000000..45a78baab0 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterJaxbManager.java @@ -0,0 +1,82 @@ +package com.raytheon.uf.common.datadelivery.harvester; + +/** + * 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. + **/ + +import javax.xml.bind.JAXBException; + +import com.raytheon.uf.common.datadelivery.registry.Connection; +import com.raytheon.uf.common.datadelivery.registry.Provider; +import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType; +import com.raytheon.uf.common.datadelivery.registry.ProviderType; +import com.raytheon.uf.common.serialization.JAXBManager; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; +/** + * JAXB for Harvester + * + *
+ * 
+ * SOFTWARE HISTORY
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 23, 2013 2361       dhladky     Initial creation
+ * 
+ * 
+ * + * @author dhladky + * @version 1.0 + */ + +public class HarvesterJaxbManager { + + private static final IUFStatusHandler statusHandler = UFStatus + .getHandler(HarvesterJaxbManager.class); + + private static Class[] clazzess = new Class[] { + HarvesterConfig.class, Provider.class, Connection.class, + ProviderType.class, ServiceType.class, Agent.class, + CrawlAgent.class, OGCAgent.class, ConfigLayer.class }; + + private JAXBManager jaxb = null; + + private static HarvesterJaxbManager instance = new HarvesterJaxbManager(); + + /** + * marshall and unmarshall harvester objects + * + * @return + */ + public static JAXBManager getJaxb() { + + if (instance.jaxb == null) { + try { + instance.jaxb = new JAXBManager(clazzess); + + } catch (JAXBException e) { + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), + e); + } + } + return instance.jaxb; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/CrawlMetaDataHandler.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/CrawlMetaDataHandler.java index 43d0024b82..0553472940 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/CrawlMetaDataHandler.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/CrawlMetaDataHandler.java @@ -15,6 +15,7 @@ import java.util.Set; import com.raytheon.uf.common.datadelivery.harvester.Agent; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; +import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; import com.raytheon.uf.common.datadelivery.registry.Collection; import com.raytheon.uf.common.datadelivery.registry.Provider; import com.raytheon.uf.common.datadelivery.registry.Utils; @@ -63,6 +64,7 @@ import com.raytheon.uf.edex.registry.ebxml.init.RegistryInitializedListener; * Feb 05, 2013 1580 mpduff EventBus refactor. * 3/18/2013 1802 bphillip Modified to insert provider object after database is initialized * Jun 24, 2013 2106 djohnson Accepts ProviderHandler as a constructor argument. + * Oct 28, 2013 2361 dhladky Fixed up JAXBManager. * * * @@ -76,7 +78,7 @@ public class CrawlMetaDataHandler implements RegistryInitializedListener { private static final IUFStatusHandler statusHandler = UFStatus .getHandler(CrawlMetaDataHandler.class); - + /** Path to crawler links directory. */ private static final String PROCESSED_DIR = StringUtil.join(new String[] { "datadelivery", "harvester", "processed" }, File.separatorChar); @@ -99,11 +101,7 @@ public class CrawlMetaDataHandler implements RegistryInitializedListener { for (LocalizationFile file : files) { try { - - HarvesterConfig hc = SerializationUtil - .jaxbUnmarshalFromXmlFile(HarvesterConfig.class, - file.getFile()); - + HarvesterConfig hc = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, file.getFile()); Agent agent = hc.getAgent(); if (agent != null) { @@ -117,7 +115,7 @@ public class CrawlMetaDataHandler implements RegistryInitializedListener { hcs.put(hc.getProvider().getName(), hc); } } - } catch (SerializationException e1) { + } catch (Exception e1) { statusHandler.error( "Serialization Error Reading Crawler Config files", e1); diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/CrawlLauncher.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/CrawlLauncher.java index 2b30da160d..67a9f483b4 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/CrawlLauncher.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/CrawlLauncher.java @@ -12,13 +12,13 @@ import org.quartz.JobExecutionException; import com.raytheon.uf.common.datadelivery.harvester.Agent; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; +import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.serialization.JAXBManager; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -33,6 +33,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * ------------ ---------- ----------- -------------------------- * Oct 4, 2012 1038 dhladky Initial creation * Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects. + * Oct 28, 2013 2361 dhladky Fixed up JAXBManager. * * * @@ -141,11 +142,10 @@ public abstract class CrawlLauncher implements Job { .getLocalizedFiles(); if (files != null) { - JAXBManager jaxbMan = new JAXBManager(HarvesterConfig.class); for (LocalizationFile lf : files) { - - HarvesterConfig hc = (HarvesterConfig) jaxbMan - .unmarshalFromXmlFile(lf.getFile()); + HarvesterConfig hc = HarvesterJaxbManager.getJaxb() + .unmarshalFromXmlFile(HarvesterConfig.class, + lf.getFile()); if (hc.getAgent() != null) { // we only want crawler types for CrawlerMetadata Agent agent = hc.getAgent(); diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java index 8ab153e509..84245a613e 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java @@ -16,9 +16,9 @@ import com.raytheon.edex.util.Util; import com.raytheon.uf.common.comm.ProxyConfiguration; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; +import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; import com.raytheon.uf.common.datadelivery.registry.Collection; import com.raytheon.uf.common.serialization.SerializationException; -import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -38,6 +38,7 @@ import edu.uci.ics.crawler4j.crawler.CrawlConfig; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Oct 4, 2012 1038 dhladky Initial creation + * Oct 28, 2013 2361 dhladky Fixed up JAXBManager. * * * @@ -138,7 +139,7 @@ public abstract class Crawler { HarvesterConfig hc = null; try { - hc = SerializationUtil.jaxbUnmarshalFromXmlFile( + hc = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile( HarvesterConfig.class, configFile); } catch (SerializationException e1) { e1.printStackTrace(); diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/FileCommunicationStrategy.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/FileCommunicationStrategy.java index 4780298667..eb74177c16 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/FileCommunicationStrategy.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/FileCommunicationStrategy.java @@ -34,6 +34,7 @@ import java.util.regex.Pattern; import com.google.common.annotations.VisibleForTesting; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; +import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; import com.raytheon.uf.common.datadelivery.harvester.ProtoCollection; import com.raytheon.uf.common.datadelivery.registry.Collection; import com.raytheon.uf.common.datadelivery.registry.Provider; @@ -73,6 +74,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.ProviderCollectionLinkStore; * Aug 06, 2012 1022 djohnson Add shutdown(), write out millis with filename to prevent overwriting. * Sep 10, 2012 1154 djohnson Use JAXB instead of thrift, allowing introspection of links, return files in ascending order. * Mar 14, 2013 1794 djohnson Consolidate common FilenameFilter implementations. + * Oct 28, 2013 2361 dhladky Fixed up JAXBManager. * * * @@ -373,7 +375,7 @@ class FileCommunicationStrategy implements CommunicationStrategy { File file = lf.getFile(); try { - SerializationUtil.jaxbMarshalToXmlFile(hconfig, + HarvesterJaxbManager.getJaxb().marshalToXmlFile(hconfig, file.getAbsolutePath()); lf.save(); } catch (SerializationException e) { diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/MainSequenceCrawlLauncher.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/MainSequenceCrawlLauncher.java index f9d41f27e3..f611eefce6 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/MainSequenceCrawlLauncher.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/MainSequenceCrawlLauncher.java @@ -6,13 +6,13 @@ import java.util.List; import com.raytheon.uf.common.datadelivery.harvester.Agent; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; +import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -29,6 +29,7 @@ import com.raytheon.uf.edex.datadelivery.harvester.cron.HarvesterJobController; * Mar 14, 2012 00357 dhladky Initial creation * Jun 12, 2012 00609 djohnson Update path to crawl script. * Aug 06, 2012 01022 djohnson Launch the crawler in the same JVM. + * Oct 28, 2013 2361 dhladky Fixed up JAXBManager. * * * @@ -78,8 +79,8 @@ public class MainSequenceCrawlLauncher extends CrawlLauncher { // if many, start many for (LocalizationFile lf : getLocalizedFiles()) { - HarvesterConfig hc = SerializationUtil - .jaxbUnmarshalFromXmlFile(HarvesterConfig.class, + HarvesterConfig hc = HarvesterJaxbManager.getJaxb() + .unmarshalFromXmlFile(HarvesterConfig.class, lf.getFile()); if (hc.getProvider().getName().equals(providerName)) { if (hc.getAgent() != null) { diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/SeedCrawlLauncher.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/SeedCrawlLauncher.java index 1bf84ed477..ba9f1e443a 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/SeedCrawlLauncher.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/SeedCrawlLauncher.java @@ -6,13 +6,13 @@ import java.util.List; import com.raytheon.uf.common.datadelivery.harvester.Agent; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; +import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.serialization.JAXBManager; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -28,6 +28,7 @@ import com.raytheon.uf.edex.datadelivery.harvester.cron.HarvesterJobController; * ------------ ---------- ----------- -------------------------- * Oct 4, 2012 1038 dhladky Initial creation * Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects. + * Oct 28, 2013 2361 dhladky Fixed up JAXBManager. * * * @@ -76,8 +77,8 @@ public class SeedCrawlLauncher extends CrawlLauncher { // if many, start many for (LocalizationFile lf : getLocalizedFiles()) { - HarvesterConfig hc = (HarvesterConfig) new JAXBManager( - HarvesterConfig.class).unmarshalFromXmlFile( + HarvesterConfig hc = HarvesterJaxbManager.getJaxb() + .unmarshalFromXmlFile(HarvesterConfig.class, lf.getFile()); if (hc.getProvider().getName().equals(providerName)) { From c57dc46dfccb7fd372b28f222e0590d68985b20a Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Tue, 29 Oct 2013 12:28:00 -0500 Subject: [PATCH 08/15] Issue #2491 Move ncep bundles off od SerializationUtil. Former-commit-id: 9c62c3bae2d8007561eedb929a6db03176302f96 [formerly a4174430f7ed0497728970c9c9013be6bd797ef6] [formerly 9c62c3bae2d8007561eedb929a6db03176302f96 [formerly a4174430f7ed0497728970c9c9013be6bd797ef6] [formerly 204b47c67df199c9316aa86748b31b2e5afb8821 [formerly ddaa8e9ded31fb0676f949d5a98a30ad1709a25b]]] Former-commit-id: 204b47c67df199c9316aa86748b31b2e5afb8821 Former-commit-id: 09347cdd5a54cd307aa675909b8ff9848b67117d [formerly 9540b309b36e47f21e6de63fff802ff560d59947] Former-commit-id: fd931a3e6434122e77cf5a95233090ebf626cd50 --- .../META-INF/MANIFEST.MF | 3 +- .../META-INF/MANIFEST.MF | 1 + .../viz/resources/manager/AbstractRBD.java | 54 +++++++++++++++---- .../resources/manager/ResourceFactory.java | 19 +++---- 4 files changed, 55 insertions(+), 22 deletions(-) diff --git a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF index 47222c2ab8..a3561a026f 100644 --- a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Core Plug-in Bundle-SymbolicName: com.raytheon.uf.viz.core;singleton:=true -Bundle-Version: 1.12.1174.qualifier +Bundle-Version: 1.13.0.qualifier Bundle-Activator: com.raytheon.uf.viz.core.Activator Bundle-Vendor: Raytheon Require-Bundle: org.eclipse.ui, @@ -77,6 +77,7 @@ Export-Package: com.raytheon.uf.viz.core, com.raytheon.uf.viz.core.notification.observers, com.raytheon.uf.viz.core.preferences, com.raytheon.uf.viz.core.procedures, + com.raytheon.uf.viz.core.reflect, com.raytheon.uf.viz.core.requests, com.raytheon.uf.viz.core.rsc, com.raytheon.uf.viz.core.rsc.capabilities, diff --git a/ncep/gov.noaa.nws.ncep.viz.resources/META-INF/MANIFEST.MF b/ncep/gov.noaa.nws.ncep.viz.resources/META-INF/MANIFEST.MF index fda659921f..1d5205be98 100644 --- a/ncep/gov.noaa.nws.ncep.viz.resources/META-INF/MANIFEST.MF +++ b/ncep/gov.noaa.nws.ncep.viz.resources/META-INF/MANIFEST.MF @@ -10,6 +10,7 @@ Require-Bundle: org.apache.batik;bundle-version="1.6.0", org.eclipse.ui, org.eclipse.core.runtime, com.raytheon.viz.core, + com.raytheon.uf.viz.core, com.raytheon.viz.ui, javax.measure;bundle-version="1.0.0", org.apache.commons.lang, diff --git a/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/AbstractRBD.java b/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/AbstractRBD.java index a14e41e0b3..897ffaa727 100644 --- a/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/AbstractRBD.java +++ b/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/AbstractRBD.java @@ -1,7 +1,5 @@ package gov.noaa.nws.ncep.viz.resources.manager; -import gov.noaa.nws.ncep.viz.common.area.PredefinedArea; -import gov.noaa.nws.ncep.viz.common.area.PredefinedAreaFactory; import gov.noaa.nws.ncep.viz.common.display.INatlCntrsDescriptor; import gov.noaa.nws.ncep.viz.common.display.INatlCntrsPaneManager; import gov.noaa.nws.ncep.viz.common.display.INatlCntrsRenderableDisplay; @@ -21,6 +19,7 @@ import gov.noaa.nws.ncep.viz.ui.display.NcPaneLayout; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.util.Collection; import java.util.Map; import javax.xml.bind.JAXBException; @@ -32,14 +31,16 @@ import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.serialization.ISerializableObject; +import com.raytheon.uf.common.serialization.JAXBManager; import com.raytheon.uf.common.serialization.SerializationException; -import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.serialization.jaxb.JAXBClassLocator; +import com.raytheon.uf.common.serialization.jaxb.JaxbDummyObject; import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.VariableSubstitutionUtil; import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay; import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.reflect.SubClassLocator; import com.raytheon.uf.viz.core.rsc.ResourceList; import com.raytheon.viz.ui.editor.AbstractEditor; @@ -62,7 +63,8 @@ import com.raytheon.viz.ui.editor.AbstractEditor; * 11/25/12 #630 Greg Hull getDefaultRBD() * 02/22/10 #972 Greg Hull created from old RbdBundle * 05/14/13 #862 Greg Hull implement INatlCntrsPaneManager - * + * 10/29/13 #2491 bsteffen Use custom JAXB context instead of SerializationUtil. + * * * * @author ghull @@ -71,7 +73,9 @@ import com.raytheon.viz.ui.editor.AbstractEditor; @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) public abstract class AbstractRBD - implements INatlCntrsPaneManager, ISerializableObject, Comparable> { + implements INatlCntrsPaneManager, Comparable> { + + private static JAXBManager jaxb; @XmlElement protected NcDisplayType displayType = NcDisplayType.NMAP_DISPLAY; @@ -259,7 +263,7 @@ public abstract class AbstractRBD File tempRbdFile = File.createTempFile("tempRBD-", ".xml"); - SerializationUtil.jaxbMarshalToXmlFile( rbdBndl, + getJaxbManager().marshalToXmlFile(rbdBndl, tempRbdFile.getAbsolutePath() ); AbstractRBD clonedRbd = getRbd( tempRbdFile ); @@ -289,6 +293,8 @@ public abstract class AbstractRBD } catch (SerializationException e) { throw new VizException( e ); + } catch (JAXBException e) { + throw new VizException(e); } catch (VizException e) { throw new VizException("Error loading rbd "+rbdBndl.rbdName+" :"+e.getMessage() ); } catch (IOException e) { // from createTempFile @@ -396,7 +402,7 @@ public abstract class AbstractRBD public String toXML() throws VizException { try { - return SerializationUtil.marshalToXml(this); + return getJaxbManager().marshalToXml(this); } catch (JAXBException e) { throw new VizException(e); } @@ -588,7 +594,7 @@ public abstract class AbstractRBD String substStr = VariableSubstitutionUtil.processVariables( bundleStr, variables); - Object xmlObj = SerializationUtil.unmarshalFromXml(substStr); + Object xmlObj = getJaxbManager().unmarshalFromXml(substStr); if (!(xmlObj instanceof AbstractRBD)) { System.out.println("Unmarshalled rbd file is not a valid RBD?"); return null; @@ -660,6 +666,36 @@ public abstract class AbstractRBD } } + /** + * Builds and returns a JAXB manager which has the ability to + * marshal/unmarshall all AbstractRBD types. + * + * @return a JAXBManager to use for marshalling/unmarshalling RBDs. + * @throws JAXBException + * if there are illegal JAXB annotations. + */ + public static synchronized JAXBManager getJaxbManager() + throws JAXBException { + if (jaxb == null) { + SubClassLocator locator = new SubClassLocator(); + Collection> classes = JAXBClassLocator.getJAXBClasses( + locator, AbstractRBD.class); + locator.save(); + + Class[] jaxbClasses = new Class[classes.size() + 1]; + classes.toArray(jaxbClasses); + /* + * Add JaxbDummyObject at the begining so properties are loaded + * correctly + */ + jaxbClasses[jaxbClasses.length - 1] = jaxbClasses[0]; + jaxbClasses[0] = JaxbDummyObject.class; + + jaxb = new JAXBManager(jaxbClasses); + } + return jaxb; + } + public NCTimeMatcher getTimeMatcher() { if (timeMatcher == null) { timeMatcher = (NCTimeMatcher) displays[0].getDescriptor() diff --git a/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/ResourceFactory.java b/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/ResourceFactory.java index d9cb7f756f..1103ac2264 100644 --- a/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/ResourceFactory.java +++ b/ncep/gov.noaa.nws.ncep.viz.resources/src/gov/noaa/nws/ncep/viz/resources/manager/ResourceFactory.java @@ -6,26 +6,20 @@ import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsRequestableResourceData; import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsResourceData; import gov.noaa.nws.ncep.viz.resources.INatlCntrsResourceData; -import java.io.BufferedReader; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileReader; -import java.io.IOException; import java.util.HashMap; -import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.viz.core.VariableSubstitutionUtil; -import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.procedures.Bundle; import com.raytheon.uf.viz.core.rsc.ResourceGroup; import com.raytheon.uf.viz.core.rsc.ResourceList; /** - * Class used by the content providers for Resources and Overlays. This stores the - * instantiated Resource Bundle Templates first with the default attributes and - * additionally stores later changes to the attributes. + * Class used by the content providers for Resources and Overlays. This stores + * the instantiated Resource Bundle Templates first with the default attributes + * and additionally stores later changes to the attributes. * *
  * SOFTWARE HISTORY
@@ -43,10 +37,11 @@ import com.raytheon.uf.viz.core.rsc.ResourceList;
  * 08/23/10     #273        Greg Hull       isVisible()
  * 11/17/11     #518        Greg Hull       set dfltFrameTimes (GDATTIM)
  * 02/10/13     #972        Greg Hull       getSupportedDisplayTypes
- *   
+ * 10/29/13     #2491       bsteffen        Use AbstratRBD JAXBManager instead of SerializationUtil.
+ * 
  * 
* - * @author + * @author * @version 1 */ @@ -187,7 +182,7 @@ public class ResourceFactory { ResourceList bndl_rscs = null; - Object rg = SerializationUtil.unmarshalFromXml(substStr); + Object rg = AbstractRBD.getJaxbManager().unmarshalFromXml(substStr); if( !(rg instanceof ResourceGroup) ) { throw new VizException("Resource Bundle template has unexpected class. (not ResourceGroup)"); From 90d3c540a669a2d9c90afecef65ad7933473e2a0 Mon Sep 17 00:00:00 2001 From: Dave Hladky Date: Tue, 29 Oct 2013 13:05:47 -0500 Subject: [PATCH 09/15] Issue #2361 Centralized serialization to the HarvesterConfigurationManager. Former-commit-id: f5b9d3be39ee86972a5a1e1a081fcc4935c23705 [formerly 6cb541d1a1764863327f8677f98e10d4bd24b35e] [formerly f5b9d3be39ee86972a5a1e1a081fcc4935c23705 [formerly 6cb541d1a1764863327f8677f98e10d4bd24b35e] [formerly 15aed68c0221ce6a72329bae4ee1914536f0ba61 [formerly ded6bbf39f6d6fe05f31d61f310e7473d55a6643]]] Former-commit-id: 15aed68c0221ce6a72329bae4ee1914536f0ba61 Former-commit-id: b5e309f973423fcac05168cb31957a046929cfca [formerly a8ab9072cc82e6fcf2016a7d8ac0b6662f191cc4] Former-commit-id: 072fa5de62e2e798498b1d7474a2db94308a4d48 --- .../HarvesterConfigurationManager.java | 52 ++++++++++++++----- .../harvester/CrawlMetaDataHandler.java | 6 +-- .../harvester/crawler/CrawlLauncher.java | 9 ++-- .../harvester/crawler/Crawler.java | 8 +-- .../crawler/FileCommunicationStrategy.java | 14 ++--- .../crawler/MainSequenceCrawlLauncher.java | 8 +-- .../harvester/crawler/SeedCrawlLauncher.java | 6 +-- 7 files changed, 61 insertions(+), 42 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java b/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java index 174c2f7f64..170a3b72eb 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java @@ -20,6 +20,7 @@ package com.raytheon.uf.common.datadelivery.harvester; * further licensing information. **/ +import java.io.File; import java.util.Arrays; import java.util.List; @@ -79,13 +80,7 @@ public class HarvesterConfigurationManager { for (LocalizationFile lf : getLocalizedFiles()) { - try { - config = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, lf.getFile()); - } catch (SerializationException e) { - statusHandler.handle(Priority.ERROR, - "Can't deserialize harvester config at " - + lf.getFile().getPath(), e); - } + config = getHarvesterFile(lf.getFile()); if (config != null) { Agent agent = config.getAgent(); @@ -110,13 +105,7 @@ public class HarvesterConfigurationManager { for (LocalizationFile lf : getLocalizedFiles()) { - try { - config = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, lf.getFile()); - } catch (SerializationException e) { - statusHandler.handle(Priority.ERROR, - "Can't deserialize harvester config at " - + lf.getFile().getPath(), e); - } + config = getHarvesterFile(lf.getFile()); if (config != null) { Agent agent = config.getAgent(); @@ -132,4 +121,39 @@ public class HarvesterConfigurationManager { return config; } + /** + * Get this harvester configuration File + * @param file + * @return + */ + public static HarvesterConfig getHarvesterFile(File file) { + + HarvesterConfig config = null; + + try { + config = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, file); + } catch (SerializationException e) { + statusHandler.handle(Priority.ERROR, + "Can't deserialize harvester config at " + + file.getPath(), e); + } + + return config; + + } + + /** + * Writes the harvester config files + * @param config + * @param file + */ + public static void setHarvesterFile(HarvesterConfig config, File file) { + try { + HarvesterJaxbManager.getJaxb().marshalToXmlFile(config, + file.getAbsolutePath()); + } catch (SerializationException e) { + statusHandler.handle(Priority.ERROR, "Couldn't write Harvester Config file.", e); + } + } + } diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/CrawlMetaDataHandler.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/CrawlMetaDataHandler.java index 0553472940..a5233f864a 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/CrawlMetaDataHandler.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/CrawlMetaDataHandler.java @@ -15,7 +15,7 @@ import java.util.Set; import com.raytheon.uf.common.datadelivery.harvester.Agent; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; -import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; +import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager; import com.raytheon.uf.common.datadelivery.registry.Collection; import com.raytheon.uf.common.datadelivery.registry.Provider; import com.raytheon.uf.common.datadelivery.registry.Utils; @@ -99,9 +99,9 @@ public class CrawlMetaDataHandler implements RegistryInitializedListener { if (files != null) { for (LocalizationFile file : files) { - try { - HarvesterConfig hc = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, file.getFile()); + HarvesterConfig hc = HarvesterConfigurationManager + .getHarvesterFile(file.getFile()); Agent agent = hc.getAgent(); if (agent != null) { diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/CrawlLauncher.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/CrawlLauncher.java index 67a9f483b4..c6a150c0c1 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/CrawlLauncher.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/CrawlLauncher.java @@ -12,7 +12,7 @@ import org.quartz.JobExecutionException; import com.raytheon.uf.common.datadelivery.harvester.Agent; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; -import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; +import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; @@ -143,9 +143,10 @@ public abstract class CrawlLauncher implements Job { if (files != null) { for (LocalizationFile lf : files) { - HarvesterConfig hc = HarvesterJaxbManager.getJaxb() - .unmarshalFromXmlFile(HarvesterConfig.class, - lf.getFile()); + + HarvesterConfig hc = HarvesterConfigurationManager + .getHarvesterFile(lf.getFile()); + if (hc.getAgent() != null) { // we only want crawler types for CrawlerMetadata Agent agent = hc.getAgent(); diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java index 84245a613e..a5d8aa879e 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java @@ -16,6 +16,7 @@ import com.raytheon.edex.util.Util; import com.raytheon.uf.common.comm.ProxyConfiguration; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; +import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager; import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; import com.raytheon.uf.common.datadelivery.registry.Collection; import com.raytheon.uf.common.serialization.SerializationException; @@ -139,10 +140,9 @@ public abstract class Crawler { HarvesterConfig hc = null; try { - hc = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile( - HarvesterConfig.class, configFile); - } catch (SerializationException e1) { - e1.printStackTrace(); + hc = HarvesterConfigurationManager.getHarvesterFile(configFile); + } catch (Exception e1) { + statusHandler.handle(Priority.ERROR, e1.getLocalizedMessage(), e1); } return hc; diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/FileCommunicationStrategy.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/FileCommunicationStrategy.java index eb74177c16..3b5c439810 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/FileCommunicationStrategy.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/FileCommunicationStrategy.java @@ -34,7 +34,7 @@ import java.util.regex.Pattern; import com.google.common.annotations.VisibleForTesting; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; -import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; +import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager; import com.raytheon.uf.common.datadelivery.harvester.ProtoCollection; import com.raytheon.uf.common.datadelivery.registry.Collection; import com.raytheon.uf.common.datadelivery.registry.Provider; @@ -44,7 +44,6 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException; import com.raytheon.uf.common.serialization.ExceptionWrapper; import com.raytheon.uf.common.serialization.SerializableExceptionWrapper; import com.raytheon.uf.common.serialization.SerializationException; @@ -74,7 +73,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.ProviderCollectionLinkStore; * Aug 06, 2012 1022 djohnson Add shutdown(), write out millis with filename to prevent overwriting. * Sep 10, 2012 1154 djohnson Use JAXB instead of thrift, allowing introspection of links, return files in ascending order. * Mar 14, 2013 1794 djohnson Consolidate common FilenameFilter implementations. - * Oct 28, 2013 2361 dhladky Fixed up JAXBManager. + * * Oct 28, 2013 2361 dhladky Fixed up JAXBManager. * * * @@ -375,18 +374,15 @@ class FileCommunicationStrategy implements CommunicationStrategy { File file = lf.getFile(); try { - HarvesterJaxbManager.getJaxb().marshalToXmlFile(hconfig, - file.getAbsolutePath()); + HarvesterConfigurationManager.setHarvesterFile(hconfig, file); lf.save(); - } catch (SerializationException e) { + } catch (Exception e) { statusHandler .error("Unable to recreate the " + provider + "-harvester.xml configuration! Save of new collections failed", e); - } catch (LocalizationOpFailedException e) { - statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e); - } + } } /** diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/MainSequenceCrawlLauncher.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/MainSequenceCrawlLauncher.java index f611eefce6..7ab85f2738 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/MainSequenceCrawlLauncher.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/MainSequenceCrawlLauncher.java @@ -6,7 +6,7 @@ import java.util.List; import com.raytheon.uf.common.datadelivery.harvester.Agent; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; -import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; +import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; @@ -79,9 +79,9 @@ public class MainSequenceCrawlLauncher extends CrawlLauncher { // if many, start many for (LocalizationFile lf : getLocalizedFiles()) { - HarvesterConfig hc = HarvesterJaxbManager.getJaxb() - .unmarshalFromXmlFile(HarvesterConfig.class, - lf.getFile()); + HarvesterConfig hc = HarvesterConfigurationManager + .getHarvesterFile(lf.getFile()); + if (hc.getProvider().getName().equals(providerName)) { if (hc.getAgent() != null) { // we only want crawler types for CrawlerMetadata diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/SeedCrawlLauncher.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/SeedCrawlLauncher.java index ba9f1e443a..9e81389b66 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/SeedCrawlLauncher.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/SeedCrawlLauncher.java @@ -6,7 +6,7 @@ import java.util.List; import com.raytheon.uf.common.datadelivery.harvester.Agent; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; -import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; +import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; @@ -77,9 +77,7 @@ public class SeedCrawlLauncher extends CrawlLauncher { // if many, start many for (LocalizationFile lf : getLocalizedFiles()) { - HarvesterConfig hc = HarvesterJaxbManager.getJaxb() - .unmarshalFromXmlFile(HarvesterConfig.class, - lf.getFile()); + HarvesterConfig hc = HarvesterConfigurationManager.getHarvesterFile(lf.getFile()); if (hc.getProvider().getName().equals(providerName)) { if (hc.getAgent() != null) { From cec7d355058491b5059e4fa6b7dd756fe7dd1d51 Mon Sep 17 00:00:00 2001 From: Dave Hladky Date: Tue, 29 Oct 2013 13:45:05 -0500 Subject: [PATCH 10/15] Issue #2361 Moved to private JAXB Former-commit-id: be351c82edc0dab6f5b9a4f756d1668767b0b4ec [formerly 5b5e1ca293eddf536bf9fa80b0788479acf438b4] [formerly be351c82edc0dab6f5b9a4f756d1668767b0b4ec [formerly 5b5e1ca293eddf536bf9fa80b0788479acf438b4] [formerly 33a0890d310f71afcf045305081b419dd3527f29 [formerly facfc8287c3826ca9764b7be336cc332b5567a94]]] Former-commit-id: 33a0890d310f71afcf045305081b419dd3527f29 Former-commit-id: 3eff51897bdb0cfd5a60944f3973ccfdd58a46e3 [formerly b55b05fa8bc4027a1b43b67b291167a7ccdee9d0] Former-commit-id: b5e892c16e5f9370fdba07cddadd6ef50adc77f6 --- .../HarvesterConfigurationManager.java | 56 ++++++++++--- .../harvester/HarvesterJaxbManager.java | 82 ------------------- .../harvester/crawler/Crawler.java | 2 - 3 files changed, 46 insertions(+), 94 deletions(-) delete mode 100644 edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterJaxbManager.java diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java b/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java index 170a3b72eb..3c72740961 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterConfigurationManager.java @@ -24,9 +24,16 @@ import java.io.File; import java.util.Arrays; import java.util.List; +import javax.xml.bind.JAXBException; + +import com.raytheon.uf.common.datadelivery.registry.Connection; +import com.raytheon.uf.common.datadelivery.registry.Provider; +import com.raytheon.uf.common.datadelivery.registry.ProviderType; +import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.serialization.JAXBManager; import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -53,6 +60,32 @@ public class HarvesterConfigurationManager { private static final IUFStatusHandler statusHandler = UFStatus .getHandler(HarvesterConfigurationManager.class); + + private static final Class[] clazzess = new Class[] { + HarvesterConfig.class, Provider.class, Connection.class, + ProviderType.class, ServiceType.class, Agent.class, + CrawlAgent.class, OGCAgent.class, ConfigLayer.class }; + + private static JAXBManager jaxb = null; + + /** + * marshall and unmarshall harvester objects + * + * @return + */ + private static JAXBManager getJaxb() { + + if (jaxb == null) { + try { + jaxb = new JAXBManager(clazzess); + + } catch (JAXBException e) { + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), + e); + } + } + return jaxb; + } /** * Gets site and base level configs for harvesters @@ -123,36 +156,39 @@ public class HarvesterConfigurationManager { /** * Get this harvester configuration File + * * @param file * @return */ public static HarvesterConfig getHarvesterFile(File file) { - + HarvesterConfig config = null; - + try { - config = HarvesterJaxbManager.getJaxb().unmarshalFromXmlFile(HarvesterConfig.class, file); + config = getJaxb() + .unmarshalFromXmlFile(HarvesterConfig.class, file); } catch (SerializationException e) { statusHandler.handle(Priority.ERROR, - "Can't deserialize harvester config at " - + file.getPath(), e); + "Can't deserialize harvester config at " + file.getPath(), + e); } - + return config; } - + /** * Writes the harvester config files + * * @param config * @param file */ public static void setHarvesterFile(HarvesterConfig config, File file) { try { - HarvesterJaxbManager.getJaxb().marshalToXmlFile(config, - file.getAbsolutePath()); + getJaxb().marshalToXmlFile(config, file.getAbsolutePath()); } catch (SerializationException e) { - statusHandler.handle(Priority.ERROR, "Couldn't write Harvester Config file.", e); + statusHandler.handle(Priority.ERROR, + "Couldn't write Harvester Config file.", e); } } diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterJaxbManager.java b/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterJaxbManager.java deleted file mode 100644 index 45a78baab0..0000000000 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.harvester/src/com/raytheon/uf/common/datadelivery/harvester/HarvesterJaxbManager.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.raytheon.uf.common.datadelivery.harvester; - -/** - * 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. - **/ - -import javax.xml.bind.JAXBException; - -import com.raytheon.uf.common.datadelivery.registry.Connection; -import com.raytheon.uf.common.datadelivery.registry.Provider; -import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType; -import com.raytheon.uf.common.datadelivery.registry.ProviderType; -import com.raytheon.uf.common.serialization.JAXBManager; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; -/** - * JAXB for Harvester - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Oct 23, 2013 2361       dhladky     Initial creation
- * 
- * 
- * - * @author dhladky - * @version 1.0 - */ - -public class HarvesterJaxbManager { - - private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(HarvesterJaxbManager.class); - - private static Class[] clazzess = new Class[] { - HarvesterConfig.class, Provider.class, Connection.class, - ProviderType.class, ServiceType.class, Agent.class, - CrawlAgent.class, OGCAgent.class, ConfigLayer.class }; - - private JAXBManager jaxb = null; - - private static HarvesterJaxbManager instance = new HarvesterJaxbManager(); - - /** - * marshall and unmarshall harvester objects - * - * @return - */ - public static JAXBManager getJaxb() { - - if (instance.jaxb == null) { - try { - instance.jaxb = new JAXBManager(clazzess); - - } catch (JAXBException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), - e); - } - } - return instance.jaxb; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java index a5d8aa879e..fb8263eaec 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.harvester/src/com/raytheon/uf/edex/datadelivery/harvester/crawler/Crawler.java @@ -17,9 +17,7 @@ import com.raytheon.uf.common.comm.ProxyConfiguration; import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig; import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager; -import com.raytheon.uf.common.datadelivery.harvester.HarvesterJaxbManager; import com.raytheon.uf.common.datadelivery.registry.Collection; -import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; From 26941f1033914d23c03d9bd2b5d1a0f4cb022bc1 Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Mon, 28 Oct 2013 12:27:40 -0500 Subject: [PATCH 11/15] Issue #2430 - Implement the percent used bandwidth utilization graph. Change-Id: Iad1d750ec1bb0a66a833f8358e27a80d0d6b42c5 Former-commit-id: 2d7c38290eb56d24298e5c52c12a755382694cb9 [formerly 6d5f69730084b2c2c8ba17c9366af4bb0c802b77] [formerly 2d7c38290eb56d24298e5c52c12a755382694cb9 [formerly 6d5f69730084b2c2c8ba17c9366af4bb0c802b77] [formerly 25e4a4741cbbddc6361182cb2b7f9f306698b10d [formerly 5b628ac782fc8b76729c74fe8bf995a7fc634aaa]]] Former-commit-id: 25e4a4741cbbddc6361182cb2b7f9f306698b10d Former-commit-id: 4beb79d5a7878fc4ec4c7dbcf308a1ff8a2604fd [formerly 73ecb9af6b369f072e620a94431496733e4260bd] Former-commit-id: 2c7dbda379befc045a569ed00e129e7babab28a4 --- .../actions/BandwidthScheduleGraphAction.java | 2 +- .../bandwidth/ui/BandwidthCanvasComp.java | 322 +++++++++- .../bandwidth/ui/BandwidthImageMgr.java | 142 +++- .../bandwidth/ui/BandwidthUsedConfigDlg.java | 179 ++++++ .../bandwidth/ui/BandwidthUtilizationDlg.java | 73 ++- .../datadelivery/bandwidth/ui/GraphImage.java | 11 +- .../datadelivery/bandwidth/ui/GraphPoint.java | 87 +++ .../bandwidth/ui/IGraphOptions.java | 24 +- .../bandwidth/ui/UtilizationGraphImage.java | 334 ++++++++++ .../bandwidth/ui/UtilizationHeaderImage.java | 175 +++++ .../bandwidth/ui/UtilizationLabelImage.java | 175 +++++ .../bandwidth/ui/XHeaderImage.java | 8 +- .../viz/ui/widgets/TwoValueSliderCanvas.java | 608 ++++++++++++++++++ 13 files changed, 2116 insertions(+), 24 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthUsedConfigDlg.java create mode 100644 cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/GraphPoint.java create mode 100644 cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/UtilizationGraphImage.java create mode 100644 cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/UtilizationHeaderImage.java create mode 100644 cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/UtilizationLabelImage.java create mode 100644 cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/TwoValueSliderCanvas.java diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/actions/BandwidthScheduleGraphAction.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/actions/BandwidthScheduleGraphAction.java index 515fe0ddfc..187c7f1912 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/actions/BandwidthScheduleGraphAction.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/actions/BandwidthScheduleGraphAction.java @@ -39,6 +39,7 @@ import com.raytheon.uf.viz.datadelivery.bandwidth.ui.GraphDataUtil; * ------------ ---------- ----------- -------------------------- * Nov 25, 2012 1269 mpduff Initial creation. * Dec 13, 2012 1269 lvenable Updated to use a graph utility for the graph data. + * Oct 28, 2013 2430 mpduff Removed redraw if already open. * * * @@ -64,7 +65,6 @@ public class BandwidthScheduleGraphAction extends AbstractHandler { dlg = new BandwidthUtilizationDlg(shell, gdu); dlg.open(); } else { - dlg.redrawGraph(); dlg.open(); } diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthCanvasComp.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthCanvasComp.java index 4286ec7b6b..addfae2635 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthCanvasComp.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthCanvasComp.java @@ -47,6 +47,7 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -61,6 +62,7 @@ import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Slider; import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData; +import com.raytheon.uf.common.datadelivery.registry.Network; import com.raytheon.uf.common.datadelivery.service.SubscriptionNotificationResponse; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; @@ -71,6 +73,8 @@ import com.raytheon.uf.viz.core.notification.NotificationException; import com.raytheon.uf.viz.core.notification.NotificationMessage; import com.raytheon.uf.viz.core.notification.jobs.NotificationManagerJob; import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.CanvasImages; +import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphSection; +import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphType; import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.SortBy; import com.raytheon.uf.viz.datadelivery.common.ui.IDialogClosed; import com.raytheon.uf.viz.datadelivery.common.ui.SubscriptionViewer; @@ -78,9 +82,10 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils; /** * - * This class contains all of the canvases for graphing data. There are Graph , - * X Label, Y Label, X Header, and Y Header canvases on the display. The Graph, - * X Label, and Y Label canvases can be zoomed and panned. + * This class contains all of the canvases for graphing data. There are + * Subscription Graph, Bandwidth Graph, X Label, Y Label, X Header, and Y Header + * canvases on the display. The Graph, X Label, and Y Label canvases can be + * zoomed and panned. * *
  * 
@@ -92,7 +97,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
  * Dec 13, 2012   1269     lvenable    Fixes and updates.
  * Jan 07, 2013   1451     djohnson    Use TimeUtil.newGmtCalendar().
  * Jan 28, 2013   1529     djohnson    Disable menu items if no subscriptions selected.
- * 
+ * Oct 28, 2013   2430     mpduff      Add % of bandwidth utilized graph.
  * 
* * @author lvenable @@ -105,6 +110,8 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, private final IUFStatusHandler statusHandler = UFStatus .getHandler(BandwidthCanvasComp.class); + private final int MISSING = -999; + /** Parent composite */ private final Composite parentComp; @@ -165,12 +172,18 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, /** Counts the minutes until the next full update. */ private int fullUpdateMinuteCount = 0; + /** Vertical line marking the mouse pointer's location */ + private int mouseMarker; + + /** Bandwidth popup menu */ + private Menu bandwidthPopupMenu; + /** * Constructor. * * @param parentComp * Parent composite. - * @param bgd + * @param graphDataUtil * Bandwidth graph data object */ public BandwidthCanvasComp(Composite parentComp, GraphDataUtil graphDataUtil) { @@ -211,16 +224,28 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, this.setLayout(gl); this.setLayoutData(gd); + createFillerSpace(2); + createUtilizationHeaderCanvas(); + createFillerSpace(1); + + createFillerSpace(1); + createUtilizationLabelCanvas(); + createUtilizationGraphCanvas(); + createFillerSpace(1); + createFillerSpace(2); createXHeaderCanvas(); createFillerSpace(1); + createYHeaderCanvas(); createYLabelCanvas(); createGraphCanvas(); createVerticalSlider(); + createFillerSpace(2); createXLabelCanvas(); createFillerSpace(1); + createFillerSpace(2); createHorizontalSlider(); createFillerSpace(1); @@ -315,6 +340,18 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, // Create the y header canvas settings cs = new CanvasSettings(35, heightWithBuffer, 35, 440, 0, 0); canvasSettingsMap.put(CanvasImages.Y_HEADER, cs); + + // Create the bandwidth utilization header settings + cs = new CanvasSettings(140, 60, 140, 0, 20, 0); + canvasSettingsMap.put(CanvasImages.UTILIZATION_LABEL, cs); + + // Create the bandwidth utilization graph settings + cs = new CanvasSettings(740, 60, graphSize.x, 100, xSpaceBuffer, 0); + canvasSettingsMap.put(CanvasImages.UTILIZATION_GRAPH, cs); + + // Create the Utilization header canvas settings + cs = new CanvasSettings(740, 40, 740, 40, xSpaceBuffer, 0); + canvasSettingsMap.put(CanvasImages.UTILIZATION_HEADER, cs); } /** @@ -365,6 +402,124 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, spaceLbl.setVisible(false); } + /** + * Create the utilization graph header canvas. + */ + private void createUtilizationHeaderCanvas() { + Canvas canvas = new Canvas(this, SWT.DOUBLE_BUFFERED); + CanvasSettings cs = canvasSettingsMap + .get(CanvasImages.UTILIZATION_HEADER); + + GridData gd = new GridData(cs.getCanvasWidth(), cs.getCanvasHeight()); + canvas.setLayoutData(gd); + + canvas.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + drawUtilizationHeaderCanvas(e.gc); + } + }); + + canvas.addMouseListener(new MouseAdapter() { + @Override + public void mouseDown(MouseEvent e) { + if (e.button == 1) { + handleUtilizationHeaderMouseEvent(e); + } + } + }); + + canvasMap.put(CanvasImages.UTILIZATION_HEADER, canvas); + } + + /** + * Create the utilization graph's label canvas. + */ + private void createUtilizationLabelCanvas() { + Canvas canvas = new Canvas(this, SWT.DOUBLE_BUFFERED); + CanvasSettings cs = canvasSettingsMap + .get(CanvasImages.UTILIZATION_LABEL); + + GridData gd = new GridData(cs.getCanvasWidth(), cs.getCanvasHeight()); + canvas.setLayoutData(gd); + + canvas.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + drawUtilizationLabelCanvas(e.gc); + } + }); + + canvasMap.put(CanvasImages.UTILIZATION_LABEL, canvas); + } + + /** + * Create the utilization graph canvas. + */ + private void createUtilizationGraphCanvas() { + Canvas canvas = new Canvas(this, SWT.DOUBLE_BUFFERED); + CanvasSettings cs = canvasSettingsMap + .get(CanvasImages.UTILIZATION_GRAPH); + + GridData gd = new GridData(cs.getCanvasWidth(), cs.getCanvasHeight()); + canvas.setLayoutData(gd); + + canvas.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + drawUtilizationGraphCanvas(e.gc); + } + }); + + /* + * Add a mouse track listener to determine when the mouse hovers over + * the canvas. + */ + canvas.addMouseTrackListener(new MouseTrackAdapter() { + @Override + public void mouseExit(MouseEvent e) { + // Remove mouse vertical line + mouseMarker = MISSING; + canvasMap.get(CanvasImages.GRAPH).redraw(); + canvasMap.get(CanvasImages.UTILIZATION_GRAPH).redraw(); + } + }); + + /* + * Add a mouse move listener to determine when the mouse is moving over + * the canvas. + */ + canvas.addMouseMoveListener(new MouseMoveListener() { + @Override + public void mouseMove(MouseEvent e) { + + // If the mouse button is not pressed then set the previous + // mouse x,y coordinates to the current mouse x,y position. + if (!mouseDown) { + previousMousePoint.x = e.x; + previousMousePoint.y = e.y; + mouseMarker = e.x; + canvasMap.get(CanvasImages.GRAPH).redraw(); + canvasMap.get(CanvasImages.UTILIZATION_GRAPH).redraw(); + return; + } + + mouseMarker = MISSING; + } + }); + + canvas.addMouseListener(new MouseAdapter() { + @Override + public void mouseDown(MouseEvent e) { + if (e.button == 3) { + bandwidthUsedPopupMenu(); + } + } + }); + + canvasMap.put(CanvasImages.UTILIZATION_GRAPH, canvas); + } + /** * Create the X header canvas. */ @@ -424,7 +579,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, * Create the graph canvas. */ private void createGraphCanvas() { - Canvas graphCanvas = new Canvas(this, SWT.DOUBLE_BUFFERED); + final Canvas graphCanvas = new Canvas(this, SWT.DOUBLE_BUFFERED); GridData gd = new GridData(graphCanvasSettings.getCanvasWidth(), graphCanvasSettings.getCanvasHeight()); @@ -468,6 +623,14 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, * the canvas. */ graphCanvas.addMouseTrackListener(new MouseTrackAdapter() { + @Override + public void mouseExit(MouseEvent e) { + // Remove mouse vertical line + mouseMarker = MISSING; + canvasMap.get(CanvasImages.GRAPH).redraw(); + canvasMap.get(CanvasImages.UTILIZATION_GRAPH).redraw(); + } + @Override public void mouseHover(MouseEvent e) { displayToolTipText(e, CanvasImages.GRAPH); @@ -487,6 +650,9 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, if (mouseDown == false) { previousMousePoint.x = e.x; previousMousePoint.y = e.y; + mouseMarker = e.x; + canvasMap.get(CanvasImages.GRAPH).redraw(); + canvasMap.get(CanvasImages.UTILIZATION_GRAPH).redraw(); return; } @@ -523,6 +689,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, canvasMap.get(CanvasImages.GRAPH).redraw(); canvasMap.get(CanvasImages.X_LABEL).redraw(); canvasMap.get(CanvasImages.Y_LABEL).redraw(); + canvasMap.get(CanvasImages.UTILIZATION_GRAPH).redraw(); previousMousePoint.x = e.x; previousMousePoint.y = e.y; @@ -719,6 +886,47 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, canvasMap.get(CanvasImages.GRAPH).redraw(); canvasMap.get(CanvasImages.X_LABEL).redraw(); + canvasMap.get(CanvasImages.UTILIZATION_GRAPH).redraw(); + } + + private void drawUtilizationHeaderCanvas(GC gc) { + gc.drawImage(imgMap.get(CanvasImages.UTILIZATION_HEADER), 0, 0); + } + + private void drawUtilizationLabelCanvas(GC gc) { + gc.drawImage(imgMap.get(CanvasImages.UTILIZATION_LABEL), 0, 0); + + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + CanvasSettings cs = canvasSettingsMap + .get(CanvasImages.UTILIZATION_LABEL); + gc.drawLine(0, 0, cs.getCanvasWidth(), 0); + gc.drawLine(0, 0, 0, cs.getCanvasHeight()); + gc.drawLine(0, cs.getCanvasHeight() - 1, cs.getCanvasWidth(), + cs.getCanvasHeight() - 1); + gc.drawLine(cs.getCanvasWidth() - 1, 0, cs.getCanvasWidth() - 1, + cs.getCanvasHeight() - 1); + } + + private void drawUtilizationGraphCanvas(GC gc) { + gc.drawImage(imgMap.get(CanvasImages.UTILIZATION_GRAPH), + cornerPointOffset.x, 0); + + CanvasSettings cs = canvasSettingsMap + .get(CanvasImages.UTILIZATION_GRAPH); + + // draw the mouse locator line + if (mouseMarker != MISSING && mouseMarker > cs.getXSpaceBuffer()) { + gc.drawLine(mouseMarker, 0, mouseMarker, cs.getCanvasHeight()); + } + + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + gc.drawLine(0, 0, cs.getCanvasWidth(), 0); + gc.drawLine(0, 0, 0, cs.getCanvasHeight()); + gc.drawLine(0, cs.getCanvasHeight() - 1, cs.getCanvasWidth(), + cs.getCanvasHeight() - 1); + gc.drawLine(cs.getCanvasWidth() - 1, 0, cs.getCanvasWidth() - 1, + cs.getCanvasHeight() - 1); + } /** @@ -751,6 +959,13 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, gc.drawImage(imgMap.get(CanvasImages.GRAPH), cornerPointOffset.x, cornerPointOffset.y); + // draw the mouse locator line + if (mouseMarker != MISSING + && mouseMarker > graphCanvasSettings.getXSpaceBuffer()) { + gc.drawLine(mouseMarker, 0, mouseMarker, + graphCanvasSettings.getCanvasHeight()); + } + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); gc.drawLine(0, 0, graphCanvasSettings.getCanvasWidth(), 0); gc.drawLine(0, 0, 0, graphCanvasSettings.getCanvasHeight()); @@ -845,6 +1060,19 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, redrawImage(CanvasImages.GRAPH); } + /** + * Handle the mouse event on the Utilization header canvas. + * + * @param me + * Mouse Event + */ + private void handleUtilizationHeaderMouseEvent(MouseEvent me) { + imageMgr.performAction(CanvasImages.UTILIZATION_HEADER, new Point(me.x, + me.y)); + redrawImage(CanvasImages.UTILIZATION_HEADER); + redrawImage(CanvasImages.UTILIZATION_GRAPH); + } + /** * Scroll wheel event handler. * @@ -970,6 +1198,37 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, m.setVisible(true); } + private void bandwidthUsedPopupMenu() { + if (bandwidthPopupMenu == null) { + bandwidthPopupMenu = new Menu(this.getShell(), SWT.POP_UP); + + MenuItem lineMenu = new MenuItem(bandwidthPopupMenu, SWT.RADIO); + lineMenu.setText("Display as Line Graph"); + lineMenu.setSelection(true); + lineMenu.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleBandwidthGraphStyleSelection(GraphType.LINE); + } + }); + + MenuItem barMenu = new MenuItem(bandwidthPopupMenu, SWT.RADIO); + barMenu.setText("Display as Bar Graph"); + barMenu.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleBandwidthGraphStyleSelection(GraphType.BAR); + } + }); + } + bandwidthPopupMenu.setVisible(true); + } + + protected void handleBandwidthGraphStyleSelection(GraphType type) { + imageMgr.setBandwidthGraphType(type); + redrawImage(CanvasImages.UTILIZATION_GRAPH); + } + /** * Select/Deselect all event handler. * @@ -1038,7 +1297,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, * @param ci * The image to redraw */ - private void redrawImage(CanvasImages ci) { + protected void redrawImage(CanvasImages ci) { imageMgr.regenerateImage(ci); imgMap.put(ci, imageMgr.getImage(ci)); canvasMap.get(ci).redraw(); @@ -1094,6 +1353,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, public void setColorByPriority(boolean colorByPriority) { imageMgr.setColorByPriority(colorByPriority); redrawImage(CanvasImages.GRAPH); + redrawImage(CanvasImages.UTILIZATION_GRAPH); } /** @@ -1146,8 +1406,10 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, .getTimeInMillis()); redrawImage(CanvasImages.GRAPH); redrawImage(CanvasImages.X_LABEL); + redrawImage(CanvasImages.UTILIZATION_GRAPH); canvasMap.get(CanvasImages.GRAPH).redraw(); canvasMap.get(CanvasImages.X_LABEL).redraw(); + canvasMap.get(CanvasImages.UTILIZATION_GRAPH); } }); @@ -1191,4 +1453,50 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed, } }); } + + /** + * Set the network for display. + * + * @param network + * The network to display + */ + public void setGraphNetwork(Network network) { + imageMgr.setGraphNetwork(network); + redrawImage(CanvasImages.GRAPH); + redrawImage(CanvasImages.UTILIZATION_GRAPH); + redrawImage(CanvasImages.UTILIZATION_HEADER); + redrawImage(CanvasImages.UTILIZATION_LABEL); + redrawImage(CanvasImages.X_HEADER); + redrawImage(CanvasImages.X_LABEL); + redrawImage(CanvasImages.Y_HEADER); + redrawImage(CanvasImages.Y_LABEL); + } + + /** + * Set the bandwidth used threshold values. + * + * @param thresholdValues + * The threshold values + */ + public void setBandwidthThresholdValues(int[] thresholdValues) { + imageMgr.setBandwidthThreholdValues(thresholdValues); + } + + /** + * Get the bandwidth used threshold values. + * + * @return thresholdValues The threshold values + */ + public int[] getBandwidthThresholdValues() { + return imageMgr.getBandwidthThreholdValues(); + } + + /** + * Get the bandwidth threshold colors. + * + * @return Threshold colors + */ + public Map getBandwidthThresholdColors() { + return imageMgr.getPercentageColorMap(); + } } diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthImageMgr.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthImageMgr.java index 70a2b068ea..568971cdbc 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthImageMgr.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthImageMgr.java @@ -22,6 +22,7 @@ package com.raytheon.uf.viz.datadelivery.bandwidth.ui; import java.util.Collection; import java.util.EnumMap; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import org.eclipse.swt.graphics.Image; @@ -31,7 +32,9 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData; +import com.raytheon.uf.common.datadelivery.registry.Network; import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority; +import com.raytheon.uf.viz.core.RGBColors; /** * Bandwidth utilization graph image manager. @@ -42,10 +45,11 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPri * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Nov 28, 2012 1269 lvenable Initial creation + * Nov 28, 2012 1269 lvenable Initial creation * Dec 13, 2012 1269 lvenable Fixes and updates. * Jan 25, 2013 1528 djohnson Subscription priority is now an enum on subscriptions. - * Jan 28, 2013 1529 djohnson Add hasSubscriptionNameChecked(). + * Jan 28, 2013 1529 djohnson Add hasSubscriptionNameChecked(). + * Oct 28, 2013 2430 mpduff Add % of bandwidth utilized graph. * * * @@ -58,7 +62,7 @@ public class BandwidthImageMgr implements IGraphOptions { * Image type enumeration. */ public enum CanvasImages { - X_HEADER, Y_HEADER, GRAPH, X_LABEL, Y_LABEL; + X_HEADER, Y_HEADER, GRAPH, X_LABEL, Y_LABEL, UTILIZATION_LABEL, UTILIZATION_GRAPH, UTILIZATION_HEADER; }; /** @@ -80,6 +84,20 @@ public class BandwidthImageMgr implements IGraphOptions { } } + /** + * Graph Type + */ + public enum GraphType { + BAR, LINE; + } + + /** + * Signifies which section of the graph. + */ + public enum GraphSection { + LOWER, MIDDLE, UPPER; + } + /** Map of CanvasImages type -> image */ private Map canvasImgMap; @@ -107,9 +125,21 @@ public class BandwidthImageMgr implements IGraphOptions { /** Sort time in millis */ private long sortTimeMillis; - /** Map of priorities to colors. This hold the changed colors by the user. */ + /** Map of priorities to colors. This holds the colors changed by the user. */ private Map priorityColorMap; + /** Map of percentage to colors. This holds the colors changed by the user. */ + private Map percentageColorMap = new LinkedHashMap( + 3); + + /** The bandwidth graph type */ + private GraphType bandwidthGraphType = GraphType.LINE; + + /** The network currently displayed in the graph */ + private Network network = Network.OPSNET; + + private int[] bandwidthThreholdValues = new int[] { 33, 66 }; + /** * Constructor. * @@ -139,13 +169,17 @@ public class BandwidthImageMgr implements IGraphOptions { */ private void init(Composite parentComp, BandwidthGraphData graphData, Map canvasSettingsMap) { - priorityColorMap = new EnumMap( SubscriptionPriority.class); priorityColorMap.put(SubscriptionPriority.LOW, new RGB(6, 122, 255)); priorityColorMap.put(SubscriptionPriority.NORMAL, new RGB(0, 255, 0)); priorityColorMap.put(SubscriptionPriority.HIGH, new RGB(255, 0, 0)); + percentageColorMap.put(GraphSection.LOWER, new RGB(0, 255, 0)); + percentageColorMap.put(GraphSection.MIDDLE, + RGBColors.getRGBColor("yellow")); + percentageColorMap.put(GraphSection.UPPER, new RGB(255, 0, 0)); + canvasImgMap = new HashMap(); populateCanvasMap(parentComp, graphData, canvasSettingsMap); } @@ -188,6 +222,21 @@ public class BandwidthImageMgr implements IGraphOptions { aci = new YHeaderImage(parentComp, cs, graphData); canvasImgMap.put(CanvasImages.Y_HEADER, aci); + // utilization header image + cs = canvasSettingsMap.get(CanvasImages.UTILIZATION_HEADER); + aci = new UtilizationHeaderImage(parentComp, cs, this); + canvasImgMap.put(CanvasImages.UTILIZATION_HEADER, aci); + + // utilization label image + cs = canvasSettingsMap.get(CanvasImages.UTILIZATION_LABEL); + aci = new UtilizationLabelImage(parentComp, cs, this); + canvasImgMap.put(CanvasImages.UTILIZATION_LABEL, aci); + + // utilization graph image + cs = canvasSettingsMap.get(CanvasImages.UTILIZATION_GRAPH); + aci = new UtilizationGraphImage(parentComp, cs, graphData, this); + canvasImgMap.put(CanvasImages.UTILIZATION_GRAPH, aci); + // Regenerate all of the images for (CanvasImages ci : CanvasImages.values()) { canvasImgMap.get(ci).regenerateImage(); @@ -501,4 +550,87 @@ public class BandwidthImageMgr implements IGraphOptions { public boolean hasSubscriptionNameChecked() { return checkMap.containsValue(Boolean.TRUE); } + + /** + * @return the percentageColorMap + */ + public Map getPercentageColorMap() { + return percentageColorMap; + } + + /** + * @param percentageColorMap + * the percentageColorMap to set + */ + public void setPercentageColorMap(Map percentageColorMap) { + this.percentageColorMap = percentageColorMap; + } + + /** + * {@inheritDoc} + */ + @Override + public RGB getPercentColor(GraphSection section) { + return this.percentageColorMap.get(section); + } + + /** + * {@inheritDoc} + */ + @Override + public void setPercentColor(GraphSection percentString, RGB rgb) { + this.percentageColorMap.put(percentString, rgb); + } + /** + * Set the bandwidth used graph type. + * + * @param type + * The graph type + */ + public void setBandwidthGraphType(GraphType type) { + this.bandwidthGraphType = type; + } + + /** + * Get the bandwidth graph type. + * + * @return The Bandwidth graph type + */ + public GraphType getBandwidthGraphType() { + return this.bandwidthGraphType; + } + + /** + * Set the network. + * + * @param network + * The network + */ + public void setGraphNetwork(Network network) { + this.network = network; + } + + /** + * Get the network. + * + * @return The network + */ + public Network getNetwork() { + return this.network; + } + + /** + * @return the bandwidthThreholdValues + */ + public int[] getBandwidthThreholdValues() { + return bandwidthThreholdValues; + } + + /** + * @param bandwidthThreholdValues + * the bandwidthThreholdValues to set + */ + public void setBandwidthThreholdValues(int[] bandwidthThreholdValues) { + this.bandwidthThreholdValues = bandwidthThreholdValues; + } } diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthUsedConfigDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthUsedConfigDlg.java new file mode 100644 index 0000000000..674c61a2e3 --- /dev/null +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthUsedConfigDlg.java @@ -0,0 +1,179 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.datadelivery.bandwidth.ui; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.Shell; + +import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase; +import com.raytheon.viz.ui.widgets.TwoValueSliderCanvas; + +/** + * Dialog to configure the values for the bandwidth used graph. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 27, 2013    2430    mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class BandwidthUsedConfigDlg extends CaveSWTDialogBase { + + private TwoValueSliderCanvas slider; + + private final int lowerVal; + + private final int upperVal; + + private final RGB lowerColor; + + private final RGB midColor; + + private final RGB upperColor; + + /** + * Constructor. + * + * @param shell + * The parent shell + * @param lowerVal + * The lower threshold value + * @param upperVal + * The upper threshold value + * @param lowerColor + * The lower threshold color + * @param midColor + * The middle threshold color + * @param upperColor + * The upper threshold color + */ + public BandwidthUsedConfigDlg(Shell shell, int lowerVal, int upperVal, + RGB lowerColor, RGB midColor, RGB upperColor) { + super(shell, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK + | CAVE.INDEPENDENT_SHELL); + this.setText("Utilization Threshold"); + this.lowerVal = lowerVal; + this.upperVal = upperVal; + this.lowerColor = lowerColor; + this.midColor = midColor; + this.upperColor = upperColor; + } + + /** + * {@inheritDoc} + */ + @Override + protected Layout constructShellLayout() { + return new GridLayout(1, false); + } + + /** + * {@inheritDoc} + */ + @Override + protected Object constructShellLayoutData() { + return new GridData(SWT.FILL, SWT.DEFAULT, true, false); + } + + /** + * {@inheritDoc} + */ + @Override + protected void initializeComponents(Shell shell) { + Group thresholdGroup = new Group(shell, SWT.NONE); + thresholdGroup.setLayout(new GridLayout(1, false)); + thresholdGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, + true)); + thresholdGroup.setText(" Bandwidth Threshold Configuration "); + + slider = new TwoValueSliderCanvas(thresholdGroup, 0, 100, 1, lowerVal, + upperVal, lowerColor, midColor, upperColor); + + GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); + GridLayout gl = new GridLayout(2, true); + Composite buttonComp = new Composite(shell, SWT.NONE); + buttonComp.setLayoutData(gd); + buttonComp.setLayout(gl); + + gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false); + gd.widthHint = 70; + Button okBtn = new Button(buttonComp, SWT.PUSH); + okBtn.setText("OK"); + okBtn.setLayoutData(gd); + okBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + int[] returnVal = new int[2]; + returnVal[0] = slider.getLowerValue(); + returnVal[1] = slider.getUpperValue(); + setReturnValue(returnVal); + close(); + } + }); + + gd = new GridData(SWT.LEFT, SWT.DEFAULT, true, false); + gd.widthHint = 70; + Button cancelBtn = new Button(buttonComp, SWT.PUSH); + cancelBtn.setText("Cancel"); + cancelBtn.setLayoutData(gd); + cancelBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + setReturnValue(false); + close(); + } + }); + } + + /** + * Get the lower value. + * + * @return The lower value + */ + public int getLowerValue() { + return slider.getLowerValue(); + } + + /** + * Get the upper value. + * + * @return The upper value + */ + public int getUpperValue() { + return slider.getUpperValue(); + } +} diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthUtilizationDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthUtilizationDlg.java index 5f399d46f8..9dc41ca4c0 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthUtilizationDlg.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/BandwidthUtilizationDlg.java @@ -19,9 +19,12 @@ **/ package com.raytheon.uf.viz.datadelivery.bandwidth.ui; +import java.util.Map; + import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -31,7 +34,11 @@ import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; +import com.raytheon.uf.common.datadelivery.registry.Network; +import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.CanvasImages; +import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphSection; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; +import com.raytheon.viz.ui.dialogs.ICloseCallback; /** * Bandwidth Utilization Dialog. @@ -44,6 +51,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * Nov 28, 2012 1269 mpduff Initial creation. * Dec 13, 2012 1269 lvenable Fixes and updates. + * Oct 28, 2013 2430 mpduff Add % of bandwidth utilized graph. * * * @@ -69,13 +77,19 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog { private BandwidthCanvasComp canvasComp; /** Graph data utility class */ - private GraphDataUtil graphDataUtil; + private final GraphDataUtil graphDataUtil; + + private MenuItem displayOpsNetMI; + + private MenuItem displaySbnMI; /** * Constructor. * * @param parent * Parent shell + * @param graphDataUtil + * Graph data utility object */ public BandwidthUtilizationDlg(Shell parent, GraphDataUtil graphDataUtil) { super(parent, SWT.DIALOG_TRIM | SWT.MIN, CAVE.DO_NOT_BLOCK @@ -193,6 +207,27 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog { Menu graphMenu = new Menu(menuBar); graphMenuItem.setMenu(graphMenu); + displayOpsNetMI = new MenuItem(graphMenu, SWT.RADIO); + displayOpsNetMI.setSelection(true); + displayOpsNetMI.setText("Display for OPSNET"); + displayOpsNetMI.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + canvasComp.setGraphNetwork(Network.OPSNET); + } + }); + + displaySbnMI = new MenuItem(graphMenu, SWT.RADIO); + displaySbnMI.setText("Display for SBN"); + displaySbnMI.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + canvasComp.setGraphNetwork(Network.SBN); + } + }); + + new MenuItem(graphMenu, SWT.SEPARATOR); + liveUpdateMI = new MenuItem(graphMenu, SWT.CHECK); liveUpdateMI.setText("Live Update"); liveUpdateMI.setSelection(true); @@ -204,7 +239,7 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog { }); colorByPriorityMI = new MenuItem(graphMenu, SWT.CHECK); - colorByPriorityMI.setText("Color By Priority"); + colorByPriorityMI.setText("Color By Priority/Percentage"); colorByPriorityMI.setSelection(true); colorByPriorityMI.addSelectionListener(new SelectionAdapter() { @Override @@ -224,7 +259,41 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog { canvasComp.setShowSubscriptionLines(showSubLinesMI .getSelection()); } + }); + new MenuItem(graphMenu, SWT.SEPARATOR); + + MenuItem percentConfigMI = new MenuItem(graphMenu, SWT.NONE); + percentConfigMI.setText("Configure Bandwidth Percent..."); + percentConfigMI.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + Map colors = canvasComp + .getBandwidthThresholdColors(); + int[] values = canvasComp.getBandwidthThresholdValues(); + BandwidthUsedConfigDlg dlg = new BandwidthUsedConfigDlg( + getShell(), values[0], values[1], colors + .get(GraphSection.LOWER), colors + .get(GraphSection.MIDDLE), colors + .get(GraphSection.UPPER)); + dlg.setCloseCallback(new ICloseCallback() { + @Override + public void dialogClosed(Object returnValue) { + if (returnValue instanceof int[]) { + int[] threshValues = (int[]) returnValue; + canvasComp + .setBandwidthThresholdValues(threshValues); + canvasComp + .redrawImage(CanvasImages.UTILIZATION_LABEL); + canvasComp + .redrawImage(CanvasImages.UTILIZATION_HEADER); + canvasComp + .redrawImage(CanvasImages.UTILIZATION_GRAPH); + } + } + }); + dlg.open(); + } }); } diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/GraphImage.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/GraphImage.java index 7b7e44fa96..a9867fa198 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/GraphImage.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/GraphImage.java @@ -52,6 +52,7 @@ import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.SortBy; * Jan 07, 2013 1451 djohnson Use TimeUtil.newGmtCalendar(). * Jan 04, 2013 1420 mpduff Change default priority to normal priority. * Jan 25, 2013 1528 djohnson Subscription priority is now an enum, remove incorrect use of ordinal values. + * Oct 28, 2013 2430 mpduff Add % of bandwidth utilized graph. * * * @@ -106,7 +107,9 @@ public class GraphImage extends AbstractCanvasImage { */ @Override public void disposeResources() { - bgColor.dispose(); + if (bgColor != null) { + bgColor.dispose(); + } } /** @@ -159,7 +162,6 @@ public class GraphImage extends AbstractCanvasImage { gc.setForeground(display.getSystemColor(SWT.COLOR_GRAY)); if (graphData == null) { - return; } @@ -193,15 +195,14 @@ public class GraphImage extends AbstractCanvasImage { } // Draw the dashed subscription line - gc.setLineStyle(SWT.LINE_DASH); if (imageMgr.isShowSubscriptionLines()) { + gc.setLineStyle(SWT.LINE_DASH); gc.setLineWidth(1); gc.setForeground(display.getSystemColor(SWT.COLOR_GRAY)); gc.drawLine(0, yCoord + 4, cs.getImageWidth(), yCoord + 4); + gc.setLineStyle(SWT.LINE_SOLID); } - gc.setLineStyle(SWT.LINE_SOLID); - long startTime = 0; List timeWindows = dataMap.get(subName); for (TimeWindowData data : timeWindows) { diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/GraphPoint.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/GraphPoint.java new file mode 100644 index 0000000000..f3e265d9c6 --- /dev/null +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/GraphPoint.java @@ -0,0 +1,87 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.datadelivery.bandwidth.ui; + +/** + * Point object for graph points. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 24, 2013   2430     mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class GraphPoint { + + private int x; + + private int y; + + /** + * Constructor. + * + * @param x + * x coordinate + * @param y + * y coordinate + */ + public GraphPoint(int x, int y) { + this.x = x; + this.y = y; + } + + /** + * @return the x + */ + public int getX() { + return x; + } + + /** + * @param x + * the x to set + */ + public void setX(int x) { + this.x = x; + } + + /** + * @return the y + */ + public int getY() { + return y; + } + + /** + * @param y + * the y to set + */ + public void setY(int y) { + this.y = y; + } +} diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/IGraphOptions.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/IGraphOptions.java index aaf84b96d3..8d3f32a3e4 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/IGraphOptions.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/IGraphOptions.java @@ -22,9 +22,10 @@ package com.raytheon.uf.viz.datadelivery.bandwidth.ui; import org.eclipse.swt.graphics.RGB; import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority; +import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphSection; /** - * TODO Add Description + * Graph options interface. * *
  * 
@@ -34,6 +35,7 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPri
  * ------------ ---------- ----------- --------------------------
  * Dec 4, 2012     1269    mpduff      Initial creation.
  * Dec 13, 2012   1269     lvenable    Fixes and updates.
+ * Oct 28, 2013   2430     mpduff      Add % of bandwidth utilized graph.
  * 
  * 
* @@ -109,4 +111,24 @@ public interface IGraphOptions { * RGB color. */ void setPriorityColor(SubscriptionPriority priority, RGB rgb); + + /** + * Get the RGB color associated with the specified percentage. + * + * @param percentString + * The percent string + * @return RGB color. + */ + RGB getPercentColor(GraphSection section); + + /** + * Set the color associated with the specified percentage. + * + * @param section + * The GraphSection + * + * @param rgb + * RGB color. + */ + void setPercentColor(GraphSection section, RGB rgb); } diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/UtilizationGraphImage.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/UtilizationGraphImage.java new file mode 100644 index 0000000000..032b74d922 --- /dev/null +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/UtilizationGraphImage.java @@ -0,0 +1,334 @@ +/** + * 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.datadelivery.bandwidth.ui; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; +import java.util.Map; +import java.util.SortedSet; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Composite; + +import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthBucketDescription; +import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData; +import com.raytheon.uf.common.datadelivery.registry.Network; +import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphSection; +import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphType; + +/** + * Percent utilized graph image. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 20, 2013   2430     mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class UtilizationGraphImage extends AbstractCanvasImage { + /** Lower percent limit line */ + private int lowerLimitLine; + + /** Upper percent limit line */ + private int upperLimitLine; + + private Color nonPriorityColor; + + /** + * Constructor. + * + * @param parentComp + * Parent composite + * @param cs + * Canvas settings + * @param graphData + * Graph data + * @param imageMgr + * The BandwidthImageManager + */ + public UtilizationGraphImage(Composite parentComp, CanvasSettings cs, + BandwidthGraphData graphData, BandwidthImageMgr imageMgr) { + super(parentComp, cs, graphData, null); + bgColor = display.getSystemColor(SWT.COLOR_WHITE); + this.imageMgr = imageMgr; + init(); + } + + /** + * Initialize + */ + private void init() { + millisPerPix = millis48Hrs + / (cs.getImageWidth() - cs.getXSpaceBuffer() * 2); + bgColor = new Color(display, 230, 230, 230); + nonPriorityColor = new Color(display, new RGB(6, 122, 255)); + } + + /** + * Draw the vertical time lines. + * + * @param gc + * Graphics Context + */ + private void drawTimeLines(GC gc) { + Calendar cal = TimeUtil.newGmtCalendar(); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + long currentTimeMillis = cal.getTimeInMillis(); + long endTimeMillis = currentTimeMillis + millis48Hrs; + + cal.set(Calendar.MINUTE, 0); + cal.add(Calendar.HOUR, 1); + long hourInMillis = cal.getTimeInMillis(); + + // Current time vertical line + gc.setLineWidth(2); + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + gc.drawLine(cs.getXSpaceBuffer(), 0, cs.getXSpaceBuffer(), + cs.getImageHeight()); + + gc.setLineWidth(1); + + // Draw hour lines + while (hourInMillis < endTimeMillis) { + int xCoord = (int) ((hourInMillis - currentTimeMillis) / millisPerPix); + xCoord += cs.getXSpaceBuffer(); + + // Draw a thicker line at 00Z + if (cal.get(Calendar.HOUR_OF_DAY) == 0) { + gc.setLineWidth(3); + gc.drawLine(xCoord, 0, xCoord, cs.getImageHeight()); + gc.setLineWidth(1); + } else { + gc.drawLine(xCoord, 0, xCoord, cs.getImageHeight()); + } + + cal.add(Calendar.HOUR, 1); + hourInMillis = cal.getTimeInMillis(); + } + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.datadelivery.bandwidth.ui.AbstractCanvasImage# + * disposeResources() + */ + @Override + public void disposeResources() { + if (bgColor != null) { + bgColor.dispose(); + } + + if (nonPriorityColor != null) { + nonPriorityColor.dispose(); + } + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.datadelivery.bandwidth.ui.AbstractCanvasImage#drawImage + * () + */ + @Override + public void drawImage() { + GC gc = new GC(image); + gc.setAntialias(SWT.ON); + + gc.setBackground(bgColor); + gc.fillRectangle(0, 0, cs.getImageWidth(), cs.getImageHeight()); + + gc.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); + gc.fillRectangle(0, 0, this.cs.getXSpaceBuffer(), cs.getImageHeight()); + + // Draw vertical time lines + drawTimeLines(gc); + drawPercentLines(gc); + drawData(gc); + } + + /** + * Draw the data. + * + * @param gc + */ + private void drawData(GC gc) { + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); + + Map> dataMap = this.graphData + .getNetworkBucketMap(); + SortedSet data = dataMap.get(imageMgr + .getNetwork()); + if (data == null || data.isEmpty()) { + return; + } + + long currentTimeMillis = imageMgr.getCurrentTimeMillis(); + + int height = cs.getCanvasHeight(); + List points = new ArrayList(); + for (BandwidthBucketDescription bucket : data) { + long bucketSize = bucket.getBucketSize(); + long startTime = bucket.getBucketStartTime(); + long usedBytes = bucket.getUsedBytes(); + + if (startTime < currentTimeMillis) { + continue; + } + + int x = Math.round(((startTime - currentTimeMillis) / millisPerPix) + + 1 + cs.getXSpaceBuffer()); + + double percent = usedBytes / (double) bucketSize; + + int y = (int) Math.round(height * percent); + y = 60 - y; + GraphPoint point = new GraphPoint(x, y); + points.add(point); + } + + if (imageMgr.getBandwidthGraphType() == GraphType.LINE) { + drawLineGraph(points, gc); + } else { + drawBarGraph(points, gc); + } + } + + /** + * Draw the bar graph. + * + * @param points + * @param gc + */ + private void drawBarGraph(List points, GC gc) { + int height = cs.getCanvasHeight(); + if (!imageMgr.isColorByPriority()) { + gc.setBackground(nonPriorityColor); + } + for (GraphPoint point : points) { + if (imageMgr.isColorByPriority()) { + Color c = getColor(point.getY()); + gc.setForeground(c); + gc.setBackground(c); + c.dispose(); + } + + if (height - point.getY() != 0) { + gc.fillRectangle(point.getX() - 1, point.getY() - 1, 3, height + - point.getY()); + } + } + } + + /** + * Draw the line graph. + * + * @param points + * @param gc + */ + private void drawLineGraph(List points, GC gc) { + // Draw the line + GraphPoint prevPoint = points.get(0); + for (int i = 1; i < points.size(); i++) { + GraphPoint p = points.get(i); + gc.setForeground(display.getSystemColor(SWT.COLOR_DARK_GRAY)); + gc.drawLine(p.getX(), p.getY(), prevPoint.getX(), prevPoint.getY()); + prevPoint = p; + } + + // Draw the points + for (GraphPoint p : points) { + int x = p.getX(); + int y = p.getY(); + + Color c = null; + if (imageMgr.isColorByPriority()) { + c = getColor(y); + gc.setForeground(c); + gc.setBackground(c); + c.dispose(); + } + gc.drawRectangle(x - 1, (Math.round(y)) - 1, 3, 3); + gc.fillRectangle(x, Math.round(y), 3, 3); + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); + } + gc.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); + } + + /** + * Get the color for the point y. + * + * @param y + * The point + * @return The color for the point + */ + private Color getColor(int y) { + Color c = null; + if (y > lowerLimitLine) { + c = new Color(display, imageMgr.getPercentColor(GraphSection.LOWER)); + } else if (y > upperLimitLine) { + c = new Color(display, + imageMgr.getPercentColor(GraphSection.MIDDLE)); + } else { + c = new Color(display, imageMgr.getPercentColor(GraphSection.UPPER)); + } + return c; + } + + /** + * Draw the percent threshold lines. + * + * @param gc + */ + private void drawPercentLines(GC gc) { + int[] threshValues = imageMgr.getBandwidthThreholdValues(); + int height = cs.getCanvasHeight(); + lowerLimitLine = 60 - ((int) Math.round(height + * (threshValues[0] / 100.0))); + upperLimitLine = 60 - ((int) Math.round(height + * (threshValues[1] / 100.0))); + + gc.setLineStyle(SWT.LINE_DASH); + gc.setLineWidth(1); + gc.setForeground(display.getSystemColor(SWT.COLOR_GRAY)); + gc.drawLine(cs.getXSpaceBuffer(), lowerLimitLine, cs.getImageWidth(), + lowerLimitLine); + gc.drawLine(cs.getXSpaceBuffer(), upperLimitLine, cs.getImageWidth(), + upperLimitLine); + gc.setLineStyle(SWT.LINE_SOLID); + } +} diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/UtilizationHeaderImage.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/UtilizationHeaderImage.java new file mode 100644 index 0000000000..3d3a6cd85e --- /dev/null +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/UtilizationHeaderImage.java @@ -0,0 +1,175 @@ +/** + * 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.datadelivery.bandwidth.ui; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.ColorDialog; +import org.eclipse.swt.widgets.Composite; + +import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphSection; + +/** + * Utilization header image. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 24, 2013   2430     mpduff      Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class UtilizationHeaderImage extends AbstractCanvasImage { + /** Title text */ + private final String TITLE = "Percent of Bandwidth Used"; + + /** Legend text */ + private final String LEGEND = "Legend: "; + + /** Percent sign */ + private final String PERCENT = "%"; + + /** Map of Rectangles -> GraphSection */ + private final Map rectPercentMap = new HashMap(); + + /** + * Constructor. + * + * @param parentComp + * Parent composite + * @param cs + * Canvas settings + * @param imageMgr + * The image manager + */ + public UtilizationHeaderImage(Composite parentComp, CanvasSettings cs, + BandwidthImageMgr imageMgr) { + super(parentComp, cs, null, imageMgr); + bgColor = display.getSystemColor(SWT.COLOR_WHITE); + } + + @Override + public void disposeResources() { + // No-op + + } + + /** + * {@inheritDoc} + */ + @Override + public void drawImage() { + GC gc = new GC(image); + gc.setAntialias(SWT.ON); + + // Fill the background of the image + gc.setBackground(bgColor); + gc.fillRectangle(0, 0, cs.getImageWidth(), cs.getImageHeight()); + + String titleStr = TITLE + " (" + imageMgr.getNetwork().name() + ")"; + + Point extent = gc.stringExtent(titleStr); + int yCoord = 5; + int fontHeight = extent.y; + + int xCoord = cs.getImageWidth() / 2 - extent.x; + gc.drawText(titleStr, xCoord, yCoord, true); + + int legendSpace = 7; + Point legendPt = gc.stringExtent(LEGEND); + xCoord = cs.getXSpaceBuffer() + legendSpace; + yCoord = cs.getCanvasHeight() - fontHeight - 3; + gc.drawText(LEGEND, xCoord, yCoord, true); + xCoord += legendPt.x + legendSpace; + + Color c; + Rectangle r; + int[] thresholdValues = imageMgr.getBandwidthThreholdValues(); + for (GraphSection section : imageMgr.getPercentageColorMap().keySet()) { + StringBuilder percentString = new StringBuilder("> "); + if (section == GraphSection.MIDDLE) { + percentString.append(thresholdValues[0]).append(PERCENT); + } else if (section == GraphSection.UPPER) { + percentString.append(thresholdValues[1]).append(PERCENT); + } else { + percentString.append("0").append(PERCENT); + } + Point p = gc.stringExtent(percentString.toString()); + gc.drawText(percentString.toString(), xCoord, yCoord, true); + c = new Color(display, imageMgr.getPercentageColorMap() + .get(section)); + gc.setBackground(c); + xCoord += p.x + 3; + r = new Rectangle(xCoord, yCoord + 4, 10, 10); + gc.fillRectangle(r); + gc.drawRectangle(r); + xCoord += 10 + legendSpace * 3; + c.dispose(); + rectPercentMap.put(r, section); + } + + gc.dispose(); + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.datadelivery.bandwidth.ui.AbstractCanvasImage# + * performAction(org.eclipse.swt.graphics.Point) + */ + @Override + public void performAction(Point mousePt) { + for (Rectangle rec : this.rectPercentMap.keySet()) { + if (rec.contains(mousePt)) { + ColorDialog colorDlg = new ColorDialog(display.getActiveShell()); + + // Set the selected color in the dialog from + // user's selected color + colorDlg.setRGB(imageMgr.getPercentColor(rectPercentMap + .get(rec))); + + // Change the title bar text + colorDlg.setText("Select a Color"); + + // Open the dialog and retrieve the selected color + RGB rgb = colorDlg.open(); + + if (rgb != null) { + imageMgr.setPercentColor(rectPercentMap.get(rec), rgb); + } + break; + } + } + } +} diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/UtilizationLabelImage.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/UtilizationLabelImage.java new file mode 100644 index 0000000000..371b163339 --- /dev/null +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/UtilizationLabelImage.java @@ -0,0 +1,175 @@ +/** + * 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.datadelivery.bandwidth.ui; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; + +/** + * Utilization graph label image. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 20, 2013   2430         mpduff     Initial creation
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class UtilizationLabelImage extends AbstractCanvasImage { + + /** + * Constructor. + * + * @param parentComp + * Parent composite + * @param cs + * Canvas settings + * @param imageMgr + * BandwidthImageMgr + */ + public UtilizationLabelImage(Composite parentComp, CanvasSettings cs, + BandwidthImageMgr imageMgr) { + super(parentComp, cs, null, null); + bgColor = display.getSystemColor(SWT.COLOR_WHITE); + this.imageMgr = imageMgr; + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.datadelivery.bandwidth.ui.AbstractCanvasImage# + * disposeResources() + */ + @Override + public void disposeResources() { + // No-op + + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.datadelivery.bandwidth.ui.AbstractCanvasImage#drawImage + * () + */ + @Override + public void drawImage() { + GC gc = new GC(image); + gc.setAntialias(SWT.ON); + + // Fill the background of the image + gc.setBackground(bgColor); + gc.fillRectangle(0, 0, cs.getImageWidth(), cs.getImageHeight()); + + // Get the scale labels/ These are double so the division is floating + // point division + int[] threshValues = imageMgr.getBandwidthThreholdValues(); + double lowerValue = threshValues[0]; + double upperValue = threshValues[1]; + + // Draw scale labels + String label1 = lowerValue + "%"; + String label2 = upperValue + "%"; + + Point extent1 = gc.stringExtent(label1); + Point extent2 = gc.stringExtent(label2); + + // Draw the label(s) + // y is the lower threshold value, y2 is the upper + double y = cs.getCanvasHeight() + - ((lowerValue / 100) * cs.getCanvasHeight()) - (extent1.y / 2); + int x = cs.getCanvasWidth() - extent1.x - 5; + + double y2 = cs.getCanvasHeight() + - ((upperValue / 100) * cs.getCanvasHeight()) - (extent2.y / 2); + int x2 = cs.getCanvasWidth() - extent2.x - 5; + + // Align in relation to each other + if (y2 + extent2.y >= y) { + y2 = y - extent2.y + 1; + } + + // If off the top of the canvas then move down + if (y2 <= 0) { + y2 = 0; + if (y <= y2 + extent2.y) { + // If overlap then move the other + y = y2 + extent2.y; + } + } + + // If off the bottom of the canvas then move up + if (y + extent1.y > cs.getCanvasHeight()) { + y = cs.getCanvasHeight() - extent1.y; + if (y < y2 + extent2.y) { + // if overlap then move the other + y2 = y - extent1.y; + } + } + if (y + extent2.y >= 60) { + y = 60 - extent1.y - 1; + } + + gc.drawText(label1, x, (int) y, true); + gc.drawText(label2, x2, (int) y2, true); + + gc.dispose(); + } + + /** + * @return the lowerValue + */ + public int getLowerValue() { + return imageMgr.getBandwidthThreholdValues()[0]; + } + + /** + * @param lowerValue + * the lowerValue to set + */ + public void setLowerValue(int lowerValue) { + this.imageMgr.getBandwidthThreholdValues()[0] = lowerValue; + } + + /** + * @return the upperValue + */ + public int getUpperValue() { + return imageMgr.getBandwidthThreholdValues()[1]; + } + + /** + * @param upperValue + * the upperValue to set + */ + public void setUpperValue(int upperValue) { + this.imageMgr.getBandwidthThreholdValues()[1] = upperValue; + } +} diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/XHeaderImage.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/XHeaderImage.java index 6e2b3d7156..772375711e 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/XHeaderImage.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/bandwidth/ui/XHeaderImage.java @@ -46,6 +46,7 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPri * Nov 28, 2012 1269 lvenable Initial creation. * Dec 13, 2012 1269 lvenable Fixes and updates. * Jan 25, 2013 1528 djohnson Subscription priority is now an enum. + * Oct 28, 2013 2430 mpduff Changed labels. * * * @@ -118,12 +119,13 @@ public class XHeaderImage extends AbstractCanvasImage { gc.setBackground(bgColor); gc.fillRectangle(0, 0, cs.getImageWidth(), cs.getImageHeight()); - Point extent = gc.stringExtent(xHeaderStr); - int yCoord = 5; + String title = xHeaderStr + " (" + imageMgr.getNetwork().name() + ")"; + Point extent = gc.stringExtent(title); + int yCoord = 25; int fontHeight = extent.y; int xCoord = cs.getImageWidth() / 2 - extent.x; - gc.drawText(xHeaderStr, xCoord, yCoord, true); + gc.drawText(title, xCoord, yCoord, true); int legendSpace = 5; Point priorityPt = gc.stringExtent(priorityStr); diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/TwoValueSliderCanvas.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/TwoValueSliderCanvas.java new file mode 100644 index 0000000000..5326a0ca9f --- /dev/null +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/TwoValueSliderCanvas.java @@ -0,0 +1,608 @@ +/** + * 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.ui.widgets; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseMoveListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.graphics.Region; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; + +/** + * A two value slider widget. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 27, 2013   2430     mpduff      Initial version.
+ * 
+ * 
+ */ + +public class TwoValueSliderCanvas { + /** Parent composite */ + private final Composite parentComp; + + /** The display */ + private final Display display; + + /** The lower range color */ + private Color lowRangeColor; + + /** The middle range color */ + private Color midRangeColor; + + /** The upper range color */ + private Color upperRangeColor; + + /* + * Canvas information + */ + private Canvas canvas; + + private final int CANVAS_WIDTH = 255; + + private final int CANVAS_HEIGHT = 70; + + /* + * Bar information. + */ + private final int barBottomYCoord = 45; + + private final int barWidth = 200; + + private final int barHeight = 10; + + private final int barXCoord = 25; + + private final int barYCoord = 35; + + /* + * Upper arrow, label and values + */ + private Region upperRegion; + + private int[] upperPtArray = new int[] { 0, 0 }; + + private int upperArrowXCoord = 150; + + private Rectangle upperLblRect; + + private String upperStr; + + private final int upperLblYCoord = 1; + + private boolean moveUpper = false; + + private int upperDisplayVal = 0; + + /* + * Lower arrow, label and values + */ + private Region lowerRegion; + + private int[] lowerPtArray = new int[] { 0, 0 }; + + private int lowerArrowXCoord = 50; + + private Rectangle lowerLblRect; + + private String lowerStr; + + private final int lowerLblYCoord = 14; + + private boolean moveLower = false; + + private int lowerDisplayVal = 0; + + /* + * Mouse information. + */ + private Point mousePt; + + private boolean mouseDown = false; + + /* + * Font/text information + */ + private Font labelFont; + + private int textWidth = 0; + + private int textHeight = 0; + + /* + * Min/Range/Increment information + */ + private int minValue = Integer.MIN_VALUE; + + private int rangeValue = Integer.MIN_VALUE; + + private int incValue = Integer.MIN_VALUE; + + private double incPerPixel = Double.NaN; + + private String formatStr; + + private int minValLblPixWidth = 0; + + private int maxValLblPixWidth = 0; + + /** + * Constructor. + * + * @param parentComp + * The parent composite + * @param min + * The minimum value + * @param range + * The range + * @param inc + * The increment + * @param startingLowerVal + * The starting lower value + * @param startingUpperVal + * The starting upper value + */ + public TwoValueSliderCanvas(Composite parentComp, int min, int range, + int inc, int startingLowerVal, int startingUpperVal) { + this(parentComp, min, range, inc, startingLowerVal, startingUpperVal, + null, null, null); + } + + /** + * Constructor. + * + * @param parentComp + * The parent composite + * @param min + * The minimum value + * @param range + * The range + * @param inc + * The increment + * @param startingLowerVal + * The starting lower value + * @param startingUpperVal + * The starting upper value + * @param lowerRGB + * Low range RGB color + * @param midRGB + * Mid range RGB color + * @param upperRGB + * High range RGB color + */ + public TwoValueSliderCanvas(Composite parentComp, int min, int range, + int inc, int startingLowerVal, int startingUpperVal, RGB lowerRGB, + RGB midRGB, RGB upperRGB) { + this.parentComp = parentComp; + + display = this.parentComp.getDisplay(); + + setValues(min, range, inc, startingLowerVal, startingUpperVal); + + createColors(lowerRGB, midRGB, upperRGB); + calcMinMaxLabelXCoords(); + init(); + createCanvas(); + } + + /** + * Create the colors. + * + * @param lowerRGB + * @param midRGB + * @param upperRGB + */ + private void createColors(RGB lowerRGB, RGB midRGB, RGB upperRGB) { + if (lowerRGB == null) { + lowRangeColor = new Color(display, display.getSystemColor( + SWT.COLOR_GREEN).getRGB()); + } else { + lowRangeColor = new Color(display, lowerRGB); + } + + if (midRGB == null) { + midRangeColor = new Color(display, display.getSystemColor( + SWT.COLOR_YELLOW).getRGB()); + } else { + midRangeColor = new Color(display, midRGB); + } + + if (upperRGB == null) { + upperRangeColor = new Color(display, display.getSystemColor( + SWT.COLOR_RED).getRGB()); + } else { + upperRangeColor = new Color(display, upperRGB); + } + } + + /** + * Initialize + */ + private void init() { + upperLblRect = new Rectangle(0, 0, 0, 0); + lowerLblRect = new Rectangle(0, 0, 0, 0); + + labelFont = new Font(display, "Monospaced", 10, SWT.BOLD); + mousePt = new Point(0, 0); + upperRegion = new Region(display); + lowerRegion = new Region(display); + + makeCalculations(); + } + + /** + * Create the canvas. + */ + private void createCanvas() { + canvas = new Canvas(parentComp, SWT.DOUBLE_BUFFERED); + GridData gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true); + gd.heightHint = CANVAS_HEIGHT; + gd.widthHint = CANVAS_WIDTH; + + canvas.setSize(CANVAS_WIDTH, CANVAS_HEIGHT); + + canvas.setLayoutData(gd); + canvas.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + drawCanvas(e.gc); + } + }); + + canvas.addMouseListener(new MouseAdapter() { + @Override + public void mouseDown(MouseEvent e) { + if (upperRegion.contains(e.x, e.y) == true + || upperLblRect.contains(e.x, e.y) == true) { + mousePt.x = e.x; + mousePt.y = e.y; + mouseDown = true; + moveUpper = true; + } else if (lowerRegion.contains(e.x, e.y) == true + || lowerLblRect.contains(e.x, e.y) == true) { + mousePt.x = e.x; + mousePt.y = e.y; + mouseDown = true; + moveLower = true; + } + } + + @Override + public void mouseUp(MouseEvent e) { + mouseDown = false; + moveLower = false; + moveUpper = false; + } + }); + + canvas.addMouseMoveListener(new MouseMoveListener() { + @Override + public void mouseMove(MouseEvent e) { + handleMouseMove(e); + } + }); + + canvas.addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + upperRegion.dispose(); + lowerRegion.dispose(); + labelFont.dispose(); + lowRangeColor.dispose(); + midRangeColor.dispose(); + upperRangeColor.dispose(); + } + }); + } + + /** + * Draw the canvas. + * + * @param gc + */ + private void drawCanvas(GC gc) { + gc.setAntialias(SWT.ON); + gc.setFont(labelFont); + gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); + + gc.fillRectangle(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); + + gc.setBackground(lowRangeColor); + gc.fillRectangle(barXCoord, barYCoord, barWidth, barHeight); + + gc.setBackground(midRangeColor); + gc.fillRectangle(lowerArrowXCoord, barYCoord, barWidth + 25 + - lowerArrowXCoord, barHeight); + + gc.setBackground(upperRangeColor); + gc.fillRectangle(upperArrowXCoord, barYCoord, barWidth + 25 + - upperArrowXCoord, barHeight); + + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + gc.drawRectangle(barXCoord, barYCoord, barWidth, barHeight); + + gc.drawString(String.valueOf(minValue) + "%", barXCoord + - (minValLblPixWidth / 2), barYCoord + 10, true); + gc.drawString(String.valueOf(minValue + rangeValue) + "%", barXCoord + + barWidth - (maxValLblPixWidth / 2), barYCoord + 10, true); + + updateLowerArrow(gc); + updateLowerLabel(gc); + + updateUpperArrow(gc); + updateUpperLabel(gc); + } + + /** + * Update the upper arrow. + * + * @param gc + */ + private void updateUpperArrow(GC gc) { + upperRegion.subtract(upperPtArray); + upperPtArray = new int[] { upperArrowXCoord, + barBottomYCoord - barHeight - 3, upperArrowXCoord + 4, + barBottomYCoord, upperArrowXCoord - 4, barBottomYCoord }; + upperRegion.add(upperPtArray); + + gc.setBackground(upperRangeColor); + gc.fillPolygon(upperPtArray); + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + gc.drawPolygon(upperPtArray); + } + + /** + * Update the lower label. + * + * @param gc + */ + private void updateUpperLabel(GC gc) { + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + upperStr = createDisplayString(upperDisplayVal); + int lblXCoord = (int) (upperArrowXCoord - textWidth + * (double) upperStr.length() / 2.0); + gc.drawString(upperStr + "%", lblXCoord, upperLblYCoord, true); + upperLblRect.x = lblXCoord; + upperLblRect.y = upperLblYCoord; + upperLblRect.width = textWidth * upperStr.length() + textWidth * 2; + upperLblRect.height = textHeight; + } + + /** + * Update lower arrow. + * + * @param gc + */ + private void updateLowerArrow(GC gc) { + lowerRegion.subtract(lowerPtArray); + lowerPtArray = new int[] { lowerArrowXCoord, + barBottomYCoord - barHeight - 3, lowerArrowXCoord + 4, + barBottomYCoord, lowerArrowXCoord - 4, barBottomYCoord }; + lowerRegion.add(lowerPtArray); + + gc.setBackground(midRangeColor); + gc.fillPolygon(lowerPtArray); + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + gc.drawPolygon(lowerPtArray); + } + + /** + * Update lower label + * + * @param gc + */ + private void updateLowerLabel(GC gc) { + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + lowerStr = createDisplayString(lowerDisplayVal); + int lblXCoord = (int) (lowerArrowXCoord - Math.round((double) textWidth + * (double) lowerStr.length() / 2.0)); + gc.drawString(lowerStr + "%", lblXCoord, lowerLblYCoord, true); + lowerLblRect.x = lblXCoord; + lowerLblRect.y = lowerLblYCoord; + lowerLblRect.width = textWidth * lowerStr.length() + textWidth * 2; + lowerLblRect.height = textHeight; + } + + /** + * Mouse mover handler. + * + * @param e + */ + private void handleMouseMove(MouseEvent e) { + if (mouseDown == false) { + return; + } + + if (moveUpper == true) { + int xDiff = e.x - mousePt.x; + upperArrowXCoord += xDiff; + + if (upperArrowXCoord > 225) { + upperArrowXCoord = 225; + } else if (upperArrowXCoord < 25) { + upperArrowXCoord = 25; + } else if (upperArrowXCoord < lowerArrowXCoord) { + upperArrowXCoord = lowerArrowXCoord; + } + + upperDisplayVal = calcDisplayValue(upperArrowXCoord); + } else if (moveLower == true) { + int xDiff = e.x - mousePt.x; + lowerArrowXCoord += xDiff; + + if (lowerArrowXCoord > 225) { + lowerArrowXCoord = 225; + } else if (lowerArrowXCoord < 25) { + lowerArrowXCoord = 25; + } else if (lowerArrowXCoord > upperArrowXCoord) { + lowerArrowXCoord = upperArrowXCoord; + } + lowerDisplayVal = calcDisplayValue(lowerArrowXCoord); + } + + mousePt.x = e.x; + mousePt.y = e.y; + canvas.redraw(); + } + + /** + * Determine text height and width. + */ + private void makeCalculations() { + GC gc = new GC(parentComp); + gc.setFont(labelFont); + + textWidth = gc.getFontMetrics().getAverageCharWidth(); + textHeight = gc.getFontMetrics().getHeight(); + + gc.dispose(); + } + + /** + * Calculate the display value for the provided x coordinate. + * + * @param xCoord + * @return + */ + private int calcDisplayValue(int xCoord) { + double xCoordAsValue = (xCoord - barXCoord) * incPerPixel + minValue; + if (incValue == .25) { + return (int) ((Math.round(xCoordAsValue * 4.00)) / 4.00); + } else if (incValue == .10) { + return (int) ((Math.round(xCoordAsValue * 10.00)) / 10.00); + } else { + return (int) Math.round(xCoordAsValue); + } + } + + /** + * Calculate the min/max pixel values. + */ + private void calcMinMaxLabelXCoords() { + GC gc = new GC(parentComp); + gc.setFont(labelFont); + + Point ext = gc.stringExtent(String.valueOf(minValue)); + minValLblPixWidth = ext.x; + + ext = gc.stringExtent(String.valueOf(minValue + rangeValue)); + maxValLblPixWidth = ext.x; + + gc.dispose(); + } + + /** + * Create the display string. + * + * @param displVal + * @return + */ + private String createDisplayString(int displVal) { + return String.format(formatStr, displVal); + } + + /** + * Calculate the bar value to x coordinate value. + * + * @param val + * @return + */ + private int calcValueToBarXCoord(double val) { + int result = (int) Math.round((val - minValue) / incPerPixel + + barXCoord); + + return result; + } + + /** + * Set the values. + * + * @param min + * @param range + * @param inc + * @param startingLowerVal + * @param startingUpperVal + */ + private void setValues(int min, int range, int inc, int startingLowerVal, + int startingUpperVal) { + this.minValue = min; + this.rangeValue = range; + this.incValue = inc; + + if (startingUpperVal < startingLowerVal) { + startingUpperVal = startingLowerVal; + } + + if (startingLowerVal < min || startingLowerVal > (min + range)) { + startingLowerVal = min; + } + + if (startingUpperVal < min || startingUpperVal > (min + range)) { + startingUpperVal = min + range; + } + + incPerPixel = this.rangeValue / (double) barWidth; + + formatStr = "%d"; + + upperArrowXCoord = calcValueToBarXCoord(startingUpperVal); + lowerArrowXCoord = calcValueToBarXCoord(startingLowerVal); + + upperDisplayVal = calcDisplayValue(upperArrowXCoord); + lowerDisplayVal = calcDisplayValue(lowerArrowXCoord); + } + + /** + * Get the upper value. + * + * @return the upper value + */ + public int getUpperValue() { + return upperDisplayVal; + } + + /** + * Get the lower value + * + * @return The lower value + */ + public int getLowerValue() { + return lowerDisplayVal; + } +} From f2184b93794e90c31607c84126898b0600625680 Mon Sep 17 00:00:00 2001 From: Nate Jensen Date: Tue, 29 Oct 2013 09:47:28 -0500 Subject: [PATCH 12/15] Issue #2476 fixed crash, added short[] numpy support, removed gfe wx/discrete string keys hack, cleaned up jep numpy interfaces and code Former-commit-id: 554a9cddf39e3f7e36fab85cfe8ab6e14a0a736f [formerly f3143ba7b47affa765fbfaaa16a37bcf9f298f35] [formerly 554a9cddf39e3f7e36fab85cfe8ab6e14a0a736f [formerly f3143ba7b47affa765fbfaaa16a37bcf9f298f35] [formerly 6880a18f1a059143f6af8fec62db7d9104566e42 [formerly 0c24c900ce938982306bad9307f3b1ef27b362bb]]] Former-commit-id: 6880a18f1a059143f6af8fec62db7d9104566e42 Former-commit-id: 19043faeaae6f64db04a849515391aac35da44ee [formerly f2751f017ec69dc56b3c21928b9464538d97a685] Former-commit-id: e8c199f1086fca7a7824d8157d9cb727fe132cc7 --- .../core/interp/InterpolationContainer.java | 4 +- .../derivparam/python/MasterDerivScript.java | 15 +-- .../function/CapeFuncPythonAdapter.java | 2 +- .../gfe/userPython/utilities/SmartScript.py | 32 +++-- .../python/query/DBSSClient.py | 19 ++- .../gfe/core/griddata/DiscreteGridData.java | 2 +- .../gfe/core/griddata/WeatherGridData.java | 2 +- .../core/parm/vcparm/CalcVcModGridArg.java | 13 +- .../smarttool/script/SmartToolController.java | 11 +- cots/org.jep/jep.jar | Bin 51677 -> 51688 bytes .../edex/plugin/gfe/smartinit/FakeTopo.java | 77 ------------ .../edex_static/base/smartinit/Init.py | 50 +++++--- .../gfe/db/objects/GridLocation.java | 4 +- .../dataplugin/gfe/grid/Grid2DBoolean.java | 2 +- .../dataplugin/gfe/grid/Grid2DByte.java | 2 +- .../dataplugin/gfe/grid/Grid2DFloat.java | 2 +- .../gfe/slice/DiscreteGridSlice.java | 22 ++-- .../gfe/slice/PythonWeatherGridSlice.java | 4 +- .../dataplugin/gfe/slice/ScalarGridSlice.java | 2 +- .../dataplugin/gfe/slice/VectorGridSlice.java | 2 +- .../gfe/slice/WeatherGridSlice.java | 22 ++-- .../common/python/PythonNumpyFloatArray.java | 4 +- .../python/decoder/PythonNumpyByteArray.java | 4 +- .../jepp-2.3/src/jep/INumpyable.java | 18 ++- .../rary.cots.jepp/jepp-2.3/src/jep/Jep.java | 6 +- .../jepp-2.3/src/jep/pyjobject.c | 115 +++++------------- .../jepp-2.3/src/jep/pyjobject.h | 3 +- .../rary.cots.jepp/jepp-2.3/src/jep/util.c | 107 +++++++++++++++- .../rary.cots.jepp/jepp-2.3/src/jep/util.h | 8 +- .../viz/gfe/contours/TestContourAnalyzer.java | 4 +- 30 files changed, 284 insertions(+), 274 deletions(-) delete mode 100644 edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/smartinit/FakeTopo.java diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/interp/InterpolationContainer.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/interp/InterpolationContainer.java index eaacba9507..4a602dcbf4 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/interp/InterpolationContainer.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/interp/InterpolationContainer.java @@ -61,10 +61,10 @@ public class InterpolationContainer implements INumpyable { /* * (non-Javadoc) * - * @see jep.INumpyable#getNumPy() + * @see jep.INumpyable#getNumpy() */ @Override - public Object[] getNumPy() { + public Object[] getNumpy() { // todo return new Object[] { xValues, yValues, zValues }; } diff --git a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/MasterDerivScript.java b/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/MasterDerivScript.java index 494bfd7f9a..3e89a873d6 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/MasterDerivScript.java +++ b/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/MasterDerivScript.java @@ -49,6 +49,7 @@ import com.raytheon.uf.viz.derivparam.tree.CubeLevel; * Jul 8, 2008 njensen Initial creation * Nov 20, 2009 #3387 jelkins Use derived script's variableId instead of filename * Nov 21, 2009 #3576 rjpeter Refactored to populate DerivParamDesc. + * Oct 29, 2013 2476 njensen Renamed numeric methods to numpy * * * @author njensen @@ -214,7 +215,7 @@ public class MasterDerivScript extends PythonInterpreter { argKey += "_" + Integer.toHexString((val.hashCode())); } - // setNumeric won't work with indexed objects + // setNumpy won't work with indexed objects evaluateArgument(argKey, val); jep.eval(argName + ".append(" + argKey + ")"); } @@ -231,7 +232,7 @@ public class MasterDerivScript extends PythonInterpreter { for (int argIdx = 0; argIdx < valList.length; argIdx++) { IDataRecord val = valList[argIdx]; jep.eval(argName + ".append(None)"); - // setNumeric won't work with indexed objects + // setNumpy won't work with indexed objects evaluateArgument("__tmp", val); jep.eval(argName + "[" + argIdx + "] = __tmp"); } @@ -241,10 +242,10 @@ public class MasterDerivScript extends PythonInterpreter { setDataRecordArg(argName, (IDataRecord) argValue); } else if (argValue instanceof float[]) { float[] val = (float[]) argValue; - jep.setNumeric(argName, val, val.length, 1); + jep.setNumpy(argName, val, val.length, 1); } else if (argValue instanceof int[]) { int[] val = (int[]) argValue; - jep.setNumeric(argName, val, val.length, 1); + jep.setNumpy(argName, val, val.length, 1); } else if (argValue instanceof Float) { jep.set(argName, (argValue)); } else if (argValue instanceof DerivedParameterRequest) { @@ -401,7 +402,7 @@ public class MasterDerivScript extends PythonInterpreter { if (argValue instanceof FloatDataRecord) { FloatDataRecord record = (FloatDataRecord) argValue; if (sizes.length == 2) { - jep.setNumeric(argName, record.getFloatData(), (int) sizes[0], + jep.setNumpy(argName, record.getFloatData(), (int) sizes[0], (int) sizes[1]); reshape = false; } else { @@ -415,7 +416,7 @@ public class MasterDerivScript extends PythonInterpreter { } else if (argValue instanceof IntegerDataRecord) { IntegerDataRecord record = (IntegerDataRecord) argValue; if (sizes.length == 2) { - jep.setNumeric(argName, record.getIntData(), (int) sizes[0], + jep.setNumpy(argName, record.getIntData(), (int) sizes[0], (int) sizes[1]); reshape = false; } else { @@ -424,7 +425,7 @@ public class MasterDerivScript extends PythonInterpreter { } else if (argValue instanceof ByteDataRecord) { ByteDataRecord record = (ByteDataRecord) argValue; if (sizes.length == 2) { - jep.setNumeric(argName, record.getByteData(), (int) sizes[0], + jep.setNumpy(argName, record.getByteData(), (int) sizes[0], (int) sizes[1]); reshape = false; } else { diff --git a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CapeFuncPythonAdapter.java b/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CapeFuncPythonAdapter.java index 09d64920bf..6448eb18eb 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CapeFuncPythonAdapter.java +++ b/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CapeFuncPythonAdapter.java @@ -59,7 +59,7 @@ public class CapeFuncPythonAdapter { } @Override - public Object[] getNumPy() { + public Object[] getNumpy() { return new Object[] { cape, cin }; } 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 7b9a7b7f18..93797c1dc7 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 @@ -50,6 +50,7 @@ # so mask can be used with advanced indexing # (e.g. grid[mask] = value) # Oct 07, 2013 2424 randerso remove use of pytz +# Oct 29, 2013 2476 njensen Improved getting wx/discrete keys in _getGridResults # ######################################################################## import types, string, time, sys @@ -463,24 +464,31 @@ class SmartScript(BaseTool.BaseTool): elif "List" == mode: xlated = [] for rgrid in result: - xlgrid = rgrid.getGridSlice() - xlgrid = xlgrid.__numpy__ + jxlgrid = rgrid.getGridSlice() + xlgrid = jxlgrid.__numpy__ if len(xlgrid) == 1: - xlgrid = xlgrid[0]; - elif len(xlgrid) == 2 and isinstance(xlgrid[1], str): - xlgrid[1] = eval(xlgrid[1]) + if xlgrid[0].dtype != numpy.int8: + # scalar + xlgrid = xlgrid[0] + else: + # discrete or weather + keys = JUtil.javaObjToPyVal(jxlgrid.getKeyList()) + xlgrid.append(keys) xlated.append(xlgrid) retVal = xlated else: result = result[0]; - result = result.getGridSlice() - result = result.__numpy__ + slice = result.getGridSlice() + result = slice.__numpy__ if len(result) == 1: - retVal = result[0] - elif len(result) == 2 and isinstance(result[1], str): - retVal = (result[0], eval(result[1])) - else: - retVal = (result[0], result[1]) + if result[0].dtype != numpy.int8: + # scalar + result = result[0] + else: + # discrete or weather + keys = JUtil.javaObjToPyVal(slice.getKeyList()) + result.append(keys) + retVal = result if retVal is None or retVal == []: if noDataError == 1: diff --git a/cave/com.raytheon.viz.gfe/python/query/DBSSClient.py b/cave/com.raytheon.viz.gfe/python/query/DBSSClient.py index 7ea3a28797..fa95809a08 100644 --- a/cave/com.raytheon.viz.gfe/python/query/DBSSClient.py +++ b/cave/com.raytheon.viz.gfe/python/query/DBSSClient.py @@ -17,12 +17,14 @@ # See the AWIPS II Master Rights File ("Master Rights File.pdf") for # further licensing information. ## -import DatabaseID, AbsTime +import DatabaseID, AbsTime, JUtil from com.raytheon.uf.common.dataplugin.gfe.db.objects import DatabaseID as JavaDatabaseID from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceID from com.raytheon.uf.common.dataplugin.gfe.db.objects import ParmID +from numpy import int8 + class DBSSWE: def __init__(self, parm): self._parm = parm @@ -47,12 +49,17 @@ class DBSSWE: self._parm.getGridInventory()): if t == key: #return g.pyData() - g.populate() - result = g.getGridSlice().__numpy__ + g.populate() + slice = g.getGridSlice() + result = slice.__numpy__ if len(result) == 1: - result = result[0] - elif len(result) == 2 and isinstance(result[1], str): - result[1] = eval(result[1]) + if result[0].dtype != int8: + # scalar + result = result[0] + else: + # discrete or weather + dkeys = JUtil.javaObjToPyVal(slice.getKeyList()) + result.append(dkeys) return result return None 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 a5b7c2ae5c..ad1dbe8e5a 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 @@ -840,7 +840,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable { } @Override - public Object[] getNumPy() { + public Object[] getNumpy() { return new Object[] { this.getGrid().getBuffer().array() }; } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/WeatherGridData.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/WeatherGridData.java index fd24fb53bf..98bb91ccd4 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/WeatherGridData.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/WeatherGridData.java @@ -817,7 +817,7 @@ public class WeatherGridData extends AbstractGridData implements INumpyable { } @Override - public Object[] getNumPy() { + public Object[] getNumpy() { return new Object[] { this.getGrid().getBuffer().array() }; } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/vcparm/CalcVcModGridArg.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/vcparm/CalcVcModGridArg.java index 461e689170..0ebaecbc42 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/vcparm/CalcVcModGridArg.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/vcparm/CalcVcModGridArg.java @@ -48,6 +48,7 @@ import com.raytheon.viz.gfe.core.griddata.WeatherGridData; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 12, 2012 dgilling Initial creation + * Oct 29, 2013 2476 njensen Renamed numeric methods to numpy * * * @@ -117,7 +118,7 @@ public class CalcVcModGridArg implements IVcModuleArgument { ScalarGridData grid = (ScalarGridData) gd; Grid2DFloat f = (grid.getScalarSlice()).getScalarGrid(); String name = prefix + "grid"; - jep.setNumeric(name, f.getFloats(), f.getXdim(), f.getYdim()); + jep.setNumpy(name, f.getFloats(), f.getXdim(), f.getYdim()); jepString.append(name); jepString.append(", "); tempGridNames.add(name); @@ -127,9 +128,9 @@ public class CalcVcModGridArg implements IVcModuleArgument { Grid2DFloat dir = (grid.getVectorSlice()).getDirGrid(); String magName = prefix + "Mag"; String dirName = prefix + "Dir"; - jep.setNumeric(magName, mag.getFloats(), mag.getXdim(), + jep.setNumpy(magName, mag.getFloats(), mag.getXdim(), mag.getYdim()); - jep.setNumeric(dirName, dir.getFloats(), dir.getXdim(), + jep.setNumpy(dirName, dir.getFloats(), dir.getXdim(), dir.getYdim()); jepString.append('('); jepString.append(magName); @@ -142,7 +143,7 @@ public class CalcVcModGridArg implements IVcModuleArgument { WeatherGridData grid = (WeatherGridData) gd; Grid2DByte bytes = grid.getWeatherSlice().getWeatherGrid(); String name = prefix + "grid"; - jep.setNumeric(name, bytes.getBytes(), bytes.getXdim(), + jep.setNumpy(name, bytes.getBytes(), bytes.getXdim(), bytes.getYdim()); jepString.append('('); jepString.append(name); @@ -159,7 +160,7 @@ public class CalcVcModGridArg implements IVcModuleArgument { DiscreteGridData grid = (DiscreteGridData) gd; Grid2DByte bytes = grid.getDiscreteSlice().getDiscreteGrid(); String name = prefix + "grid"; - jep.setNumeric(name, bytes.getBytes(), bytes.getXdim(), + jep.setNumpy(name, bytes.getBytes(), bytes.getXdim(), bytes.getYdim()); jepString.append('('); jepString.append(name); @@ -175,7 +176,7 @@ public class CalcVcModGridArg implements IVcModuleArgument { } String maskName = prefix + "mask"; - jep.setNumeric(maskName, mask.getBytes(), mask.getXdim(), + jep.setNumpy(maskName, mask.getBytes(), mask.getXdim(), mask.getYdim()); jepString.append(maskName); sb.append(jepString); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolController.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolController.java index 4c81b4319a..cb64d5e49e 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolController.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolController.java @@ -69,6 +69,7 @@ import com.raytheon.viz.gfe.core.wxvalue.WxValue; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Oct 20, 2008 njensen Initial creation + * Oct 29, 2013 2476 njensen Renamed numeric methods to numpy * * * @author njensen @@ -178,7 +179,7 @@ public class SmartToolController extends BaseGfePyController { if (parmToEdit == null) { return null; } else { - return getNumericResult(parmToEdit.getGridInfo().getGridType()); + return getNumpyResult(parmToEdit.getGridInfo().getGridType()); } } @@ -246,7 +247,7 @@ public class SmartToolController extends BaseGfePyController { * @return the result of the execution in Java format * @throws JepException */ - protected Object getNumericResult(GridType type) throws JepException { + protected Object getNumpyResult(GridType type) throws JepException { Object result = null; boolean resultFound = (Boolean) jep.getValue(RESULT + " is not None"); @@ -308,9 +309,9 @@ public class SmartToolController extends BaseGfePyController { Grid2DFloat dir = (grid.getVectorSlice()).getDirGrid(); String magName = argName + "Mag"; String dirName = argName + "Dir"; - jep.setNumeric(magName, mag.getFloats(), mag.getXdim(), + jep.setNumpy(magName, mag.getFloats(), mag.getXdim(), mag.getYdim()); - jep.setNumeric(dirName, dir.getFloats(), dir.getXdim(), + jep.setNumpy(dirName, dir.getFloats(), dir.getXdim(), dir.getYdim()); jep.eval(argName + " = [" + magName + ", " + dirName + "]"); jep.eval(magName + " = None"); @@ -318,7 +319,7 @@ public class SmartToolController extends BaseGfePyController { } else if (argValue instanceof ScalarGridData) { ScalarGridData grid = (ScalarGridData) argValue; Grid2DFloat f = (grid.getScalarSlice()).getScalarGrid(); - jep.setNumeric(argName, f.getFloats(), f.getXdim(), f.getYdim()); + jep.setNumpy(argName, f.getFloats(), f.getXdim(), f.getYdim()); } else if (argValue instanceof DiscreteGridData) { DiscreteGridData grid = (DiscreteGridData) argValue; jep.set("discreteGridData", grid); diff --git a/cots/org.jep/jep.jar b/cots/org.jep/jep.jar index a9d1006b65ee928947942a4614b63ce2906d4030..8c379a7cb51b85a1bfa8c7a5d017d2a954c492b6 100644 GIT binary patch delta 3725 zcmZu!3s_ZE7XH_{_j=Afo(tRr;>`t>haiM61biU)A|w$-F`-1fyhK2rUN8|KAZi6} z6&p>>v9g@XiE6SYOG^>0tnvHi`{tYadf3yNnY5WwGn=*Vtr%zK!d`2y^{=(}+K;pL z-tP<37sBL~n{6`tLgT+vMMarCUMXfb&(1dO35e@?XhKk4$-`#~0mw3F{BF^r%$_e@ zX04zovv1$%-WW}~o&WyO3!>my3e}1w-XY@YW4p{&X>cQEpV_>ueNkqg?~9YjTr6v` zkCvG{wH=4oczf(p7Vh`;)E+q*t{5h>&Yc48HcIK008e)j2h0|;D%+j?Qog3i5O!aP zdq+GS8r_zsV!nn2IuzuqSg6B-MH&huUu?w~+%0QMBwQ%PB3Zjf#l1Sbuv7}gQoT$= zi4>M=aB3)()iMp`Dk?No>IlFJ4OJReT2YM}4YfK}p-yL^uwFxhG-%Y&q@h{GY7H(O zBhjLvRl^!ty-&kh$(N{T(=i&0bgVZ9KOJRB9aMerL#8iPG>EF5)5RcLwwj95|xcP3>DXvH900b z40K|%fi$EV=)x8QTd~bR3Q~p55k7Q|fo?FFfaJbp$FoG);!=ders9BsM{v-<6in@l zjVx4B*n-zZ2lwmd+=82P!_0#)i8*01*A;~Ej9aBEYtqH>5eI3SC?2^YF@sSD)Sr+9 zg;ZpM$@CjARLr;zippR~m!2~*i(5(W`(b1yv1@7c{wnD@0$w+vtC&r6yWJi*&gVKT zfj=TnMHXF0+zmvLs^dC&_q~CP<#F(nQHqR7%y6Lupc&q|#&^xim!zQ&mdWF`uSMAw#819Sdo? z6lSP2Q^#VOC5724W$7rSJEf4V(i}Y)_fn3O?viA#B)O8zcKN~Gv2T4_)<)fm`= zy(-ljw2JC@w-*{zPYqm2G^ml9L}&Aqux46Kutq1;*H%?D#6%n9LKi`ajy0%-T1C%6 zKXJ9Wt9lJi7<3;_@K=;o-BesvvD{HwQRPf^7_^pJ4g3+W7&wUE8q`Lu{8<^aj@k+S zzZy4Imo!w=R6DARS2`0^T5r$>+GyYq9_M&$25q7a1BbZ*9Kr9zDlIUc^}0dL)M?;B z;)L}So-uF~&l>2%^9EkPiw1R}+n_DfE{@*guNydqm!CyB+6S7XJ5o81}@?=NxqPtmkjz1$3S~% zFJYMc_-kDaZvH&Xbg-=_uIMoMm?hWPa8_9`cH0OyV&Kgs(7Ss9E$wE8w zv7Qh2O<0P}sNhqf4%^_u{hSB8#bfI>*&pMC@;H2XfkN>FqVc4d)Shm6j`QL3qP=}r z>}%Zj3D|j9es}|cIECTpM?B8(88CnXoI?@bL@C}9>Faj~z6T$?&nLtO2**c=#m5-O zJQbhxU0xqgMOLV!!%jotN8Sh|A4Jk^oC=3=e(*&a`5}Y+`O^>NPdEq#6pXtmoIkYT zSW6?Yj$+VBvDis**iZ2|Oo@1sl5m8^;3$n1EgLu6a=C|j+(RDsut2=l zNZ~0`c#4z-jO23*0m6UlVtWZA%NcPpQidp{oPC`3de%0uwvn~Xh*ws-Tk_hLZr{Mj zMn*O<(#b7tb|cM<2u5}=vXhZsMs~aV_;6bu?>AL>oRPzfJjuurH?rjZJo_<5USi~B zMqXj$xEuL1BX2Wuo{@JL`4b}-+{nBK^6Vcm@-ZV98Tpiv&)mqHjQo?4e=+hMBUc%@ z=0;{cm}gg^nl#u=R`{8QBHU!Sk&}!BF%ry32qR&Pgu9W+-Ff!Wj3h9U$Vd_+W5j{( zmG%_Yrm{ATwUZHPn!@(}ew+{ZE+P1gmsgW8E+64jajrW_wDj2R)7fVR`^;pY+3b_` zv(IP$OZt;k~SK|2gqREYH+XT(zV%ruBXC7->g9Oukm|$9qG*cUTc{Dmq+6@rz;V@EU z@^X*xZ=yg%S-W61ZQ;Aq-$kd04&TXl!d=|cKiERSH@VrQ_;QN*KxC18 zRfK*sFRjrG$l`sA(dVN)x3b*2n$<4Py-Y@_^C0C>&#V`T2SUZDGoBl#$YuZR)uL)3Wbk#g>a@RdXr1Uf z9qf?pTv~N@e}KV(b8*}f{C8V9m;{HsrY`a6jN~f?qSvu3@e_ zDlkt&rH(4h*I7wjprKki)M%*HP^V&{hDADV$6^gjG%S_kG7ZZm&r`8N$8hB6ScTO( zkGn?4NaUzktKva%eD!uUi&Nu&adKv`1r6MrShnUq+h~j;sO81;V^WLf6DZn13L3?g zLjNchQWj}P=vvDZK|_8AzD3C`Gtd}SlS-3cN=i)pHb3cq@PDo%`!C+o( zcNxl-MA5NsA0>&h^>bq;G8zQ+7sNs#6?cM3@^u(0?z#pFO=eA(k&|#Y_mb!|Z73%W zt$b)ty$l@+&u-`{CKC;^T7BaNT!Y2;1|n75L)Q>_9igP^n8KcB9@vw+;AN31uqBu| zF}Fkhw_fj=;>MP-x!i4 zI~vGcfS;}zp^S#XKsa|jm2C>{MLlz!V}~;bG`ZJxm+0ErKSb;{o8OWR&tIbe$pbYStkVz*l1Q*dA<}r8j$l|+@2 zbWEd(Qn^#5WF6D#E~!jX>24i)G+8S5s5C`KKBY({Ri!i?vnXBnXDvgTrb=?JB$;w% zSuBY&PfiSXr&%)3LY4Rys-xM`qezn38qLwEm`YSCRp|j|)b2Cn$x^&ZWdw6sWm&E0 zP7e@1drQb$EZo^Z$9NCsy6o%D{EEZ(L9W z1oyD$n)wxFwc%j~Eyf0d5;n}BCA3sHQhkK^=?!z1;jBT+ah4BdO65XFMcJI7lCp~8 zaX|*Hprr<0!YKp$u-~ASw3JV&LG`qXVEeCgU1d>iSyg3FrDI-kv`VWDT0?6M9Kb=& z$HSlpsX<(QdRXW}YUG=Z)){yP&l)&_Rs&AFVBjc@8?+u<4cb7f#Kc2G=pj*fD8sao zn#7Sq{-#Z|S-gJ8Z|oM@YM>2oa;D{ug^rjCM`dYDdR1kqLEGqI3BAz=N?uZ1Y>=Qw zMDSr>)1$OqOgQWxu!HBzu3eI}OVTOHYcjQ+qV{l1z$JWa;1WKS3}1h-@Z!7O&KG|m-_0RN=If`Ht#y3!E#fFkkCiCIYLsCOs?oqm zBj1S|MC)@6);)Z2?S(h%f&7TVuwP7RooIOmZuq0v)Vh7xi#+xTSaA|QI0avv#%*{R zQ8>$Qgf`@&9R+v=CFl_8&Yiv&F#vD#+u~ge!TT774>-g3+4Do^4QCV;C{W1+E1BU# z8hpteA=Hm=Gk%$o2NK8=$<&`u??66n@yK&+x*tfLS-N<*=SZbu7+ z;}AvQFh$}BMTy22)_bJz2&p_m8jp}6wjH&J*rU@tX0f%9tq!&pv9-*jhAp*hsbk9` zmtWwq1llO_jwO5ShMD&8E!oWYKGAY4hn^MP$MQYS@y2auTL=88OOzfTZ+QzAx+q$X zN6<&k3&-6l?=pA$CA)mZ-F}Mzx`HUWijnjklIVMWvHcS{^aI}=|H54QH>&AJtfrr^ zo?mY}=x6Mv>v)E4;CbrCIr;_X`Q`PVqTpl2O^iCxXthCA2EnS>;iLFrh~h6|&)UT& zCnkGD!mLEWLy3l$5+mYI=2^$FZvy*{XWvBjO%lx~bFI8Q3NMes%cEqlb*ig}keBkT z`HU1WGLw-)geng9w~GTWWmqd1na4;aBl8iZEN~%yrzTpLGqQq_m5i+7-d4MiwTv_| zvWbz+jBI6On`@k}PG$3cQ9$Th@FvgYbaa8*c#5(2)0JL{M*mwSVu52l94z@MkB-&FE^48 zAAT+c1iz+bnKGE$C43^@IU6e)+pN|J9Fxc~NgQ)0$0Xm3`SgEc{^5!-pR-!0a7+rv zq;gC;$GA2&kMr4YV%qSz$U2uKpQVYPrHP-VsgN^v$c(LD^zjbHWpVyo!Gucot%7E% zX5Sjz#(bEm4$-EC7;RdF1k+;d;F;(!Y1cu#PY07CFD}>Yz7liVL*3WFY+B1j(bqz> zhXrot+Hebx^bLC`__ntca+Uk$rfkFf7g-8r)tD_k<^DT&l$tzcHd)^-)7uBF0jtNQ!9f3C~-cqxF1C6z2|6JW289+w9km z67gPpye7X&y0_W^*}OR6-d`?>?>mECUnZjbRlg)( zzn)4gyRLF*Y)>tg$t9G|DH`#2xJ+XAfUnIXewD*&yxyz>P3KTDP z`3K1YG4M)OLLHZvvhnn9`F#^EGCKmpW$ie7hi-T#3Z>r8)XDXNN@`Cew>;@oPP;VSdrv&%!BmTTa6ERJe zs9OW&Q(u;zS@s6cQa1lSfnIyXteU_+0W!&_`_0@QX98sN?Gxbtl(^6l=Gp?HyTeau zY!R7p{zB_ATzf_=V4K@ - * SOFTWARE HISTORY - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * May 1, 2008 njensen Initial creation - * - * - * - * @author njensen - * @version 1.0 - */ - -public class FakeTopo implements INumpyable { - - // TODO need real topo databases! - - private static final int x = 145; - - private static final int y = 145; - - /* - * (non-Javadoc) - * - * @see jep.INumpyable#getNumPy() - */ - @Override - public Object[] getNumPy() { - return new Object[] { new float[x * y] }; - } - - /* - * (non-Javadoc) - * - * @see jep.INumpyable#getNumpyX() - */ - @Override - public int getNumpyX() { - return x; - } - - /* - * (non-Javadoc) - * - * @see jep.INumpyable#getNumpyY() - */ - @Override - public int getNumpyY() { - return y; - } - -} diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/smartinit/Init.py b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/smartinit/Init.py index 2b69ed97f1..bb8c4fd59e 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/smartinit/Init.py +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/smartinit/Init.py @@ -28,6 +28,7 @@ # 04/04/13 #1787 randerso fix validTime check to work with accumulative parms # fix logging so you can actually determine why # a smartInit is not calculating a parameter +# Oct 29, 2013 2476 njensen Improved getting wx/discrete keys when retrieving data # ## import string, sys, re, time, types, getopt, fnmatch, LogStream, DatabaseID, JUtil, AbsTime, TimeRange @@ -967,12 +968,16 @@ class Forecaster(GridUtilities): pytr = TimeRange.encodeJavaTimeRange(tr) pkeys = TimeRange.javaTimeRangeListToPyList(p.getKeys()) if pytr in pkeys: - slice = p.getItem(tr) - slice = slice.__numpy__ + jslice = p.getItem(tr) + slice = jslice.__numpy__ if len(slice) == 1: - slice = slice[0] - elif len(slice) == 2 and type(slice[1]) is str: - exec "slice[1] = " + slice[1] + if slice[0].dtype != int8: + # scalar + slice = slice[0] + else: + # discrete or weather + keys = JUtil.javaObjToPyVal(jslice.getKeyList()) + slice.append(keys) cache[arg] = (slice, pytr) else: cache[arg] = (None, time) @@ -1048,11 +1053,16 @@ class Forecaster(GridUtilities): if type(rval) is not ndarray: if type(rval) is not tuple: + jrval = rval rval = rval.__numpy__ if len(rval) == 1: - rval = rval[0] - elif len(rval) == 2 and type(rval[1]) is str: - exec "rval[1] = " + rval[1] + if rval[0].dtype != int8: + # scalar + rval = rval[0] + else: + # discrete or weather + keys = JUtil.javaObjToPyVal(jrval.getKeyList()) + rval.append(keys) cache[we] = (rval, time) if rval is not None and cache['mtime'][0] is not None and doStore: parm = self.__getNewWE(we) @@ -1211,9 +1221,13 @@ class IFPIO: slice = self.getSrcWE(name, 0).getItem(time) out = slice.__numpy__ if len(out) == 1: - out = out[0] - elif len(out) == 2 and type(out[1]) is str: - exec "out[1] = " + out[1] + if out[0].dtype != int8: + # scalar + out = out[0] + else: + # discrete or weather + keys = JUtil.javaObjToPyVal(slice.getKeyList()) + out.append(keys) else: out = self._getcube(self.eta, name, time) return out @@ -1239,12 +1253,16 @@ class IFPIO: pres = [] for l in lvls: p = self.getSrcWE(parm + "_" + l, 0) - slice = p.getItem(time) - slice = slice.__numpy__ + jslice = p.getItem(time) + slice = jslice.__numpy__ if len(slice) == 1: - slice = slice[0] - elif len(slice) == 2 and type(slice[1]) is str: - exec "slice[1] = " + slice[1] + if slice[0].dtype != int8: + # scalar + slice = slice[0] + else: + # discrete or weather + keys = JUtil.javaObjToPyVal(jslice.getKeyList()) + slice.append(keys) lst.append(slice) pres.append(int(l[2:])) if type(lst[0]) == types.TupleType or type(lst[0]) == types.ListType: diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/objects/GridLocation.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/objects/GridLocation.java index f55048c570..4b4d997446 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/objects/GridLocation.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/db/objects/GridLocation.java @@ -131,7 +131,7 @@ public class GridLocation extends PersistableDataObject implements } @Override - public Object[] getNumPy() { + public Object[] getNumpy() { return new Object[] { data }; } @@ -1048,7 +1048,7 @@ public class GridLocation extends PersistableDataObject implements System.out.println(gridCoord.x + "," + gridCoord.y + " " + latLon); PythonNumpyLatLonGrid latLonGrid = gloc.getLatLonGrid(); - float[] data = (float[]) latLonGrid.getNumPy()[0]; + float[] data = (float[]) latLonGrid.getNumpy()[0]; for (int x = 0; x < gloc.getNx(); x++) { for (int y = 0; y < gloc.getNy(); y++) { int idx = 2 * ((x * gloc.ny) + y); diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/grid/Grid2DBoolean.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/grid/Grid2DBoolean.java index 05f40fd51f..769e32dea0 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/grid/Grid2DBoolean.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/grid/Grid2DBoolean.java @@ -408,7 +408,7 @@ public class Grid2DBoolean implements IGrid2D, Cloneable, INumpyable, } @Override - public Object[] getNumPy() { + public Object[] getNumpy() { return new Object[] { buffer.array() }; } 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 39d8a7100a..bc563797e6 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 @@ -414,7 +414,7 @@ public class Grid2DByte implements IGrid2D, Cloneable, INumpyable, } @Override - public Object[] getNumPy() { + public Object[] getNumpy() { return new Object[] { buffer.array() }; } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/grid/Grid2DFloat.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/grid/Grid2DFloat.java index bc308fec99..29d3015818 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/grid/Grid2DFloat.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/grid/Grid2DFloat.java @@ -425,7 +425,7 @@ public class Grid2DFloat implements IGrid2D, Cloneable, INumpyable, } @Override - public Object[] getNumPy() { + public Object[] getNumpy() { return new Object[] { buffer.array() }; } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/DiscreteGridSlice.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/DiscreteGridSlice.java index 012a72637d..423e78af45 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/DiscreteGridSlice.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/DiscreteGridSlice.java @@ -36,7 +36,6 @@ import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteKey; import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DBit; import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DByte; import com.raytheon.uf.common.dataplugin.gfe.grid.IGrid2D; -import com.raytheon.uf.common.python.PyUtil; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.status.IUFStatusHandler; @@ -58,6 +57,7 @@ import com.raytheon.uf.common.time.TimeRange; * string * 08/13/2013 1571 randerso Removed toString to stop it from hanging the * debugger when trying to display the grid + * 10/29/2013 2476 njensen Updated getNumpy() and added getKeyList() * * * @author chammack @@ -789,16 +789,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable { } @Override - public Object[] getNumPy() { - Object[] numpy = new Object[2]; - numpy[0] = getDiscreteGrid().getBuffer().array(); - List keyList = new ArrayList(); - for (DiscreteKey k : key) { - keyList.add(k.toString()); - } - String pyList = PyUtil.listToList(keyList); - numpy[1] = pyList; - return numpy; + public Object[] getNumpy() { + return new Object[] { getDiscreteGrid().getBuffer().array() }; } @Override @@ -860,4 +852,12 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable { diskCache.removeFromCache(cacheId); } } + + public List getKeyList() { + List list = new ArrayList(key.length); + for (DiscreteKey k : key) { + list.add(k.toString()); + } + return list; + } } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/PythonWeatherGridSlice.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/PythonWeatherGridSlice.java index 9d1a14c9bd..3cb3e5b5e0 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/PythonWeatherGridSlice.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/PythonWeatherGridSlice.java @@ -72,10 +72,10 @@ public class PythonWeatherGridSlice extends AbstractGridSlice { /* * (non-Javadoc) * - * @see jep.INumpyable#getNumPy() + * @see jep.INumpyable#getNumpy() */ @Override - public Object[] getNumPy() { + public Object[] getNumpy() { Object[] numpy = new Object[2]; numpy[0] = weatherGrid.getBuffer().array(); String pyList = PyUtil.listToList(keys); diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/ScalarGridSlice.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/ScalarGridSlice.java index f215d2afb5..235af74b9f 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/ScalarGridSlice.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/ScalarGridSlice.java @@ -937,7 +937,7 @@ public class ScalarGridSlice extends AbstractGridSlice implements } @Override - public Object[] getNumPy() { + public Object[] getNumpy() { return new Object[] { this.getScalarGrid().getFloats() }; } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/VectorGridSlice.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/VectorGridSlice.java index c0c565ccc6..0e47319ca4 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/VectorGridSlice.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/slice/VectorGridSlice.java @@ -1225,7 +1225,7 @@ public class VectorGridSlice extends ScalarGridSlice implements Cloneable, } @Override - public Object[] getNumPy() { + public Object[] getNumpy() { return new Object[] { this.getMagGrid().getFloats(), this.getDirGrid().getFloats() }; } 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 d71db3d1f3..bd9506aaaa 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 @@ -35,7 +35,6 @@ import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DByte; import com.raytheon.uf.common.dataplugin.gfe.grid.IGrid2D; import com.raytheon.uf.common.dataplugin.gfe.weather.WeatherKey; import com.raytheon.uf.common.dataplugin.gfe.weather.WeatherSubKey; -import com.raytheon.uf.common.python.PyUtil; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.status.IUFStatusHandler; @@ -56,6 +55,7 @@ import com.raytheon.uf.common.time.TimeRange; * 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() * * * @@ -814,16 +814,8 @@ public class WeatherGridSlice extends AbstractGridSlice { } @Override - public Object[] getNumPy() { - Object[] numpy = new Object[2]; - numpy[0] = getWeatherGrid().getBuffer().array(); - List keyList = new ArrayList(); - for (WeatherKey k : keys) { - keyList.add(k.toString()); - } - String pyList = PyUtil.listToList(keyList); - numpy[1] = pyList; - return numpy; + public Object[] getNumpy() { + return new Object[] { getWeatherGrid().getBuffer().array() }; } @Override @@ -884,4 +876,12 @@ public class WeatherGridSlice extends AbstractGridSlice { diskCache.removeFromCache(cacheId); } } + + public List getKeyList() { + List list = new ArrayList(keys.length); + for (WeatherKey k : keys) { + list.add(k.toString()); + } + return list; + } } diff --git a/edexOsgi/com.raytheon.uf.common.python/src/com/raytheon/uf/common/python/PythonNumpyFloatArray.java b/edexOsgi/com.raytheon.uf.common.python/src/com/raytheon/uf/common/python/PythonNumpyFloatArray.java index ec3357c58a..c366fde088 100644 --- a/edexOsgi/com.raytheon.uf.common.python/src/com/raytheon/uf/common/python/PythonNumpyFloatArray.java +++ b/edexOsgi/com.raytheon.uf.common.python/src/com/raytheon/uf/common/python/PythonNumpyFloatArray.java @@ -52,10 +52,10 @@ public class PythonNumpyFloatArray implements INumpyable { /* * (non-Javadoc) * - * @see jep.INumpyable#getNumPy() + * @see jep.INumpyable#getNumpy() */ @Override - public Object[] getNumPy() { + public Object[] getNumpy() { return new Object[] { messageData }; } diff --git a/edexOsgi/com.raytheon.uf.edex.python.decoder/src/com/raytheon/uf/edex/python/decoder/PythonNumpyByteArray.java b/edexOsgi/com.raytheon.uf.edex.python.decoder/src/com/raytheon/uf/edex/python/decoder/PythonNumpyByteArray.java index 42c4569c1e..229e64ddde 100644 --- a/edexOsgi/com.raytheon.uf.edex.python.decoder/src/com/raytheon/uf/edex/python/decoder/PythonNumpyByteArray.java +++ b/edexOsgi/com.raytheon.uf.edex.python.decoder/src/com/raytheon/uf/edex/python/decoder/PythonNumpyByteArray.java @@ -46,10 +46,10 @@ public class PythonNumpyByteArray implements INumpyable { /* * (non-Javadoc) * - * @see jep.INumpyable#getNumPy() + * @see jep.INumpyable#getNumpy() */ @Override - public Object[] getNumPy() { + public Object[] getNumpy() { return new Object[] { messageData }; } diff --git a/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/INumpyable.java b/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/INumpyable.java index 38f91c463b..0174f94ca2 100644 --- a/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/INumpyable.java +++ b/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/INumpyable.java @@ -20,13 +20,14 @@ package jep; /** - * TODO Add Description + * Interface representing a Java object that can be transformed into a numpy + * array. * *
  * SOFTWARE HISTORY
- * Date			Ticket#		Engineer	Description
+ * Date         Ticket#         Engineer        Description
  * ------------	----------	-----------	--------------------------
- * Apr 4, 2008				njensen	Initial creation
+ * Apr 4, 2008                  njensen         Initial creation
  * 
  * 
* @@ -39,14 +40,21 @@ public interface INumpyable { /** * Gets an Object[] representation of the object to transform into numpy. * Each index in the Object[] should be another array of the primitive type, - * e.g. {float[], float[]} + * e.g. {float[], float[]}. The result in python will then be a python + * list, e.g. [numpy.ndarray(dtype=float32), numpy.ndarray(dtype=float32)]. * * @return */ - public Object[] getNumPy(); + public Object[] getNumpy(); + /** + * Gets the x dimension of the arrays returned by getNumpy(). + */ public int getNumpyX(); + /** + * Gets the y dimension of hte arrays returned by getNumpy(). + */ public int getNumpyY(); } diff --git a/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/Jep.java b/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/Jep.java index 5302e4aa2e..cc46254d63 100644 --- a/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/Jep.java +++ b/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/Jep.java @@ -821,7 +821,7 @@ public final class Jep { throws JepException; // added by njensen - public void setNumeric(String name, float[] v, int nx, int ny) throws JepException { + public void setNumpy(String name, float[] v, int nx, int ny) throws JepException { if(this.closed) throw new JepException("Jep has been closed."); isValidThread(); @@ -832,7 +832,7 @@ public final class Jep { private native void setNumeric(long tstate, String name, float[] v, int nx, int ny) throws JepException; // end of added by njensen - public void setNumeric(String name, int[] v, int nx, int ny) throws JepException { + public void setNumpy(String name, int[] v, int nx, int ny) throws JepException { if(this.closed) throw new JepException("Jep has been closed."); isValidThread(); @@ -843,7 +843,7 @@ public final class Jep { private native void setNumeric(long tstate, String name, int[] v, int nx, int ny) throws JepException; - public void setNumeric(String name, byte[] v, int nx, int ny) throws JepException { + public void setNumpy(String name, byte[] v, int nx, int ny) throws JepException { if(this.closed) throw new JepException("Jep has been closed."); isValidThread(); diff --git a/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/pyjobject.c b/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/pyjobject.c index 4b9feaa71f..e516ba812f 100644 --- a/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/pyjobject.c +++ b/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/pyjobject.c @@ -86,17 +86,11 @@ static jmethodID objectGetClass = 0; static jmethodID classGetMethods = 0; static jmethodID classGetFields = 0; +// all following static variables added by njensen static jmethodID xMethod = 0; static jmethodID yMethod = 0; -static jmethodID getMethod = 0; +static jmethodID getNumpyMethod = 0; -// added by njensen -static jclass floatarrayclass = NULL; -static jclass bytearrayclass = NULL; -static jclass intarrayclass = NULL; -static jclass stringclass = NULL; - -// added by njensen static jmethodID classGetName = 0; static PyObject* classnamePyJMethodsDict = NULL; @@ -739,35 +733,35 @@ static PyObject* pyjobject_getattr(PyJobject_Object *obj, // added by njensen static PyObject* pyjobject_numpy(PyJobject_Object *obj) { - int i=0; - /* updated by bkowal */ - npy_intp *dims = NULL; - jfloat *dataFloat = NULL; - jbyte *dataByte = NULL; - jint *dataInt = NULL; - const char *message = NULL; - jobjectArray objarray = NULL; - PyObject *resultList = NULL; - jint xsize = 0; - jint ysize = 0; - jsize listSize =0; + int i=0; + /* updated by bkowal */ + npy_intp *dims = NULL; + jobjectArray objarray = NULL; + PyObject *resultList = NULL; + jint xsize = 0; + jint ysize = 0; + jsize listSize =0; - JNIEnv *env = pyembed_get_env(); + JNIEnv *env = pyembed_get_env(); + // methods are forever but classes are fleeting jclass numpyable = (*env)->FindClass(env, "jep/INumpyable"); if((*env)->IsInstanceOf(env, obj->object, numpyable)) { - xMethod = (*env)->GetMethodID(env, numpyable, "getNumpyX", "()I"); + if(xMethod == NULL) + xMethod = (*env)->GetMethodID(env, numpyable, "getNumpyX", "()I"); xsize = (jint) (*env)->CallIntMethod(env, obj->object, xMethod); - yMethod = (*env)->GetMethodID(env, numpyable, "getNumpyY", "()I"); + if(yMethod == NULL) + yMethod = (*env)->GetMethodID(env, numpyable, "getNumpyY", "()I"); ysize = (jint) (*env)->CallIntMethod(env, obj->object, yMethod); dims = malloc(2 * sizeof(npy_intp)); dims[0] = ysize; dims[1] = xsize; - getMethod = (*env)->GetMethodID(env, numpyable, "getNumPy", "()[Ljava/lang/Object;"); - objarray = (jobjectArray) (*env)->CallObjectMethod(env, obj->object, getMethod); + if(getNumpyMethod == NULL) + getNumpyMethod = (*env)->GetMethodID(env, numpyable, "getNumpy", "()[Ljava/lang/Object;"); + objarray = (jobjectArray) (*env)->CallObjectMethod(env, obj->object, getNumpyMethod); if(process_java_exception(env) || !objarray) { Py_INCREF(Py_None); @@ -775,59 +769,19 @@ static PyObject* pyjobject_numpy(PyJobject_Object *obj) { } listSize = (*env)->GetArrayLength(env, objarray); - - initNumpy(); - - resultList = PyList_New(listSize); - - if(floatarrayclass == NULL) - floatarrayclass = (*env)->FindClass(env, "[F"); - if(bytearrayclass == NULL) - bytearrayclass = (*env)->FindClass(env, "[B"); - if(intarrayclass == NULL) - intarrayclass = (*env)->FindClass(env, "[I"); - if(stringclass == NULL) - stringclass = (*env)->FindClass(env, "java/lang/String"); - + resultList = PyList_New(listSize); for(i=0; i < listSize; i=i+1) { - PyObject *pyjob; + PyObject *pyjob = NULL; jobject jo = (*env)->GetObjectArrayElement(env, objarray, i); - if((*env)->IsInstanceOf(env, jo, floatarrayclass)) + pyjob = javaToNumpyArray(env, jo, dims); + if(pyjob == NULL) { - pyjob = PyArray_SimpleNew(2, dims, NPY_FLOAT32); - dataFloat = (*env)->GetFloatArrayElements(env, jo, 0); - memcpy(((PyArrayObject *)pyjob)->data, - dataFloat, ysize * xsize * sizeof(float)); - (*env)->ReleaseFloatArrayElements(env, jo, dataFloat, 0); - } - else if((*env)->IsInstanceOf(env, jo, bytearrayclass)) - { - pyjob = PyArray_SimpleNew(2, dims, NPY_BYTE); - dataByte = (*env)->GetByteArrayElements(env, jo, 0); - memcpy(((PyArrayObject *)pyjob)->data, - dataByte, ysize * xsize * 1); - (*env)->ReleaseByteArrayElements(env, jo, dataByte, 0); - } - else if((*env)->IsInstanceOf(env, jo, intarrayclass)) - { - pyjob = PyArray_SimpleNew(2, dims, NPY_INT32); - dataInt = (*env)->GetIntArrayElements(env, jo, 0); - memcpy(((PyArrayObject *)pyjob)->data, - dataInt, ysize * xsize * sizeof(int)); - (*env)->ReleaseIntArrayElements(env, jo, dataInt, 0); - } - else if((*env)->IsInstanceOf(env, jo, stringclass)) - { - message = jstring2char(env, jo); - pyjob = PyString_FromString(message); - release_utf_char(env, jo, message); - } - else - { - Py_INCREF(Py_None); - pyjob = Py_None; - } + PyErr_Format(PyExc_TypeError, "Cannot transform INumpyable.getNumpy()[%i] java object to numpy array", i); + free(dims); + Py_DECREF(resultList); + return NULL; + } PyList_SetItem(resultList, i, pyjob); (*env)->DeleteLocalRef(env, jo); } @@ -837,20 +791,11 @@ static PyObject* pyjobject_numpy(PyJobject_Object *obj) { } else { - Py_INCREF(Py_None); - return Py_None; + PyErr_Format(PyExc_TypeError, "Object does not implement INumpyable and therefore cannot be transformed to numpy array"); + return NULL; } } -// added by njensen -static void initNumpy(void) -{ - if (!numpyInit) - { - import_array(); - numpyInit = 1; - } -} // set attribute v for object. // uses obj->attr dictionary for storage. diff --git a/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/pyjobject.h b/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/pyjobject.h index fb1b8b52e8..97c3b03f46 100644 --- a/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/pyjobject.h +++ b/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/pyjobject.h @@ -69,7 +69,6 @@ int pyjobject_check(PyObject *obj); //added by njensen static PyObject* pyjobject_numpy(PyJobject_Object *obj); -static void initNumpy(void); -static int numpyInit = 0; + #endif // ndef pyjobject diff --git a/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/util.c b/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/util.c index d42ecf7d5e..d63c800bbc 100644 --- a/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/util.c +++ b/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/util.c @@ -95,6 +95,7 @@ jclass JBOOLEAN_ARRAY_TYPE = NULL; jclass JDOUBLE_ARRAY_TYPE = NULL; jclass JFLOAT_ARRAY_TYPE = NULL; jclass JBYTE_ARRAY_TYPE = NULL; +jclass JSHORT_ARRAY_TYPE = NULL; // cached methodids jmethodID objectToString = 0; @@ -905,6 +906,15 @@ int cache_primitive_classes(JNIEnv *env) { (*env)->DeleteLocalRef(env, clazz); } + if(JSHORT_ARRAY_TYPE == NULL) { + clazz = (*env)->FindClass(env, "[S"); + if((*env)->ExceptionOccurred(env)) + return 0; + + JSHORT_ARRAY_TYPE = (*env)->NewGlobalRef(env, clazz); + (*env)->DeleteLocalRef(env, clazz); + } + return 1; } @@ -985,6 +995,11 @@ void unref_cache_primitive_classes(JNIEnv *env) { (*env)->DeleteGlobalRef(env, JDOUBLE_ARRAY_TYPE); JDOUBLE_ARRAY_TYPE = NULL; } + if(JSHORT_ARRAY_TYPE != NULL) { + (*env)->DeleteGlobalRef(env, JSHORT_ARRAY_TYPE); + JSHORT_ARRAY_TYPE = NULL; + } + } @@ -1402,7 +1417,7 @@ jvalue convert_pynumpyarg_jvalue(JNIEnv *env, arr = NULL; if(param != Py_None && !pyjarray_check(param)) { - initUtil(); + initNumpy(); if(PyArray_Check(param)) { @@ -1580,7 +1595,7 @@ jvalue convert_pyarg_jvalue(JNIEnv *env, } else { //added by njensen - initUtil(); + initNumpy(); if(PyArray_Check(param)) { ret.l = numpyToJavaArray(env, param, NULL); @@ -1723,7 +1738,7 @@ jarray numpyToJavaArray(JNIEnv* env, PyObject *param, jclass desiredType) PyArrayObject *pa = NULL; int minDim = 0; int maxDim = 0; - initUtil(); + initNumpy(); sz = PyArray_Size(param); if(desiredType == NULL) @@ -1732,6 +1747,8 @@ jarray numpyToJavaArray(JNIEnv* env, PyObject *param, jclass desiredType) desiredType = JBOOLEAN_ARRAY_TYPE; else if(((PyArrayObject *) param)->descr->type_num == NPY_BYTE) desiredType = JBYTE_ARRAY_TYPE; + else if(((PyArrayObject *) param)->descr->type_num == NPY_INT16) + desiredType = JSHORT_ARRAY_TYPE; else if(((PyArrayObject *) param)->descr->type_num == NPY_INT32) desiredType = JINT_ARRAY_TYPE; else if(((PyArrayObject *) param)->descr->type_num == NPY_INT64) @@ -1762,6 +1779,15 @@ jarray numpyToJavaArray(JNIEnv* env, PyObject *param, jclass desiredType) pa = (PyArrayObject *) nvalue; (*env)->SetByteArrayRegion(env, arr, 0, sz, (const jbyte *)pa->data); } + else if((*env)->IsSameObject(env, desiredType, JSHORT_ARRAY_TYPE) + && (((PyArrayObject *) param)->descr->type_num == NPY_INT16)) + { + arr = (*env)->NewShortArray(env, sz); + nobj = PyArray_ContiguousFromObject(param, NPY_INT16, minDim, maxDim); + nvalue = (PyObject *)PyArray_Cast((PyArrayObject *)nobj, NPY_INT16); + pa = (PyArrayObject *) nvalue; + (*env)->SetShortArrayRegion(env, arr, 0, sz, (const jshort *)pa->data); + } else if((*env)->IsSameObject(env, desiredType, JINT_ARRAY_TYPE) && (((PyArrayObject *) param)->descr->type_num == NPY_INT32)) { @@ -1808,6 +1834,75 @@ jarray numpyToJavaArray(JNIEnv* env, PyObject *param, jclass desiredType) return arr; } +// added by njensen +PyObject* javaToNumpyArray(JNIEnv* env, jobject jo, npy_intp *dims) +{ + PyObject *pyjob = NULL; + int ysize, xsize; + ysize = dims[0]; + xsize = dims[1]; + initNumpy(); + + if((*env)->IsInstanceOf(env, jo, JBOOLEAN_ARRAY_TYPE)) + { + jboolean *dataBool = NULL; + pyjob = PyArray_SimpleNew(2, dims, NPY_BOOL); + dataBool = (*env)->GetBooleanArrayElements(env, jo, 0); + memcpy(((PyArrayObject *)pyjob)->data, dataBool, ysize * xsize * 1); + (*env)->ReleaseBooleanArrayElements(env, jo, dataBool, 0); + } + else if((*env)->IsInstanceOf(env, jo, JBYTE_ARRAY_TYPE)) + { + jbyte *dataByte = NULL; + pyjob = PyArray_SimpleNew(2, dims, NPY_BYTE); + dataByte = (*env)->GetByteArrayElements(env, jo, 0); + memcpy(((PyArrayObject *)pyjob)->data, dataByte, ysize * xsize * 1); + (*env)->ReleaseByteArrayElements(env, jo, dataByte, 0); + } + else if((*env)->IsInstanceOf(env, jo, JSHORT_ARRAY_TYPE)) + { + jshort *dataShort = NULL; + pyjob = PyArray_SimpleNew(2, dims, NPY_INT16); + dataShort = (*env)->GetShortArrayElements(env, jo, 0); + memcpy(((PyArrayObject *)pyjob)->data, dataShort, ysize * xsize * 2); + (*env)->ReleaseShortArrayElements(env, jo, dataShort, 0); + } + else if((*env)->IsInstanceOf(env, jo, JINT_ARRAY_TYPE)) + { + jint *dataInt = NULL; + pyjob = PyArray_SimpleNew(2, dims, NPY_INT32); + dataInt = (*env)->GetIntArrayElements(env, jo, 0); + memcpy(((PyArrayObject *)pyjob)->data, dataInt, ysize * xsize * 4); + (*env)->ReleaseIntArrayElements(env, jo, dataInt, 0); + } + else if((*env)->IsInstanceOf(env, jo, JLONG_ARRAY_TYPE)) + { + jlong *dataLong = NULL; + pyjob = PyArray_SimpleNew(2, dims, NPY_INT64); + dataLong = (*env)->GetLongArrayElements(env, jo, 0); + memcpy(((PyArrayObject *)pyjob)->data, dataLong, ysize * xsize * 8); + (*env)->ReleaseLongArrayElements(env, jo, dataLong, 0); + } + else if((*env)->IsInstanceOf(env, jo, JFLOAT_ARRAY_TYPE)) + { + jfloat *dataFloat = NULL; + pyjob = PyArray_SimpleNew(2, dims, NPY_FLOAT32); + dataFloat = (*env)->GetFloatArrayElements(env, jo, 0); + memcpy(((PyArrayObject *)pyjob)->data, dataFloat, ysize * xsize * 4); + (*env)->ReleaseFloatArrayElements(env, jo, dataFloat, 0); + } + else if((*env)->IsInstanceOf(env, jo, JDOUBLE_ARRAY_TYPE)) + { + jdouble *dataDouble = NULL; + pyjob = PyArray_SimpleNew(2, dims, NPY_FLOAT64); + dataDouble = (*env)->GetDoubleArrayElements(env, jo, 0); + memcpy(((PyArrayObject *)pyjob)->data, dataDouble, ysize * xsize * 8); + (*env)->ReleaseDoubleArrayElements(env, jo, dataDouble, 0); + } + + return pyjob; +} + // added by njensen, code from brockwoo jarray pylistToJStringList(JNIEnv* env, PyObject* plist) { @@ -1827,12 +1922,12 @@ jarray pylistToJStringList(JNIEnv* env, PyObject* plist) } // added by njensen -static void initUtil(void) +static void initNumpy(void) { - if (!utilInit) + if (!numpyInited) { import_array(); - utilInit = 1; + numpyInited = 1; } } diff --git a/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/util.h b/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/util.h index 8972695a4f..603090bb09 100755 --- a/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/util.h +++ b/nativeLib/rary.cots.jepp/jepp-2.3/src/jep/util.h @@ -37,6 +37,9 @@ #endif #include +// added by njensen +#include "numpy/arrayobject.h" + #ifndef _Included_util #define _Included_util @@ -106,11 +109,12 @@ int process_py_exception(JNIEnv*, int); // added by njensen char *PyTraceback_AsString(PyObject*); -static void initUtil(void); -static int utilInit = 0; +static void initNumpy(void); +static int numpyInited = 0; jstring javaStacktrace_tostring(JNIEnv*, jthrowable); jarray numpyToJavaArray(JNIEnv*, PyObject*, jclass); jarray pylistToJStringList(JNIEnv*, PyObject*); +PyObject* javaToNumpyArray(JNIEnv*, jobject, npy_intp*); // convert java exception to pyerr. // true (1) if an exception was processed. diff --git a/tests/unit/com/raytheon/viz/gfe/contours/TestContourAnalyzer.java b/tests/unit/com/raytheon/viz/gfe/contours/TestContourAnalyzer.java index f7e8a7da12..34bad84ad6 100644 --- a/tests/unit/com/raytheon/viz/gfe/contours/TestContourAnalyzer.java +++ b/tests/unit/com/raytheon/viz/gfe/contours/TestContourAnalyzer.java @@ -202,8 +202,8 @@ public class TestContourAnalyzer { String label) { assertEquals(label + ":getXdim()", expected.getXdim(), result.getXdim()); assertEquals(label + ":getYdim()", expected.getYdim(), result.getYdim()); - assertArrayEquals(label + ":values", expected.getNumPy(), - result.getNumPy()); + assertArrayEquals(label + ":values", expected.getNumpy(), + result.getNumpy()); } /** From af7e9dd4ef6df24256749f78176e9697148bf4be Mon Sep 17 00:00:00 2001 From: Brad Gonzales Date: Tue, 29 Oct 2013 15:09:38 -0500 Subject: [PATCH 13/15] Issue #2267 Remove java.nio.file dependencies from the SbnSimulator. Fixed handler setting for UFStatus in test env. Change-Id: I8245eef53573b6596546e17a7900a1538455cee2 Former-commit-id: ac8136bd82aba83c9000dc723423c5d0c5c96067 [formerly f1480cfc627e16a32b5ec304038b8947057c393f] [formerly ac8136bd82aba83c9000dc723423c5d0c5c96067 [formerly f1480cfc627e16a32b5ec304038b8947057c393f] [formerly 6bc585aaf6f27360df725a82099f23f0f2d131a9 [formerly 6b8ff162be029543c8b9a7fcb3f8a359962aa6d7]]] Former-commit-id: 6bc585aaf6f27360df725a82099f23f0f2d131a9 Former-commit-id: 47690ea8d03edd4b9bfdcf7c6d153d94c2fdd95a [formerly aeccaa2329be3f61dae5eb2f507622319525f8f7] Former-commit-id: 3b2127c1033b49d9493bf0f155d3154531157cd7 --- .../raytheon/uf/common/status/UFStatus.java | 14 ++-- .../com/raytheon/uf/common/util/FileUtil.java | 69 ++++++++-------- .../bandwidth/sbn/SbnSimulator.java | 79 ++++++++++++++----- .../bandwidth/sbn/SbnSimulatorTest.java | 6 +- 4 files changed, 97 insertions(+), 71 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/UFStatus.java b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/UFStatus.java index 88e22b582d..96cf7b7512 100644 --- a/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/UFStatus.java +++ b/edexOsgi/com.raytheon.uf.common.status/src/com/raytheon/uf/common/status/UFStatus.java @@ -23,8 +23,6 @@ import java.util.Iterator; import java.util.ServiceLoader; import java.util.concurrent.atomic.AtomicReference; -import com.raytheon.uf.common.status.UFStatus.Priority; - /** * The principal mechanism for representing the outcome of an operation.
* @@ -103,23 +101,22 @@ public class UFStatus { protected final String message; /** handler factory */ - private static AtomicReference handlerFactoryRef = createHandlerFactory(); + private static AtomicReference handlerFactoryRef = new AtomicReference(); - private static final AtomicReference createHandlerFactory() { + static { ServiceLoader loader = ServiceLoader.load( IUFStatusHandlerFactory.class, IUFStatusHandlerFactory.class.getClassLoader()); Iterator handlerIterator = loader.iterator(); - IUFStatusHandlerFactory factory = null; if (handlerIterator.hasNext()) { - factory = handlerIterator.next(); + UFStatus.setHandlerFactory(handlerIterator.next()); } else { - factory = new DefaultStatusHandlerFactory(); + UFStatus.setHandlerFactory(new DefaultStatusHandlerFactory()); Exception e = new RuntimeException("No " + IUFStatusHandlerFactory.class.getName() + " found.\nUsing default handler."); - factory.getInstance() + UFStatus.getHandler() .handle(Priority.CRITICAL, e.getLocalizedMessage() + "\nPlease ignore if you are in a unit test environment\n"); @@ -130,7 +127,6 @@ public class UFStatus { + IUFStatusHandlerFactory.class.getName() + " handlers defined"); } - return new AtomicReference(factory); } /** diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java index dedcb82118..5f06f0578c 100644 --- a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java @@ -31,13 +31,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.channels.FileChannel; -import java.nio.file.DirectoryStream; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; @@ -932,36 +926,37 @@ public class FileUtil { return size; } - /** - * List files/directories that match a FileFilter. - * - * @param directory - * @param filter - * @param recurse - * @return - * @throws IOException - */ - public static List listPaths(File directory, - DirectoryStream.Filter filter, boolean recurse) - throws IOException { - // List of files / directories - List files = new LinkedList(); - - // Get files / directories in the directory accepted by the filter. - Path dirPath = FileSystems.getDefault().getPath( - directory.getAbsolutePath()); - DirectoryStream stream = null; - try { - stream = Files.newDirectoryStream(dirPath, filter); - for (final Iterator it = stream.iterator(); it.hasNext();) { - files.add(it.next()); - } - } finally { - if (stream != null) { - stream.close(); - } - } - return files; - } + // TODO Java 1.7 potential code + // /** + // * List files/directories that match a FileFilter. + // * + // * @param directory + // * @param filter + // * @param recurse + // * @return + // * @throws IOException + // */ + // public static List listPaths(File directory, + // DirectoryStream.Filter filter, boolean recurse) + // throws IOException { + // // List of files / directories + // List files = new LinkedList(); + // + // // Get files / directories in the directory accepted by the filter. + // Path dirPath = FileSystems.getDefault().getPath( + // directory.getAbsolutePath()); + // DirectoryStream stream = null; + // try { + // stream = Files.newDirectoryStream(dirPath, filter); + // for (final Iterator it = stream.iterator(); it.hasNext();) { + // files.add(it.next()); + // } + // } finally { + // if (stream != null) { + // stream.close(); + // } + // } + // return files; + // } } diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/src/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulator.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/src/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulator.java index 02b7017252..f01563cf23 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/src/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulator.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth.ncf/src/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulator.java @@ -21,9 +21,6 @@ package com.raytheon.uf.edex.datadelivery.bandwidth.sbn; import java.io.File; import java.io.IOException; -import java.nio.file.FileSystems; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; import java.util.List; import com.google.common.annotations.VisibleForTesting; @@ -95,6 +92,8 @@ public class SbnSimulator { private final IFileProcessor fileProcessor; + private String site; + /** * Private constructor. */ @@ -115,6 +114,7 @@ public class SbnSimulator { this.sitesDirectory = new File(directoryToScan, "sbnSimulator"); this.localSiteDirectory = new File(sitesDirectory, site); this.localSiteDirectory.mkdirs(); + this.site = site; } /** @@ -126,8 +126,8 @@ public class SbnSimulator { final List files = FileUtil.listFiles(localSiteDirectory, FilenameFilters.ACCEPT_VISIBLE_FILES, false); - statusHandler.info("Found [" + files.size() + "] files for " - + SiteUtil.getSite() + " from the SBN..."); + statusHandler.info("Found [" + files.size() + "] files for " + site + + " from the SBN..."); for (File file : files) { @@ -150,36 +150,73 @@ public class SbnSimulator { * @throws IOException */ public void distributeToSiteDirs() throws IOException { - final List undistributedFiles = FileUtil.listPaths( + final List undistributedFiles = FileUtil.listFiles( directoryToScan, - FilenameFilters.ACCEPT_PATH_FILES, false); + FilenameFilters.ACCEPT_FILES, false); // get list of site dirs - final List sites = FileUtil.listPaths(sitesDirectory, - FilenameFilters.ACCEPT_PATH_DIRECTORIES, false); + final List sites = FileUtil.listFiles(sitesDirectory, + FilenameFilters.ACCEPT_DIRECTORIES, false); statusHandler.info("Found [" + undistributedFiles.size() + "] files to distribute..."); // distribute to site specific directories - for (Path file : undistributedFiles) { + for (File file : undistributedFiles) { statusHandler.info("Distributing file [" + file + "]"); - for (Path siteDir : sites) { - Path dest = FileSystems.getDefault().getPath( - siteDir.toString(), file.getFileName().toString()); - Path hiddenDest = FileSystems.getDefault() - .getPath(siteDir.toString(), - "." + file.getFileName().toString()); + for (File siteDir : sites) { + File dest = new File(siteDir, file.getName().toString()); + File hiddenDest = new File(siteDir, "." + + file.getName().toString()); // move to site sbn directory as hidden - java.nio.file.Files.copy(file, hiddenDest, - StandardCopyOption.REPLACE_EXISTING); + FileUtil.copyFile(file, hiddenDest); // rename dest to un-hidden - java.nio.file.Files.move(hiddenDest, dest, - StandardCopyOption.ATOMIC_MOVE); + hiddenDest.renameTo(dest); statusHandler.info("===> to file [" + dest + "]"); } // delete source file - java.nio.file.Files.delete(file); + file.delete(); } } + // TODO Java 1.7 version of the distributeToSiteDirs() method + // /** + // * Distribute to the site directories. Enables all site client registries + // * to ingest shared data. + // * + // * @throws IOException + // */ + // public void distributeToSiteDirs() throws IOException { + // final List undistributedFiles = FileUtil.listPaths( + // directoryToScan, + // FilenameFilters.ACCEPT_PATH_FILES, false); + // // get list of site dirs + // final List sites = FileUtil.listPaths(sitesDirectory, + // FilenameFilters.ACCEPT_PATH_DIRECTORIES, false); + // + // statusHandler.info("Found [" + undistributedFiles.size() + + // "] files to distribute..."); + // + // // distribute to site specific directories + // for (Path file : undistributedFiles) { + // statusHandler.info("Distributing file [" + file + "]"); + // for (Path siteDir : sites) { + // Path dest = FileSystems.getDefault().getPath( + // siteDir.toString(), file.getFileName().toString()); + // Path hiddenDest = FileSystems.getDefault() + // .getPath(siteDir.toString(), + // "." + file.getFileName().toString()); + // + // // move to site sbn directory as hidden + // java.nio.file.Files.copy(file, hiddenDest, + // StandardCopyOption.REPLACE_EXISTING); + // // rename dest to un-hidden + // java.nio.file.Files.move(hiddenDest, dest, + // StandardCopyOption.ATOMIC_MOVE); + // statusHandler.info("===> to file [" + dest + "]"); + // } + // // delete source file + // java.nio.file.Files.delete(file); + // } + // } + } diff --git a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulatorTest.java b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulatorTest.java index aa87aa0ccf..a767a3dae3 100644 --- a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulatorTest.java +++ b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/sbn/SbnSimulatorTest.java @@ -117,10 +117,8 @@ public class SbnSimulatorTest { @Test public void errorOnOneFileDoesNotStopTheOthers() throws IOException { - File fileOneExpectedResult = createTestFileGetExpected(testDir, - "fileOne.txt", "AA1"); - File fileTwoExpectedResult = createTestFileGetExpected(testDir, - "fileTwo.txt", "AA2"); + createTestFileGetExpected(testDir, "fileOne.txt", "AA1"); + createTestFileGetExpected(testDir, "fileTwo.txt", "AA2"); doThrow(new IOException()).when(fileProcessor).processFile( any(File.class)); From ef522381001365ce1b298f9a0073bf9e990cc92c Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Tue, 29 Oct 2013 16:46:44 -0500 Subject: [PATCH 14/15] Issue #2491 Clean resource datas out of ncep plugins. Former-commit-id: b713ae826d642de4225ea8e2c837a7eeb13c6cd1 [formerly e1180db74bf386e76ec6830f32ac15487d7629fb] [formerly b713ae826d642de4225ea8e2c837a7eeb13c6cd1 [formerly e1180db74bf386e76ec6830f32ac15487d7629fb] [formerly 1ac69169faf16a833ae518a745d9ef62775947de [formerly e1259eb7fa31d3142ca9ce43bf46c52f00fb098e]]] Former-commit-id: 1ac69169faf16a833ae518a745d9ef62775947de Former-commit-id: fe29ef1c58c63f92e557f1318104b5b1da85ca49 [formerly e1054d923ca9618b47cb73b95f8a8bf575c41b16] Former-commit-id: bec7eb3d7f8b13375a181c746e8c139ddc1cef68 --- ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 21 +------------------ ...f.common.serialization.ISerializableObject | 6 ------ ...f.common.serialization.ISerializableObject | 7 +------ ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 2 -- ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 2 -- ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 3 --- ...f.common.serialization.ISerializableObject | 4 ---- ...f.common.serialization.ISerializableObject | 1 - ...f.common.serialization.ISerializableObject | 1 - 26 files changed, 2 insertions(+), 62 deletions(-) delete mode 100644 ncep/gov.noaa.nws.ncep.ui.nctextui/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.overlays/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.airmet/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.atcf/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.convsigmet/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.ffg/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.hrcn/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.idft/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.intlsig/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.lightning/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.mosaic/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.ncradar/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.ncscat/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.nonconvsigmet/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.pgen/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.satellite/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.stormtrack/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.wavesat/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.rsc.wcp/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.tools/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject delete mode 100644 ncep/gov.noaa.nws.ncep.viz.ui.seek/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject diff --git a/ncep/gov.noaa.nws.ncep.ui.nctextui/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.ui.nctextui/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index cdd0e8c863..0000000000 --- a/ncep/gov.noaa.nws.ncep.ui.nctextui/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.ui.nctextui.rsc.NctextuiResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.ui.nsharp/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject index 367c10c0f5..5e8da50f67 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -1,23 +1,4 @@ gov.noaa.nws.ncep.ui.nsharp.NsharpConfigStore gov.noaa.nws.ncep.ui.nsharp.NsharpLineProperty gov.noaa.nws.ncep.ui.nsharp.NsharpGraphProperty -gov.noaa.nws.ncep.ui.nsharp.NsharpDataPageProperty -gov.noaa.nws.ncep.ui.nsharp.display.NsharpSkewTPaneDisplay -gov.noaa.nws.ncep.ui.nsharp.display.NsharpInsetPaneDisplay -gov.noaa.nws.ncep.ui.nsharp.display.NsharpDataPaneDisplay -gov.noaa.nws.ncep.ui.nsharp.display.NsharpHodoPaneDisplay -gov.noaa.nws.ncep.ui.nsharp.display.NsharpTimeStnPaneDisplay -gov.noaa.nws.ncep.ui.nsharp.display.NsharpWitoPaneDisplay -gov.noaa.nws.ncep.ui.nsharp.display.NsharpSpcGraphsPaneDisplay -gov.noaa.nws.ncep.ui.nsharp.display.NsharpAbstractPaneDescriptor -gov.noaa.nws.ncep.ui.nsharp.display.NsharpHodoPaneDescriptor -gov.noaa.nws.ncep.ui.nsharp.display.NsharpSkewTPaneDescriptor -gov.noaa.nws.ncep.ui.nsharp.display.NsharpSpcGraphsPaneDescriptor -gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpDataPaneResourceData -gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpHodoPaneResourceData -gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpInsetPaneResourceData -gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpSkewTPaneResourceData -gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpSpcGraphsPaneResourceData -gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpTimeStnPaneResourceData -gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpWitoPaneResourceData -gov.noaa.nws.ncep.ui.nsharp.display.map.NsharpMapResourceData +gov.noaa.nws.ncep.ui.nsharp.NsharpDataPageProperty \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.overlays/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.overlays/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 7122db9d01..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.overlays/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1,6 +0,0 @@ -gov.noaa.nws.ncep.viz.overlays.resources.LatLonOverlayResourceData -gov.noaa.nws.ncep.viz.overlays.resources.ScaleOverlayResourceData -gov.noaa.nws.ncep.viz.overlays.resources.DbOverlayResourceData -gov.noaa.nws.ncep.viz.overlays.resources.PgenStaticOverlayResourceData -gov.noaa.nws.ncep.viz.overlays.resources.PointOverlayResourceData -gov.noaa.nws.ncep.viz.overlays.resources.OverlayResourceGroupData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.resources/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.resources/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject index 6596805ea8..28c6329d31 100644 --- a/ncep/gov.noaa.nws.ncep.viz.resources/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ b/ncep/gov.noaa.nws.ncep.viz.resources/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -1,8 +1,3 @@ -gov.noaa.nws.ncep.viz.resources.time_match.NCTimeMatcher -gov.noaa.nws.ncep.viz.resources.manager.NcMapRBD -gov.noaa.nws.ncep.viz.resources.manager.NTransRBD -gov.noaa.nws.ncep.viz.resources.manager.SolarRBD gov.noaa.nws.ncep.viz.resources.manager.ResourceDefinition gov.noaa.nws.ncep.viz.resources.manager.ResourceDefinitionFilters -gov.noaa.nws.ncep.viz.resources.manager.AttrSetGroup -gov.noaa.nws.ncep.viz.resources.colorBar.ColorBarResourceData \ No newline at end of file +gov.noaa.nws.ncep.viz.resources.manager.AttrSetGroup \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.airmet/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.airmet/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index afcfb81561..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.airmet/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.airmet.rsc.AirmetResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.atcf/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.atcf/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 498fb0911a..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.atcf/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.atcf.rsc.AtcfResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.convsigmet/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.convsigmet/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 85db651dd2..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.convsigmet/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.convsigmet.rsc.ConvSigmetResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.ffg/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.ffg/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index d0bf3d5234..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.ffg/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.ffg.rsc.FFGResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.hrcn/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.hrcn/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 07e5128d38..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.hrcn/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.hrcn.rsc.HrcnResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.idft/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.idft/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 526cfb3794..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.idft/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.idft.rsc.IDFTResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.intlsig/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.intlsig/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 522f83b9ae..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.intlsig/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.intlsig.rsc.IntlSigmetResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.lightning/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.lightning/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 890d435415..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.lightning/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.lightning.rsc.LightningResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.mosaic/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.mosaic/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 0d455a6284..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.mosaic/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.mosaic.rsc.MosaicResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject index 7d56f80286..f97ec8539c 100644 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ b/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -1,3 +1 @@ -gov.noaa.nws.ncep.viz.rsc.ncgrid.rsc.NcgridResourceData -gov.noaa.nws.ncep.viz.rsc.ncgrid.rsc.NcEnsembleResourceData gov.noaa.nws.ncep.edex.common.dataRecords.NcFloatDataRecord \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.ncradar/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.ncradar/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 2a1734cc70..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.ncradar/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.ncradar.rsc.RadarResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.ncscat/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.ncscat/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 60097e19a3..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.ncscat/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.ncscat.rsc.NcscatResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.nonconvsigmet/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.nonconvsigmet/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 3675106d2a..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.nonconvsigmet/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.nonconvsigmet.rsc.NonConvSigmetResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.pgen/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.pgen/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index a339da9abc..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.pgen/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.pgen.rsc.PgenDisplayResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.satellite/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.satellite/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 70b526e2e7..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.satellite/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.satellite.rsc.SatelliteResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.stormtrack/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.stormtrack/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 90184e8306..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.stormtrack/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.stormtrack.rsc.StormTrackResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.wavesat/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.wavesat/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index d600a6ca5a..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.wavesat/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1,2 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.wavesat.rsc.WaveSatResourceData -gov.noaa.nws.ncep.viz.rsc.wavesat.rsc.WaveSatAlertParser \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.wcp/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.rsc.wcp/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 44250f888f..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.wcp/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.rsc.wcp.rsc.WCPResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.tools/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.tools/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index d920f6e973..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.tools/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1,3 +0,0 @@ -gov.noaa.nws.ncep.viz.tools.aodt.AODTResourceData -gov.noaa.nws.ncep.viz.tools.logos.LogosResourceData -gov.noaa.nws.ncep.viz.tools.panZoom.NcZoomToolResourceData \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.ui.display/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.ui.display/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject index 1b6070a7d6..f8232a1403 100644 --- a/ncep/gov.noaa.nws.ncep.viz.ui.display/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ b/ncep/gov.noaa.nws.ncep.viz.ui.display/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -1,6 +1,2 @@ -gov.noaa.nws.ncep.viz.ui.display.NCMapRenderableDisplay -gov.noaa.nws.ncep.viz.ui.display.NCMapDescriptor -gov.noaa.nws.ncep.viz.ui.display.NCNonMapRenderableDisplay -gov.noaa.nws.ncep.viz.ui.display.NCNonMapDescriptor gov.noaa.nws.ncep.viz.ui.display.ColorBar gov.noaa.nws.ncep.viz.ui.display.ColorBarFromColormap \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.ui.locator/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.ui.locator/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject index b7a0a0ad88..8c0b72aa53 100644 --- a/ncep/gov.noaa.nws.ncep.viz.ui.locator/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ b/ncep/gov.noaa.nws.ncep.viz.ui.locator/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -1,2 +1 @@ -gov.noaa.nws.ncep.viz.ui.locator.resource.LocatorResourceData gov.noaa.nws.ncep.viz.ui.locator.resource.LocatorDataSource \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.viz.ui.seek/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/ncep/gov.noaa.nws.ncep.viz.ui.seek/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 200b32ec7e..0000000000 --- a/ncep/gov.noaa.nws.ncep.viz.ui.seek/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -gov.noaa.nws.ncep.viz.ui.seek.SeekResourceData \ No newline at end of file From 7be692352058dc75c8ad157e661520479cfe1850 Mon Sep 17 00:00:00 2001 From: Brad Gonzales Date: Tue, 29 Oct 2013 17:04:00 -0500 Subject: [PATCH 15/15] Issue #2267 Removed java.nio.file dependencies from FilenameFilter. Change-Id: I6af1cafe17609a6468a7805ccab61b28ecc0a733 Former-commit-id: 433ee7d9427e9d7bb7cfa61317b32b3bc64ca0f5 [formerly 011c42b8062b2c2eb06011a4617cf6f32a816c00] [formerly 433ee7d9427e9d7bb7cfa61317b32b3bc64ca0f5 [formerly 011c42b8062b2c2eb06011a4617cf6f32a816c00] [formerly 057ba113b539d3613d64ef45bc6ab39e174ef4b9 [formerly 36571478911119efe7195d51f6c820d6e745ccee]]] Former-commit-id: 057ba113b539d3613d64ef45bc6ab39e174ef4b9 Former-commit-id: 3c0bd6db168cd4c7b54b926e01794bc63e39947b [formerly 9325d477a990d0a1b571cf002300db9169f37e38] Former-commit-id: 759c3b2cef58d97867e6061a3b9738b09d010cfc --- .../uf/common/util/file/FilenameFilters.java | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/file/FilenameFilters.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/file/FilenameFilters.java index 6b329459c8..6b97a8c40f 100644 --- a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/file/FilenameFilters.java +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/file/FilenameFilters.java @@ -21,10 +21,6 @@ package com.raytheon.uf.common.util.file; import java.io.File; import java.io.FilenameFilter; -import java.io.IOException; -import java.nio.file.DirectoryStream; -import java.nio.file.Files; -import java.nio.file.Path; /** * Consolidates common filename filters. @@ -179,23 +175,26 @@ public final class FilenameFilters { } }; - /** - * Accepts Path directories. - */ - public static final DirectoryStream.Filter ACCEPT_PATH_DIRECTORIES = new DirectoryStream.Filter() { - public boolean accept(Path path) throws IOException { - return (Files.isDirectory(path)); - } - }; - - /** - * Accepts Path files. - */ - public static final DirectoryStream.Filter ACCEPT_PATH_FILES = new DirectoryStream.Filter() { - public boolean accept(Path path) throws IOException { - return (Files.isRegularFile(path)); - } - }; + // TODO Code that can be uncommented after a transition to Java 1.7 + // /** + // * Accepts Path directories. + // */ + // public static final DirectoryStream.Filter ACCEPT_PATH_DIRECTORIES + // = new DirectoryStream.Filter() { + // public boolean accept(Path path) throws IOException { + // return (Files.isDirectory(path)); + // } + // }; + // + // /** + // * Accepts Path files. + // */ + // public static final DirectoryStream.Filter ACCEPT_PATH_FILES = new + // DirectoryStream.Filter() { + // public boolean accept(Path path) throws IOException { + // return (Files.isRegularFile(path)); + // } + // }; /** * Returns a {@link FilenameFilter} that matches the specified file