From ecf47b4586a17c8bb411b65adae0ff2c2e86bbba Mon Sep 17 00:00:00 2001 From: Max Schenkelberg Date: Wed, 17 Jul 2013 16:04:23 -0500 Subject: [PATCH] Issue #2156 added orphan checking to time match basis on time match and set to null if not on any descriptor Amend: Accepted ticket Change-Id: I27df5b96cc411bb3b48850e3c6fb1ee862dbd760 Former-commit-id: bb531196787bd153f5944a123ace00a6a6216882 [formerly 7f94b93c841785f9a3ff3c564bee74d6e2ab2457] [formerly 29943f945c551dfda591a4056ab11390ddc080c8 [formerly 782a1b71f83ee3d0db7b7df82eecabe7f7fecd4f]] Former-commit-id: 29943f945c551dfda591a4056ab11390ddc080c8 Former-commit-id: a2210eebf92c4834e1c2c83fee60fdecaf049aa0 --- .../uf/viz/d2d/core/time/D2DTimeMatcher.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/time/D2DTimeMatcher.java b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/time/D2DTimeMatcher.java index 6b5ca44255..6595e62312 100644 --- a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/time/D2DTimeMatcher.java +++ b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/time/D2DTimeMatcher.java @@ -104,7 +104,6 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { /** The number of frames time matched against */ private int lastFrameCount; - public DataTime[] getLastBaseTimes() { return lastBaseTimes; } @@ -195,6 +194,32 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { } } + /** + * Checks if a resource is contained in the {@link IResourceGroup} + * recursively checking for {@link IResourceGroup}s in the group's list + * + * @param group + * @param resource + * @return + */ + private boolean contained(IResourceGroup group, + AbstractVizResource resource) { + ResourceList list = group.getResourceList(); + if (list.containsRsc(resource)) { + return true; + } else { + for (ResourcePair rp : list) { + if (rp.getResourceData() instanceof IResourceGroup) { + if (contained((IResourceGroup) rp.getResourceData(), + resource)) { + return true; + } + } + } + } + return false; + } + /* * (non-Javadoc) * @@ -205,8 +230,13 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { synchronized (this) { if (timeMatchBasis != null) { IDescriptor tmDescriptor = timeMatchBasis.getDescriptor(); - if (tmDescriptor != null && tmDescriptor != descriptor) { - redoTimeMatching(timeMatchBasis.getDescriptor()); + if (tmDescriptor != null) { + if (tmDescriptor != descriptor) { + redoTimeMatching(tmDescriptor); + } else if (contained(tmDescriptor, timeMatchBasis) == false) { + // Checks to ensure the timeMatchBasis is not "orphaned" + timeMatchBasis = null; + } } } FramesInfo currInfo = descriptor.getFramesInfo(); @@ -499,7 +529,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { DataTime[] times = makeEmptyLoadList(numberOfFrames, rsc); if (times != null) { TimeCache cache = getTimeCache(rsc); - synchronized(cache){ + synchronized (cache) { cache.setTimes(null, times, numberOfFrames); } return times;