diff --git a/cave/build/.pydevproject b/cave/build/.pydevproject index faf12629d9..f4a659751e 100644 --- a/cave/build/.pydevproject +++ b/cave/build/.pydevproject @@ -2,6 +2,6 @@ -python 2.5 +python 2.7 Default diff --git a/cave/build/static/common/cave/etc/gfe/userPython/utilities/ProductParser.py b/cave/build/static/common/cave/etc/gfe/userPython/utilities/ProductParser.py index d15deaa24a..0cea29c727 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/utilities/ProductParser.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/utilities/ProductParser.py @@ -2,19 +2,19 @@ ## # 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. ## @@ -119,7 +119,7 @@ nnn = r'(?:[A-Z]{2}[ZC])?\d{3}' purge = r'(?P\d{6})-' ugc = r'\n(?P' + r'[A-Z]{2}[Z|C](?:(?:\d{3})|(?:ALL))' + r'(?:[->]\n?' + nnn + \ r')*-\n?' + purge + el + r')' -cityh = r'(?<=-\n(?!.*-\n))(?P(?:.*\n))' +cityh = r'-\n(?P(?:\s*\n)*(?:INCLUDING THE (?:CITIES|CITY) OF...)?)' body = r'(?P(?:^.*\n)*?)' #body = r'.*' @@ -192,20 +192,20 @@ class ProductParser: #l = headline_re.finditer(str) l = single_head_re.finditer(str) for m in l: - if m is not None: + if m is not None: #print 'phl m = ', m newstart = start + m.start() m = headline_re.match(m.group(0)) if m is not None: hdlns.append(self.dumpMatch(m, newstart)) - + #print 'hdlns = ', hdlns rval['headInfo'] = hdlns def dumpMatch(self, m, offset=0, rval=None): if rval is None: rval = {} - + #print 'dumpmatch m = ', m.groupdict() for k in m.groupdict().keys(): if m.start(k) != -1 and m.start(k) != m.end(k): @@ -234,7 +234,7 @@ class ProductParser: segs = [] l = ugch_re.finditer(self._str) - + for m in l: if m is not None: m1 = cityh_re.search(self._str, m.end()) @@ -250,7 +250,7 @@ class ProductParser: else: continue m4 = head_re.search(self._str, m.end(), m3.end()) - + d = self.dumpMatch(m) d = self.dumpMatch(m2, rval=d) d = self.dumpMatch(m3, rval=d) @@ -266,7 +266,7 @@ class ProductParser: else: d['city'] = (self.tkc(m2.start()), self.tkc(m2.start())) - + if m4 is not None: #print 'm4 = ', m4.group() d = self.dumpMatch(m4, rval=d) @@ -284,7 +284,7 @@ class ProductParser: rval['frames'] = frames return rval - + def parseFromJava(self, text): self._str = text self._ci = None @@ -295,13 +295,13 @@ class ProductParser: lc.append(count) count += l self._totals = lc - + #print 'text START ----------------------' #print text #print 'text END ------------------------' - + result = self.parse() - + #print 'result = ', result - + return JUtil.pyDictToJavaMap(result) diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelUtilities.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelUtilities.java index f6cf111c91..ee065cd1cf 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelUtilities.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelUtilities.java @@ -24,6 +24,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.NavigableSet; +import java.util.Set; import java.util.TreeSet; import javax.measure.unit.Unit; @@ -34,6 +35,7 @@ import com.raytheon.uf.common.dataplugin.level.CompareType; import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.LevelFactory; import com.raytheon.uf.common.dataplugin.level.MasterLevel; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.viz.core.exception.VizCommunicationException; /** @@ -57,8 +59,8 @@ public class LevelUtilities { static { try { - hPa = (Unit) UnitFormat.getUCUMInstance().parseProductUnit( - "hPa", new ParsePosition(0)); + hPa = UnitFormat.getUCUMInstance().parseProductUnit("hPa", + new ParsePosition(0)); } catch (Exception e) { // this is bad } @@ -122,7 +124,15 @@ public class LevelUtilities { }; Map> masterLevelToOrderedSet = new HashMap>(); - for (Level level : LevelMappingFactory.getInstance().getAllLevels()) { + Set allLevels; + try { + allLevels = LevelMappingFactory.getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) + .getAllLevels(); + } catch (CommunicationException e) { + throw new VizCommunicationException(e); + } + for (Level level : allLevels) { NavigableSet levels = masterLevelToOrderedSet.get(level .getMasterLevel().getName()); if (levels == null) { diff --git a/cave/com.raytheon.uf.viz.d2d.xy.adapters/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.d2d.xy.adapters/META-INF/MANIFEST.MF index f4e82edc0c..e6600a06ad 100644 --- a/cave/com.raytheon.uf.viz.d2d.xy.adapters/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.d2d.xy.adapters/META-INF/MANIFEST.MF @@ -15,11 +15,12 @@ Require-Bundle: org.eclipse.core.runtime, com.raytheon.viz.core;bundle-version="1.12.1174", com.raytheon.viz.core.graphing;bundle-version="1.12.1174", com.raytheon.uf.viz.xy.timeseries;bundle-version="1.12.1174", - javax.measure;bundle-version="1.0.0" + javax.measure;bundle-version="1.0.0", + com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174", + com.raytheon.uf.common.comm;bundle-version="1.12.1174" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.raytheon.uf.common.dataplugin, com.raytheon.uf.common.dataplugin.grid, - com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.dataplugin.radar, com.raytheon.uf.common.dataplugin.radar.util, com.raytheon.uf.common.dataquery.requests, diff --git a/cave/com.raytheon.uf.viz.d2d.xy.adapters/src/com/raytheon/uf/viz/d2d/xy/adapters/timeseries/PointDataTimeSeriesAdapter.java b/cave/com.raytheon.uf.viz.d2d.xy.adapters/src/com/raytheon/uf/viz/d2d/xy/adapters/timeseries/PointDataTimeSeriesAdapter.java index 8ad51cafd0..5d99123897 100644 --- a/cave/com.raytheon.uf.viz.d2d.xy.adapters/src/com/raytheon/uf/viz/d2d/xy/adapters/timeseries/PointDataTimeSeriesAdapter.java +++ b/cave/com.raytheon.uf.viz.d2d.xy.adapters/src/com/raytheon/uf/viz/d2d/xy/adapters/timeseries/PointDataTimeSeriesAdapter.java @@ -35,6 +35,8 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.geospatial.MapUtil; @@ -44,8 +46,6 @@ import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.TimeRange; import com.raytheon.uf.viz.core.datastructure.DataCubeContainer; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.level.LevelMapping; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; import com.raytheon.uf.viz.core.level.LevelUtilities; import com.raytheon.uf.viz.core.rsc.DisplayType; import com.raytheon.uf.viz.core.style.level.SingleLevel; @@ -238,6 +238,7 @@ public class PointDataTimeSeriesAdapter extends return loadDataOAInternal(recordsToLoad); } + @Override public SingleLevel getLevel() { SingleLevel level = new SingleLevel("SURFACE"); level.setValue(0.0); @@ -246,7 +247,8 @@ public class PointDataTimeSeriesAdapter extends return level; } try { - LevelMapping mapping = LevelMappingFactory.getInstance() + LevelMapping mapping = LevelMappingFactory.getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) .getLevelMappingForKey(resourceData.getLevelKey()); for (Level l : mapping.getLevels()) { if (LevelUtilities.isPressureLevel(l)) { @@ -260,7 +262,7 @@ public class PointDataTimeSeriesAdapter extends } } } - } catch (VizException e) { + } catch (Exception e) { // return the default } return level; diff --git a/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/inv/AbstractInventory.java b/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/inv/AbstractInventory.java index e4b9877298..7e9dcee725 100644 --- a/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/inv/AbstractInventory.java +++ b/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/inv/AbstractInventory.java @@ -35,6 +35,7 @@ import java.util.concurrent.BlockingQueue; import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.derivparam.tree.AbstractNode; import com.raytheon.uf.common.derivparam.tree.DataTree; @@ -47,7 +48,6 @@ import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.viz.core.exception.VizCommunicationException; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; import com.raytheon.uf.viz.core.level.LevelUtilities; import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData; import com.raytheon.uf.viz.derivparam.data.FloatRequestableData; @@ -137,27 +137,36 @@ public abstract class AbstractInventory implements DerivParamUpdateListener { */ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } StackEntry other = (StackEntry) obj; - if (!getOuterType().equals(other.getOuterType())) + if (!getOuterType().equals(other.getOuterType())) { return false; - if (level != other.level) + } + if (level != other.level) { return false; + } if (source == null) { - if (other.source != null) + if (other.source != null) { return false; - } else if (!source.equals(other.source)) + } + } else if (!source.equals(other.source)) { return false; + } if (parameter == null) { - if (other.parameter != null) + if (other.parameter != null) { return false; - } else if (!parameter.equals(other.parameter)) + } + } else if (!parameter.equals(other.parameter)) { return false; + } return true; } @@ -474,8 +483,10 @@ public abstract class AbstractInventory implements DerivParamUpdateListener { protected Collection getAllLevels() { if (allLevels == null) { try { - return LevelMappingFactory.getInstance().getAllLevels(); - } catch (VizCommunicationException e) { + return LevelMappingFactory.getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) + .getAllLevels(); + } catch (CommunicationException e) { // TODO recover from this. statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); @@ -1094,7 +1105,13 @@ public abstract class AbstractInventory implements DerivParamUpdateListener { // because it is valid for all requests } else if (type == LevelType.LevelMapping) { LevelNode target = null; - for (Level fieldLevel : field.getLevelMapping().getLevels()) { + List levels; + try { + levels = field.getLevelMapping().getLevels(); + } catch (CommunicationException e) { + throw new VizCommunicationException(e); + } + for (Level fieldLevel : levels) { target = resolveNode(fieldSourceNode, fieldParamAbbrev, fieldLevel, stack, nodata); if (target != null) { diff --git a/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/library/DerivParamField.java b/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/library/DerivParamField.java index 7f1859e02a..97cfd8bd32 100644 --- a/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/library/DerivParamField.java +++ b/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/library/DerivParamField.java @@ -27,11 +27,11 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.adapters.UnitAdapter; import com.raytheon.uf.viz.core.exception.VizCommunicationException; -import com.raytheon.uf.viz.core.level.LevelMapping; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; /** * Metadata about a derived parameter field. @@ -131,7 +131,8 @@ public class DerivParamField implements ISerializableObject, IDerivParamField { public boolean setLevel(String level) throws VizCommunicationException { levelType = LevelType.parseLevel(level); if (levelType == LevelType.LevelMapping) { - levelMapping = LevelMappingFactory.getInstance() + levelMapping = LevelMappingFactory.getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) .getLevelMappingForKey(level); if (levelMapping == null) { levelType = null; diff --git a/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/library/ValidLevelGenerator.java b/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/library/ValidLevelGenerator.java index 9a394f5b83..05d2c3289b 100644 --- a/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/library/ValidLevelGenerator.java +++ b/cave/com.raytheon.uf.viz.derivparam/src/com/raytheon/uf/viz/derivparam/library/ValidLevelGenerator.java @@ -34,11 +34,11 @@ import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.LevelFactory; import com.raytheon.uf.common.dataplugin.level.MasterLevel; import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapper; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.util.mapping.Mapper; import com.raytheon.uf.common.util.mapping.MultipleMappingException; import com.raytheon.uf.viz.core.exception.VizCommunicationException; -import com.raytheon.uf.viz.core.level.LevelMapping; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; /** * Generates the valid levels for a derived parameter script based on it @@ -74,7 +74,8 @@ public class ValidLevelGenerator { private Set masterLevelsHandled; public ValidLevelGenerator() { - lmf = LevelMappingFactory.getInstance(); + lmf = LevelMappingFactory + .getInstance(LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE); lf = LevelFactory.getInstance(); lm = LevelMapper.getInstance(); } @@ -84,61 +85,65 @@ public class ValidLevelGenerator { masterLevels = new HashMap>(); validLevels = new HashSet(); masterLevelsHandled = new HashSet(); - if (validLevelsString != null && validLevelsString.length() > 0) { - String[] levelTokenArray = validLevelsString.split(","); - List tokensToProcess = new ArrayList( - levelTokenArray.length); + try { + if (validLevelsString != null && validLevelsString.length() > 0) { + String[] levelTokenArray = validLevelsString.split(","); + List tokensToProcess = new ArrayList( + levelTokenArray.length); - for (String token : levelTokenArray) { - tokensToProcess.add(token); - } - - // generate initial list - Iterator iter = tokensToProcess.iterator(); - - while (iter.hasNext()) { - String token = iter.next(); - - if (token.charAt(0) == '!') { - token = token.substring(1); + for (String token : levelTokenArray) { + tokensToProcess.add(token); } - // See if this is a group. - Map> tmp = lmf - .getLevelMapForGroup(token); - if (tmp != null) { - masterLevels = tmp; - iter.remove(); - break; - } - } + // generate initial list + Iterator iter = tokensToProcess.iterator(); - if (masterLevels.size() == 0 && tokensToProcess.size() > 0) { - for (Level l : lmf.getAllLevels()) { - MasterLevel ml = l.getMasterLevel(); - Set levels = masterLevels.get(ml); - if (levels == null) { - levels = new HashSet(); - masterLevels.put(ml, levels); + while (iter.hasNext()) { + String token = iter.next(); + + if (token.charAt(0) == '!') { + token = token.substring(1); } + // See if this is a group. + Map> tmp = lmf + .getLevelMapForGroup(token); - levels.add(l); - } - } - - if (tokensToProcess.size() > 0) { - for (String token : tokensToProcess) { - try { - processLevelToken(token); - } catch (CommunicationException e) { - throw new VizCommunicationException(e); + if (tmp != null) { + masterLevels = tmp; + iter.remove(); + break; } } - } else { - for (Set levels : masterLevels.values()) { - validLevels.addAll(levels); + + if (masterLevels.size() == 0 && tokensToProcess.size() > 0) { + for (Level l : lmf.getAllLevels()) { + MasterLevel ml = l.getMasterLevel(); + Set levels = masterLevels.get(ml); + if (levels == null) { + levels = new HashSet(); + masterLevels.put(ml, levels); + } + + levels.add(l); + } + } + + if (tokensToProcess.size() > 0) { + for (String token : tokensToProcess) { + try { + processLevelToken(token); + } catch (CommunicationException e) { + throw new VizCommunicationException(e); + } + } + } else { + for (Set levels : masterLevels.values()) { + validLevels.addAll(levels); + } } } + } catch (CommunicationException e) { + throw new VizCommunicationException(e); } return validLevels; diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java index 744dcb9c75..40b9a4e7e2 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java @@ -93,6 +93,7 @@ import com.raytheon.uf.viz.monitor.listeners.IMonitorListener; * 02/19/13 1639 njensen Replaced ConcurrentHashMaps with data structures * 02/20/13 1635 D. Hladky Fixed multi guidance sources * Mar 6, 2013 1769 dhladky Changed threading to use count down latch. + * Apr 9, 2013 1890 dhladky Fixed the broken cache file load * * * @@ -386,19 +387,40 @@ public class FFMPMonitor extends ResourceMonitor { * @param dataKey * @param source */ - public void insertFFMPData(FFMPAggregateRecord data, String siteKey, - String source) { - // TODO do we need this method if we're no longer supporting cache - // records? - if (siteDataMap.containsSite(siteKey)) { - if (siteDataMap.get(siteKey).containsSource(source)) { - for (Entry entry : data.getBasinsMap() - .entrySet()) { - FFMPBasinData basinData = entry.getValue(); - basinData.populate(data.getTimes()); + public void insertFFMPData(FFMPAggregateRecord data, + NavigableMap> uris, String siteKey, String source) { + + // get record from cache + FFMPSourceData sourceData = siteDataMap.get(siteKey).getSourceData(source); + FFMPRecord curRecord = sourceData.getRecord(); + + if (curRecord == null) { + // add each huc requested + for (String huc : data.getBasinsMap().keySet()) { + // add all of the uris + for (Entry> duris : uris.entrySet()) { + for (String uri : duris.getValue()) { + + if (curRecord == null) { + curRecord = new FFMPRecord(uri); + sourceData.setRecord(curRecord); + } + + sourceData.addLoadedUri(huc, uri); + } } } } + + if (curRecord != null) { + for (Entry entry : data.getBasinsMap() + .entrySet()) { + + FFMPBasinData basinData = entry.getValue(); + basinData.populate(data.getTimes()); + curRecord.populate(basinData, entry.getKey()); + } + } } /** diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/fffg/FFFGDlg.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/fffg/FFFGDlg.java index 344882bdf2..2e61fc166d 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/fffg/FFFGDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/fffg/FFFGDlg.java @@ -89,6 +89,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Changes for non-blocking HelpDlg. * Changes for non-blocking RetrieveMergeDlg. * Changes for non-blocking LoadSaveDeleteSelectDlg. + * Apr, 15, 2013 #1911 dhladky dialog wouldn't open every time to retrieve file. * * * @@ -1607,8 +1608,8 @@ public class FFFGDlg extends CaveSWTDialog implements ISourceCompAction, } if (isDialogClear() && (fileNameLbl.getText().trim().length() == 0)) { - return; - } else { + getRetrieveFilename(RetrieveMergeAction.RETRIEVE); + } else { if (retMergeDlg == null) { retMergeDlg = new RetrieveMergeDlg(shell); retMergeDlg.setCloseCallback(new ICloseCallback() { diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPConfig.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPConfig.java index 04d9846250..52a88d068b 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPConfig.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPConfig.java @@ -55,6 +55,7 @@ import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPTableColumnXML; * ------------ ---------- ----------- -------------------------- * Aug 01, 2012 14168 mpduff Add convenience methods for * getting ColorCell and ReverseFilter + * Apr 15. 2013 1890 dhladky Added Mikes fix for singleton. * * * @@ -123,27 +124,9 @@ public class FFMPConfig { } public static synchronized FFMPConfig getInstance() { - if (classInstance == null) { - classInstance = new FFMPConfig(); - } - return classInstance; } - public void disposeResources() { - upperColor.dispose(); - midColor.dispose(); - lowerColor.dispose(); - belowLowerColor.dispose(); - defaultColor.dispose(); - forcedFFGColor.dispose(); - vgbColor.dispose(); - } - - public static void unloadConfig() { - classInstance = null; - } - private void init() { threshMgrMap = new HashMap(); diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java index 8e44c4333d..42fda1468e 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java @@ -319,8 +319,8 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements dataLoadFont.dispose(); timeDurFont.dispose(); - FFMPConfig.getInstance().disposeResources(); - FFMPConfig.unloadConfig(); + //FFMPConfig.getInstance().disposeResources(); + //FFMPConfig.unloadConfig(); if (refreshColor != null) { refreshColor.dispose(); @@ -1311,15 +1311,20 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements if (attributeDlg == null || attributeDlg.isDisposed()) { attrData = ffmpTable.getVisibleColumns(); attributeDlg = new AttributesDlg(shell, resource, attrData, this); + attributeDlg.open(); + } else { + attributeDlg.bringToTop(); } - attributeDlg.open(); } private void displayThresholdsDialog(ThreshColNames colName) { if (attrThreshDlg == null) { attrThreshDlg = new AttributeThresholdDlg(shell, colName, this); + attrThreshDlg.open(); + } else { + attrThreshDlg.bringToTop(); } - attrThreshDlg.open(); + attrThreshDlg.newThreshold(colName); } @@ -2105,13 +2110,17 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements shell.pack(); } - String prefix = null; + String prefix = null; - if (status.getLoaderType() == LOADER_TYPE.SECONDARY) { - prefix = " Secondary Data Load: "; - } else { - prefix = " Tertiary Data Load: "; - } + if (status.getLoaderType() == LOADER_TYPE.SECONDARY) { + prefix = " Secondary Data Load: "; + } else if (status.getLoaderType() == LOADER_TYPE.TERTIARY) { + prefix = " Tertiary Data Load: "; + } else if (status.getLoaderType() == LOADER_TYPE.GENERAL) { + prefix = " General Data Load: "; + } else { + prefix = " Tertiary Data Load: "; + } if (status.isDone() == false) { dataLoadingLbl.setText(prefix + status.getMessage()); diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFFGForceUtil.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFFGForceUtil.java index 213049f2fb..7fe7ccf968 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFFGForceUtil.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFFGForceUtil.java @@ -24,6 +24,7 @@ import java.util.List; import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasin; import com.raytheon.uf.common.dataplugin.ffmp.FFMPGuidanceInterpolation; +import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord; import com.raytheon.uf.common.dataplugin.ffmp.FFMPTemplates; import com.raytheon.uf.common.monitor.config.FFFGDataMgr; import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager; @@ -41,6 +42,7 @@ import com.raytheon.uf.common.monitor.xml.SourceXML; * ------------ ---------- ----------- -------------------------- * Jul 20, 2011 mpduff Initial creation * 01/14/13 1569 dhladky changed arraylist to list + * 04/15/13 1890 dhladky Changed COUNTY to use constant * * * @@ -132,7 +134,7 @@ public class FFFGForceUtil { pfafList = ft.getAggregatePfafs(cBasin.getPfaf(), resource.getSiteKey(), resource.getHuc()); } else if (!domain.equals("NA")) { - if (!resource.getHuc().equals("ALL")) { + if (!resource.getHuc().equals(FFMPRecord.ALL)) { pfafList = ft.getAggregatePfafsByDomain(cBasin.getPfaf(), resource.getSiteKey(), domain, resource.getHuc()); } diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataGenerator.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataGenerator.java index 8e764e812e..a22a00bfc1 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataGenerator.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataGenerator.java @@ -71,6 +71,8 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.dialogs.FfmpTableConfigData; * Feb 19, 2013 1639 njensen Replaced FFMPCacheRecord with FFMPRecord * feb 20, 2013 1635 dhladky Fixed multi guidance displays * Feb 28, 2013 1729 dhladky General enhancements for speed. + * Apr 15, 2013 1890 dhladky Added another constant fix. + * Apr 15, 2013 1911 dhladky Fixed forced FFG for centered aggregates. * * @author dhladky * @version 1.0 @@ -497,7 +499,7 @@ public class FFMPDataGenerator { forced = forceUtil.isForced(); } - if ((!forcedPfafs.isEmpty()) && forced) { + if ((!forcedPfafs.isEmpty()) && forced && centeredAggregationKey == null) { // Recalculate the guidance using the forced // value(s) guidance = guidRecords @@ -510,7 +512,7 @@ public class FFMPDataGenerator { guidance, forcedPfafs, resource.getGuidSourceExpiration(guidType)); - } else if (!forcedPfafs.isEmpty()) { + } else if (!forcedPfafs.isEmpty() && centeredAggregationKey == null) { guidance = guidRecords .get(guidType) .getBasinData(ALL) @@ -522,7 +524,7 @@ public class FFMPDataGenerator { forcedPfafs, resource.getGuidSourceExpiration(guidType)); forced = true; - } else if (!pfafList.isEmpty()) { + } else if (!pfafList.isEmpty() && centeredAggregationKey == null) { guidance = guidRecords .get(guidType) .getBasinData(ALL) @@ -674,7 +676,7 @@ public class FFMPDataGenerator { forced = forceUtil.isForced(); } - if ((!forcedPfafs.isEmpty()) && forced) { + if ((!forcedPfafs.isEmpty()) && forced && centeredAggregationKey == null) { // Recalculate the guidance using the forced // value(s) guidance = guidRecords @@ -687,7 +689,7 @@ public class FFMPDataGenerator { guidance, forcedPfafs, resource.getGuidSourceExpiration(guidType)); - } else if (!forcedPfafs.isEmpty()) { + } else if (!forcedPfafs.isEmpty() && centeredAggregationKey == null) { guidance = guidRecords .get(guidType) .getBasinData(ALL) @@ -699,7 +701,7 @@ public class FFMPDataGenerator { forcedPfafs, resource.getGuidSourceExpiration(guidType)); forced = true; - } else if (!pfafList.isEmpty()) { + } else if (!pfafList.isEmpty() && centeredAggregationKey == null) { guidance = guidRecords .get(guidType) .getBasinData(ALL) @@ -843,7 +845,7 @@ public class FFMPDataGenerator { ArrayList pfafs = ft.getAggregatePfafs(basin.getPfaf(), siteKey, huc); if (!pfafs.isEmpty()) { - if (huc.equals("COUNTY")) { + if (huc.equals(FFMPRecord.COUNTY)) { name = ft.getCountyStateName(siteKey, basin.getPfaf()); } else { for (int i = 0; i < pfafs.size(); i++) { diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataLoader.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataLoader.java index 8fcd97df1b..121cd59cd4 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataLoader.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataLoader.java @@ -20,7 +20,6 @@ package com.raytheon.uf.viz.monitor.ffmp.ui.rsc; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -67,6 +66,7 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.listeners.FFMPLoaderEvent; * 02/01/13 1569 D. Hladky Changed to reading aggregate records from pypies * Feb 28, 2013 1729 dhladky Changed the way status messages are sent to the FFMP Dialog. * Mar 6, 2013 1769 dhladky Changed threading to use count down latch. + * Apr 9, 2013 1890 dhladky removed loading of phantom Virtual template and cache file processing. * * * @author dhladky @@ -74,7 +74,8 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.listeners.FFMPLoaderEvent; */ public class FFMPDataLoader extends Thread { - private static final IUFStatusHandler statusHandler = UFStatus.getHandler(FFMPDataLoader.class); + private static final IUFStatusHandler statusHandler = UFStatus + .getHandler(FFMPDataLoader.class); private ProductXML product = null; @@ -156,13 +157,14 @@ public class FFMPDataLoader extends Thread { @Override public void run() { - + long time = System.currentTimeMillis(); try { resourceData.setLoader(loadType); - FFMPMonitor monitor = getMonitor(); - FFMPSourceConfigurationManager sourceConfig = monitor.getSourceConfig(); + FFMPMonitor monitor = getMonitor(); + FFMPSourceConfigurationManager sourceConfig = monitor + .getSourceConfig(); ProductRunXML productRun = runner.getProduct(siteKey); ArrayList qpfSources = new ArrayList(); @@ -235,6 +237,10 @@ public class FFMPDataLoader extends Thread { if (loadType == LOADER_TYPE.TERTIARY) { hucsToLoad.clear(); hucsToLoad.add(FFMPRecord.ALL); + } else { + // Only used as place holder name, No data is linked to it, uses + // ALL + hucsToLoad.remove(FFMPRecord.VIRTUAL); } if (isDone()) { @@ -253,29 +259,28 @@ public class FFMPDataLoader extends Thread { } // qpes - fireLoaderEvent(loadType, "Processing " + product.getQpe(), isDone()); + fireLoaderEvent(loadType, "Processing " + product.getQpe(), + isDone()); FFMPAggregateRecord qpeCache = null; if (loadType == LOADER_TYPE.INITIAL) { - SourceXML source = sourceConfig.getSource( - product.getQpe()); + SourceXML source = sourceConfig.getSource(product.getQpe()); qpeCache = readAggregateRecord(source, dataKey, wfo); if (qpeCache != null) { - monitor.insertFFMPData(qpeCache, siteKey, - product.getQpe()); + monitor.insertFFMPData(qpeCache, qpeURIs, siteKey, product.getQpe()); } } - // Use this method of QPE data retrieval if you don't have cache files + // Use this method of QPE data retrieval if you don't have cache + // files if (!qpeURIs.isEmpty() && qpeCache == null) { for (String phuc : hucsToLoad) { - if (phuc.equals(layer) - || phuc.equals(FFMPRecord.ALL)) { - monitor.processUris(qpeURIs, isProductLoad, - siteKey, product.getQpe(), timeBack, phuc); + if (phuc.equals(layer) || phuc.equals(FFMPRecord.ALL)) { + monitor.processUris(qpeURIs, isProductLoad, siteKey, + product.getQpe(), timeBack, phuc); } } } @@ -291,7 +296,6 @@ public class FFMPDataLoader extends Thread { if (loadType == LOADER_TYPE.INITIAL) { - SourceXML source = sourceConfig .getSource(qpfSources.get(i)); @@ -300,36 +304,36 @@ public class FFMPDataLoader extends Thread { if (qpfCache != null) { for (String phuc : hucsToLoad) { - if ((phuc.equals(layer) || phuc.equals(FFMPRecord.ALL)) + if ((phuc.equals(layer) || phuc + .equals(FFMPRecord.ALL)) && loadType == LOADER_TYPE.INITIAL && source.getSourceName().equals( config.getFFMPConfigData() - .getIncludedQPF())) { + .getIncludedQPF())) { if (!qpfURIs.isEmpty()) { - monitor.processUris(qpfURIs, - isProductLoad, siteKey, - source.getSourceName(), timeBack, - phuc); + monitor.processUris(qpfURIs, isProductLoad, + siteKey, source.getSourceName(), + timeBack, phuc); } } } - monitor.insertFFMPData(qpfCache, siteKey, + monitor.insertFFMPData(qpfCache, qpfURIs, siteKey, source.getSourceName()); } } // if (isUrisProcessNeeded(qpfData,qpfURIs)) // {/*DR13839*/ - // Use this method of QPF data retrieval if you don't have cache files + // Use this method of QPF data retrieval if you don't have cache + // files if ((qpfCache == null) && !qpfURIs.isEmpty()) { for (String phuc : hucsToLoad) { - if (phuc.equals(layer) - || phuc.equals(FFMPRecord.ALL)) { // old - // code: - // keep - // for - // reference*/ + if (phuc.equals(layer) || phuc.equals(FFMPRecord.ALL)) { // old + // code: + // keep + // for + // reference*/ // if (isHucProcessNeeded(phuc)) {/*DR13839*/ monitor.processUris(qpfURIs, isProductLoad, siteKey, product.getQpf(i), timeBack, phuc); @@ -344,24 +348,8 @@ public class FFMPDataLoader extends Thread { fireLoaderEvent(loadType, "Processing " + product.getVirtual(), isDone()); - FFMPAggregateRecord vgbCache = null; - - if (loadType == LOADER_TYPE.INITIAL) { - - SourceXML source = sourceConfig.getSource( - product.getVirtual()); - - vgbCache = readAggregateRecord(source, dataKey, wfo); - - if (vgbCache != null) { - - monitor.insertFFMPData(vgbCache, siteKey, - product.getVirtual()); - } - } - - // Use this method of Virtual data retrieval if you don't have cache files - if ((vgbCache == null) && !virtualURIs.isEmpty()) { + // process virtual all for all only, never uses cache files + if (!virtualURIs.isEmpty()) { monitor.processUris(virtualURIs, isProductLoad, siteKey, product.getVirtual(), timeBack, FFMPRecord.ALL); } @@ -379,10 +367,12 @@ public class FFMPDataLoader extends Thread { .get(guidSource.getSourceName()); fireLoaderEvent(loadType, - "Processing " + guidSource.getSourceName(), isDone()); + "Processing " + guidSource.getSourceName(), + isDone()); monitor.processUris(iguidURIs, isProductLoad, siteKey, - guidSource.getSourceName(), timeBack, FFMPRecord.ALL); + guidSource.getSourceName(), timeBack, + FFMPRecord.ALL); fireLoaderEvent(loadType, guidSource.getSourceName(), isDone()); @@ -390,10 +380,11 @@ public class FFMPDataLoader extends Thread { } } } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM,"General Problem in Loading FFMP Data", e); + statusHandler.handle(Priority.PROBLEM, + "General Problem in Loading FFMP Data", e); } finally { latch.countDown(); - synchronized(this) { + synchronized (this) { this.notifyAll(); } } @@ -406,7 +397,8 @@ public class FFMPDataLoader extends Thread { } long endTime = (System.currentTimeMillis()) - time; - System.out.println(loadType.loaderType + " Loader took: " + endTime / 1000 + " seconds"); + System.out.println(loadType.loaderType + " Loader took: " + endTime + / 1000 + " seconds"); fireLoaderEvent(loadType, message, isDone()); } @@ -503,7 +495,8 @@ public class FFMPDataLoader extends Thread { try { // we are just checking if it exists or not String pdataKey = product.getProductKey(); - String sourceSiteDataKey = getSourceSiteDataKey(source, pdataKey); + String sourceSiteDataKey = getSourceSiteDataKey(source, + pdataKey); File hdf5File = FFMPUtils.getHdf5File(wfo, sourceSiteDataKey); DataStoreFactory.getDataStore(hdf5File); @@ -516,16 +509,16 @@ public class FFMPDataLoader extends Thread { return siteKey; } - + /** * Get the sourceSiteDataKey for this piece of data + * * @param source * @param pdataKey * @return */ private String getSourceSiteDataKey(SourceXML source, String pdataKey) { - return source.getSourceName() + "-" + siteKey + "-" - + pdataKey; + return source.getSourceName() + "-" + siteKey + "-" + pdataKey; } public boolean isDone() { diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java index 6ce8585739..347a23d10d 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java @@ -163,6 +163,7 @@ import com.vividsolutions.jts.geom.Point; * Feb 20, 2013 1635 dhladky Fixed multiple guidance display * Feb 28, 2013 1729 dhladky Changed the way the loaders are managed via the status updates. * Mar 6, 2013 1769 dhladky Changed threading to use count down latch. + * Apr 9, 2013 1890 dhladky General cleanup. * Apr 10, 2013 1896 bsteffen Make FFMPResource work better with D2D * time matcher. * @@ -1219,7 +1220,7 @@ public class FFMPResource extends paintProps.setAlpha(getCapability(ImagingCapability.class) .getAlpha()); - boolean isShaded = isPolygonal(); + boolean isShaded = true; FFMPDrawable drawable = null; if (paintTime != null) { @@ -1571,14 +1572,6 @@ public class FFMPResource extends return geometryType; } - protected boolean isLineal() { - return getGeometryType().endsWith("LINESTRING"); - } - - protected boolean isPolygonal() { - return getGeometryType().endsWith("POLYGON"); - } - /** * Get color wrapper class * diff --git a/cave/com.raytheon.uf.viz.objectiveanalysis/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.objectiveanalysis/META-INF/MANIFEST.MF index 3cf4e5f9b3..a67744bba3 100644 --- a/cave/com.raytheon.uf.viz.objectiveanalysis/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.objectiveanalysis/META-INF/MANIFEST.MF @@ -23,12 +23,12 @@ Require-Bundle: org.eclipse.ui, com.raytheon.viz.grid;bundle-version="1.11.17", com.raytheon.viz.core.contours;bundle-version="1.11.17", com.raytheon.uf.viz.sounding;bundle-version="1.11.17", - com.raytheon.uf.common.dataplugin.bufrua;bundle-version="1.11.17" + com.raytheon.uf.common.dataplugin.bufrua;bundle-version="1.11.17", + com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.viz.objectiveanalysis.rsc Import-Package: com.raytheon.uf.common.comm, - com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.dataplugin.radar, com.raytheon.uf.common.gridcoverage, com.raytheon.uf.viz.derivparam.library, diff --git a/cave/com.raytheon.uf.viz.objectiveanalysis/src/com/raytheon/uf/viz/objectiveanalysis/rsc/OAResourceData.java b/cave/com.raytheon.uf.viz.objectiveanalysis/src/com/raytheon/uf/viz/objectiveanalysis/rsc/OAResourceData.java index 63c9cd9839..6950598c18 100644 --- a/cave/com.raytheon.uf.viz.objectiveanalysis/src/com/raytheon/uf/viz/objectiveanalysis/rsc/OAResourceData.java +++ b/cave/com.raytheon.uf.viz.objectiveanalysis/src/com/raytheon/uf/viz/objectiveanalysis/rsc/OAResourceData.java @@ -32,10 +32,10 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.LevelFactory; import com.raytheon.uf.common.dataplugin.level.MasterLevel; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.viz.core.exception.VizCommunicationException; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.LoadProperties; @@ -196,29 +196,30 @@ public class OAResourceData extends AbstractRequestableResourceData { DataTime[] times = super.getAvailableTimes(); if (this.levelKey.equals(ALL_TILTS)) { LevelFactory factory = LevelFactory.getInstance(); - MasterLevel ml; - try { - ml = factory.getMasterLevel("TILT"); - } catch (CommunicationException e) { - throw new VizCommunicationException(e); - } - Set allLevels = LevelMappingFactory.getInstance() - .getAllLevels(); - List levels = new ArrayList(); - for (Level l : allLevels) { - if (l.getMasterLevel().equals(ml)) { - levels.add(l); - } - } List timesWithLevels = new ArrayList(); - for (int i = 0; i < times.length; ++i) { - for (int j = 0; j < levels.size(); ++j) { - DataTime time = times[i].clone(); - time.setLevelValue(levels.get(j).getLevelonevalue()); - if (time.isSpatial()) { - timesWithLevels.add(time); + try { + MasterLevel ml = factory.getMasterLevel("TILT"); + Set allLevels = LevelMappingFactory.getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) + .getAllLevels(); + List levels = new ArrayList(); + for (Level l : allLevels) { + if (l.getMasterLevel().equals(ml)) { + levels.add(l); } } + + for (int i = 0; i < times.length; ++i) { + for (int j = 0; j < levels.size(); ++j) { + DataTime time = times[i].clone(); + time.setLevelValue(levels.get(j).getLevelonevalue()); + if (time.isSpatial()) { + timesWithLevels.add(time); + } + } + } + } catch (CommunicationException e) { + throw new VizCommunicationException(e); } return timesWithLevels .toArray(new DataTime[timesWithLevels.size()]); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/AbstractGridData.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/AbstractGridData.java index c9e8de0441..568397224a 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/AbstractGridData.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/AbstractGridData.java @@ -67,6 +67,8 @@ import com.vividsolutions.jts.geom.Coordinate; * 03/13/2008 879 rbell Legacy conversion. * 06/10/2009 2159 rjpeter Updated isValid to call gridSlice.isValid * 02/19/2013 1637 randerso Added throws declarations to translateDataFrom + * 04/15/2013 1892 randerso Adding logging to help determine what is different in the gridInfos + * Changed how gridInfo is retrieved which seems to have fixed the problem * * * @author chammack @@ -1026,16 +1028,20 @@ public abstract class AbstractGridData implements IGridData { return false; } - if (!((AbstractGridData) source).gridSlice.getGridInfo().equals( - this.gridSlice.getGridInfo())) { + if (!source.getParm().getGridInfo() + .equals(this.getParm().getGridInfo())) { statusHandler.handle(Priority.PROBLEM, - "Differing gridInfos for source/dest for replace()"); + "Differing gridInfos for source/dest for replace()." + + "\nSource: " + source.getParm().getGridInfo() + + "\nDest: " + this.getParm().getGridInfo()); return false; } if (!source.getGridTime().equals(getGridTime())) { statusHandler.handle(Priority.PROBLEM, - "Differing gridTimes for source/dest for replace()"); + "Differing gridTimes for source/dest for replace()" + + "\nSource: " + source.getGridTime() + "\nDest: " + + this.getGridTime()); return false; } diff --git a/cave/com.raytheon.viz.grid/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.grid/META-INF/MANIFEST.MF index 949ac37275..defcc04b8b 100644 --- a/cave/com.raytheon.viz.grid/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.grid/META-INF/MANIFEST.MF @@ -25,7 +25,8 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.viz.points;bundle-version="1.0.0", com.raytheon.uf.common.gridcoverage, org.apache.commons.beanutils;bundle-version="1.8.3", - com.raytheon.uf.common.dataplugin.grid;bundle-version="1.0.0" + com.raytheon.uf.common.dataplugin.grid;bundle-version="1.0.0", + com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174" Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.viz.grid, com.raytheon.viz.grid.inv, @@ -36,7 +37,6 @@ Export-Package: com.raytheon.viz.grid, Import-Package: com.raytheon.edex.scriptfactory, com.raytheon.uf.common.colormap, com.raytheon.uf.common.comm, - com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.derivparam.tree, com.raytheon.uf.common.localization, com.raytheon.uf.common.message, diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/GridProductBrowserDataDefinition.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/GridProductBrowserDataDefinition.java index f0d46ed512..668f13dfb7 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/GridProductBrowserDataDefinition.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/GridProductBrowserDataDefinition.java @@ -42,15 +42,14 @@ import com.raytheon.uf.common.dataplugin.grid.dataset.DatasetInfoLookup; import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.LevelFactory; import com.raytheon.uf.common.dataplugin.level.MasterLevel; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.datastructure.DataCubeContainer; import com.raytheon.uf.viz.core.drawables.ResourcePair; -import com.raytheon.uf.viz.core.exception.VizCommunicationException; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; import com.raytheon.uf.viz.core.rsc.DisplayType; import com.raytheon.uf.viz.core.rsc.ResourceProperties; import com.raytheon.uf.viz.core.rsc.ResourceType; @@ -195,8 +194,11 @@ public class GridProductBrowserDataDefinition extends params = Arrays.asList(value); } else if (key.equals(GridInventory.MASTER_LEVEL_QUERY)) { if (levels == null) { - levels = new ArrayList(LevelMappingFactory - .getInstance().getAllLevels()); + levels = new ArrayList( + LevelMappingFactory + .getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) + .getAllLevels()); } Iterator iter = levels.iterator(); while (iter.hasNext()) { @@ -209,8 +211,11 @@ public class GridProductBrowserDataDefinition extends } else if (key.equals(GridInventory.LEVEL_ONE_QUERY)) { double doubleValue = Double.parseDouble(value); if (levels == null) { - levels = new ArrayList(LevelMappingFactory - .getInstance().getAllLevels()); + levels = new ArrayList( + LevelMappingFactory + .getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) + .getAllLevels()); } Iterator iter = levels.iterator(); while (iter.hasNext()) { @@ -221,8 +226,11 @@ public class GridProductBrowserDataDefinition extends } else if (key.equals(GridInventory.LEVEL_TWO_QUERY)) { double doubleValue = Double.parseDouble(value); if (levels == null) { - levels = new ArrayList(LevelMappingFactory - .getInstance().getAllLevels()); + levels = new ArrayList( + LevelMappingFactory + .getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) + .getAllLevels()); } Iterator iter = levels.iterator(); while (iter.hasNext()) { @@ -280,9 +288,6 @@ public class GridProductBrowserDataDefinition extends return returnQueue.toArray(new String[0]); } } - } catch (VizCommunicationException e) { - statusHandler.handle(Priority.ERROR, "Unable to query data for " - + productName, e); } catch (CommunicationException e) { statusHandler.handle(Priority.ERROR, "Unable to query data for " + productName, e); diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridNameGenerator.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridNameGenerator.java index 809059318b..a1c7ad0321 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridNameGenerator.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridNameGenerator.java @@ -19,11 +19,11 @@ **/ package com.raytheon.viz.grid.rsc; +import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.viz.core.exception.VizCommunicationException; -import com.raytheon.uf.viz.core.level.LevelMapping; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; import com.raytheon.uf.viz.core.rsc.AbstractNameGenerator; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; @@ -144,13 +144,14 @@ public class GridNameGenerator extends AbstractNameGenerator { private String lookupPlane(Level level) { try { - LevelMapping mapping = LevelMappingFactory.getInstance() + LevelMapping mapping = LevelMappingFactory.getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) .getLevelMappingForLevel(level); if (mapping == null) { return level.getMasterLevel().getName(); } return mapping.getDisplayName(); - } catch (VizCommunicationException e) { + } catch (CommunicationException e) { return level.getMasterLevel().getName(); } diff --git a/cave/com.raytheon.viz.mpe.ui/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/cave/com.raytheon.viz.mpe.ui/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject index eca84054a6..c712423f98 100644 --- a/cave/com.raytheon.viz.mpe.ui/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ b/cave/com.raytheon.viz.mpe.ui/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -1,4 +1,5 @@ com.raytheon.viz.mpe.ui.rsc.MPERadarRingOverlayResourceData com.raytheon.viz.mpe.ui.displays.MPEMapRenderableDisplay com.raytheon.viz.mpe.ui.displays.MPETimeMatcher -com.raytheon.viz.mpe.ui.rsc.RadarGageOverlayRscData \ No newline at end of file +com.raytheon.viz.mpe.ui.rsc.RadarGageOverlayRscData +com.raytheon.viz.mpe.ui.rsc.MPEFieldResourceData \ No newline at end of file diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java index b8ac2daf9b..e6544bcfad 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java @@ -99,6 +99,7 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor; * ------------ ---------- ----------- -------------------------- * Dec 18, 2012 mschenke Initial creation * Mar 14, 2013 1457 mpduff Reset the gages on the resource. + * Apr 18, 2013 1920 mpduff Added updateGages method to reload the gage data. * * * @@ -401,6 +402,10 @@ public class MPEDisplayManager { private DisplayFieldData displayedField; + private int displayedAccumHrs; + + private ArealDisplay displayedArealDisplay; + private final MPEFieldResourceData fieldResourceData = new MPEFieldResourceData(); private MPEFieldResource displayedFieldResource; @@ -698,9 +703,14 @@ public class MPEDisplayManager { */ public void displayFieldData(DisplayFieldData fieldToDisplay, int accumulationHrs, ArealDisplay arealDisplay) { - if (displayedField != fieldToDisplay || displayedFieldResource == null) { + if (displayedField != fieldToDisplay || displayedFieldResource == null + || accumulationHrs != displayedAccumHrs + || arealDisplay != displayedArealDisplay) { DisplayFieldData oldField = displayedField; + displayedField = fieldToDisplay; + displayedAccumHrs = accumulationHrs; + displayedArealDisplay = arealDisplay; ResourceList list = display.getDescriptor().getResourceList(); if (displayedFieldResource != null) { @@ -725,14 +735,6 @@ public class MPEDisplayManager { listener.displayFieldChanged(oldField, fieldToDisplay); } } - - // reset gages - List rscs = display.getDescriptor() - .getResourceList() - .getResourcesByTypeAsType(MPEGageResource.class); - for (MPEGageResource rsc : rscs) { - rsc.reloadGages(); - } } displayedFieldResource.issueRefresh(); @@ -1118,4 +1120,15 @@ public class MPEDisplayManager { + " - OK to Proceed?"); } + /** + * Update the Gage resource. + */ + public void updateGages() { + // reset gages + List rscs = display.getDescriptor().getResourceList() + .getResourcesByTypeAsType(MPEGageResource.class); + for (MPEGageResource rsc : rscs) { + rsc.reloadGages(); + } + } } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/MPEColorScaleMgrAction.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/MPEColorScaleMgrAction.java index 9af5c782a6..722972f157 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/MPEColorScaleMgrAction.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/MPEColorScaleMgrAction.java @@ -26,10 +26,13 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; import com.raytheon.uf.viz.core.localization.LocalizationManager; +import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability; import com.raytheon.viz.hydrocommon.colorscalemgr.ColorScaleMgrDlg; import com.raytheon.viz.mpe.ui.DisplayFieldData; import com.raytheon.viz.mpe.ui.MPEDisplayManager; import com.raytheon.viz.mpe.ui.colors.MPEColorManager; +import com.raytheon.viz.mpe.ui.rsc.MPEFieldResource; +import com.raytheon.viz.mpe.ui.rsc.MPEFieldResourceData; /** * TODO Add Description @@ -39,6 +42,7 @@ import com.raytheon.viz.mpe.ui.colors.MPEColorManager; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 5, 2008 mschenke Initial creation + * Apr 18, 2013 1920 mpduff Set new ColorMap. * * * @author mschenke @@ -69,9 +73,24 @@ public class MPEColorScaleMgrAction extends AbstractHandler { colorScaleDlg.open(); } - DisplayFieldData dt = MPEDisplayManager.getCurrent() - .getDisplayFieldType(); - MPEDisplayManager.getCurrent().displayFieldData(dt); + MPEFieldResource displayedFieldResource = MPEDisplayManager + .getCurrent().getDisplayedFieldResource(); + + if (displayedFieldResource != null) { + MPEFieldResourceData resourceData = displayedFieldResource + .getResourceData(); + displayedFieldResource.getCapability(ColorMapCapability.class) + .setColorMapParameters( + MPEDisplayManager.createColorMap( + resourceData.getCvUseString(), + resourceData.getDurationInHours(), + resourceData.getDataUnits(), + resourceData.getDisplayUnits())); + DisplayFieldData dt = MPEDisplayManager.getCurrent() + .getDisplayFieldType(); + + MPEDisplayManager.getCurrent().displayFieldData(dt); + } return null; } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/DisplayFieldGenDialog.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/DisplayFieldGenDialog.java index affd3ec161..0c20b6c3bb 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/DisplayFieldGenDialog.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/DisplayFieldGenDialog.java @@ -41,7 +41,7 @@ import com.raytheon.viz.mpe.ui.rsc.MPEFieldResource; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; /** - * TODO Add Description + * The Run FieldGen dialog. * *
  * SOFTWARE HISTORY
@@ -49,6 +49,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
  * ------------ ---------- ----------- --------------------------
  * Oct 27, 2008            snaples     Initial creation
  * Nov 10, 2008  1649      snaples     Added handlers for Yes button
+ * Apr 18, 2013  1920      mpduff      Call back to MPEDisplayManager to reload the gages.
  * 
* * @author snaples @@ -109,6 +110,8 @@ public class DisplayFieldGenDialog extends CaveJFACEDialog { if (rsc != null) { rsc.getResourceData().update(dt); } + + instance.updateGages(); } catch (VizException ex) { Activator.statusHandler.handle(Priority.PROBLEM, "Error regenerating hourly fields", ex); diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java index 6b2f0e0f93..7d8a97d864 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java @@ -192,8 +192,7 @@ public class MPEGageResource extends AbstractMPEInputResource implements displayMgr.registerDisplayFieldChangedListener(this); fontFactory = new MPEFontFactory(target, this); loadColors(); - lastDate = displayMgr.getCurrentEditDate(); - addPoints(MPEDataManager.getInstance().readGageData(lastDate, lastDate)); + reloadGages(); } @Override @@ -651,7 +650,7 @@ public class MPEGageResource extends AbstractMPEInputResource implements public void displayFieldChanged(DisplayFieldData oldFieldData, DisplayFieldData newFieldData) { loadColors(); + reloadGages(); issueRefresh(); } - } diff --git a/cave/com.raytheon.viz.pointdata/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.pointdata/META-INF/MANIFEST.MF index 6c4bd232bd..ef1104283b 100644 --- a/cave/com.raytheon.viz.pointdata/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.pointdata/META-INF/MANIFEST.MF @@ -18,7 +18,8 @@ Require-Bundle: org.apache.batik, com.raytheon.uf.viz.localization;bundle-version="1.12.1174", org.jep;bundle-version="1.0.0", com.raytheon.uf.common.python;bundle-version="1.12.1161", - com.raytheon.uf.common.pointdata;bundle-version="1.12.1174" + com.raytheon.uf.common.pointdata;bundle-version="1.12.1174", + com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174" Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.viz.pointdata, com.raytheon.viz.pointdata.drawables, @@ -28,7 +29,6 @@ Export-Package: com.raytheon.viz.pointdata, Import-Package: com.raytheon.edex.meteoLib, com.raytheon.uf.common.comm, com.raytheon.uf.common.dataplugin.grid, - com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.derivparam.tree, com.raytheon.uf.common.message.response, com.raytheon.uf.common.pointdata, diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelDataDefinition.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelDataDefinition.java index 883e627541..170deb5510 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelDataDefinition.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelDataDefinition.java @@ -18,6 +18,7 @@ import java.util.concurrent.LinkedBlockingQueue; import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.LevelFactory; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; @@ -29,9 +30,7 @@ import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.BinOffset; import com.raytheon.uf.viz.core.datastructure.DataCubeContainer; -import com.raytheon.uf.viz.core.exception.VizCommunicationException; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; import com.raytheon.uf.viz.core.map.MapDescriptor; import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.ResourceType; @@ -281,14 +280,15 @@ public class PlotModelDataDefinition extends try { Level level = LevelFactory.getInstance().getLevel( Long.parseLong(levelid)); - validLevels.add(LevelMappingFactory.getInstance() - .getLevelMappingForLevel(level).getDisplayName()); + validLevels + .add(LevelMappingFactory + .getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) + .getLevelMappingForLevel(level) + .getDisplayName()); } catch (CommunicationException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); - } catch (VizCommunicationException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), - e); } } return validLevels.toArray(new String[0]); diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/AbstractPointDataInventory.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/AbstractPointDataInventory.java index 26a6fd0bfa..956e46e980 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/AbstractPointDataInventory.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/AbstractPointDataInventory.java @@ -28,7 +28,9 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.derivparam.tree.DataTree; import com.raytheon.uf.common.derivparam.tree.LevelNode; @@ -40,9 +42,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.viz.core.RecordFactory; import com.raytheon.uf.viz.core.catalog.CatalogQuery; -import com.raytheon.uf.viz.core.exception.VizCommunicationException; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData; import com.raytheon.uf.viz.derivparam.inv.AbstractInventory; import com.raytheon.uf.viz.derivparam.library.DerivParamDesc; @@ -278,9 +278,11 @@ public abstract class AbstractPointDataInventory extends AbstractInventory { public static Level getStationLevel() { try { - return LevelMappingFactory.getInstance() + return LevelMappingFactory + .getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) .getLevelMappingForKey("Station").getLevels().get(0); - } catch (VizCommunicationException e) { + } catch (CommunicationException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); return null; } diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/PointDataCubeAdapter.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/PointDataCubeAdapter.java index 5ebbb8282e..8dc020a32f 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/PointDataCubeAdapter.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/util/PointDataCubeAdapter.java @@ -25,8 +25,10 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest; import com.raytheon.uf.common.dataquery.requests.TimeQueryRequestSet; @@ -45,8 +47,8 @@ import com.raytheon.uf.viz.core.comm.Loader; import com.raytheon.uf.viz.core.datastructure.CubeUtil; import com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter; import com.raytheon.uf.viz.core.datastructure.VizDataCubeException; +import com.raytheon.uf.viz.core.exception.VizCommunicationException; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; import com.raytheon.uf.viz.core.requests.ThriftClient; import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData; import com.raytheon.uf.viz.derivparam.inv.AvailabilityContainer; @@ -143,8 +145,15 @@ public class PointDataCubeAdapter implements IDataCubeAdapter { source += type; } - List levels = LevelMappingFactory.getInstance() - .getLevelMappingForKey(levelKey).getLevels(); + List levels; + try { + levels = LevelMappingFactory + .getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) + .getLevelMappingForKey(levelKey).getLevels(); + } catch (CommunicationException e) { + throw new VizCommunicationException(e); + } List nodes = inventory.getNodes(source, Arrays.asList(parameters), levels); PointMetadataContainer pmc = new PointMetadataContainer(queryParams, diff --git a/cave/com.raytheon.viz.volumebrowser/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.volumebrowser/META-INF/MANIFEST.MF index 6ceafd4e11..c8353b6ce8 100644 --- a/cave/com.raytheon.viz.volumebrowser/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.volumebrowser/META-INF/MANIFEST.MF @@ -31,7 +31,9 @@ Require-Bundle: org.eclipse.ui, com.raytheon.uf.viz.d2d.nsharp;bundle-version="1.0.0", gov.noaa.nws.ncep.ui.nsharp;bundle-version="1.0.0", com.raytheon.uf.common.message;bundle-version="1.12.1174", - com.raytheon.viz.core.graphing;bundle-version="1.12.1174" + com.raytheon.viz.core.graphing;bundle-version="1.12.1174", + com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174", + com.raytheon.uf.common.comm;bundle-version="1.12.1174" Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.viz.volumebrowser, com.raytheon.viz.volumebrowser.catalog, @@ -41,7 +43,6 @@ Export-Package: com.raytheon.viz.volumebrowser, Import-Package: com.raytheon.uf.common.comm, com.raytheon.uf.common.dataplugin.grid, com.raytheon.uf.common.dataplugin.grid.dataset, - com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.gridcoverage, com.raytheon.uf.common.menus.xml, com.raytheon.uf.viz.core.maps.display, diff --git a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/AbstractDataCatalog.java b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/AbstractDataCatalog.java index 350c8ee3dd..16eb26a3b7 100644 --- a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/AbstractDataCatalog.java +++ b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/AbstractDataCatalog.java @@ -29,15 +29,16 @@ import java.util.List; import java.util.Set; import java.util.regex.Pattern; +import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.exception.VizCommunicationException; -import com.raytheon.uf.viz.core.level.LevelMapping; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; import com.raytheon.uf.viz.core.level.LevelUtilities; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.DisplayType; @@ -373,12 +374,13 @@ public abstract class AbstractDataCatalog implements IDataCatalog { } } else { try { - LevelMappingFactory lmf = LevelMappingFactory.getInstance(); + LevelMappingFactory lmf = LevelMappingFactory + .getInstance(LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE); LevelMapping lm = lmf.getLevelMappingForKey(planesKey); if (lm != null) { levels = lm.getLevels(); } - } catch (VizCommunicationException e) { + } catch (CommunicationException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); } diff --git a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/AbstractInventoryDataCatalog.java b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/AbstractInventoryDataCatalog.java index e4bc9d0202..112efe0bb2 100644 --- a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/AbstractInventoryDataCatalog.java +++ b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/AbstractInventoryDataCatalog.java @@ -38,13 +38,13 @@ import org.eclipse.core.runtime.jobs.Job; import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.LevelFactory; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.datastructure.DataCubeContainer; import com.raytheon.uf.viz.core.exception.VizCommunicationException; -import com.raytheon.uf.viz.core.level.LevelMapping; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; import com.raytheon.uf.viz.core.level.LevelUtilities; import com.raytheon.uf.viz.derivparam.inv.AbstractInventory; import com.raytheon.viz.volumebrowser.vbui.DataListsProdTableComp.DataSelection; @@ -184,16 +184,13 @@ public abstract class AbstractInventoryDataCatalog extends AbstractDataCatalog { } request.addAvailablePlane("spatial-" + level.getMasterLevel().getName()); - try { - LevelMapping lm = LevelMappingFactory.getInstance() - .getLevelMappingForLevel(level); + LevelMapping lm = LevelMappingFactory + .getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) + .getLevelMappingForLevel(level); - if (lm != null) { - request.addAvailablePlane(lm.getKey()); - } - } catch (VizCommunicationException e) { - statusHandler.handle(Priority.PROBLEM, - e.getLocalizedMessage(), e); + if (lm != null) { + request.addAvailablePlane(lm.getKey()); } } catch (CommunicationException e) { statusHandler.handle(Priority.PROBLEM, @@ -255,6 +252,7 @@ public abstract class AbstractInventoryDataCatalog extends AbstractDataCatalog { return result; } + @Override public List getSupportedSources() { return getSupportedSourcesInternal(); } @@ -280,7 +278,8 @@ public abstract class AbstractInventoryDataCatalog extends AbstractDataCatalog { if (selectedPlanes == null || selectedPlanes.length == 0) { return null; } - LevelMappingFactory lmf = LevelMappingFactory.getInstance(); + LevelMappingFactory lmf = LevelMappingFactory + .getInstance(LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE); for (String plane : selectedPlanes) { Collection levels = Collections.emptyList(); if (plane.startsWith("spatial-")) { @@ -297,7 +296,7 @@ public abstract class AbstractInventoryDataCatalog extends AbstractDataCatalog { if (lm != null) { try { levels = lm.getLevels(); - } catch (VizCommunicationException e) { + } catch (CommunicationException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); } diff --git a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/GridDataCatalog.java b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/GridDataCatalog.java index 49db9b9853..b3c468c6e0 100644 --- a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/GridDataCatalog.java +++ b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/GridDataCatalog.java @@ -35,8 +35,10 @@ import org.geotools.geometry.Envelope2D; import org.geotools.geometry.jts.ReferencedEnvelope; import org.opengis.referencing.operation.MathTransform; +import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.grid.GridConstants; import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.geospatial.MapUtil; @@ -47,7 +49,6 @@ import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.exception.VizCommunicationException; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; import com.raytheon.uf.viz.core.level.LevelUtilities; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.DisplayType; @@ -182,11 +183,12 @@ public class GridDataCatalog extends AbstractInventoryDataCatalog { // Get all possible levels for the selected levels List selectedLevels = Collections.emptyList(); try { - LevelMappingFactory lmf = LevelMappingFactory.getInstance(); + LevelMappingFactory lmf = LevelMappingFactory + .getInstance(LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE); selectedLevels = new ArrayList(lmf .getLevelMappingForKey( catalogEntry.selectedPlanesKey).getLevels()); - } catch (VizCommunicationException e) { + } catch (CommunicationException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); } @@ -422,8 +424,8 @@ public class GridDataCatalog extends AbstractInventoryDataCatalog { .getCoordinateReferenceSystem()); Envelope2D env = gridGeom.getEnvelope2D(); for (String letter : pointLetters) { - Coordinate c = PointsDataManager.getInstance() - .getCoordinate(letter); + Coordinate c = PointsDataManager.getInstance() + .getCoordinate(letter); DirectPosition2D dp = new DirectPosition2D(c.x, c.y); llToCRS.transform(dp, dp); if (env.contains(dp.x, dp.y)) { @@ -508,8 +510,8 @@ public class GridDataCatalog extends AbstractInventoryDataCatalog { .getTransformFromLatLon(gridGeom .getCoordinateReferenceSystem()); Envelope2D env = gridGeom.getEnvelope2D(); - for (String letter : pdm.getPointNames()) { - Coordinate c = pdm.getCoordinate(letter); + for (String letter : pdm.getPointNames()) { + Coordinate c = pdm.getCoordinate(letter); DirectPosition2D dp = new DirectPosition2D(c.x, c.y); llToCRS.transform(dp, dp); if (env.contains(dp.x, dp.y)) { diff --git a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/PointDataCatalog.java b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/PointDataCatalog.java index 5dca1d2ee1..4a21e11deb 100644 --- a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/PointDataCatalog.java +++ b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/PointDataCatalog.java @@ -32,7 +32,9 @@ import java.util.Set; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; +import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation; @@ -41,9 +43,7 @@ import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.BinOffset; import com.raytheon.uf.viz.core.catalog.DbQuery; -import com.raytheon.uf.viz.core.exception.VizCommunicationException; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.ResourceType; import com.raytheon.uf.viz.d2d.nsharp.rsc.BufruaNSharpResourceData; @@ -390,9 +390,11 @@ public class PointDataCatalog extends AbstractInventoryDataCatalog { @Override protected Collection get3DLevels() { try { - return LevelMappingFactory.getInstance() + return LevelMappingFactory + .getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) .getLevelMappingForKey("Station").getLevels(); - } catch (VizCommunicationException e) { + } catch (CommunicationException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); return Collections.emptyList(); } diff --git a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/widget/MenuContributionItem.java b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/widget/MenuContributionItem.java index 72ddf033da..708b559514 100644 --- a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/widget/MenuContributionItem.java +++ b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/widget/MenuContributionItem.java @@ -28,8 +28,8 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; -import com.raytheon.uf.viz.core.level.LevelMapping; -import com.raytheon.uf.viz.core.level.LevelMappingFactory; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.viz.volumebrowser.vbui.MenuItemManager; import com.raytheon.viz.volumebrowser.xml.MenuContribution; @@ -93,7 +93,8 @@ public class MenuContributionItem extends ContributionItem { item.setData(this); if (menuContribution.xml.textLookup.equals("LevelMapping")) { - LevelMapping mapping = LevelMappingFactory.getInstance() + LevelMapping mapping = LevelMappingFactory.getInstance( + LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) .getLevelMappingForKey(menuContribution.xml.key); if (mapping != null) { menuContribution.xml.menuText = mapping.getDisplayName(); diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/PolygonUtil.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/PolygonUtil.java index d529229f9d..e850772790 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/PolygonUtil.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/PolygonUtil.java @@ -21,7 +21,10 @@ package com.raytheon.viz.warngen.gis; import java.util.ArrayList; import java.util.Arrays; +import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import org.geotools.coverage.grid.GeneralGridEnvelope; import org.geotools.coverage.grid.GridGeometry2D; @@ -57,6 +60,8 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; * ------------ ---------- ----------- -------------------------- * Dec 1, 2010 mschenke Initial creation * 12/06/2012 DR 15559 Qinglu Lin Added round() methods. + * 04/16/2013 DR 16045 Qinglu Lin Relocated removeDuplicateCoordinate(), computeSlope(), + * computeCoordinate(), and adjustPolygon from WarngenUIState. * * * @@ -982,4 +987,178 @@ public class PolygonUtil { coordinate.x = x / Math.pow(10, decimalPlaces); coordinate.y = y / Math.pow(10, decimalPlaces); } + + /** + * removeDuplicateCoordinate remove duplicate intermediate coordinates in + * warningPolygon. History 10-26-2012 Qinglu Lin DR15479 Created. + */ + public static Polygon removeDuplicateCoordinate(Polygon polygon) { + if (polygon == null) { + return null; + } + + Coordinate[] verts = polygon.getCoordinates(); + Set coords = new LinkedHashSet(); + for (Coordinate c : verts) + coords.add(c); + if ((verts.length - coords.size()) < 2) + return polygon; + Coordinate[] vertices = new Coordinate[coords.size() + 1]; + Iterator iter = coords.iterator(); + int i = 0; + while (iter.hasNext()) { + vertices[i] = new Coordinate(iter.next()); + i += 1; + } + vertices[i] = new Coordinate(vertices[0]); + GeometryFactory gf = new GeometryFactory(); + return gf.createPolygon(gf.createLinearRing(vertices), null); + } + + /** + * computeSlope compute the slope of a line. + * + * History 12/06/2012 DR 15559 Qinglu Lin Created. + */ + private static double computeSlope(Coordinate[] coords, int i) { + double min = 1.0E-08; + double dx = coords[i].x - coords[i + 1].x; + double slope = 0.0; + if (Math.abs(dx) > min) { + slope = (coords[i].y - coords[i + 1].y) / dx; + } + return slope; + } + + /** + * computeCoordinate Compute the x component of a coordinate after its y + * component is adjusted. + * + * History 12/06/2012 DR 15559 Qinglu Lin Created. + */ + private static void computeCoordinate(Coordinate[] c, int i, int j) { + double slope; + slope = computeSlope(c, i); + int iPlus1 = i + 1; + if (c[j].x >= c[i].x && c[j].x <= c[iPlus1].x || c[j].x >= c[iPlus1].x + && c[j].x <= c[i].x) { + + double x, y; + double min1 = 0.005d; + y = slope * (c[j].x - c[i].x) + c[i].y; + double d = Math.abs(y - c[j].y); + if (d > min1) + return; + + double min2 = 1.0E-8d; + double delta = 0.005d; // empirical value + double dyMin = 0.01d; + int jMinus1 = j - 1; + if (jMinus1 < 0) + jMinus1 = c.length - 2; + int jPlus1 = j + 1; + if (Math.abs(y - c[j].y) < min1) { + double dy1, dy2; + dy1 = Math.abs(c[jMinus1].y - y); + dy2 = Math.abs(c[jPlus1].y - y); + if (dy1 >= dy2 + && (Math.abs(dy1) > dyMin || Math.abs(dy2) > dyMin)) { + // attempt to use l2 for computation + if (c[j].y == c[jMinus1].y + && Math.abs(c[j].x - c[jMinus1].x) > min2) { + // l2 is a horizontal line, use l3 for computation + if (c[jPlus1].y < c[j].y) + delta = -delta; + slope = computeSlope(c, j); + if (Math.abs(slope) > min2) { + y = c[j].y + delta; + x = (y - c[jPlus1].y) / slope + c[jPlus1].x; + } else { + // l3 is a vertical line + y = c[j].y + delta; + x = c[j].x; + } + } else { + // use l2 for computation + if (c[jMinus1].y < c[j].y) + delta = -delta; + slope = computeSlope(c, jMinus1); + if (Math.abs(slope) > min2) { + y = c[j].y + delta; + x = (y - c[jMinus1].y) / slope + c[jMinus1].x; + } else { + // l2 is a vertical line + y = c[j].y + delta; + x = c[j].x; + } + } + } else { + if (Math.abs(dy1) > dyMin || Math.abs(dy2) > dyMin) { + // attempt to use l3 for computation + if (c[j].y == c[jPlus1].y + && Math.abs(c[j].x - c[jPlus1].x) > min2) { + // l3 is a horizontal line, use l2 for computation + if (c[jMinus1].y < c[j].y) + delta = -delta; + slope = computeSlope(c, jMinus1); + if (Math.abs(slope) > min2) { + y = c[j].y + delta; + x = (y - c[jMinus1].y) / slope + c[jMinus1].x; + } else { + // l2 is a vertical line + y = c[j].y + delta; + x = c[j].x; + } + } else { + // use l3 for computation + if (c[jPlus1].y < c[j].y) + delta = -delta; + slope = computeSlope(c, j); + if (Math.abs(slope) > min2) { + y = c[j].y + delta; + x = (y - c[jPlus1].y) / slope + c[jPlus1].x; + } else { + // l3 is a vertical line + y = c[j].y + delta; + x = c[j].x; + } + } + } else { + x = c[j].x; + y = c[j].y; + } + } + c[j].x = x; + c[j].y = y; + if (j == 0) + c[c.length - 1] = c[j]; + } + } + } + + /** + * adjustPolygon When a point is very close to a line in the initial warning + * polygon, the resulting coordinates cause the failure of polygon drawing + * in follow-up. The method move that kind of points away from the line, and + * return a Polygon. + * + * History 12/06/2012 DR 15559 Qinglu Lin Created. + */ + public static void adjustPolygon(Coordinate[] coords) { + int n = coords.length; + for (int i = 0; i < n - 1; ++i) { + int j; + for (j = i + 2; j <= n - 2; j++) { + computeCoordinate(coords, i, j); + } + if (i <= n - 3) + for (j = 0; j < i; j++) { + computeCoordinate(coords, i, j); + } + else + for (j = 1; j < i; j++) { + computeCoordinate(coords, i, j); + } + } + } } diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java index 78f18ccf02..c599898769 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java @@ -135,7 +135,7 @@ import com.vividsolutions.jts.geom.Polygon; * and removed it from updateListSelected(). * Feb 18, 2013 #1633 rferrel Changed checkFollowupSelection to use SimulatedTime. * Mar 28, 2013 DR 15974 D. Friedman Do not track removed GIDs. - * + * Apr 11, 2013 1894 jsanchez Removed the ability to load/unload maps via bullet selection. This will be resolved in a follow on ticket. * * * @author chammack @@ -1426,7 +1426,6 @@ public class WarngenDialog extends CaveSWTDialog implements .getBullets(), warngenLayer.getConfiguration() .getDamInfoBullets()); refreshBulletList(); - updateMaps(bulletListManager.getMapsToLoad()); // duration boolean enableDuration = warngenLayer.getConfiguration() @@ -1626,7 +1625,10 @@ public class WarngenDialog extends CaveSWTDialog implements bulletListManager.recreateBullets(warngenLayer .getConfiguration().getBullets(), warngenLayer .getConfiguration().getDamInfoBullets()); - updateMaps(bulletListManager.getMapsToLoad()); + // TODO Repair load/unload maps via bullet selection + // A follow on ticket will be written to fix the existing broken + // functionality of loading/unloading maps + // updateMaps(bulletListManager.getMapsToLoad()); } else { bulletListManager.recreateBulletsFromFollowup( warngenLayer.getConfiguration(), action, oldWarning); @@ -1729,7 +1731,10 @@ public class WarngenDialog extends CaveSWTDialog implements bulletList.deselectAll(); bulletList.setItems(bulletListManager.getAllBulletTexts()); bulletList.select(bulletListManager.getSelectedIndices()); - updateMaps(bulletListManager.getMapsToLoad()); + // TODO Repair load/unload maps via bullet selection + // A follow on ticket will be written to fix the existing broken + // functionality of loading/unloading maps + // updateMaps(bulletListManager.getMapsToLoad()); } private void updateMaps(ArrayList mapsToLoad) { diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java index efe7626d00..434fb31bae 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java @@ -165,9 +165,11 @@ import com.vividsolutions.jts.io.WKTReader; * 03/28/2013 DR 15974 D. Friedman Preserve the set of selected counties when recreating the polygon from the * hatched area and remember marked counties outside the polygon on followup. * 04/03/2013 1858 jsanchez Handled creating follow up warnings when created before 0z but issued after 0z. - * 03/13/2013 DR 15942 Qinglu Lin Added code to prevent small area from being toggled on that + * 04/03/2013 DR 15942 Qinglu Lin Added code to prevent small area from being toggled on that * does not meet inclusionPercent/inclusionArea criteria. * 04/10/2013 DR 16044 D. Friedman Fix NPE in getAllFipsInArea. + * 04/11/2013 1894 jsanchez Kept tracked of the currently loaded custom maps. + * 04/12/1013 DR 16045 Qinglu Lin Updated AreaHatcher's run() by calling removeDuplicateCoordinate(). * * * @author mschenke @@ -197,7 +199,7 @@ public class WarngenLayer extends AbstractStormTrackResource { private class CustomMaps extends Job { - private final Set customMaps = new HashSet(); + private Set customMaps = new HashSet(); private Set mapsToLoad; @@ -228,7 +230,7 @@ public class WarngenLayer extends AbstractStormTrackResource { for (String load : toLoad) { manager.loadMapByName(load); } - + customMaps = toLoad; issueRefresh(); } @@ -241,6 +243,7 @@ public class WarngenLayer extends AbstractStormTrackResource { synchronized (this) { mapsToLoad = new HashSet(maps); } + schedule(); } @@ -285,6 +288,7 @@ public class WarngenLayer extends AbstractStormTrackResource { } try { + warningPolygon = PolygonUtil.removeDuplicateCoordinate(warningPolygon); Polygon hatched = polygonUtil.hatchWarningArea( warningPolygon, removeCounties(warningArea, @@ -293,7 +297,7 @@ public class WarngenLayer extends AbstractStormTrackResource { // DR 15559 Coordinate[] coords = hatched.getCoordinates(); PolygonUtil.round(coords, 2); - WarngenUIState.adjustPolygon(coords); + PolygonUtil.adjustPolygon(coords); GeometryFactory gf = new GeometryFactory(); LinearRing lr = gf.createLinearRing(coords); hatchedArea = gf.createPolygon(lr, null); diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenUIState.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenUIState.java index ec32c86814..d9e8f149b4 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenUIState.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenUIState.java @@ -45,6 +45,11 @@ import com.vividsolutions.jts.geom.Polygon; * and adjustPolygon(). * Feb 15, 2013 1624 jsanchez Fix NullPointerException in removeDuplicateCoordinate. * 03/28/2013 DR 15974 D. Friedman Track marked areas outside polygon. + * 04/12/2013 DR 16045 Qinglu Lin Updated setWarningPolygon() by removing the call to + * removeDuplicateCoordinate() and updated removeDuplicateCoordinate() + * by changing access control level from private to public. + * Moved removeDuplicateCoordinate(), computeSlope(),computeCoordinate(), + * and adjustPolygon to PolygonUtil. * * * @@ -126,180 +131,6 @@ public class WarngenUIState { return oldWarningArea; } - /** - * removeDuplicateCoordinate remove duplicate intermediate coordinates in - * warningPolygon. History 10-26-2012 Qinglu Lin DR15479 Created. - */ - private static Polygon removeDuplicateCoordinate(Polygon polygon) { - if (polygon == null) { - return null; - } - - Coordinate[] verts = polygon.getCoordinates(); - Set coords = new LinkedHashSet(); - for (Coordinate c : verts) - coords.add(c); - if ((verts.length - coords.size()) < 2) - return polygon; - Coordinate[] vertices = new Coordinate[coords.size() + 1]; - Iterator iter = coords.iterator(); - int i = 0; - while (iter.hasNext()) { - vertices[i] = new Coordinate(iter.next()); - i += 1; - } - vertices[i] = new Coordinate(vertices[0]); - GeometryFactory gf = new GeometryFactory(); - return gf.createPolygon(gf.createLinearRing(vertices), null); - } - - /** - * computeSlope compute the slope of a line. - * - * History 12/06/2012 DR 15559 Qinglu Lin Created. - */ - private static double computeSlope(Coordinate[] coords, int i) { - double min = 1.0E-08; - double dx = coords[i].x - coords[i + 1].x; - double slope = 0.0; - if (Math.abs(dx) > min) { - slope = (coords[i].y - coords[i + 1].y) / dx; - } - return slope; - } - - /** - * computeCoordinate Compute the x component of a coordinate after its y - * component is adjusted. - * - * History 12/06/2012 DR 15559 Qinglu Lin Created. - */ - private static void computeCoordinate(Coordinate[] c, int i, int j) { - double slope; - slope = computeSlope(c, i); - int iPlus1 = i + 1; - if (c[j].x >= c[i].x && c[j].x <= c[iPlus1].x || c[j].x >= c[iPlus1].x - && c[j].x <= c[i].x) { - - double x, y; - double min1 = 0.005d; - y = slope * (c[j].x - c[i].x) + c[i].y; - double d = Math.abs(y - c[j].y); - if (d > min1) - return; - - double min2 = 1.0E-8d; - double delta = 0.005d; // empirical value - double dyMin = 0.01d; - int jMinus1 = j - 1; - if (jMinus1 < 0) - jMinus1 = c.length - 2; - int jPlus1 = j + 1; - if (Math.abs(y - c[j].y) < min1) { - double dy1, dy2; - dy1 = Math.abs(c[jMinus1].y - y); - dy2 = Math.abs(c[jPlus1].y - y); - if (dy1 >= dy2 - && (Math.abs(dy1) > dyMin || Math.abs(dy2) > dyMin)) { - // attempt to use l2 for computation - if (c[j].y == c[jMinus1].y - && Math.abs(c[j].x - c[jMinus1].x) > min2) { - // l2 is a horizontal line, use l3 for computation - if (c[jPlus1].y < c[j].y) - delta = -delta; - slope = computeSlope(c, j); - if (Math.abs(slope) > min2) { - y = c[j].y + delta; - x = (y - c[jPlus1].y) / slope + c[jPlus1].x; - } else { - // l3 is a vertical line - y = c[j].y + delta; - x = c[j].x; - } - } else { - // use l2 for computation - if (c[jMinus1].y < c[j].y) - delta = -delta; - slope = computeSlope(c, jMinus1); - if (Math.abs(slope) > min2) { - y = c[j].y + delta; - x = (y - c[jMinus1].y) / slope + c[jMinus1].x; - } else { - // l2 is a vertical line - y = c[j].y + delta; - x = c[j].x; - } - } - } else { - if (Math.abs(dy1) > dyMin || Math.abs(dy2) > dyMin) { - // attempt to use l3 for computation - if (c[j].y == c[jPlus1].y - && Math.abs(c[j].x - c[jPlus1].x) > min2) { - // l3 is a horizontal line, use l2 for computation - if (c[jMinus1].y < c[j].y) - delta = -delta; - slope = computeSlope(c, jMinus1); - if (Math.abs(slope) > min2) { - y = c[j].y + delta; - x = (y - c[jMinus1].y) / slope + c[jMinus1].x; - } else { - // l2 is a vertical line - y = c[j].y + delta; - x = c[j].x; - } - } else { - // use l3 for computation - if (c[jPlus1].y < c[j].y) - delta = -delta; - slope = computeSlope(c, j); - if (Math.abs(slope) > min2) { - y = c[j].y + delta; - x = (y - c[jPlus1].y) / slope + c[jPlus1].x; - } else { - // l3 is a vertical line - y = c[j].y + delta; - x = c[j].x; - } - } - } else { - x = c[j].x; - y = c[j].y; - } - } - c[j].x = x; - c[j].y = y; - if (j == 0) - c[c.length - 1] = c[j]; - } - } - } - - /** - * adjustPolygon When a point is very close to a line in the initial warning - * polygon, the resulting coordinates cause the failure of polygon drawing - * in follow-up. The method move that kind of points away from the line, and - * return a Polygon. - * - * History 12/06/2012 DR 15559 Qinglu Lin Created. - */ - public static void adjustPolygon(Coordinate[] coords) { - int n = coords.length; - for (int i = 0; i < n - 1; ++i) { - int j; - for (j = i + 2; j <= n - 2; j++) { - computeCoordinate(coords, i, j); - } - if (i <= n - 3) - for (j = 0; j < i; j++) { - computeCoordinate(coords, i, j); - } - else - for (j = 1; j < i; j++) { - computeCoordinate(coords, i, j); - } - } - } - /** * Set the old warning area in lat/lon projection. Will be converted to * local @@ -326,7 +157,7 @@ public class WarngenUIState { * the warningPolygon to set */ public void setWarningPolygon(Polygon warningPolygon) { - this.warningPolygon = removeDuplicateCoordinate(warningPolygon); + this.warningPolygon = warningPolygon; } public Set getFipsOutsidePolygon() { diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/ICommonPatterns.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/ICommonPatterns.java index d56d3b0f2b..646c798cbd 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/ICommonPatterns.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/ICommonPatterns.java @@ -33,6 +33,7 @@ import java.util.regex.Pattern; * Sep 24, 2012 15332 jsanchez Initial creation * Oct 18, 2012 15332 jsanchez Replaced listOfAreaNamesPtrn with String pattern. * Mar 13, 2013 DR 15892 D. Friedman Allow some punctuation in area names. + * Apr 18, 2013 DR 16055 D. Friedman Allow more than one contiguous space in areas. * * * @@ -56,7 +57,7 @@ public interface ICommonPatterns { // LOCK_END can be added at the start of the line if a previous line has // been locked. public static final String listOfAreaName = "^((" + LOCK_END - + "){0,1}((([\\?\\(\\)\\w\\.,/'-]+\\s{1})+\\w{2}-)*(([\\?\\(\\)\\w\\.,/'-]+\\s{1})+\\w{2}-)))"; + + "){0,1}((([\\?\\(\\)\\w\\.,/'-]+\\s{1,})+\\w{2}-)*(([\\?\\(\\)\\w\\.,/'-]+\\s{1,})+\\w{2}-)))"; // LOCK_END should not be found at the beginning of a first bullet since the // previous line should be blank. diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/WrapUtil.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/WrapUtil.java index e07566bf3a..e1feee56d3 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/WrapUtil.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/WrapUtil.java @@ -33,6 +33,7 @@ import java.util.regex.Pattern; * ------------ ---------- ----------- -------------------------- * Sep 24, 2012 15322 jsanchez Initial creation * Oct 19, 2012 15332 jsanchez Created a local pattern listOfAreaNamesPtrn. + * Apr 18, 2013 DR 16055 D. Friedman Fix word wrapping of long area names. * * * @@ -48,24 +49,13 @@ public class WrapUtil implements ICommonPatterns { private static final String BULLET_START = "* "; - private static final Pattern wrapUgcPtrn = Pattern.compile("(\\S{1," - + (MAX_WIDTH - 1) + "}-)"); + // Guess at the amount of extra characters added by wrapping + private static final int WRAP_COUNT_GUESS = 16 * 3; // *3 for bullet indent + \n - private static final Pattern wrapListOfNamesPtrn = Pattern.compile("(.{1," - + (MAX_WIDTH - 4) + "} \\w{2}-)"); - - // Locations in 4th bullet or locations paragraph of followup - // ex: ellipsis, spaces, period - private static final Pattern wrapDefaultPtrn = Pattern - .compile("(\\w{1,}\\.\\.\\.)|(AND \\w+\\.\\.\\.)|(\\w+\\.\\.\\.\\s{1,2})|" - + "(" - + LOCK_START - + "\\w+" - + LOCK_END - + "\\.\\.\\.)|\\S+\\.\\.\\." - + LOCK_END - + "|\\S+\\.\\.\\.|" - + "(\\s*\\S+\\s+)|(.+\\.)|(\\S+$)"); + private static final String DELIM_GROUP = "\0"; + private static final String[] NORMAL_DELIMS = { " ", "...", DELIM_GROUP, "-" }; + private static final String[] AREA_DELIMS = { "-", "...", DELIM_GROUP, " " }; + private static final String[] UGC_DELIMS = AREA_DELIMS; // ugc pattern private static final Pattern ugcPtrn = Pattern.compile(ugc); @@ -93,19 +83,24 @@ public class WrapUtil implements ICommonPatterns { if (unlocked.trim().length() == 0) { // BLANK LINE inBullet = false; addLine = line; - } else if (unlocked.length() <= MAX_WIDTH) { // LESS THAN MAX - // Add indenting if the template didn't account for it yet. - if (inBullet && !unlocked.startsWith(INDENT)) { - sb.append(INDENT); - } + } else { + boolean wasInBullet = inBullet; if (unlocked.startsWith(BULLET_START)) { inBullet = true; } - addLine = line; - } else { // NEEDS TO BE WRAPPED - addLine = wrapLongLines(line, inBullet); + // Add indenting if the template didn't account for it yet. + int add = wasInBullet && !unlocked.startsWith(INDENT) ? INDENT + .length() : 0; + if (unlocked.length() <= MAX_WIDTH - add) { // LESS THAN MAX + if (add > 0) { + sb.append(INDENT); + } + addLine = line; + } else { // NEEDS TO BE WRAPPED + addLine = wrapLongLines(line, inBullet); + } } sb.append(addLine); @@ -125,34 +120,122 @@ public class WrapUtil implements ICommonPatterns { * @return */ private static String wrapLongLines(String line, boolean inBullet) { - StringBuffer sb = new StringBuffer(line.length()); - String unlockedLine = line.replaceAll(LOCK_START + "|" + LOCK_END, ""); + String[] delims = getDelimiters(line); + return wrapLongLine(line, inBullet, delims, MAX_WIDTH); + } - if (unlockedLine.startsWith(BULLET_START)) { - inBullet = true; - } + /** + * Wraps a line of text to the given maximum width, if possible, by breaking + * at the given delimiters. + * + * @param line + * @param inBullet + * @param delims + * a list of delimiters divided into groups by the object + * instance DELIM_GROUP. A delimiter in an earlier group will be + * used before using any delimiter from a later group. Within a + * group, the delimiter closest to the margin is used. + * @param maxLength + * @return + */ + public static String wrapLongLine(String line, boolean inBullet, String[] delims, int maxLength) { + StringBuilder sb = new StringBuilder(line.length() + WRAP_COUNT_GUESS); + int start = 0; + int allowLength = maxLength; + boolean failed = false; - Pattern p = getPattern(line); - Matcher m = p.matcher(line.trim()); - String tmp = inBullet && !unlockedLine.startsWith(BULLET_START) ? INDENT - : ""; - - while (m.find()) { - String group = m.group(); - String unlocked = group.replaceAll(LOCK_START + "|" + LOCK_END, ""); - - int len = tmp.replaceAll(LOCK_START + "|" + LOCK_END, "").length(); - if (len + unlocked.length() > MAX_WIDTH && tmp.trim().length() > 0) { - sb.append(tmp + "\n"); - tmp = inBullet ? INDENT : ""; - tmp += group; - } else { - tmp += group; + /* + * Skip over initial bullet point and/or indent OR add indentation if + * missing. + */ + if (inBullet) { + char[] cb = new char[2]; + int i = indexIgnoringLockMarkers(line, start, 0); + int o = 0; + while (i < line.length() && o < 2) { + cb[o++] = line.charAt(i); + i = indexIgnoringLockMarkers(line, i, 1); + } + if (o == 2) { + String lead = new String(cb, 0, o); + if (INDENT.equals(lead) || BULLET_START.equals(lead)) { + allowLength -= lead.length(); + start = i; + sb.append(line, 0, i); + } else { + allowLength -= INDENT.length(); + sb.append(INDENT); + } } } - if (tmp.trim().length() > 0) { - sb.append(tmp); + while (start < line.length()) { + int limit = indexIgnoringLockMarkers(line, start, allowLength); + if (limit >= line.length()) { + appendRTrim(line, start, line.length(), sb); + break; + } + + /* + * Find delimiter in a group of delimiters that is closest to the + * wrap margin. If not found, try again with the next group. + * + * Searches before the limit (or at the limit if the delimiter is a + * space). If the whole process has failed once, searches after the + * limit. + */ + String bestDelim = null; + int bestP = -1; + for (String delim : delims) { + if (delim == DELIM_GROUP) { + if (bestDelim != null) + break; + continue; + } + int backup = " ".equals(delim) ? 0 : delim.length(); + int p = !failed ? line.lastIndexOf(delim, limit - backup) + : line.indexOf(delim, limit - backup); + if (p >= start && (bestDelim == null + || !failed ? p > bestP : p < bestP)) { + bestDelim = delim; + bestP = p; + } + } + + if (bestDelim != null) { + failed = false; + int next = indexIgnoringLockMarkers(line, + bestP + bestDelim.length(), 0); + int segmentEnd = " ".equals(bestDelim) ? bestP : next; + appendRTrim(line, start, segmentEnd, sb); + + // Remove any leading space at the start of the next line. + while (next < line.length() && line.charAt(next) == ' ') + next = indexIgnoringLockMarkers(line, next, 1); + + if (next < line.length()) { + sb.append('\n'); + if (inBullet) { + sb.append(INDENT); + allowLength = maxLength - INDENT.length(); + } + } + start = next; + } else if (! failed) { + /* + * Failed to wrap before the margin. Try again, wrapping the + * line after the margin, but still as close to it as possible. + */ + failed = true; + continue; + } else { + /* + * Failed to find any kind of break. Just dump the rest of the + * text. + */ + appendRTrim(line, start, line.length(), sb); + break; + } } return sb.toString(); @@ -164,21 +247,73 @@ public class WrapUtil implements ICommonPatterns { * @param line * @return */ - private static Pattern getPattern(String line) { - + private static String[] getDelimiters(String line) { Matcher m = ugcPtrn.matcher(line); // UGC line or FIPS line if (m.find()) { - return wrapUgcPtrn; + return UGC_DELIMS; } m = listOfAreaNamePtrn.matcher(line); // List of area names. if (m.find() && !line.startsWith(BULLET_START)) { - return wrapListOfNamesPtrn; + return AREA_DELIMS; } - return wrapDefaultPtrn; + return NORMAL_DELIMS; } + /** + * Returns the index in {@code text} that is {@code count} characters after + * {@code start}, skipping past any lock markers. This includes any lock + * markers at the desired index. This greediness prevents wrapping to a new + * line that would only contain lock markers. + * + * @param text + * @param start + * 0 <= start < text.length() + * @param count + * Number of characters to skip. May be greater than the number + * of characters in text past start. + * @return + */ + private static int indexIgnoringLockMarkers(String text, int start, int count) { + int i = start; + do { + if (text.startsWith(LOCK_START, i)) + i += LOCK_START.length(); + else if (text.startsWith(LOCK_END, i)) + i += LOCK_END.length(); + else if (count > 0) { + if (i >= text.length()) + break; + ++i; + --count; + } else + break; + } while (true); + return i; + } + + /** + * Append text.substring(start, end) to sb, removing any trailing + * whitespace. The trailing whitespace may have have embedded lock marks. + */ + private static void appendRTrim(String text, int start, int end, StringBuilder sb) { + int sbStart = sb.length(); + sb.append(text, start, end); + int i = sb.length(); + while (i > sbStart) { + if (Character.isWhitespace(sb.charAt(i - 1))) { + sb.deleteCharAt(--i); + } else if (i - sbStart >= LOCK_START.length() && + LOCK_START.equals(sb.substring(i - LOCK_START.length(), i))) { + i -= LOCK_START.length(); + } else if (i - sbStart >= LOCK_END.length() && + LOCK_END.equals(sb.substring(i - LOCK_END.length(), i))) { + i -= LOCK_END.length(); + } else + break; + } + } } diff --git a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/AbstractWWAResource.java b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/AbstractWWAResource.java index cf5ea38296..d3d030baa1 100644 --- a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/AbstractWWAResource.java +++ b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/AbstractWWAResource.java @@ -3,6 +3,7 @@ package com.raytheon.viz.warnings.rsc; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -74,6 +75,8 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; * String array returned from getText method * Jun 04, 2012 DR14992 mgamazaychikov Reversed the previous changes * Sep 26, 2012 jsanchez Refactored AbstractWarningResource and AbstractWatchesResource into this class. + * Apr 11, 2013 1877 jsanchez Updated conditions for matching a frame. + * Apr 18, 2013 1877 jsanchez Had the child classes set the comparator. Fixed a null pointer. * * * @@ -152,7 +155,7 @@ public abstract class AbstractWWAResource extends protected List recordsToLoad; - protected WarningRecordComparator comparator = new WarningRecordComparator(); + protected Comparator comparator; protected abstract void updateDisplay(IGraphicsTarget target) throws VizException; @@ -284,18 +287,24 @@ public abstract class AbstractWWAResource extends PaintProperties paintProps) throws VizException { FramesInfo info = paintProps.getFramesInfo(); DataTime[] frames = info.getFrameTimes(); - int frameToRequestedCompare = frames[0].compareTo(earliestRequested); - if (frameToRequestedCompare < 0) { - // we haven't requested data this far back + if (earliestRequested == null) { this.requestData(frames[0]); - } else if (frameToRequestedCompare > 0) { - // the previous earliest frame was removed as updates came in, so - // the warnings need to be disposed and we need to update the - // earliestRequested so if they ever went back in time to that - // again, it would be re-requested - earliestRequested = frames[0]; - if (paintProps.getDataTime() != null) { - cleanupData(paintProps.getDataTime(), frames); + } else { + int frameToRequestedCompare = frames[0] + .compareTo(earliestRequested); + if (frameToRequestedCompare < 0) { + // we haven't requested data this far back + this.requestData(frames[0]); + } else if (frameToRequestedCompare > 0) { + // the previous earliest frame was removed as updates came in, + // so + // the warnings need to be disposed and we need to update the + // earliestRequested so if they ever went back in time to that + // again, it would be re-requested + earliestRequested = frames[0]; + if (paintProps.getDataTime() != null) { + cleanupData(paintProps.getDataTime(), frames); + } } } int index = info.getFrameIndex(); @@ -436,16 +445,13 @@ public abstract class AbstractWWAResource extends if (action == WarningAction.CAN && refTime.equals(paintTime)) { return false; // If this entry has been altered/updated, display its pre-altered - // version - // only in the frames prior to the time it was altered + // version only in the frames prior to the time it was altered } else if (entry.altered) { if (frameStart.getTime() >= refTime.getTime() - && frameStart.getTime() < (entry.timeAltered.getTime()) - && frameStart.getTime() < entry.frameAltered.getTime()) + && frameStart.getTime() <= (entry.timeAltered.getTime()) + && frameStart.getTime() < entry.frameAltered.getTime()) { return true; - if (frameStart.getTime() >= (entry.timeAltered.getTime())) - return false; - + } } else if (refTime.equals(paintTime) || recordPeriod.contains(frameTime) || (framePeriod.contains(centerTime) && (!lastFrame || !entry.altered))) { @@ -518,8 +524,9 @@ public abstract class AbstractWWAResource extends } } - /* Sorts by phensig, etn, starttime (descending), act */ - Collections.sort(sortedWarnings, comparator); + if (comparator != null) { + Collections.sort(sortedWarnings, comparator); + } return sortedWarnings.toArray(new AbstractWarningRecord[sortedWarnings .size()]); } diff --git a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WarningRecordComparator.java b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WarningRecordComparator.java index 1a7ff08ef0..ac4069d19d 100644 --- a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WarningRecordComparator.java +++ b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WarningRecordComparator.java @@ -18,6 +18,7 @@ import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction; * ------------ ---------- ----------- -------------------------- * May 12, 2011 jsanchez Initial creation * Sep 27, 2012 1149 jsanchez Updated order of actions. Put CON before CAN,EXP + * Apr 18, 2013 1877 jsanchez Ordered by starttime before action to handle updates and initial load of the resource. * * * @author jsanchez @@ -27,8 +28,8 @@ public class WarningRecordComparator implements Comparator { /** - * Compares the WarningRecords by phenSig, ETN, action, then starttime - * (descending order) + * Compares the WarningRecords by phenSig, ETN, starttime (ascending order), + * then action */ @Override public int compare(AbstractWarningRecord wr1, AbstractWarningRecord wr2) { @@ -43,6 +44,11 @@ public class WarningRecordComparator implements rval = Double.compare(Double.parseDouble(wr1.getEtn()), Double.parseDouble(wr2.getEtn())); } + + if (rval == 0) { + rval = wr1.getStartTime().compareTo(wr2.getStartTime()); + } + if (rval == 0) { if (wr1.getAct() != null && wr2.getAct() != null) { WarningAction act1 = WarningAction.valueOf(wr1.getAct()); @@ -55,24 +61,15 @@ public class WarningRecordComparator implements rval = 1; } else if (act1 == WarningAction.CON && (act2 == WarningAction.CAN || act2 == WarningAction.EXP)) { - return -1; + return 1; } else if (act2 == WarningAction.CON && (act1 == WarningAction.CAN || act1 == WarningAction.EXP)) { - return 1; + return -1; } else { rval = wr1.getAct().compareTo(wr2.getAct()); } } - if (rval == 0) { - rval = wr1.getStartTime().compareTo(wr2.getStartTime()); - // sort warnings in descending order - if (wr1.getSig() != null) { - if (!wr1.getSig().equals("A")) { - rval *= -1; - } - } - } } } return rval; diff --git a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WarningsResource.java b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WarningsResource.java index d4257aede8..79225af4f3 100644 --- a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WarningsResource.java +++ b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WarningsResource.java @@ -58,6 +58,7 @@ import com.vividsolutions.jts.geom.Geometry; * Jun 04, 2012 DR14992 mgamazaychikov Fix the problem with plotting expiration time for * NEW warning when CAN warning is issued * Sep 27, 2012 1149 jsanchez Refactored methods from AbstractWarningsResource into this class. + * Arp 18, 2013 1877 jsanchez Ordered the records the same for update and initial load. * * * @author jsanchez @@ -104,6 +105,7 @@ public class WarningsResource extends AbstractWWAResource { */ public WarningsResource(WWAResourceData data, LoadProperties props) { super(data, props); + comparator = new WarningRecordComparator(); resourceName = "Warnings"; } @@ -148,7 +150,7 @@ public class WarningsResource extends AbstractWWAResource { synchronized (WarningsResource.this) { { try { - addRecord(pdo); + addRecord(sort(pdo)); } catch (VizException e) { statusHandler.handle(Priority.SIGNIFICANT, e.getLocalizedMessage(), e); diff --git a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesComparator.java b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesComparator.java new file mode 100644 index 0000000000..e753c155b8 --- /dev/null +++ b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesComparator.java @@ -0,0 +1,93 @@ +/** + * 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.warnings.rsc; + +import java.util.Comparator; + +import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord; +import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction; + +/** + * Comparator class for SPC watches. The logic for the compare method differs + * from the WarningRecordComparator. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 18, 2013            jsanchez     Initial creation
+ * 
+ * 
+ * + * @author jsanchez + * @version 1.0 + */ + +public class WatchesComparator implements Comparator { + /** + * Compares the WarningRecords by phenSig, ETN, action, then starttime + * (ascending order) + */ + @Override + public int compare(AbstractWarningRecord wr1, AbstractWarningRecord wr2) { + int rval = 0; + + if (wr1.getPhensig() != null && wr2.getPhensig() != null) { + rval = wr1.getPhensig().compareTo(wr2.getPhensig()); + } + + if (rval == 0) { + if (wr1.getEtn() != null && wr2.getEtn() != null) { + rval = Double.compare(Double.parseDouble(wr1.getEtn()), + Double.parseDouble(wr2.getEtn())); + } + + if (rval == 0) { + if (wr1.getAct() != null && wr2.getAct() != null) { + WarningAction act1 = WarningAction.valueOf(wr1.getAct()); + WarningAction act2 = WarningAction.valueOf(wr2.getAct()); + if (act1 == act2) { + rval = 0; + } else if (act1 == WarningAction.NEW) { + rval = -1; + } else if (act2 == WarningAction.NEW) { + rval = 1; + } else if (act1 == WarningAction.CON + && (act2 == WarningAction.CAN || act2 == WarningAction.EXP)) { + return -1; + } else if (act2 == WarningAction.CON + && (act1 == WarningAction.CAN || act1 == WarningAction.EXP)) { + return 1; + } else { + rval = wr1.getAct().compareTo(wr2.getAct()); + } + } + + } + + if (rval == 0) { + rval = wr1.getStartTime().compareTo(wr2.getStartTime()); + } + } + return rval; + } +} diff --git a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesResource.java b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesResource.java index ae2b363dc2..8cc0f60e94 100644 --- a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesResource.java +++ b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesResource.java @@ -94,6 +94,7 @@ public class WatchesResource extends AbstractWWAResource { public WatchesResource(WWAResourceData data, LoadProperties props) { super(data, props); + comparator = new WatchesComparator(); timer = new Timer(); expTaskSet = new HashSet(); resourceName = "Watches"; diff --git a/edexOsgi/build.edex/esb/data/utility/common_static/base/python/gfe/TimeRange.py b/edexOsgi/build.edex/esb/data/utility/common_static/base/python/gfe/TimeRange.py index 2cd383d2a3..8ce0fcc277 100644 --- a/edexOsgi/build.edex/esb/data/utility/common_static/base/python/gfe/TimeRange.py +++ b/edexOsgi/build.edex/esb/data/utility/common_static/base/python/gfe/TimeRange.py @@ -32,8 +32,9 @@ import JUtil # ------------ ---------- ----------- -------------------------- # 04/10/08 chammack Initial Creation. # 09/30/08 1566 wdougher Quit returning TimeRange from overlaps(), etc. -# 09/16/09 2899 njensen Huge performance boost by caching -# +# 09/16/09 2899 njensen Huge performance boost by caching +# 04/04/2013 #1787 randerso Removed isValid check to allow 0 duration +# time ranges to be used in python # # @@ -159,8 +160,6 @@ def javaTimeRangeListToPyList(timeRanges): return pylist def encodeJavaTimeRange(javaTimeRange): - if not javaTimeRange.isValid(): - return None time = TimeRange(javaTimeRange) start = time.startTime() end = time.endTime() diff --git a/edexOsgi/build.edex/esb/data/utility/edex_static/base/smartinit/Init.py b/edexOsgi/build.edex/esb/data/utility/edex_static/base/smartinit/Init.py index be5b6c6a1e..2b69ed97f1 100644 --- a/edexOsgi/build.edex/esb/data/utility/edex_static/base/smartinit/Init.py +++ b/edexOsgi/build.edex/esb/data/utility/edex_static/base/smartinit/Init.py @@ -24,7 +24,10 @@ # 02/16/12 14439 jdynina modified haines thresholds # 02/16/12 13917 jdynina merged in changes from TRAC ticket 11391 # 07/25/12 #957 dgilling implement edit areas as args to calc methods. -# 10/5/12 15158 ryu add Forecaster.getDb() +# 10/05/12 15158 ryu add Forecaster.getDb() +# 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 # ## import string, sys, re, time, types, getopt, fnmatch, LogStream, DatabaseID, JUtil, AbsTime, TimeRange @@ -836,8 +839,8 @@ class Forecaster(GridUtilities): def __sortTimes(self, methods, validTime): rval = [] calced = [] - haveNoData = {} for we, mthd, args in methods: +# LogStream.logEvent("Evaluating times for calc"+we) calced.append(we) args = filter(lambda x, ma=self.magicArgs().keys() + [we]: x not in ma, args) @@ -865,27 +868,36 @@ class Forecaster(GridUtilities): if validTime is None: valid = True - elif jtr.contains(validTime): - valid = True - + else: + # need check to be inclusive on both ends for methods that + # need both accumulative and non-accumulative parms + valid = validTime.getTime() >= jtr.getStart().getTime() and \ + validTime.getTime() <= jtr.getEnd().getTime() + if valid: timelist = TimeRange.encodeJavaTimeRange(jtr) pylist.append(timelist) ttimes.append(pylist) - timeList = ttimes[len(ttimes)-1] - result = 0 - for xtime in timeList: - result += xtime[1] - xtime[0] - - if result == 0: - if not haveNoData.has_key(we): - haveNoData[we] = [p] - else: - haveNoData[we].append(p) + +# msg = "Times available for " + p + " " + str(validTime) + ":\n" +# timeList = ttimes[len(ttimes)-1] +# for xtime in timeList: +# msg += '(' +# stime = time.gmtime(xtime[0]) +# etime = time.gmtime(xtime[1]) +# stime = time.strftime('%Y%m%d_%H%M', stime) +# etime = time.strftime('%Y%m%d_%H%M', etime) +# msg += stime + ", " + etime +# msg += ')\n' +# LogStream.logEvent(msg) # compare the times of each parm and find where they match up times = self.__compTimes(None, ttimes) +# LogStream.logEvent("nargs:",nargs) +# LogStream.logEvent("ttimes:",ttimes) +# LogStream.logEvent("times:",times) + hadDataButSkipped = {} for i in range(len(ttimes)): timeList = ttimes[i] @@ -896,7 +908,16 @@ class Forecaster(GridUtilities): hadDataButSkipped[xtime].append(parmName) else: hadDataButSkipped[xtime] = [parmName] - +# LogStream.logEvent("hadDataButSkipped:",hadDataButSkipped) + + hadNoData = [] + for i in range(len(nargs)): + timeList = ttimes[i] + parmName = nargs[i] + if len(timeList) == 0: + hadNoData.append(parmName) +# LogStream.logEvent("hadNoData:",hadNoData) + missing = {} for xtime in hadDataButSkipped: stime = time.gmtime(xtime[0]) @@ -908,16 +929,17 @@ class Forecaster(GridUtilities): for parmName in nargs: if not hadDataButSkipped[xtime].__contains__(parmName): - if parmName in calced: - if haveNoData.has_key(parmName): - missing[msg].append(parmName) - else: - if parmName in haveNoData.values(): - missing[msg].append(parmName) - - if not len(missing[msg]): - del missing[msg] - + missing[msg].append(parmName) + + if len(missing) == 0 and len(hadNoData) > 0: + msg = '' + if (validTime is not None): + vtime = validTime.getTime()/1000 + vtime = time.gmtime(vtime) + msg = time.strftime('%Y%m%d_%H%M', vtime) + missing[msg] = hadNoData +# LogStream.logEvent("missing:",missing) + if len(missing): LogStream.logEvent("Skipping calc" + we + " for some times due to the following " + "missing data:", missing) @@ -1130,7 +1152,7 @@ class Forecaster(GridUtilities): parm = self.__getNewWE(m[0]) tr = parm.getTimeRange(t[0]) - # A vaild time range was not found so the parameter + # A valid time range was not found so the parameter # cannot be calculated, so continue if not tr.isValid(): continue diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.plugin.gfe/META-INF/MANIFEST.MF index 227ba85dff..eaefe8a49a 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/META-INF/MANIFEST.MF @@ -29,6 +29,7 @@ Require-Bundle: com.raytheon.uf.common.dataplugin.gfe;bundle-version="1.12.1174" com.google.guava;bundle-version="1.0.0", com.raytheon.uf.common.util;bundle-version="1.12.1174", org.apache.commons.lang;bundle-version="2.3.0", + com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174", com.raytheon.uf.common.python.concurrent;bundle-version="1.0.0" Export-Package: com.raytheon.edex.plugin.gfe, com.raytheon.edex.plugin.gfe.config, @@ -53,7 +54,6 @@ Import-Package: com.raytheon.edex.db.dao, com.raytheon.uf.common.activetable, com.raytheon.uf.common.comm, com.raytheon.uf.common.dataplugin, - com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.dataplugin.persist, com.raytheon.uf.common.dataplugin.warning, com.raytheon.uf.common.datastorage, diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFED2DDao.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFED2DDao.java index 5f3ae9bd82..4fb1d08c31 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFED2DDao.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFED2DDao.java @@ -22,35 +22,20 @@ package com.raytheon.edex.plugin.gfe.db.dao; import java.util.ArrayList; import java.util.Date; -import java.util.HashSet; import java.util.List; -import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.hibernate.Query; -import org.hibernate.SQLQuery; import org.hibernate.Session; -import com.raytheon.edex.plugin.gfe.config.IFPServerConfig; -import com.raytheon.edex.plugin.gfe.config.IFPServerConfigManager; -import com.raytheon.edex.plugin.gfe.exception.GfeConfigurationException; -import com.raytheon.edex.plugin.gfe.util.GridTranslator; -import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.PluginException; -import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo; -import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; import com.raytheon.uf.common.dataplugin.grid.GridConstants; -import com.raytheon.uf.common.dataplugin.grid.GridInfoConstants; import com.raytheon.uf.common.dataplugin.grid.GridRecord; import com.raytheon.uf.common.dataplugin.level.Level; -import com.raytheon.uf.common.dataplugin.level.LevelFactory; -import com.raytheon.uf.common.parameter.mapping.ParameterMapper; -import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.common.util.mapping.MultipleMappingException; +import com.raytheon.uf.common.dataquery.db.QueryParam.QueryOperand; import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.query.DatabaseQuery; import com.raytheon.uf.edex.plugin.grid.dao.GridDao; @@ -63,6 +48,9 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 03/20/13 #1774 randerso Refactored out of GFEDao + * 04/04/13 #1787 randerso Fixed to support changes to D2D grid location + * Additional cleanup to move the D2D to GFE translation + * logic into D2DGridDatabase. * * * @@ -81,27 +69,6 @@ public class GFED2DDao extends GridDao { private static final String REF_TIME = "dataTime.refTime"; - // hibernate query to find grid info record for the given datasetId and - // parameter - private static final String SQL_D2D_GRID_PARM_QUERY = "select parameter_abbreviation, id " - + "FROM grid_info WHERE " - + GridInfoConstants.DATASET_ID - + " = :" - + GridInfoConstants.DATASET_ID - + " AND " - + "level_id = :level_id AND " - + "(lower(parameter_abbreviation) = :abbrev OR lower(parameter_abbreviation) like :hourAbbrev)"; - - // hibernate query to find the times for the GridRecord for the given - // info.id, id returned to allow easy lookup of the record associated with - // the time - private static final String HQL_D2D_GRID_TIME_QUERY = "select dataTime.fcstTime, id from GridRecord " - + "where " - + GridConstants.INFO_ID - + " = :info_id AND dataTime.refTime = :refTime order by dataTime.fcstTime"; - - private static final Pattern WIND_PATTERN = Pattern.compile("wind"); - public GFED2DDao() throws PluginException { super(); } @@ -116,20 +83,12 @@ public class GFED2DDao extends GridDao { * @throws DataAccessLayerException * If errors occur while querying the metadata database */ - public List getD2DForecastTimes(DatabaseID dbId) + public List getForecastTimes(String d2dModelName, Date refTime) throws DataAccessLayerException { DatabaseQuery query = new DatabaseQuery(GridRecord.class.getName()); query.addDistinctParameter(FCST_TIME); - try { - IFPServerConfig config = IFPServerConfigManager - .getServerConfig(dbId.getSiteId()); - query.addQueryParam(GridConstants.DATASET_ID, - config.d2dModelNameMapping(dbId.getModelName())); - } catch (GfeConfigurationException e) { - throw new DataAccessLayerException( - "Error occurred looking up model name mapping", e); - } - query.addQueryParam(REF_TIME, dbId.getModelTimeAsDate()); + query.addQueryParam(GridConstants.DATASET_ID, d2dModelName); + query.addQueryParam(REF_TIME, refTime); query.addOrder(FCST_TIME, true); @SuppressWarnings("unchecked") @@ -152,14 +111,16 @@ public class GFED2DDao extends GridDao { * @throws DataAccessLayerException * If errors occur while querying the metadata database */ - public GridRecord getD2DGrid(ParmID id, Integer forecastTime, + public GridRecord getGrid(String d2dModelName, Date refTime, + String d2dParmName, Level d2dLevel, Integer forecastTime, GridParmInfo info) throws DataAccessLayerException { Session s = null; try { s = getHibernateTemplate().getSessionFactory().openSession(); // TODO: clean up so we only make one db query - SortedMap rawTimes = queryByD2DParmId(id, s); + SortedMap rawTimes = queryByParmId(d2dModelName, + refTime, d2dParmName, d2dLevel, s); // if forecastTime is null just pick one, // this is for static data since all times are the same @@ -198,108 +159,75 @@ public class GFED2DDao extends GridDao { * @throws DataAccessLayerException * If errors occur while querying the metadata database */ - public SortedMap queryByD2DParmId(ParmID id, Session s) + public SortedMap queryByParmId(String d2dModelName, + Date refTime, String d2dParmName, Level d2dLevel, Session s) throws DataAccessLayerException { - String levelName = GridTranslator.getLevelName(id.getParmLevel()); - double[] levelValues = GridTranslator.getLevelValue(id.getParmLevel()); - boolean levelOnePresent = (levelValues[0] != Level - .getInvalidLevelValue()); - boolean levelTwoPresent = (levelValues[1] != Level - .getInvalidLevelValue()); - Level level = null; - - // to have a level 2, must have a level one - try { - if (levelOnePresent && levelTwoPresent) { - level = LevelFactory.getInstance().getLevel(levelName, - levelValues[0], levelValues[1]); - } else if (levelOnePresent) { - level = LevelFactory.getInstance().getLevel(levelName, - levelValues[0]); - } else { - level = LevelFactory.getInstance().getLevel(levelName, 0.0); - } - } catch (CommunicationException e) { - logger.error(e.getLocalizedMessage(), e); - } - if (level == null) { - logger.warn("Unable to query D2D parms, ParmID " + id - + " does not map to a level"); - return new TreeMap(); - } - - SQLQuery modelQuery = s.createSQLQuery(SQL_D2D_GRID_PARM_QUERY); - modelQuery.setLong("level_id", level.getId()); - DatabaseID dbId = id.getDbId(); - - try { - IFPServerConfig config = IFPServerConfigManager - .getServerConfig(dbId.getSiteId()); - modelQuery.setString(GridInfoConstants.DATASET_ID, - config.d2dModelNameMapping(dbId.getModelName())); - } catch (GfeConfigurationException e) { - throw new DataAccessLayerException( - "Error occurred looking up model name mapping", e); - } - - String abbreviation = null; - try { - abbreviation = ParameterMapper.getInstance().lookupBaseName( - id.getParmName(), "gfeParamName"); - } catch (MultipleMappingException e) { - statusHandler.handle(Priority.WARN, e.getLocalizedMessage(), e); - abbreviation = e.getArbitraryMapping(); - } - - abbreviation = abbreviation.toLowerCase(); - modelQuery.setString("abbrev", abbreviation); - modelQuery.setString("hourAbbrev", abbreviation + "%hr"); + DatabaseQuery query = new DatabaseQuery(GridRecord.class.getName()); + query.addReturnedField(FCST_TIME); + query.addReturnedField("id"); + query.addQueryParam(GridConstants.DATASET_ID, d2dModelName); + query.addQueryParam(REF_TIME, refTime); + query.addQueryParam(GridConstants.PARAMETER_ABBREVIATION, d2dParmName); + query.addQueryParam(GridConstants.LEVEL_ID, d2dLevel.getId()); + query.addOrder(FCST_TIME, true); @SuppressWarnings("unchecked") - List results = modelQuery.list(); - - Integer modelId = null; - if (results.size() == 0) { - return new TreeMap(); - } else if (results.size() > 1) { - // hours matched, take hour with least number that matches exact - // param - Pattern p = Pattern.compile("^" + abbreviation + "(\\d+)hr$"); - int lowestHr = -1; - for (Object[] rows : results) { - String param = ((String) rows[0]).toLowerCase(); - if (param.equals(abbreviation) && (lowestHr < 0)) { - modelId = (Integer) rows[1]; - } else { - Matcher matcher = p.matcher(param); - if (matcher.matches()) { - int hr = Integer.parseInt(matcher.group(1)); - if ((lowestHr < 0) || (hr < lowestHr)) { - modelId = (Integer) rows[1]; - lowestHr = hr; - } - } - } - } - } else { - modelId = (Integer) (results.get(0))[1]; - } - - Query timeQuery = s.createQuery(HQL_D2D_GRID_TIME_QUERY); - timeQuery.setInteger("info_id", modelId); - timeQuery.setParameter("refTime", dbId.getModelTimeAsDate()); - - @SuppressWarnings("unchecked") - List timeResults = timeQuery.list(); - - if (timeResults.isEmpty()) { - return new TreeMap(); - } + List firstTry = (List) this.queryByCriteria(query); SortedMap dataTimes = new TreeMap(); - for (Object[] rows : timeResults) { - dataTimes.put((Integer) rows[0], (Integer) rows[1]); + if (firstTry.isEmpty()) { + query = new DatabaseQuery(GridRecord.class.getName()); + query.addReturnedField(FCST_TIME); + query.addReturnedField("id"); + query.addReturnedField(GridConstants.PARAMETER_ABBREVIATION); + query.addQueryParam(GridConstants.DATASET_ID, d2dModelName); + query.addQueryParam(REF_TIME, refTime); + query.addQueryParam(GridConstants.PARAMETER_ABBREVIATION, + d2dParmName + "%hr", QueryOperand.LIKE); + query.addQueryParam(GridConstants.LEVEL_ID, d2dLevel.getId()); + query.addOrder(FCST_TIME, true); + query.addOrder(GridConstants.PARAMETER_ABBREVIATION, true); + + @SuppressWarnings("unchecked") + List secondTry = (List) this + .queryByCriteria(query); + + Pattern p = Pattern.compile("^" + d2dParmName + "(\\d+)hr$"); + int i = 0; + while (i < secondTry.size()) { + Object[] row = secondTry.get(i++); + Integer fcstHr = (Integer) row[0]; + Integer id = (Integer) row[1]; + Matcher matcher = p.matcher((String) row[2]); + int dur = Integer.MAX_VALUE; + if (matcher.matches()) { + dur = Integer.parseInt(matcher.group(1)); + } + + for (int j = i; j < secondTry.size(); j++) { + Object[] nextRow = secondTry.get(j); + if (fcstHr.equals(nextRow[0])) { + i = j; + String nextParam = (String) nextRow[2]; + Matcher nextMatcher = p.matcher(nextParam); + int nextDur = Integer.MAX_VALUE; + if (nextMatcher.matches()) { + nextDur = Integer.parseInt(nextMatcher.group(1)); + } + if (nextDur < dur) { + id = (Integer) nextRow[1]; + } + } else { + break; + } + } + dataTimes.put(fcstHr, id); + } + } else { + for (Object[] row : firstTry) { + dataTimes.put((Integer) row[0], (Integer) row[1]); + } } return dataTimes; } @@ -311,66 +239,18 @@ public class GFED2DDao extends GridDao { * @return the list of forecast hours * @throws DataAccessLayerException */ - public List queryFcstHourByD2DParmId(ParmID id) + public List queryFcstHourByParmId(String d2dModelName, + Date refTime, String d2dParmName, Level d2dLevel) throws DataAccessLayerException { List timeList = new ArrayList(); Session s = null; try { s = getHibernateTemplate().getSessionFactory().openSession(); - if (id.getParmName().equalsIgnoreCase("wind")) { - String idString = id.toString(); - Matcher idWindMatcher = WIND_PATTERN.matcher(idString); - - ParmID uWindId = new ParmID(idWindMatcher.replaceAll("uW")); - SortedMap results = queryByD2DParmId(uWindId, - s); - List uTimeList = new ArrayList(results.size()); - for (Integer o : results.keySet()) { - uTimeList.add(o); - } - - ParmID vWindId = new ParmID(idWindMatcher.replaceAll("vW")); - results = queryByD2DParmId(vWindId, s); - Set vTimeList = new HashSet(results.size(), 1); - for (Integer o : results.keySet()) { - vTimeList.add(o); - } - - for (Integer tr : uTimeList) { - if (vTimeList.contains(tr)) { - timeList.add(tr); - } - } - - if (!timeList.isEmpty()) { - return timeList; - } - - ParmID sWindId = new ParmID(idWindMatcher.replaceAll("ws")); - results = queryByD2DParmId(sWindId, s); - List sTimeList = new ArrayList(results.size()); - for (Integer o : results.keySet()) { - sTimeList.add(o); - } - - ParmID dWindId = new ParmID(idWindMatcher.replaceAll("wd")); - results = queryByD2DParmId(dWindId, s); - Set dTimeList = new HashSet(results.size(), 1); - for (Integer o : results.keySet()) { - dTimeList.add(o); - } - - for (Integer tr : sTimeList) { - if (dTimeList.contains(tr)) { - timeList.add(tr); - } - } - } else { - SortedMap results = queryByD2DParmId(id, s); - for (Integer o : results.keySet()) { - timeList.add(o); - } + SortedMap results = queryByParmId(d2dModelName, + refTime, d2dParmName, d2dLevel, s); + for (Integer o : results.keySet()) { + timeList.add(o); } } finally { if (s != null) { @@ -395,7 +275,7 @@ public class GFED2DDao extends GridDao { * @return * @throws DataAccessLayerException */ - public List getD2DModelRunTimes(String d2dModelName, int maxRecords) + public List getModelRunTimes(String d2dModelName, int maxRecords) throws DataAccessLayerException { DatabaseQuery query = new DatabaseQuery(GridRecord.class.getName()); query.addDistinctParameter(REF_TIME); diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/D2DGridDatabase.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/D2DGridDatabase.java index b840e1cc36..1497851218 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/D2DGridDatabase.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/D2DGridDatabase.java @@ -23,7 +23,6 @@ package com.raytheon.edex.plugin.gfe.server.database; import java.awt.Rectangle; import java.nio.FloatBuffer; import java.util.ArrayList; -import java.util.Calendar; import java.util.Collection; import java.util.Collections; import java.util.Date; @@ -45,7 +44,7 @@ import com.raytheon.edex.plugin.gfe.paraminfo.GridParamInfo; import com.raytheon.edex.plugin.gfe.paraminfo.GridParamInfoLookup; import com.raytheon.edex.plugin.gfe.paraminfo.ParameterInfo; import com.raytheon.edex.plugin.gfe.server.GridParmManager; -import com.raytheon.edex.plugin.gfe.util.GridTranslator; +import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory; import com.raytheon.uf.common.dataplugin.gfe.RemapGrid; @@ -65,6 +64,8 @@ import com.raytheon.uf.common.dataplugin.gfe.slice.VectorGridSlice; import com.raytheon.uf.common.dataplugin.grid.GridPathProvider; import com.raytheon.uf.common.dataplugin.grid.GridRecord; import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping; +import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.datastorage.DataStoreFactory; import com.raytheon.uf.common.datastorage.IDataStore; import com.raytheon.uf.common.datastorage.Request; @@ -101,7 +102,9 @@ import com.raytheon.uf.edex.database.DataAccessLayerException; * data instead of full grid. Added logging to support * GFE performance testing * 03/19/2013 #1774 randerso Fix accumulative grid time ranges - * Apr 01, 2013 #1774 randerso Moved wind component checking to GfeIngestNotificaionFilter + * 04/04/2013 #1774 randerso Moved wind component checking to GfeIngestNotificaionFilter + * 04/04/2013 #1787 randerso Move the D2D to GFE translation logic out of GFED2DDao + * 04/17/2013 #1913 randerso Added GFE level mapping to replace GridTranslator * * * @@ -167,8 +170,7 @@ public class D2DGridDatabase extends VGridDatabase { try { GFED2DDao dao = new GFED2DDao(); - List result = dao.getD2DModelRunTimes(d2dModelName, - maxRecords); + List result = dao.getModelRunTimes(d2dModelName, maxRecords); List dbInventory = new ArrayList(); for (Date date : result) { @@ -195,6 +197,8 @@ public class D2DGridDatabase extends VGridDatabase { private static final Pattern parmHrPattern = Pattern .compile("(\\D+)\\d+hr"); + private static final String GFE_LEVEL_MAPPING_FILE = "grid/gfeLevelMappingFile.xml"; + private final IPerformanceStatusHandler perfLog = PerformanceStatus .getHandler("GFE:"); @@ -209,6 +213,8 @@ public class D2DGridDatabase extends VGridDatabase { private String[] components; + private Level level; + public D2DParm(ParmID parmId, GridParmInfo gpi, Map fcstHrToTimeRange, String... components) { this.parmId = parmId; @@ -222,6 +228,8 @@ public class D2DGridDatabase extends VGridDatabase { for (Entry entry : fcstHrToTimeRange.entrySet()) { this.timeRangeToFcstHr.put(entry.getValue(), entry.getKey()); } + + this.level = getD2DLevel(parmId.getParmLevel()); } public ParmID getParmId() { @@ -244,6 +252,10 @@ public class D2DGridDatabase extends VGridDatabase { return components; } + public Level getLevel() { + return level; + } + @Override public String toString() { return this.parmId.toString(); @@ -252,7 +264,7 @@ public class D2DGridDatabase extends VGridDatabase { private String d2dModelName; - private Date modelTime; + private Date refTime; private GridParamInfo modelInfo; @@ -275,20 +287,20 @@ public class D2DGridDatabase extends VGridDatabase { * The database ID of this database */ public D2DGridDatabase(IFPServerConfig config, String d2dModelName, - Date modelTime) throws GfeException { + Date refTime) throws GfeException { super(config); this.d2dModelName = d2dModelName; - this.modelTime = modelTime; + this.refTime = refTime; this.modelInfo = GridParamInfoLookup.getInstance().getGridParamInfo( d2dModelName); if (modelInfo == null) { throw new GfeException("No model info for: " + d2dModelName); } - this.availableTimes = modelInfo.getAvailableTimes(modelTime); + this.availableTimes = modelInfo.getAvailableTimes(refTime); // Get the database id for this database. - this.dbId = getDbId(this.d2dModelName, this.modelTime, this.config); + this.dbId = getDbId(this.d2dModelName, this.refTime, this.config); this.valid = this.dbId.isValid(); // get the output gloc' @@ -409,8 +421,10 @@ public class D2DGridDatabase extends VGridDatabase { } } + String d2dParmName = getD2DParmName(atts.getShort_name()); + D2DParm d2dParm = new D2DParm(pid, gpi, possibleInventorySlots, - atts.getShort_name()); + d2dParmName); this.gfeParms.put(pid, d2dParm); this.d2dParms.put(compositeName(atts.getShort_name(), level), d2dParm); } @@ -450,8 +464,11 @@ public class D2DGridDatabase extends VGridDatabase { availableTimes.get(i)); } + String uD2dParmName = getD2DParmName(uatts.getShort_name()); + String vD2dParmName = getD2DParmName(vatts.getShort_name()); + D2DParm d2dParm = new D2DParm(pid, gpi, possibleInventorySlots, - uatts.getShort_name(), vatts.getShort_name()); + uD2dParmName, vD2dParmName); this.gfeParms.put(pid, d2dParm); this.d2dParms.put(compositeName(uatts.getShort_name(), level), d2dParm); this.d2dParms.put(compositeName(vatts.getShort_name(), level), d2dParm); @@ -514,10 +531,8 @@ public class D2DGridDatabase extends VGridDatabase { // get database inventory where all components are available for (String component : parm.getComponents()) { - ParmID compPid = new ParmID(component, dbId, - id.getParmLevel()); - List compInv = dao - .queryFcstHourByD2DParmId(compPid); + List compInv = dao.queryFcstHourByParmId( + d2dModelName, refTime, component, parm.getLevel()); if (dbInv == null) { dbInv = compInv; @@ -828,17 +843,18 @@ public class D2DGridDatabase extends VGridDatabase { try { // Gets the metadata from the grib metadata database + D2DParm parm = this.gfeParms.get(parmId); Integer fcstHr = null; if (!GridPathProvider.STATIC_PARAMETERS.contains(parmId .getParmName())) { - D2DParm parm = this.gfeParms.get(parmId); fcstHr = parm.getTimeRangeToFcstHr().get(timeRange); if (fcstHr == null) { throw new GfeException("Invalid time range " + timeRange + " for " + parmId); } } - d2dRecord = dao.getD2DGrid(parmId, fcstHr, gpi); + d2dRecord = dao.getGrid(d2dModelName, refTime, + parm.getComponents()[0], parm.getLevel(), fcstHr, gpi); } catch (DataAccessLayerException e) { throw new GfeException( "Error retrieving D2D Grid record from database", e); @@ -955,21 +971,18 @@ public class D2DGridDatabase extends VGridDatabase { + parmId); } - String mappedModel = config.d2dModelNameMapping(dbId.getModelName()); - - if (windParm.getComponents()[0].equals("uw")) { + // TODO clean up the hard coded d2d parm names + if (windParm.getComponents()[0].equals("uW")) { try { GridRecord uRecord = null; GridRecord vRecord = null; // Get the metadata from the grib metadata database - uRecord = dao.getD2DGrid( - new ParmID("uw", this.dbId, parmId.getParmLevel()), - fcstHr, gpi); - vRecord = dao.getD2DGrid( - new ParmID("vw", this.dbId, parmId.getParmLevel()), - fcstHr, gpi); + uRecord = dao.getGrid(d2dModelName, refTime, "uW", + windParm.getLevel(), fcstHr, gpi); + vRecord = dao.getGrid(d2dModelName, refTime, "vW", + windParm.getLevel(), fcstHr, gpi); // Gets the raw grid data from the D2D grib HDF5 files Grid2DFloat uData = getRawGridData(uRecord); @@ -977,8 +990,7 @@ public class D2DGridDatabase extends VGridDatabase { // Resample the data to fit the desired region float fillV = Float.MAX_VALUE; - ParameterInfo pa = GridParamInfoLookup.getInstance() - .getParameterInfo(mappedModel, "uw"); + ParameterInfo pa = modelInfo.getParameterInfo("uw"); if (pa != null) { fillV = pa.getFillValue(); } @@ -1003,12 +1015,10 @@ public class D2DGridDatabase extends VGridDatabase { GridRecord dRecord = null; // Get the metadata from the grib metadata database - sRecord = dao.getD2DGrid( - new ParmID("ws", this.dbId, parmId.getParmLevel()), - fcstHr, gpi); - dRecord = dao.getD2DGrid( - new ParmID("wd", this.dbId, parmId.getParmLevel()), - fcstHr, gpi); + sRecord = dao.getGrid(d2dModelName, refTime, "WS", + windParm.getLevel(), fcstHr, gpi); + dRecord = dao.getGrid(d2dModelName, refTime, "WD", + windParm.getLevel(), fcstHr, gpi); // Gets the raw grid data from the D2D grib HDF5 files Grid2DFloat sData = getRawGridData(sRecord); @@ -1016,8 +1026,7 @@ public class D2DGridDatabase extends VGridDatabase { // Resample the data to fit the desired region float fillV = Float.MAX_VALUE; - ParameterInfo pa = GridParamInfoLookup.getInstance() - .getParameterInfo(mappedModel, "ws"); + ParameterInfo pa = modelInfo.getParameterInfo("ws"); if (pa != null) { fillV = pa.getFillValue(); } @@ -1153,14 +1162,11 @@ public class D2DGridDatabase extends VGridDatabase { throw new GfeException("Unable to get GFE dao!!", e); } - List fcstTimes = dao.getD2DForecastTimes(dbId); + List fcstTimes = dao.getForecastTimes(d2dModelName, refTime); SortedSet validTimes = new TreeSet(); - Calendar validTimeCalc = Calendar.getInstance(); - Date refTime = dbId.getModelTimeAsDate(); for (Integer fcstTime : fcstTimes) { - validTimeCalc.setTime(refTime); - validTimeCalc.add(Calendar.SECOND, fcstTime.intValue()); - validTimes.add(validTimeCalc.getTime()); + validTimes.add(new Date(refTime.getTime() + fcstTime + * TimeUtil.MILLIS_PER_SECOND)); } return validTimes; } @@ -1175,27 +1181,33 @@ public class D2DGridDatabase extends VGridDatabase { // no-op } - public D2DParm getD2DParm(String d2dParmName, Level level) { + public D2DParm getD2DParm(String d2dParmName, Level d2dLevel) { String gfeParmName = getGfeParmName(d2dParmName); - String levelName = GridTranslator.getShortLevelName(level - .getMasterLevel().getName(), level.getLevelonevalue(), level - .getLeveltwovalue()); + String gfeLevel = getGFELevel(d2dLevel); + if (gfeLevel == null) { + statusHandler.warn("No GFE level found for D2D model: " + + d2dModelName + " D2D parm: " + d2dParmName + + " D2D level:" + d2dLevel + " GFE model: " + + dbId.getModelName() + " GFE parm: " + gfeParmName + + ". Check gfeLevelMapping and parameterInfo files."); + return null; + } - D2DParm parm = d2dParms.get(compositeName(gfeParmName, levelName)); + D2DParm parm = d2dParms.get(compositeName(gfeParmName, gfeLevel)); if (parm == null) { // try to find one with duration (XXXnnhr) Matcher matcher = parmHrPattern.matcher(d2dParmName); if (matcher.find()) { String abbrev = matcher.group(1); gfeParmName = getGfeParmName(abbrev); - parm = d2dParms.get(compositeName(gfeParmName, levelName)); + parm = d2dParms.get(compositeName(gfeParmName, gfeLevel)); } } if (parm == null) { statusHandler.warn("No gridParameterInfo found for " - + compositeName(gfeParmName, levelName) + ":" + + compositeName(gfeParmName, gfeLevel) + ":" + dbId.getModelId() + ". Check parameterInfo file."); } @@ -1214,6 +1226,18 @@ public class D2DGridDatabase extends VGridDatabase { return gfeParmName; } + public String getD2DParmName(String gfeParmName) { + String d2dParmName = null; + try { + d2dParmName = ParameterMapper.getInstance().lookupBaseName( + gfeParmName, "gfeParamName"); + } catch (MultipleMappingException e) { + statusHandler.handle(Priority.WARN, e.getLocalizedMessage(), e); + d2dParmName = e.getArbitraryMapping(); + } + return d2dParmName; + } + public TimeRange getTimeRange(ParmID parmID, Integer fcstHour) { D2DParm parm = this.gfeParms.get(parmID); if (parm == null) { @@ -1227,4 +1251,38 @@ public class D2DGridDatabase extends VGridDatabase { private String compositeName(String parmName, String level) { return parmName + "_" + level; } + + private static Level getD2DLevel(String gfeLevel) { + List levels; + try { + levels = LevelMappingFactory.getInstance(GFE_LEVEL_MAPPING_FILE) + .getLevelMappingForKey(gfeLevel).getLevels(); + } catch (CommunicationException e) { + levels = Collections.emptyList(); + } + + Level level = null; + if (levels.isEmpty()) { + statusHandler.warn("No D2D level found for: " + gfeLevel); + } else { + level = levels.get(0); + } + return level; + } + + private static String getGFELevel(Level d2dLevel) { + LevelMapping levelMapping; + try { + levelMapping = LevelMappingFactory.getInstance( + GFE_LEVEL_MAPPING_FILE).getLevelMappingForLevel(d2dLevel); + } catch (CommunicationException e) { + levelMapping = null; + } + + String gfeLevel = null; + if (levelMapping != null) { + gfeLevel = levelMapping.getKey(); + } + return gfeLevel; + } } diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/notify/GfeIngestNotificationFilter.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/notify/GfeIngestNotificationFilter.java index 9e0caed7b8..cf101ef2f7 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/notify/GfeIngestNotificationFilter.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/notify/GfeIngestNotificationFilter.java @@ -78,6 +78,8 @@ import com.raytheon.uf.edex.core.EDEXUtil; * SectorId and PhysicalElement. * Mar 20, 2013 #1774 randerso Refactor to use grid durations from D2DGridDatabase * Apr 01, 2013 #1774 randerso Moved wind component checking to GfeIngestNotificaionFilter + * Apr 04, 2013 #1787 randerso Added null check to prevent log spamming for parameters + * not included in the parameter info file * * * diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/util/GridTranslator.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/util/GridTranslator.java deleted file mode 100644 index 2a8803628d..0000000000 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/util/GridTranslator.java +++ /dev/null @@ -1,251 +0,0 @@ -/** - * 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.edex.plugin.gfe.util; - -import java.util.Arrays; -import java.util.List; -import java.util.regex.Pattern; - -import com.raytheon.uf.common.dataplugin.level.Level; -import com.raytheon.uf.common.dataplugin.level.LevelFactory; - -/** - * Singleton that assists with grid data - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#     Engineer    Description
- * ------------ ----------  ----------- --------------------------
- * May 5, 2008              njensen     Initial creation
- * Aug 22, 2008 1502        dglazesk    Changed to JAXB unmarshalling
- * Dec 06, 2012 1394        rjpeter     Attend static compiled patterns.
- * 
- * - * @author njensen - * @version 1.0 - */ - -public class GridTranslator { - - private static final List NEEDS_ZERO = Arrays.asList("BLD", "WBZ"); - - private static final Pattern ANY_NUMBER = Pattern.compile("[0-9]"); - - private static final Pattern NOT_NUMBER = Pattern.compile("[^0-9]"); - - private GridTranslator() { - } - - public static String getLevelName(String shorthand) { - return ANY_NUMBER.matcher(shorthand).replaceAll(""); - } - - public static double[] getLevelValue(String shorthand) { - String levelString = NOT_NUMBER.matcher(shorthand).replaceAll(""); - int length = levelString.length(); - double[] retVal = new double[2]; - retVal[0] = Level.getInvalidLevelValue(); - retVal[1] = Level.getInvalidLevelValue(); - switch (length) { - case 0: - retVal[0] = 0.0; - break; - case 1: - case 2: - retVal[0] = Double.parseDouble(levelString); - break; - case 3: - if (levelString.charAt(0) != '0') { - retVal[0] = Double.parseDouble(levelString); - } else { - retVal[1] = Double.parseDouble(levelString); - if (levelString.charAt(0) == '0') { - retVal[0] = 0.0; - } - } - break; - case 4: - if (levelString.charAt(0) == '0') { - retVal[0] = 0.0; - retVal[1] = Double.parseDouble(levelString); - } else if (levelString.charAt(0) == '1') { - retVal[0] = Double.parseDouble(levelString); - } else { - retVal[0] = Double.parseDouble(levelString.substring(0, 2)); - retVal[1] = Double.parseDouble(levelString.substring(2, 4)); - } - break; - case 5: - retVal[0] = Double.parseDouble(levelString.substring(0, 2)); - retVal[1] = Double.parseDouble(levelString.substring(2, 5)); - break; - case 6: - retVal[0] = Double.parseDouble(levelString.substring(0, 3)); - retVal[1] = Double.parseDouble(levelString.substring(3, 6)); - break; - case 7: - retVal[0] = Double.parseDouble(levelString.substring(0, 4)); - retVal[1] = Double.parseDouble(levelString.substring(4, 7)); - break; - case 8: - retVal[0] = Double.parseDouble(levelString.substring(0, 4)); - retVal[1] = Double.parseDouble(levelString.substring(4, 8)); - break; - default: - break; - } - return retVal; - } - - /** - * Formats short level name in GFE format - * - * @param name - * @param levelOne - * @param levelTwo - * @return short level name - */ - public static String getShortLevelName(String name, double levelOne, - double levelTwo) { - StringBuilder tmp = new StringBuilder(); - - if (name == null) { - tmp.append(LevelFactory.UNKNOWN_LEVEL); - } else { - tmp.append(name); - - if ((levelOne != Level.getInvalidLevelValue()) - && ((levelOne != 0) - || (levelTwo != Level.getInvalidLevelValue()) || NEEDS_ZERO - .contains(name))) { - tmp.append(String.valueOf(Math.round(levelOne))); - } - if (levelTwo != Level.getInvalidLevelValue()) { - tmp.append(String.valueOf(Math.round(levelTwo))); - } - } - return tmp.toString(); - } - - public static void main(String[] args) { - double[] testLevelsBL = { 0, 30, 60, 90, 120, 150, 180, -999999 }; - double[] testLevelsMB = { 1100, 1050, 1000, 950, 900, 850, 800, 750, - 700, 650, 600, 550, 500, 450, 400, 350, 300, 250, 200, 150, - 100, -999999 }; - - String levelName; - String level; - double[] levels; - double l1, l2; - - levelName = "BL"; - for (int i = 0; i < testLevelsBL.length; i++) { - l1 = testLevelsBL[i]; - for (int j = i + 1; j < testLevelsBL.length; j++) { - l2 = testLevelsBL[j]; - level = GridTranslator.getShortLevelName(levelName, l1, l2); - levels = GridTranslator.getLevelValue(level); - System.out.println(levelName - + " " - + l1 - + " " - + l2 - + ": " - + level - + " " - + Arrays.toString(levels) - + ((l1 == levels[0]) && (l2 == levels[1]) ? " passed" - : " failed")); - } - } - - levelName = "MB"; - for (int i = 0; i < testLevelsMB.length; i++) { - l1 = testLevelsMB[i]; - for (int j = i + 1; j < testLevelsMB.length; j++) { - l2 = testLevelsMB[j]; - level = GridTranslator.getShortLevelName(levelName, l1, l2); - levels = GridTranslator.getLevelValue(level); - System.out.println(levelName - + " " - + l1 - + " " - + l2 - + ": " - + level - + " " - + Arrays.toString(levels) - + ((l1 == levels[0]) && (l2 == levels[1]) ? " passed" - : " failed")); - } - } - - levelName = "SFC"; - l1 = 0; - l2 = -999999; - level = GridTranslator.getShortLevelName(levelName, l1, l2); - levels = GridTranslator.getLevelValue(level); - System.out.println(levelName - + " " - + l1 - + " " - + l2 - + ": " - + level - + " " - + Arrays.toString(levels) - + ((l1 == levels[0]) && (l2 == levels[1]) ? " passed" - : " failed")); - - levelName = "BLD"; - l1 = 0; - l2 = -999999; - level = GridTranslator.getShortLevelName(levelName, l1, l2); - levels = GridTranslator.getLevelValue(level); - System.out.println(levelName - + " " - + l1 - + " " - + l2 - + ": " - + level - + " " - + Arrays.toString(levels) - + ((l1 == levels[0]) && (l2 == levels[1]) ? " passed" - : " failed")); - - levelName = "WBZ"; - l1 = 0; - l2 = -999999; - level = GridTranslator.getShortLevelName(levelName, l1, l2); - levels = GridTranslator.getLevelValue(level); - System.out.println(levelName - + " " - + l1 - + " " - + l2 - + ": " - + level - + " " - + Arrays.toString(levels) - + ((l1 == levels[0]) && (l2 == levels[1]) ? " passed" - : " failed")); - } -} diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/gfeLevelMappingFile.xml b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/gfeLevelMappingFile.xml new file mode 100644 index 0000000000..24e7c21b94 --- /dev/null +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/gfeLevelMappingFile.xml @@ -0,0 +1,462 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs160.xml b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs160.xml index e3fb9bbcc4..e3c8214e0f 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs160.xml +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs160.xml @@ -1,4 +1,10 @@ + 0 @@ -445,9 +451,9 @@ 20.0 -99999.0 0 - MB 0>500 + SFC - MB0500 + SFC diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs161.xml b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs161.xml index e3fb9bbcc4..e3c8214e0f 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs161.xml +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs161.xml @@ -1,4 +1,10 @@ + 0 @@ -445,9 +451,9 @@ 20.0 -99999.0 0 - MB 0>500 + SFC - MB0500 + SFC diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs213.xml b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs213.xml index d6347c6724..3bf7d18660 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs213.xml +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs213.xml @@ -1,4 +1,10 @@ + 0 @@ -275,9 +281,9 @@ 20.0 -99999.0 0 - MB 0>500 + SFC - MB0500 + SFC diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs254.xml b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs254.xml index e3fb9bbcc4..e3c8214e0f 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs254.xml +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/gfs254.xml @@ -1,4 +1,10 @@ + 0 @@ -445,9 +451,9 @@ 20.0 -99999.0 0 - MB 0>500 + SFC - MB0500 + SFC diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/hpcGuideNDFD.xml b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/hpcGuideNDFD.xml index 52f61e8294..873b4a7fbc 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/hpcGuideNDFD.xml +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/hpcGuideNDFD.xml @@ -1,6 +1,10 @@ @@ -129,7 +133,7 @@ wx Weather - + wx Weather 0.0 diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ngm202.xml b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ngm202.xml deleted file mode 100644 index 5e7fd4ee21..0000000000 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ngm202.xml +++ /dev/null @@ -1,358 +0,0 @@ - - - - 0 - 21600 - 43200 - 64800 - 86400 - 108000 - 129600 - 151200 - 172800 - - - vw - v wind component - m/s - meter/sec - vWind - -150.0 - 150.0 - -99999.0 - 21 - SIG 9823 MB 1000-50 by 50 FH 1829 2743 3658 TROP - - SIG9823 - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - FH1829 - FH2743 - FH3658 - TROP - - - - staticSpacing - Grid spacing - meters - -99999.0 - - - tp - total precipitation - mm - millimeter - totPrecip - 0.0 - 1000.0 - -99999.0 - 0 - SFC - - SFC - - - - av - absolute vorticity - /s - 1/second - absVort - -0.00999999977648 - 0.00999999977648 - -99999.0 - 4 - MB 850 700 500 250 - - MB850 - MB700 - MB500 - MB250 - - - - gh - Geopotential height - m - meters - geoPotHt - -2000.0 - 20000.0 - -99999.0 - 20 - MB 1000-50 by 50 - - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - - - - pw - precipitable water - mm - millimeter - precipH2O - 0.0 - 300.0 - -99999.0 - 0 - SIG 0>100 - - SIG0100 - - - - bli - Best lifted index - K - degree_Kelvin - bestLftInd - -20.0 - 50.0 - -99999.0 - 0 - SIG 84>98 - - SIG8498 - - - - staticCoriolis - Coriolis parameter - /s - -99999.0 - - - rh - Relative Humidity - % - percent - rh - 0.0 - 100.0 - -99999.0 - 21 - SIG 9823 MB 1000-50 by 50 SIG 47>100 - - SIG9823 - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - SIG47100 - - - - sli - Surface lifted index - K - degree_Kelvin - LftInd - -20.0 - 20.0 - -99999.0 - 0 - MB 50>100 - - MB50100 - - - - snd - snow depth - m - meters - snowDepth - 0.0 - 100.0 - -99999.0 - 0 - SFC - - SFC - - - - staticTopo - Topography - meters - -99999.0 - - - pmsl - pressure at mean sea level - Pa - pascal - PMSL - 80000.0 - 110000.0 - -99999.0 - 0 - MSL - - MSL - - - - uw - u wind component - m/s - meter/sec - uWind - -150.0 - 150.0 - -99999.0 - 21 - SIG 9823 MB 1000-50 by 50 FH 1829 2743 3658 TROP - - SIG9823 - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - FH1829 - FH2743 - FH3658 - TROP - - - - st - soil temperature - K - degree_Kelvin - soilT - 0.0 - 1000.0 - -99999.0 - 0 - BLS - - BLS - - - - p - pressure - Pa - pascal - atmP - 0.0 - 110000.0 - -99999.0 - 1 - SFC TROP - - SFC - TROP - - - - t - Temperature - K - degree_Kelvin - T - 180.0 - 330.0 - -99999.0 - 21 - SIG 9823 MB 1000-50 by 50 FH 1829 2743 3658 TROP - - SIG9823 - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - FH1829 - FH2743 - FH3658 - TROP - - - diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ngm207.xml b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ngm207.xml deleted file mode 100644 index 116284ad4b..0000000000 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ngm207.xml +++ /dev/null @@ -1,396 +0,0 @@ - - - - 0 - 21600 - 43200 - 64800 - 86400 - 108000 - 129600 - 151200 - 172800 - - - pvv - Pressure vertical velocity - Pa/s - pascal/second - Pvv - -2.5 - 2.5 - -99999.0 - 9 - MB 850 700 500 400 300 250 200 150 100 - - MB850 - MB700 - MB500 - MB400 - MB300 - MB250 - MB200 - MB150 - MB100 - - - - vw - v wind component - m/s - meter/sec - vWind - -150.0 - 150.0 - -99999.0 - 21 - SIG 9823 MB 1000-50 by 50 FH 1829 2743 3658 TROP - - SIG9823 - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - FH1829 - FH2743 - FH3658 - TROP - - - - staticSpacing - Grid spacing - meters - -99999.0 - - - tp - total precipitation - mm - millimeter - totPrecip - 0.0 - 1000.0 - -99999.0 - 0 - SFC - - SFC - - - - av - absolute vorticity - /s - 1/second - absVort - -0.00999999977648 - 0.00999999977648 - -99999.0 - 4 - MB 850 700 500 250 - - MB850 - MB700 - MB500 - MB250 - - - - cp - convective precipitation - mm - millimeter - convPrecip - 0.0 - 1000.0 - -99999.0 - 0 - SFC - - SFC - - - - gh - Geopotential height - m - meters - geoPotHt - -2000.0 - 20000.0 - -99999.0 - 20 - MB 1000-50 by 50 - - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - - - - pw - precipitable water - mm - millimeter - precipH2O - 0.0 - 300.0 - -99999.0 - 0 - SIG 0>100 - - SIG0100 - - - - bli - Best lifted index - K - degree_Kelvin - bestLftInd - -20.0 - 50.0 - -99999.0 - 0 - SIG 84>98 - - SIG8498 - - - - staticCoriolis - Coriolis parameter - /s - -99999.0 - - - rh - Relative Humidity - % - percent - rh - 0.0 - 100.0 - -99999.0 - 21 - SIG 9823 MB 1000-50 by 50 SIG 47>100 - - SIG9823 - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - SIG47100 - - - - sli - Surface lifted index - K - degree_Kelvin - LftInd - -20.0 - 20.0 - -99999.0 - 0 - MB 50>100 - - MB50100 - - - - snd - snow depth - m - meters - snowDepth - 0.0 - 100.0 - -99999.0 - 0 - SFC - - SFC - - - - staticTopo - Topography - meters - -99999.0 - - - pmsl - pressure at mean sea level - Pa - pascal - PMSL - 80000.0 - 110000.0 - -99999.0 - 0 - MSL - - MSL - - - - uw - u wind component - m/s - meter/sec - uWind - -150.0 - 150.0 - -99999.0 - 21 - SIG 9823 MB 1000-50 by 50 FH 1829 2743 3658 TROP - - SIG9823 - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - FH1829 - FH2743 - FH3658 - TROP - - - - st - soil temperature - K - degree_Kelvin - soilT - 0.0 - 1000.0 - -99999.0 - 0 - BLS - - BLS - - - - p - pressure - Pa - pascal - atmP - 0.0 - 110000.0 - -99999.0 - 1 - SFC TROP - - SFC - TROP - - - - t - Temperature - K - degree_Kelvin - T - 180.0 - 330.0 - -99999.0 - 21 - SIG 9823 MB 1000-50 by 50 FH 1829 2743 3658 TROP - - SIG9823 - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - FH1829 - FH2743 - FH3658 - TROP - - - diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ngm211.xml b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ngm211.xml deleted file mode 100644 index 27c1c995e1..0000000000 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ngm211.xml +++ /dev/null @@ -1,396 +0,0 @@ - - - - 0 - 21600 - 43200 - 64800 - 86400 - 108000 - 129600 - 151200 - 172800 - - - pvv - Pressure vertical velocity - Pa/s - pascal/second - Pvv - -2.5 - 2.5 - -99999.0 - 9 - MB 850 700 500 400 300 250 200 150 100 - - MB850 - MB700 - MB500 - MB400 - MB300 - MB250 - MB200 - MB150 - MB100 - - - - vw - v wind component - m/s - meter/sec - vWind - -150.0 - 150.0 - -99999.0 - 21 - SIG 9823 MB 1000-50 by 50 FH 1829 2743 3658 TROP - - SIG9823 - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - FH1829 - FH2743 - FH3658 - TROP - - - - staticSpacing - Grid spacing - meters - -99999.0 - - - tp - total precipitation - mm - millimeter - totPrecip - 0.0 - 1000.0 - -99999.0 - 0 - SFC - - SFC - - - - av - absolute vorticity - /s - 1/second - absVort - -0.00999999977648 - 0.00999999977648 - -99999.0 - 4 - MB 850 700 500 250 - - MB850 - MB700 - MB500 - MB250 - - - - cp - convective precipitation - mm - millimeter - convPrecip - 0.0 - 1000.0 - -99999.0 - 0 - SFC - - SFC - - - - gh - Geopotential height - m - meters - geoPotHt - -2000.0 - 20000.0 - -99999.0 - 20 - MB 1000-50 by 50 - - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - - - - pw - precipitable water - mm - millimeter - precipH2O - 0.0 - 300.0 - -99999.0 - 0 - SIG 0>100 - - SIG0100 - - - - bli - Best lifted index - K - degree_Kelvin - bestLftInd - -20.0 - 50.0 - -99999.0 - 0 - SIG 84>98 - - SIG8498 - - - - staticCoriolis - Coriolis parameter - /s - -99999.0 - - - rh - Relative Humidity - % - percent - rh - 0.0 - 100.0 - -99999.0 - 21 - SIG 9823 MB 1000-50 by 50 SIG 47>100 - - SIG9823 - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - SIG47100 - - - - sli - Surface lifted index - K - degree_Kelvin - LftInd - -20.0 - 20.0 - -99999.0 - 0 - MB 50>100 - - MB50100 - - - - snd - snow depth - m - meters - snowDepth - 0.0 - 100.0 - -99999.0 - 0 - SFC - - SFC - - - - staticTopo - Topography - meters - -99999.0 - - - pmsl - pressure at mean sea level - Pa - pascal - PMSL - 80000.0 - 110000.0 - -99999.0 - 0 - MSL - - MSL - - - - uw - u wind component - m/s - meter/sec - uWind - -150.0 - 150.0 - -99999.0 - 21 - SIG 9823 MB 1000-50 by 50 FH 1829 2743 3658 TROP - - SIG9823 - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - FH1829 - FH2743 - FH3658 - TROP - - - - st - soil temperature - K - degree_Kelvin - soilT - 0.0 - 1000.0 - -99999.0 - 0 - BLS - - BLS - - - - p - pressure - Pa - pascal - atmP - 0.0 - 110000.0 - -99999.0 - 1 - SFC TROP - - SFC - TROP - - - - t - Temperature - K - degree_Kelvin - T - 180.0 - 330.0 - -99999.0 - 21 - SIG 9823 MB 1000-50 by 50 FH 1829 2743 3658 TROP - - SIG9823 - MB1000 - MB950 - MB900 - MB850 - MB800 - MB750 - MB700 - MB650 - MB600 - MB550 - MB500 - MB450 - MB400 - MB350 - MB300 - MB250 - MB200 - MB150 - MB100 - MB50 - FH1829 - FH2743 - FH3658 - TROP - - - diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ngm213.xml b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ngm213.xml deleted file mode 100644 index 3daf7abbe6..0000000000 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ngm213.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - 21600 - 43200 - 64800 - 86400 - 108000 - 129600 - 151200 - 172800 - - - staticTopo - Topography - meters - -99999.0 - - - pvv - Pressure vertical velocity - Pa/s - pascal/second - Pvv - -2.5 - 2.5 - -99999.0 - 9 - MB 850 700 500 400 300 250 200 150 100 - - MB850 - MB700 - MB500 - MB400 - MB300 - MB250 - MB200 - MB150 - MB100 - - - - tp - total precipitation - mm - millimeter - totPrecip - 0.0 - 1000.0 - -99999.0 - 0 - SFC - - SFC - - - - staticCoriolis - Coriolis parameter - /s - -99999.0 - - - staticSpacing - Grid spacing - meters - -99999.0 - - - cp - convective precipitation - mm - millimeter - convPrecip - 0.0 - 1000.0 - -99999.0 - 0 - SFC - - SFC - - - diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ruc236.xml b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ruc236.xml index 536e49420c..79a60dc99d 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ruc236.xml +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/grid/parameterInfo/ruc236.xml @@ -1,4 +1,10 @@ + 0 @@ -457,9 +463,9 @@ 20.0 -99999.0 0 - SFC + MB 0>500 - SFC + MB0500 diff --git a/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/ColorMap.java b/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/ColorMap.java index bea147d247..8d4fc4de2c 100644 --- a/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/ColorMap.java +++ b/edexOsgi/com.raytheon.uf.common.colormap/src/com/raytheon/uf/common/colormap/ColorMap.java @@ -37,11 +37,11 @@ import com.raytheon.uf.common.serialization.ISerializableObject; /** * Implementation of a colormap - * + * *
- *
+ * 
  *  SOFTWARE HISTORY
- *
+ * 
  *  Date         Ticket#     Engineer    Description
  *  ------------ ----------  ----------- --------------------------
  *  Feb 5, 2007              chammack    Initial Creation.
@@ -50,9 +50,10 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
  *  Aug 20, 2008			 dglazesk	 Added some interface pieces to make this more
  *                                       usable
  *  Jan 10, 2013 15648       ryu         Added removeDuplicates() method.
- *
+ *  Apr 18, 2013  1920       mpduff      Default changed to true.
+ * 
  * 
- * + * * @author chammack * @version 1 */ @@ -67,7 +68,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { private Buffer glBuffer; - private boolean changed = false; + private boolean changed = true; /** * Constructor used by JiBX @@ -97,7 +98,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { /** * Creates a ColorMap using name and the list of colors in map. - * + * * @param name * Name for the new ColorMap * @param map @@ -107,12 +108,11 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { this.name = name; colors = new ArrayList(); colors.addAll(map.getColors()); - this.changed = true; } /** * Do not instantiate directly, use GLTarget methods - * + * * @param name * @param red * @param green @@ -139,9 +139,10 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { /* * (non-Javadoc) - * + * * @see com.raytheon.uf.common.colormap.IColorMap#getBlue() */ + @Override public float[] getBlue() { int colorNum = colors.size(); float[] blues = new float[colorNum]; @@ -153,9 +154,10 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { /* * (non-Javadoc) - * + * * @see com.raytheon.uf.common.colormap.IColorMap#getGreen() */ + @Override public float[] getGreen() { int colorNum = colors.size(); float[] greens = new float[colorNum]; @@ -167,9 +169,10 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { /* * (non-Javadoc) - * + * * @see com.raytheon.uf.common.colormap.IColorMap#getRed() */ + @Override public float[] getRed() { int colorNum = colors.size(); float[] reds = new float[colorNum]; @@ -181,18 +184,20 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { /* * (non-Javadoc) - * + * * @see com.raytheon.uf.common.colormap.IColorMap#getSize() */ + @Override public int getSize() { return colors.size(); } /* * (non-Javadoc) - * + * * @see com.raytheon.uf.common.colormap.IColorMap#getAlpha() */ + @Override public float[] getAlpha() { int colorNum = colors.size(); float[] alphas = new float[colorNum]; @@ -204,7 +209,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { /** * Return the buffer representation of the colormap - * + * * @return the colorMap buffer */ public synchronized Buffer getColorMap() { @@ -233,20 +238,22 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { /* * (non-Javadoc) - * + * * @see com.raytheon.edex.colormap.IColorMap#getName() */ + @Override public String getName() { return name; } + @Override public List getColors() { return colors; } /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override @@ -254,10 +261,12 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { return "COLORMAP { " + getName() + " }"; } + @Override public boolean isChanged() { return changed; } + @Override public void setAlpha(float[] anAlpha) { int size = anAlpha.length; for (int i = 0; i < size; ++i) { @@ -270,6 +279,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { changed = true; } + @Override public void setBlue(float[] aBlue) { int size = aBlue.length; for (int i = 0; i < size; ++i) { @@ -282,6 +292,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { changed = true; } + @Override public void setGreen(float[] aGreen) { int size = aGreen.length; for (int i = 0; i < size; ++i) { @@ -294,6 +305,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { changed = true; } + @Override public void setRed(float[] aRed) { int size = aRed.length; for (int i = 0; i < size; ++i) { @@ -310,10 +322,12 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { this.colors.set(index, color); } + @Override public void setChanged(boolean aChanged) { changed = aChanged; } + @Override public void setName(String aName) { name = aName; changed = true; @@ -329,7 +343,7 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { * wavelength to the maximum wavelength. If the reverse flag is set, then a * reverse spectrum is generated. The red, green, and blue indexes are * returned through the calling arguments. - * + * * @param numOfColors * @param minWaveLength * @param maxWaveLength @@ -416,10 +430,10 @@ public class ColorMap extends AbstractColorMap implements ISerializableObject { public void removeDuplicates() { List colors = new ArrayList(); Color current = null; - for (Color color: this.colors) { + for (Color color : this.colors) { if (!color.equals(current)) { - colors.add(color); - current = color; + colors.add(color); + current = color; } } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasin.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasin.java index e69744a471..fba5e152cc 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasin.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasin.java @@ -31,6 +31,7 @@ import javax.persistence.Transient; import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; +import com.raytheon.uf.common.time.util.ImmutableDate; /** * FFMP basin/aggregated value holder diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPCacheRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPCacheRecord.java deleted file mode 100644 index bccf12b826..0000000000 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPCacheRecord.java +++ /dev/null @@ -1,572 +0,0 @@ -package com.raytheon.uf.common.dataplugin.ffmp; -/** - * 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.awt.Point; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.Map.Entry; - -import com.raytheon.uf.common.cache.CacheException; -import com.raytheon.uf.common.cache.CacheFactory; -import com.raytheon.uf.common.cache.ICache; -import com.raytheon.uf.common.cache.disk.DiskCache; -import com.raytheon.uf.common.datastorage.IDataStore; -import com.raytheon.uf.common.datastorage.Request; -import com.raytheon.uf.common.datastorage.records.FloatDataRecord; -import com.raytheon.uf.common.datastorage.records.IDataRecord; -import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager; -import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager.SOURCE_TYPE; -import com.raytheon.uf.common.monitor.xml.DomainXML; -import com.raytheon.uf.common.monitor.xml.SourceXML; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; - -/** - * Cache coherent record - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#     Engineer    Description
- * ------------ ----------  ----------- --------------------------
- * 05/24/12    632     D. Hladky   Initial release
- * 
- * 
- * - * @author dhladky - * @version 1 - */ - -public class FFMPCacheRecord extends FFMPRecord { - - private final String sourceCacheName; - - private final String cacheName; - - private final String cacheDir; - - private ArrayList hucs = new ArrayList(); - - //private static final boolean useCache = !Boolean - // .getBoolean("com.raytheon.uf.common.ffmp.disableCache"); - private static final boolean useCache = false; - - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(FFMPCacheRecord.class); - - - /** - * Public constructor - * @param rec - * @param sourceCacheName - * @param cacheDir - */ - public FFMPCacheRecord(FFMPRecord rec, String sourceCacheName, String cacheDir) { - - this.setSiteKey(rec.getSiteKey()); - this.setWfo(rec.getWfo()); - this.setDataKey(rec.getDataKey()); - this.setSourceName(rec.getSourceName()); - this.setPluginName(rec.getPluginName()); - this.sourceCacheName = sourceCacheName; - this.cacheName = "FFMP-" + getWfo() + "-" + getSiteKey() + "-" +getDataKey()+ "-" - + getSourceCacheName(); - // set a default value - if (cacheDir == null) { - cacheDir = "/tmp"; - } - this.cacheDir = cacheDir; - } - - public String getSourceCacheName() { - return sourceCacheName; - } - - /** - * - */ - private static final long serialVersionUID = 1L; - - @SuppressWarnings({ "unchecked" }) - private DiskCache getCache() { - - DiskCache diskCache = null; - CacheFactory cf = CacheFactory.getInstance(); - try { - diskCache = (DiskCache) cf.getCache(this.cacheName); - } catch (CacheException e) { - synchronized (this) { - // make sure not done on another thread - try { - diskCache = (DiskCache) cf - .getCache(this.cacheName); - } catch (CacheException e1) { - diskCache = createCache(this.cacheName); - CacheFactory.getInstance().addCache(this.cacheName, - diskCache); - } - } - } - - return diskCache; - } - /** - * Get BasinData Map from cache - * - * @param siteKey - * @param sourceName - * @return - */ - @Override - public FFMPBasinData getBasinData(String hucName) { - return getBasinData(hucName, false); - } - - /** - * Get BasinData Map from cache - * - * @param siteKey - * @param sourceName - * @return - */ - public FFMPBasinData getBasinData(String hucName, boolean lock) { - FFMPBasinData basins = null; - - if (hucName != null) { - if (useCache) { - try { - - DiskCache diskCache = getCache(); - basins = (FFMPBasinData) diskCache.getFromCache(hucName, lock); - - if (basins == null) { - basins = new FFMPBasinData(hucName); - if (!hucs.contains(hucName)) { - hucs.add(hucName); - } - } - - } catch (Exception e) { - e.printStackTrace(); - } - - } else { - basins = super.getBasinData(hucName); - } - } - - return basins; - } - - - /** - * Create cache objects if needed - * - * @param siteKey - * @return - */ - private DiskCache createCache(String name) { - ICache cache = new DiskCache(); - DiskCache dc = (DiskCache) cache; - dc.setName(name); - dc.setBaseCacheDir(getCacheDir()); - dc.setSizeMemCacheMap(2); // For FFMP hold two generally COUNTY and ALL - dc.activateCache(); - - return dc; - } - - /** - * Set source record to cache - * - * @param siteKey - * @param sourceName - * @param record - */ - @Override - public void setBasinData(FFMPBasinData basins, String hucName) { - if (hucName != null) { - if (useCache) { - try { - synchronized (basins) { - DiskCache diskCache = getCache(); - - try { - diskCache.addToCache(hucName, basins); - } catch (IOException e) { - e.printStackTrace(); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } else { - super.setBasinData(basins, hucName); - } - } - } - - /** - * Cache File reader - * - * @param basins - * @param hucName - */ - public void setCacheData(FFMPBasinData basins, String hucName) { - if (getBasinData(hucName) != null) { - - basins = getBasinData(hucName, true); - //System.out.println("Adding Cache Data: "+hucName+" "+getSourceName()); - - synchronized (basins) { - for (Entry entry : basins.getBasins() - .entrySet()) { - FFMPBasin basin = basins.get(entry.getKey()); - if (basin != null) { - if (basin instanceof FFMPGuidanceBasin) { - FFMPGuidanceBasin gbasin = (FFMPGuidanceBasin) basin; - gbasin.getGuidValues().putAll( - ((FFMPGuidanceBasin) entry.getValue()) - .getGuidValues()); - } else { - basin.getValues().putAll( - entry.getValue().getValues()); - } - } else { - basins.put(entry.getKey(), entry.getValue()); - } - } - } - - setBasinData(basins, hucName); - - } else { - setBasinData(basins, hucName); - //System.out.println("Adding Whole Object Buddy Data: "+hucName+" "+getSourceName()); - } - } - - /** - * Gets the Hash out of the datastore by HUC - * - * @param dataStore - * @param huc - */ - public void retrieveMapFromDataStore(IDataStore dataStore, String uri, - FFMPTemplates template, String huc, Date date, String sourceName) - throws Exception { - - FFMPBasinData fbd = null; - - boolean aggregate = true; - - if (huc.equals("ALL")) { - aggregate = false; - } - - fbd = getBasinData(huc, true); - String key = getSiteKey(); - - synchronized (template) { - - SourceXML source = FFMPSourceConfigurationManager.getInstance() - .getSource(sourceName); - - for (DomainXML domain : template.getDomains()) { - LinkedHashMap map = template.getMap(key, - domain.getCwa(), huc); - - if (map != null && map.keySet().size() > 0) { - - IDataRecord rec = null; - - try { - rec = dataStore.retrieve(uri + "/" + domain.getCwa(), - huc, Request.ALL); - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "FFMPRecord: no data record for: " + uri + "/" - + domain.getCwa()); - } - - if (rec != null) { - float[] values = ((FloatDataRecord) rec).getFloatData(); - - int j = 0; - if (values != null) { - // System.err.println(sourceName); - if (source.getSourceType().equals( - SOURCE_TYPE.GUIDANCE.getSourceType())) { - for (Long pfaf : map.keySet()) { - try { - FFMPGuidanceBasin basin = (FFMPGuidanceBasin) fbd - .get(pfaf); - - if (basin == null) { - basin = new FFMPGuidanceBasin(pfaf, - aggregate); - fbd.put(pfaf, basin); - } - - if (basin.containsKey(date, sourceName)) { - if (basin - .getValue(date, sourceName) == FFMPUtils.MISSING - || basin.getValue(date, - sourceName).isNaN()) { - - float curval = basin.getValue( - date, sourceName); - - if (curval >= 0.0f - && values[j] >= 0.0f) { - basin.setValue(sourceName, - date, (curval + values[j])/ 2); - } else { - basin.setValue(sourceName, - date, values[j]); - } - - } - } else { - basin.setValue(sourceName, date, - values[j]); - } - - j++; - } catch (Exception e) { - break; - } - - } - } else { - for (Long pfaf : map.keySet()) { - try { - FFMPBasin basin = fbd.get(pfaf); - if (basin == null) { - basin = new FFMPBasin(pfaf, - aggregate); - fbd.put(pfaf, basin); - } - - if (basin.contains(date)) { - float curval = basin.getValue(date); - if (curval >= 0.0f - && values[j] >= 0.0f) { - basin.setValue(date, (curval + values[j]) / 2); - } else { - basin.setValue(date, values[j]); - } - } else { - basin.setValue(date, values[j]); - } - j++; - } catch (Exception e) { - break; - } - } - } - } - } - } - } - } - - setBasinData(fbd, huc); - } - - /** - * Gets a single basin out of the dataStore - * - * @param dataStore - * @param huc - */ - public void retrieveBasinFromDataStore(IDataStore dataStore, String uri, - FFMPTemplates template, String huc, Date date, String sourceName, - FFMPBasin basin) { - - FFMPBasinData fbd = null; - - try { - - SourceXML source = FFMPSourceConfigurationManager.getInstance() - .getSource(sourceName); - Long pfaf = basin.getPfaf(); - fbd = getBasinData("ALL", true); - - synchronized (template) { - - for (DomainXML domain : template.getDomains()) { - - LinkedHashMap map = template.getMap(getSiteKey(), - domain.getCwa(), huc); - - if (map != null && map.get(pfaf) != null) { - - int index = 0; - for (Long pfafToCheck : map.keySet()) { - if (pfafToCheck.equals(pfaf)) { - break; - } - index++; - } - - try { - IDataRecord rec = dataStore.retrieve(uri + "/" - + domain.getCwa(), huc, Request - .buildPointRequest(new Point(index, 0))); - - if (rec != null) { - float[] values = ((FloatDataRecord) rec) - .getFloatData(); - - boolean isFFG = false; - - if (source.getSourceType().equals( - SOURCE_TYPE.GUIDANCE.getSourceType())) { - isFFG = true; - } - - if (values != null) { - // System.err.println(sourceName); - if (isFFG) { - ((FFMPGuidanceBasin) basin).setValue( - sourceName, date, values[0]); - } else { - basin.setValue(date, values[0]); - } - } - } - } catch (Throwable e) { - statusHandler.handle(Priority.PROBLEM, - "ERROR Retrieving Map for URI: " + uri - + "..." + huc, e); - } - } - } - } - - setBasinData(fbd, "ALL"); - - } catch (Exception e) { - statusHandler.handle(Priority.ERROR, "ERROR Retrieving HUC..." - + huc); - } - } - - - /** - * Gets the Virtual Hash out of the datastore by HUC - * - * @param dataStore - * @param huc - */ - public void retrieveVirtualBasinFromDataStore(IDataStore dataStore, - String uri, FFMPTemplates template, Date date, FFMPBasin basin) { - FFMPBasinData fbd = null; - try { - boolean aggregate = false; - fbd = getBasinData("ALL", true); - String key = getDataKey(); - - for (DomainXML domain : template.getDomains()) { - - LinkedHashMap lids = template - .getVirtualGageBasins(key, domain.getCwa()); - int size = lids.size(); - - if (size > 0) { - try { - IDataRecord rec = dataStore - .retrieve(uri + "/" + domain.getCwa(), "ALL", - Request.ALL); - - if (rec != null) { - float[] values = ((FloatDataRecord) rec) - .getFloatData(); - if (values != null) { - int j = 0; - - for (Entry entry : lids - .entrySet()) { - FFMPVirtualGageBasinMetaData fvgbmd = entry - .getValue(); - FFMPVirtualGageBasin vgbasin = (FFMPVirtualGageBasin) fbd - .get(fvgbmd.getLookupId()); - if (vgbasin == null) { - vgbasin = new FFMPVirtualGageBasin( - fvgbmd.getLid(), - fvgbmd.getLookupId(), aggregate); - fbd.put(fvgbmd.getLookupId(), vgbasin); - } - vgbasin.setValue(date, values[j]); - j++; - } - } - } - } - - catch (Throwable e) { - statusHandler.handle( - Priority.PROBLEM, - "ERROR Retrieving Virtual ..." - + domain.getCwa() + " : " + "ALL"); - } - } - } - - setBasinData(fbd, "ALL"); - - } catch (Throwable e) { - statusHandler.handle(Priority.ERROR, "ERROR Retrieving Virtual..." - + "ALL"); - } - } - - - /** - * Purges out old data - * - * @param date - */ - public void purgeData(Date date) { - for (String ihuc : hucs) { - FFMPBasinData basinData = getBasinData(ihuc, true); - basinData.purgeData(date); - setBasinData(basinData, ihuc); - } - } - - /** - * Dump cache - */ - public void closeCache() { - getCache().closeCache(); - } - - public String getCacheDir() { - return cacheDir; - } - -} diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java index 399dd1c9fe..bbb8692a15 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java @@ -22,11 +22,14 @@ package com.raytheon.uf.common.dataplugin.ffmp; import java.awt.Point; import java.io.File; import java.io.FileNotFoundException; +import java.lang.ref.WeakReference; import java.util.Date; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import javax.persistence.Column; import javax.persistence.Entity; @@ -37,6 +40,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; + import org.hibernate.annotations.Index; import com.raytheon.uf.common.dataplugin.IDecoderGettable; @@ -57,6 +61,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.time.util.ImmutableDate; /** * Record implementation for FFMP plugin @@ -72,6 +77,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * Feb 28, 2013 1729 dhladky Supressed un-necessary debug loggers * Apr 4, 2013 1846 bkowal Added an index on refTime and forecastTime * Apr 8, 2013 1293 bkowal Removed references to hdffileid. + * April, 9 2013 1890 dhladky Moved dates to referenced map in record rather than multiple dates in FFMPBasin objs. * * * @@ -131,6 +137,8 @@ public class FFMPRecord extends PersistablePluginDataObject @Transient private boolean isRate = false; + + protected static ConcurrentMap> cacheTimes = new ConcurrentHashMap>(); private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(FFMPRecord.class); @@ -384,103 +392,96 @@ public class FFMPRecord extends PersistablePluginDataObject } fbd = getBasinData(huc); + ImmutableDate idate = getCacheDate(date); - synchronized (template) { + SourceXML source = FFMPSourceConfigurationManager.getInstance() + .getSource(sourceName); - SourceXML source = FFMPSourceConfigurationManager.getInstance() - .getSource(sourceName); + for (DomainXML domain : template.getDomains()) { - for (DomainXML domain : template.getDomains()) { - LinkedHashMap map = template.getMap(getSiteKey(), - domain.getCwa(), huc); + LinkedHashMap map = template.getMap(getSiteKey(), domain.getCwa(), huc); - if (map != null && map.keySet().size() > 0) { + if (map != null && !map.isEmpty()) { - IDataRecord rec = null; + IDataRecord rec = null; - try { - rec = dataStore.retrieve(uri + "/" + domain.getCwa(), - huc, Request.ALL); - } catch (Exception e) { - statusHandler.handle(Priority.DEBUG, - "FFMPRecord: no data record for: " + uri + "/" - + domain.getCwa()); - } + try { + rec = dataStore.retrieve(uri + "/" + domain.getCwa(), huc, + Request.ALL); + } catch (Exception e) { + statusHandler.handle(Priority.DEBUG, + "FFMPRecord: no data record for: " + uri + "/" + + domain.getCwa()); + } - if (rec != null) { - float[] values = ((FloatDataRecord) rec).getFloatData(); + if (rec != null) { + float[] values = ((FloatDataRecord) rec).getFloatData(); - int j = 0; - if (values != null) { - // System.err.println(sourceName); - if (source.getSourceType().equals( - SOURCE_TYPE.GUIDANCE.getSourceType())) { - for (Long pfaf : map.keySet()) { - try { - FFMPGuidanceBasin basin = (FFMPGuidanceBasin) fbd - .get(pfaf); + int j = 0; + if (values != null) { + // System.err.println(sourceName); + if (source.getSourceType().equals( + SOURCE_TYPE.GUIDANCE.getSourceType())) { + for (Long pfaf : map.keySet()) { + try { + FFMPGuidanceBasin basin = (FFMPGuidanceBasin) fbd + .get(pfaf); - if (basin == null) { - basin = new FFMPGuidanceBasin(pfaf, - aggregate); - fbd.put(pfaf, basin); - } + if (basin == null) { + basin = new FFMPGuidanceBasin(pfaf, + aggregate); + fbd.put(pfaf, basin); + } - if (basin.containsKey(date, sourceName)) { - if (basin - .getValue(date, sourceName) == FFMPUtils.MISSING - || basin.getValue(date, - sourceName).isNaN()) { + Float curval = basin.getValue(idate, + sourceName); - float curval = basin.getValue( - date, sourceName); + if (curval != FFMPUtils.MISSING + || !curval.isNaN()) { - if (curval >= 0.0f - && values[j] >= 0.0f) { - basin.setValue(sourceName, - date, (curval + values[j])/ 2); - } else { - basin.setValue(sourceName, - date, values[j]); - } - - } - } else { - basin.setValue(sourceName, date, + if (curval >= 0.0f && values[j] >= 0.0f) { + basin.setValue(sourceName, idate, + (curval + values[j]) / 2); + } else if (values[j] >= 0.0f){ + basin.setValue(sourceName, idate, values[j]); - } - - j++; - } catch (Exception e) { - break; + } + // do not overwrite original value + } else { + basin.setValue(sourceName, idate, + values[j]); } + j++; + } catch (Exception e) { + break; } - } else { - for (Long pfaf : map.keySet()) { - try { - FFMPBasin basin = fbd.get(pfaf); - if (basin == null) { - basin = new FFMPBasin(pfaf, - aggregate); - fbd.put(pfaf, basin); - } - if (basin.contains(date)) { - float curval = basin.getValue(date); - if (curval >= 0.0f - && values[j] >= 0.0f) { - basin.setValue(date, (curval + values[j])/ 2);; - } else { - basin.setValue(date, values[j]); - } - } else { - basin.setValue(date, values[j]); - } - j++; - } catch (Exception e) { - break; + } + } else { + for (Long pfaf : map.keySet()) { + try { + FFMPBasin basin = fbd.get(pfaf); + if (basin == null) { + basin = new FFMPBasin(pfaf, aggregate); + fbd.put(pfaf, basin); } + + if (basin.contains(idate)) { + float curval = basin.getValue(idate); + if (curval >= 0.0f && values[j] >= 0.0f) { + basin.setValue(idate, + (curval + values[j]) / 2); + } else if (values[j] >= 0.0f) { + basin.setValue(idate, values[j]); + } // do not overwrite original value + } else { + // no value at time exists, write regardless + basin.setValue(idate, values[j]); + } + j++; + } catch (Exception e) { + break; } } } @@ -488,6 +489,7 @@ public class FFMPRecord extends PersistablePluginDataObject } } } + } /** @@ -504,58 +506,57 @@ public class FFMPRecord extends PersistablePluginDataObject SourceXML source = FFMPSourceConfigurationManager.getInstance() .getSource(sourceName); Long pfaf = basin.getPfaf(); + ImmutableDate idate = getCacheDate(date); - synchronized (template) { + for (DomainXML domain : template.getDomains()) { - for (DomainXML domain : template.getDomains()) { + LinkedHashMap map = template.getMap(getSiteKey(), + domain.getCwa(), huc); - LinkedHashMap map = template.getMap(getSiteKey(), - domain.getCwa(), huc); + if (map != null && map.get(pfaf) != null) { - if (map != null && map.get(pfaf) != null) { - - int index = 0; - for (Long pfafToCheck : map.keySet()) { - if (pfafToCheck.equals(pfaf)) { - break; - } - index++; + int index = 0; + for (Long pfafToCheck : map.keySet()) { + if (pfafToCheck.equals(pfaf)) { + break; } + index++; + } - try { - IDataRecord rec = dataStore.retrieve(uri + "/" - + domain.getCwa(), huc, Request - .buildPointRequest(new Point(index, 0))); + try { + IDataRecord rec = dataStore.retrieve( + uri + "/" + domain.getCwa(), huc, + Request.buildPointRequest(new Point(index, 0))); - if (rec != null) { - float[] values = ((FloatDataRecord) rec) - .getFloatData(); + if (rec != null) { + float[] values = ((FloatDataRecord) rec) + .getFloatData(); - boolean isFFG = false; + boolean isFFG = false; - if (source.getSourceType().equals( - SOURCE_TYPE.GUIDANCE.getSourceType())) { - isFFG = true; - } + if (source.getSourceType().equals( + SOURCE_TYPE.GUIDANCE.getSourceType())) { + isFFG = true; + } - if (values != null) { - // System.err.println(sourceName); - if (isFFG) { - ((FFMPGuidanceBasin) basin).setValue( - sourceName, date, values[0]); - } else { - basin.setValue(date, values[0]); - } + if (values != null) { + // System.err.println(sourceName); + if (isFFG) { + ((FFMPGuidanceBasin) basin).setValue( + sourceName, idate, values[0]); + } else { + basin.setValue(idate, values[0]); } } - } catch (Throwable e) { - statusHandler.handle(Priority.PROBLEM, - "ERROR Retrieving Map for URI: " + uri - + "..." + huc); } + } catch (Throwable e) { + statusHandler.handle(Priority.PROBLEM, + "ERROR Retrieving Map for URI: " + uri + "..." + + huc); } } } + } catch (Exception e) { statusHandler.handle(Priority.ERROR, "ERROR Retrieving HUC..." + huc); @@ -575,56 +576,54 @@ public class FFMPRecord extends PersistablePluginDataObject boolean aggregate = false; fbd = getBasinData(ALL); String key = getDataKey(); + ImmutableDate idate = getCacheDate(date); - synchronized (template) { + for (DomainXML domain : template.getDomains()) { - for (DomainXML domain : template.getDomains()) { + LinkedHashMap lids = template + .getVirtualGageBasins(key, domain.getCwa()); - LinkedHashMap lids = template - .getVirtualGageBasins(key, domain.getCwa()); + if (lids != null) { + int size = lids.size(); - if (lids != null) { - int size = lids.size(); + if (size > 0) { - if (size > 0) { + IDataRecord rec = null; - IDataRecord rec = null; - - try { - rec = dataStore.retrieve( - uri + "/" + domain.getCwa(), ALL, - Request.ALL); - } catch (Exception e) { - // This is a routine error. Sometimes you can not have data for a configured source - // This suppresses spurrious messages that would inflate the loags needlessly. - if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { - statusHandler.handle(Priority.DEBUG, - "FFMPRecord: no data for: " + uri + "/" - + domain.getCwa()); - } + try { + rec = dataStore.retrieve(uri + "/" + domain.getCwa(), + ALL, Request.ALL); + } catch (Exception e) { + // This is a routine error. Sometimes you can not have + // data for a configured source + // This suppresses spurrious messages that would inflate + // the loags needlessly. + if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { + statusHandler.handle(Priority.DEBUG, + "FFMPRecord: no data for: " + uri + "/" + + domain.getCwa()); } + } - if (rec != null) { - float[] values = ((FloatDataRecord) rec) - .getFloatData(); - if (values != null) { - int j = 0; + if (rec != null) { + float[] values = ((FloatDataRecord) rec).getFloatData(); + if (values != null) { + int j = 0; - for (Entry entry : lids - .entrySet()) { - FFMPVirtualGageBasinMetaData fvgbmd = entry - .getValue(); - FFMPVirtualGageBasin vgbasin = (FFMPVirtualGageBasin) fbd - .get(fvgbmd.getLookupId()); - if (vgbasin == null) { - vgbasin = new FFMPVirtualGageBasin( - fvgbmd.getLid(), - fvgbmd.getLookupId(), aggregate); - fbd.put(fvgbmd.getLookupId(), vgbasin); - } - vgbasin.setValue(date, values[j]); - j++; + for (Entry entry : lids + .entrySet()) { + FFMPVirtualGageBasinMetaData fvgbmd = entry + .getValue(); + FFMPVirtualGageBasin vgbasin = (FFMPVirtualGageBasin) fbd + .get(fvgbmd.getLookupId()); + if (vgbasin == null) { + vgbasin = new FFMPVirtualGageBasin( + fvgbmd.getLid(), + fvgbmd.getLookupId(), aggregate); + fbd.put(fvgbmd.getLookupId(), vgbasin); } + vgbasin.setValue(idate, values[j]); + j++; } } } @@ -646,11 +645,11 @@ public class FFMPRecord extends PersistablePluginDataObject boolean aggregate = false; fbd = getBasinData(ALL); String key = getDataKey(); + ImmutableDate idate = getCacheDate(date); for (DomainXML domain : template.getDomains()) { - LinkedHashMap lids = template - .getVirtualGageBasins(key, domain.getCwa()); + LinkedHashMap lids = template.getVirtualGageBasins(key, domain.getCwa()); int size = lids.size(); if (size > 0) { @@ -677,7 +676,7 @@ public class FFMPRecord extends PersistablePluginDataObject fvgbmd.getLookupId(), aggregate); fbd.put(fvgbmd.getLookupId(), vgbasin); } - vgbasin.setValue(date, values[j]); + vgbasin.setValue(idate, values[j]); j++; } } @@ -814,5 +813,45 @@ public class FFMPRecord extends PersistablePluginDataObject setBasinData(basinData, basinData.getHucLevel()); } } + + /** + * Gets and maintains the list of times. This will lesson memory consumption + * because it means all FFMPBasin TreeMap date keys reference back to this + * Hash. Seeing as there are 10000+ of those this will certainly help. + * + * @param date + * @return + */ + protected ImmutableDate getCacheDate(Date date) { + + WeakReference idate = cacheTimes.get(date.getTime()); + ImmutableDate myDate = null; + + if (idate != null) { + myDate = idate.get(); + } + + if (myDate == null) { + long time = date.getTime(); + myDate = new ImmutableDate(time); + idate = new WeakReference(myDate); + cacheTimes.putIfAbsent(time, idate); + } + + return myDate; + } + + + /** + * Populate data from the cache files + * @param basins + * @param hucName + */ + public void populate(FFMPBasinData basins, String hucName) { + + setBasinData(basins, hucName); + //System.out.println("Adding Whole Object Cache Data: "+hucName+" "+getSourceName()); + + } } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java index fefb4571df..ce46c14dac 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java @@ -1274,7 +1274,7 @@ public class FFMPTemplates { * @param huc * @return */ - public LinkedHashMap getMap(String dataKey, String cwa, String huc) { + public synchronized LinkedHashMap getMap(String dataKey, String cwa, String huc) { LinkedHashMap map = null; HashMap> hucMap = null; @@ -1389,7 +1389,7 @@ public class FFMPTemplates { * * @return */ - public LinkedHashMap getVirtualGageBasins( + public synchronized LinkedHashMap getVirtualGageBasins( String dataKey, String cwa) { LinkedHashMap map = null; diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/DatabaseLevelMapping.java b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/DatabaseLevelMapping.java similarity index 89% rename from cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/DatabaseLevelMapping.java rename to edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/DatabaseLevelMapping.java index 592fa8ec11..dbb1cccf24 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/DatabaseLevelMapping.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/DatabaseLevelMapping.java @@ -17,7 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.viz.core.level; +package com.raytheon.uf.common.dataplugin.level.mapping; import java.util.ArrayList; import java.util.List; @@ -33,7 +33,6 @@ import com.raytheon.uf.common.dataplugin.level.LevelFactory; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.viz.core.exception.VizCommunicationException; /** * Class defines a database level @@ -46,6 +45,8 @@ import com.raytheon.uf.viz.core.exception.VizCommunicationException; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 11/16/2008 #3576 rjpeter Initial version + * 04/17/2013 #1913 randerso Moved to common + * * * * @author rjpeter @@ -59,16 +60,16 @@ public class DatabaseLevelMapping { .getHandler(DatabaseLevelMapping.class); @XmlAttribute - private String levelName = null; - - @XmlAttribute - private String levelOneValue = null; + private String unit = null; @XmlAttribute private String levelTwoValue = null; @XmlAttribute - private String unit = null; + private String levelOneValue = null; + + @XmlAttribute + private String levelName = null; public String getLevelName() { return levelName; @@ -102,7 +103,7 @@ public class DatabaseLevelMapping { this.unit = unit; } - public List getLevels() throws VizCommunicationException { + public List getLevels() throws CommunicationException { String[] levelOneValues = new String[0]; String[] levelTwoValues = new String[0]; @@ -145,16 +146,11 @@ public class DatabaseLevelMapping { } // handle any aliasing etc - try { - Level level = LevelFactory.getInstance().getLevel(levelName, - lvl1, lvl2, unit); - if (level != null) { - rval.add(level); - } - } catch (CommunicationException e) { - throw new VizCommunicationException(e); + Level level = LevelFactory.getInstance().getLevel(levelName, lvl1, + lvl2, unit); + if (level != null) { + rval.add(level); } - } return rval; diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMapping.java b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMapping.java similarity index 93% rename from cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMapping.java rename to edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMapping.java index b600ff6501..eb83bcfdf9 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMapping.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMapping.java @@ -18,7 +18,7 @@ * further licensing information. **/ -package com.raytheon.uf.viz.core.level; +package com.raytheon.uf.common.dataplugin.level.mapping; import java.util.ArrayList; import java.util.List; @@ -29,9 +29,9 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.serialization.ISerializableObject; -import com.raytheon.uf.viz.core.exception.VizCommunicationException; /** * Class defines a mapping from a display level to one or more database levels. @@ -46,6 +46,7 @@ import com.raytheon.uf.viz.core.exception.VizCommunicationException; * 11/01/2007 #518 S.Manoj Initial version * 11/16/2009 #3120 rjpeter Modifed to better integrate with level framework. * 11/21/2009 #3576 rjpeter Added group + * 04/17/2013 #1913 randerso Moved to common * * @author smanoj * @version 1.0 @@ -119,7 +120,7 @@ public class LevelMapping implements ISerializableObject { this.databaseLevels = databaseLevels; } - public List getLevels() throws VizCommunicationException { + public List getLevels() throws CommunicationException { if (levelList == null) { List levelList = new ArrayList(); for (DatabaseLevelMapping mapping : databaseLevels) { diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMappingFactory.java b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMappingFactory.java similarity index 85% rename from cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMappingFactory.java rename to edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMappingFactory.java index 234bec3cd1..da3296fa38 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMappingFactory.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMappingFactory.java @@ -17,7 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.viz.core.level; +package com.raytheon.uf.common.dataplugin.level.mapping; import java.io.File; import java.util.Collection; @@ -29,13 +29,13 @@ import java.util.Set; import javax.xml.bind.JAXB; +import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.MasterLevel; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.viz.core.exception.VizCommunicationException; /** * Factory for getting level mappings @@ -49,15 +49,19 @@ import com.raytheon.uf.viz.core.exception.VizCommunicationException; * ------------ ---------- ----------- -------------------------- * 11/16/2009 #3120 rjpeter Initial version * 11/21/2009 #3576 rjpeter Added group capability + * 04/17/2013 #1913 randerso Moved to common * * @author rjpeter * @version 1.0 */ public class LevelMappingFactory { + // TODO: this should move somewhere else + public static final String VOLUMEBROWSER_LEVEL_MAPPING_FILE = "volumebrowser/LevelMappingFile.xml"; + private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(LevelMappingFactory.class); - private static LevelMappingFactory instance = null; + private static Map instanceMap = new HashMap(); private Map keyToLevelMappings = new HashMap(); @@ -69,16 +73,17 @@ public class LevelMappingFactory { private Map>> groupToMasterLevels = new HashMap>>(); - public synchronized static LevelMappingFactory getInstance() { + public synchronized static LevelMappingFactory getInstance(String filePath) { + LevelMappingFactory instance = instanceMap.get(filePath); if (instance == null) { - instance = new LevelMappingFactory(); + instance = new LevelMappingFactory(filePath); + instanceMap.put(filePath, instance); } return instance; } - private LevelMappingFactory() { - File path = PathManagerFactory.getPathManager().getStaticFile( - "volumebrowser/LevelMappingFile.xml"); + private LevelMappingFactory(String filePath) { + File path = PathManagerFactory.getPathManager().getStaticFile(filePath); LevelMappingFile levelMapFile = null; long start = System.currentTimeMillis(); try { @@ -115,7 +120,7 @@ public class LevelMappingFactory { } public LevelMapping getLevelMappingForLevel(Level level) - throws VizCommunicationException { + throws CommunicationException { if (!levelToLevelMappingsInitialized) { initializeLevelToLevelMappings(); } @@ -126,7 +131,7 @@ public class LevelMappingFactory { return keyToLevelMappings.values(); } - public Set getAllLevels() throws VizCommunicationException { + public Set getAllLevels() throws CommunicationException { if (!levelToLevelMappingsInitialized) { initializeLevelToLevelMappings(); } @@ -134,15 +139,14 @@ public class LevelMappingFactory { } public Map> getLevelMapForGroup(String group) - throws VizCommunicationException { + throws CommunicationException { if (!groupToMasterLevelsInitialized) { initializeGroupToMasterLevels(); } return groupToMasterLevels.get(group); } - private void initializeLevelToLevelMappings() - throws VizCommunicationException { + private void initializeLevelToLevelMappings() throws CommunicationException { for (LevelMapping mapping : keyToLevelMappings.values()) { String group = mapping.getGroup(); @@ -165,8 +169,7 @@ public class LevelMappingFactory { levelToLevelMappingsInitialized = true; } - private void initializeGroupToMasterLevels() - throws VizCommunicationException { + private void initializeGroupToMasterLevels() throws CommunicationException { for (LevelMapping mapping : keyToLevelMappings.values()) { String group = mapping.getGroup(); Map> masterLevels = null; diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMappingFile.java b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMappingFile.java similarity index 91% rename from cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMappingFile.java rename to edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMappingFile.java index 53021b9f09..5aac577271 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/level/LevelMappingFile.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMappingFile.java @@ -18,7 +18,7 @@ * further licensing information. **/ -package com.raytheon.uf.viz.core.level; +package com.raytheon.uf.common.dataplugin.level.mapping; import java.util.ArrayList; import java.util.List; @@ -44,6 +44,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject; * ------------ ---------- ----------- -------------------------- * 11/01/2007 #518 S.Manoj Initial version * 11/16/2009 #3120 rjpeter Refactored to use factory and level mapping. + * 04/17/2013 #1913 randerso Moved to common * * @author smanoj * @version 1.0 @@ -56,7 +57,7 @@ public class LevelMappingFile implements ISerializableObject { STANDARD, COMPOSITE, BINARY, XSECT, TSECT, VRTGPH, DIAGRAM, ALL, SURFACE }; - @XmlElements( { @XmlElement(name = "Level", type = LevelMapping.class) }) + @XmlElements({ @XmlElement(name = "Level", type = LevelMapping.class) }) private List levelMappingFile; public List getLevelMappingFile() { diff --git a/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/FileLocker.java b/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/FileLocker.java index e71e9d5574..a85aa671dc 100644 --- a/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/FileLocker.java +++ b/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/FileLocker.java @@ -29,10 +29,8 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import com.raytheon.uf.common.localization.exception.LocalizationException; import com.raytheon.uf.common.status.UFStatus; @@ -51,8 +49,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jun 23, 2011 mschenke Initial creation - * + * Jun 23, 2011 mschenke Initial creation + * Apr 12, 2013 1903 rjpeter Fix allocateLock freezing out other lock requests. * * * @author mschenke @@ -64,14 +62,26 @@ public class FileLocker { private static class LockWaiter { } + private static enum LockState { + ACQUIRING, IN_USE, RELEASED + } + private static class LockedFile { - Type lockType; + final Type lockType; - Thread lockingThread; + final Thread lockingThread; - Set lockers = new HashSet(); + final List lockers = new ArrayList(); File lockFile; + + LockState lockState = LockState.ACQUIRING; + + LockedFile(Thread thread, Type type, Object locker) { + lockType = type; + lockingThread = thread; + lockers.add(locker); + } } public static enum Type { @@ -81,10 +91,10 @@ public class FileLocker { private static final int MAX_WAIT = 30 * 1000; /** Map of waiters on threads */ - private Map> waiters = new HashMap>(); + private final Map> waiters = new HashMap>(); /** Map of locks we have on files */ - private Map locks = new HashMap(); + private final Map locks = new HashMap(); /** Singleton instance of FileLocker class */ private static FileLocker instance = new FileLocker(); @@ -181,22 +191,27 @@ public class FileLocker { synchronized (locks) { lock = locks.get(file); if (lock == null) { - lock = new LockedFile(); + lock = new LockedFile(myThread, type, locker); locks.put(file, lock); grabbedLock = true; } } - synchronized (lock) { - if (grabbedLock) { - // We were able to grab the lock file ourselves - return allocateLock(locker, file, type, myThread, lock); - } else if (lock.lockingThread == myThread - || (type == lock.lockType && type == Type.READ)) { - // Locked on same thread to avoid indefinite waiting. If - // there are issues on how locked, they will be known - lock.lockers.add(locker); - return true; + if (grabbedLock) { + // We were able to grab the lock file ourselves + return allocateLock(file, lock); + } else { + synchronized (lock) { + // if the lock file has been obtained and either the thread is + // the same as the one that obtained the lock or the original + // lock and this request are both read locks + if ((lock.lockState == LockState.IN_USE) + && ((lock.lockingThread == myThread) || ((type == Type.READ) && (type == lock.lockType)))) { + // TODO: This is not safe as another thread could have a + // read lock and we may clobber the read + lock.lockers.add(locker); + return true; + } } } @@ -216,83 +231,121 @@ public class FileLocker { lws.add(waiter); } - while (true) { - // Sleep - try { - Thread.sleep(10); - } catch (InterruptedException e) { - // Ignore - } + boolean waiterRemoved = false; - grabbedLock = false; - synchronized (locks) { - lock = locks.get(file); - if (lock == null) { - // File ready for grabbing - synchronized (lws) { - if (lws.peek() == waiter) { - lws.poll(); - lock = new LockedFile(); - locks.put(file, lock); - grabbedLock = true; + try { + while (true) { + // Sleep + try { + Thread.sleep(10); + } catch (InterruptedException e) { + // Ignore + } + + grabbedLock = false; + synchronized (locks) { + lock = locks.get(file); + if (lock == null) { + // File ready for grabbing + synchronized (lws) { + if (lws.peek() == waiter) { + lws.poll(); + waiterRemoved = true; + lock = new LockedFile(myThread, type, + locker); + locks.put(file, lock); + grabbedLock = true; + } } } - } else if (lock.lockFile != null) { + } + + if (grabbedLock) { + // We were able to grab the lock file ourselves + return allocateLock(file, lock); + } else if (lock != null) { synchronized (lock) { - if ((System.currentTimeMillis() - lock.lockFile - .lastModified()) > MAX_WAIT) { - System.err - .println("Releasing lock since: " - + "Lock has been allocated for more than " - + (MAX_WAIT / 1000) + "s"); - locks.remove(file); + switch (lock.lockState) { + case IN_USE: + if ((type == Type.READ) + && (type == lock.lockType)) { + // A different waiter grabbed it for + // reading, we can read it also + lock.lockers.add(locker); + return true; + } else { + long curTime = System.currentTimeMillis(); + long lastMod = lock.lockFile.lastModified(); + if ((curTime - lastMod) > MAX_WAIT) { + System.err + .println("Releasing lock: " + + "Lock has been allocated for " + + ((curTime - lastMod) / 1000) + + "s on file " + + file.getPath()); + locks.remove(file); + } + } + break; + // ACUIRING - NOOP wait for lock to be acquired + // RELEASED - loop again and check if next waiter } } } } - if (grabbedLock) { - // We were able to grab the lock file ourselves - allocateLock(locker, file, type, myThread, lock); - return true; + } finally { + if (!waiterRemoved) { + synchronized (lws) { + lws.remove(waiter); + } } } } + return false; } private void unlockInternal(Object locker, File file) { try { + boolean fileUnlocked = false; LockedFile lock = null; // Get the Lock synchronized (locks) { lock = locks.get(file); - // Return early if we never locked or have already been - // unlocked - if (lock == null - || (locker != null && lock.lockers.contains(locker) == false)) { + // Return early if we have never locked + if ((lock == null) || (locker == null)) { return; } } - // Lock has locker and is not null synchronized (lock) { - lock.lockers.remove(locker); - if (lock.lockers.size() == 0) { - // No more lockers, remove lock and release - locks.remove(file); - unallocateLock(lock); + if (lock.lockState == LockState.IN_USE) { + lock.lockers.remove(locker); + + if (lock.lockers.isEmpty()) { + // No more lockers, remove lock and release + lock.lockState = LockState.RELEASED; + unallocateLock(lock); + fileUnlocked = true; + } } } - // Check for waiters on the file - synchronized (waiters) { - Deque lws = waiters.get(file); - if (lws == null) { - waiters.remove(file); - } else { - synchronized (lws) { - if (lws.size() == 0) { - waiters.remove(file); + if (fileUnlocked) { + synchronized (locks) { + locks.remove(file); + } + + // Check for waiters on the file + synchronized (waiters) { + Deque lws = waiters.get(file); + if (lws == null) { + waiters.remove(file); + } else { + synchronized (lws) { + if (lws.isEmpty()) { + waiters.remove(file); + } } } } @@ -307,20 +360,13 @@ public class FileLocker { * Function to actually allocate the lock, this needs to be cross process * aware and wait until other processes are finished with the file * - * @param locker * @param file - * @param type - * @param thread + * @param lock * @return * @throws FileNotFoundException * @throws IOException */ - private boolean allocateLock(Object locker, File file, Type type, - Thread thread, LockedFile lock) { - // Set tht thread of the lock and add lock allocator - lock.lockingThread = Thread.currentThread(); - lock.lockers.add(locker); - + private boolean allocateLock(File file, LockedFile lock) { // Get the lock directory, make sure it is not already taken File parentDir = file.getParentFile(); @@ -333,23 +379,40 @@ public class FileLocker { boolean gotLock = false; File lockFile = new File(parentDir, "." + file.getName() + "_LOCK"); try { - long waitInterval = 500; - long tryCount = MAX_WAIT / waitInterval; + // start with a moderate wait + long waitInterval = 100; + long curTime = System.currentTimeMillis(); + long maxWaitTime = curTime + MAX_WAIT; long fileTime; - for (int i = 0; !gotLock && i < tryCount; ++i) { + while ((curTime = System.currentTimeMillis()) < maxWaitTime) { gotLock = lockFile.createNewFile() - || ((fileTime = lockFile.lastModified()) > 0 && (System - .currentTimeMillis() - fileTime) > MAX_WAIT); - if (!gotLock) { + || (((fileTime = lockFile.lastModified()) > 0) && ((curTime - fileTime) > MAX_WAIT)); + + if (gotLock) { + break; + } else { try { Thread.sleep(waitInterval); } catch (InterruptedException e) { // Ignore } + + // every wait reduces the next wait down to minimum wait of + // 10 milliseconds + if (waitInterval > 10) { + waitInterval -= 10; + } } } } catch (IOException e) { - e.printStackTrace(); + UFStatus.getHandler().handle(Priority.PROBLEM, + "Error obtaining file lock: " + file, e); + } finally { + synchronized (lock) { + lock.lockFile = lockFile; + lock.lockFile.setLastModified(System.currentTimeMillis()); + lock.lockState = LockState.IN_USE; + } } if (!gotLock) { @@ -357,14 +420,14 @@ public class FileLocker { + ", returning anyway"); Thread.dumpStack(); } - lockFile.setLastModified(System.currentTimeMillis()); - lock.lockFile = lockFile; + return gotLock; } private void unallocateLock(LockedFile lock) throws IOException { if (lock.lockFile != null) { lock.lockFile.delete(); + lock.lockFile = null; } } @@ -381,8 +444,8 @@ public class FileLocker { String arg = args[i]; if (arg.startsWith("-")) { // we have a key - if (args.length > (i + 1) - && args[i + 1].startsWith("-") == false) { + if ((args.length > (i + 1)) + && (args[i + 1].startsWith("-") == false)) { argumentMap.put(arg.substring(1), args[i + 1]); ++i; } else { @@ -398,12 +461,13 @@ public class FileLocker { String fileToLock = argumentMap.get("f"); String threads = argumentMap.get("tc"); final boolean verbose = argumentMap.get("v") != null; - final boolean verboseCount = argumentMap.get("vc") != null || verbose; - final boolean verboseErrors = argumentMap.get("ve") != null || verbose; + final boolean verboseCount = (argumentMap.get("vc") != null) || verbose; + final boolean verboseErrors = (argumentMap.get("ve") != null) + || verbose; String outputAtCount = argumentMap.get("c"); String iterVal = argumentMap.get("i"); - if (fileToLock == null || argumentMap.get("help") != null) { + if ((fileToLock == null) || (argumentMap.get("help") != null)) { System.out.println("Required argument -f " + " specifies the file to use in the program"); System.out.println("-help prints out this help message"); @@ -458,6 +522,7 @@ public class FileLocker { final int[] errors = new int[1]; final File toLock = new File(fileToLock); List runnables = new ArrayList(threadCount); + final Object lockObj = new Object(); final int[] i = { 0 }; for (int j = 1; j <= threadCount; ++j) { @@ -474,8 +539,8 @@ public class FileLocker { System.out.flush(); } threadArgs = "rw"; - } else if (threadArgs.contains("r") == false - && threadArgs.contains("w") == false) { + } else if ((threadArgs.contains("r") == false) + && (threadArgs.contains("w") == false)) { System.err.println("Error parsing thread " + j + " arguments (" + threadArgs + "), defaulting to rw"); System.err.flush(); @@ -496,7 +561,7 @@ public class FileLocker { @Override public void run() { try { - if (FileLocker.lock(this, toLock, write ? Type.WRITE + if (FileLocker.lock(lockObj, toLock, write ? Type.WRITE : Type.READ)) { boolean canRead = true; if (toLock.exists() == false) { @@ -578,7 +643,7 @@ public class FileLocker { t.printStackTrace(); } } finally { - FileLocker.unlock(this, toLock); + FileLocker.unlock(lockObj, toLock); } } }); @@ -586,7 +651,7 @@ public class FileLocker { int totalErrors = 0; int count = 0; - while (iterations == null || i[0] < iterations) { + while ((iterations == null) || (i[0] < iterations)) { List threadList = new ArrayList(threadCount); for (Runnable r : runnables) { threadList.add(new Thread(r)); @@ -610,7 +675,8 @@ public class FileLocker { ++count; // Output at -c val if we are verbose or indefinitely looping - if (count == outputCountAt && (verboseCount || iterations == null)) { + if ((count == outputCountAt) + && (verboseCount || (iterations == null))) { PrintStream out = errors[0] > 0 ? System.err : System.out; out.println("Completed " + count + " iterations with " + errors[0] + " errors"); @@ -621,7 +687,7 @@ public class FileLocker { } } - if (i[0] % outputCountAt != 0 || !verboseCount) { + if ((i[0] % outputCountAt != 0) || !verboseCount) { totalErrors += errors[0]; PrintStream out = totalErrors > 0 ? System.err : System.out; out.println("Completed " + i[0] + " iterations with " + totalErrors diff --git a/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/LocalizationFile.java b/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/LocalizationFile.java index 08b78508a8..4752991678 100644 --- a/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/LocalizationFile.java +++ b/edexOsgi/com.raytheon.uf.common.localization/src/com/raytheon/uf/common/localization/LocalizationFile.java @@ -83,6 +83,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * localization performance but caused updated * files on the server not to be retrieved. * Jan 17, 2013 1412 djohnson Add jaxbMarshal. + * Apr 12, 2013 1903 rjpeter Updated getFile to check parentFile for existence. * * * @author njensen @@ -283,7 +284,7 @@ public final class LocalizationFile implements Comparable { adapter.retrieve(this); } - if ((isDirectory == false) && !file.exists()) { + if ((isDirectory == false) && !file.getParentFile().exists()) { try { file.getParentFile().mkdirs(); } catch (Throwable t) { @@ -647,7 +648,8 @@ public final class LocalizationFile implements Comparable { * @param jaxbManager * the jaxbManager */ - public void jaxbMarshal(Object obj, JAXBManager jaxbManager) throws LocalizationException{ + public void jaxbMarshal(Object obj, JAXBManager jaxbManager) + throws LocalizationException { try { String xml = jaxbManager.marshalToXml(obj); write(xml.getBytes()); diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/TimeRange.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/TimeRange.java index 5da7b72323..c8de72145f 100644 --- a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/TimeRange.java +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/TimeRange.java @@ -54,6 +54,8 @@ import com.raytheon.uf.common.time.util.TimeUtil; * 02/27/2008 879 rbell Added compareTo(TimeRange) * 03/20/2013 #1774 randerso Changed toString to display times even when * duration is 0, use TimeUtil constants. + * 04/04/2013 #1787 randerso Removed a bunch of isValid checks to the logic + * works as intended by the original A1 implementation. * * * @@ -64,7 +66,7 @@ import com.raytheon.uf.common.time.util.TimeUtil; * starting/ending time, or a time and a duration. If the duration is positive * (or zero), then the specified time is the start time. If the duration is * negative, then the specified time is the end time as shown in the design - * document*. + * document. * * TimeRanges are generally used to define a valid time range for data files. * TimeRange components (start time, end time, and duration) may be retrieved. @@ -314,11 +316,7 @@ public class TimeRange implements Serializable, Comparable, * @return the duration */ public long getDuration() { - if (isValid()) { - return end.getTime() - start.getTime(); - } else { - return 0L; - } + return end.getTime() - start.getTime(); } /* @@ -368,16 +366,13 @@ public class TimeRange implements Serializable, Comparable, * @return */ public boolean contains(Date time) { - if (!this.isValid()) { - return false; - } - if (getDuration() != 0) { + // the end time is not part of the time range (hence the < operator) return time.getTime() >= start.getTime() && time.getTime() < end.getTime(); } else { - return time.equals(start); // Special case for zero duration time - // range + // Special case for zero duration time range + return time.equals(start); } } @@ -388,7 +383,14 @@ public class TimeRange implements Serializable, Comparable, * @param time * the time to be included */ + @Deprecated public void extend(Date time) { + // TODO: remove this method as it is the only method other than the + // setters required for dynamic serialization that modify a TimeRange + // The original intent was for this class to be immutable. + // I found no Java code calling this method but it's difficult to + // determine if it's called from Python since extend is a build in + // method on lists if (!this.isValid()) { return; } @@ -409,10 +411,6 @@ public class TimeRange implements Serializable, Comparable, * @return true if a time range is contained within the range */ public boolean contains(TimeRange timeRange) { - if (!this.isValid()) { - return false; - } - if (getDuration() == 0) { return this.equals(timeRange); } else if (timeRange.getDuration() == 0) { @@ -433,10 +431,6 @@ public class TimeRange implements Serializable, Comparable, * @return true if the time ranges are adjacent */ public boolean isAdjacentTo(TimeRange timeRange) { - if (!this.isValid()) { - return false; - } - return start.equals(timeRange.end) || end.equals(timeRange.start); } @@ -452,10 +446,6 @@ public class TimeRange implements Serializable, Comparable, * @return true if the time range overlaps */ public boolean overlaps(TimeRange timeRange) { - if (!this.isValid()) { - return false; - } - if (timeRange.contains(start) || contains(timeRange.getStart())) { return true; } else { @@ -555,9 +545,6 @@ public class TimeRange implements Serializable, Comparable, */ @Override public TimeRange clone() { - if (!this.isValid()) { - return new TimeRange(); - } return new TimeRange(this.start, this.end); }