From 494fbe93db0a00844cd3b98cb1698141898696ed Mon Sep 17 00:00:00 2001 From: David Gillingham Date: Mon, 5 Mar 2012 11:23:11 -0600 Subject: [PATCH] Issue #354: Refactor AbstractParmManager to better handle ISC parm pre-loading. Former-commit-id: e2c66b33fd8c71b0da6518c419296ab8141a07e3 --- .../raytheon/viz/gfe/core/ISCParmInitJob.java | 81 ------------------ .../core/internal/AbstractParmManager.java | 84 +++++++++++++------ 2 files changed, 60 insertions(+), 105 deletions(-) delete mode 100644 cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISCParmInitJob.java diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISCParmInitJob.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISCParmInitJob.java deleted file mode 100644 index e0cbe2d7fa..0000000000 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISCParmInitJob.java +++ /dev/null @@ -1,81 +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.viz.gfe.core; - -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; - -import com.raytheon.viz.gfe.core.parm.Parm; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Dec 5, 2011            dgilling     Initial creation
- * 
- * 
- * - * @author dgilling - * @version 1.0 - */ - -public class ISCParmInitJob extends Job { - - private DataManager dataMgr; - - private List parms; - - public ISCParmInitJob(DataManager dataMgr, Parm[] parmList) { - super("GFE ISC Parm initialization"); - setSystem(true); - this.dataMgr = dataMgr; - this.parms = Arrays.asList(parmList); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime. - * IProgressMonitor) - */ - @Override - protected IStatus run(IProgressMonitor monitor) { - IISCDataAccess iscAccess = dataMgr.getIscDataAccess(); - for (Parm parm : parms) { - if (!monitor.isCanceled()) { - iscAccess.getISCParm(parm); - } else { - return Status.CANCEL_STATUS; - } - } - - return Status.OK_STATUS; - } -} diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractParmManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractParmManager.java index fe06f8d742..5178892fd4 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractParmManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractParmManager.java @@ -62,7 +62,6 @@ import com.raytheon.viz.gfe.GFEServerException; import com.raytheon.viz.gfe.PythonPreferenceStore; import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.core.IParmManager; -import com.raytheon.viz.gfe.core.ISCParmInitJob; import com.raytheon.viz.gfe.core.internal.NotificationRouter.AbstractGFENotificationObserver; import com.raytheon.viz.gfe.core.msgs.IAvailableSourcesChangedListener; import com.raytheon.viz.gfe.core.msgs.IDisplayedParmListChangedListener; @@ -90,6 +89,9 @@ import com.raytheon.viz.gfe.core.parm.vcparm.VCModule; * 02/23/2012 #346 dgilling Ensure all Parms are disposed when calling * dispose method. * 03/01/2012 #346 dgilling Use identity-based ListenerLists. + * 03/01/2012 #354 dgilling Modify setParms to always load (but not + * necessarily display) the ISC parms that + * correspond to a visible mutable parm. * * * @@ -240,8 +242,6 @@ public abstract class AbstractParmManager implements IParmManager { private AbstractGFENotificationObserver siteActivationListener; - private ISCParmInitJob iscInit; - private JobPool notificationPool; protected AbstractParmManager(final DataManager dataManager) { @@ -417,10 +417,6 @@ public abstract class AbstractParmManager implements IParmManager { module.dispose(); } - if (iscInit != null) { - iscInit.cancel(); - } - notificationPool.cancel(); } @@ -776,15 +772,46 @@ public abstract class AbstractParmManager implements IParmManager { return ret; } - // -- private - // ---------------------------------------------------------------- - // ParmMgr::setParmsDependencies() - // Helper function for setParms(). Takes the toBeLoaded, addedParms, - // removeParms, and modParms lists, calculates dependencies, and then - // returns the updated lists through the calling arguments. - // -- implementation - // --------------------------------------------------------- - // --------------------------------------------------------------------------- + /** + * Helper function for setParms. Takes the toBeLoaded and + * removeParms lists, calculates non-visible ISC dependencies, and then + * returns the updated lists through the calling arguments. + * + * @param toBeLoaded + * @param removeParms + */ + private void setParmsRemoveISCDeps(List toBeLoaded, + Collection removeParms) { + List removeList = new ArrayList(removeParms); + + for (int i = 0; i < removeList.size(); i++) { + List depParms = dependentParms(removeList.get(i), true); + for (ParmID pid : depParms) { + int index = pivdIndex(toBeLoaded, pid); + if ((index != -1) && (!toBeLoaded.get(index).isVisible())) { + removeList.add(toBeLoaded.get(index).getParmID()); + toBeLoaded.remove(index); + } + } + } + + for (ParmID pid : removeList) { + if (!removeParms.contains(pid)) { + removeParms.add(pid); + } + } + } + + /** + * Helper function for setParms. Takes the toBeLoaded, + * addedParms, removeParms, and modParms lists, calculates dependencies, and + * then returns the updated lists through the calling arguments. + * + * @param toBeLoaded + * @param addParms + * @param removeParms + * @param modParms + */ private void setParmsDependencies(List toBeLoaded, Collection addParms, Collection removeParms, Collection modParms) { @@ -793,8 +820,13 @@ public abstract class AbstractParmManager implements IParmManager { // non-displayed. If any are missing from the "tobeloaded", then // add them as undisplayed. for (int i = 0; i < toBeLoaded.size(); i++) { + // Here's a derivation from AWIPS1... + // We've hard-coded the third parameter in the dependentParms() call + // to true so that the ISC parms that correspond to the visible + // mutable parms are always loaded in the ParmManager. This was + // found to significantly improve performance when loading ISC data. List depParms = dependentParms(toBeLoaded.get(i) - .getParmID(), iscMode()); + .getParmID(), true); for (ParmID depParm : depParms) { // if not present, then add it to "tobeloaded" list @@ -934,6 +966,16 @@ public abstract class AbstractParmManager implements IParmManager { toBeLoaded = setParmsMakeParmIDVisDep(addParms, modParms, removeParms); + // Here's a derivation from AWIPS1... + // We've modified setParmsDependencies to always ensure that the ISC + // parms that correspond to parms from the mutable database are + // always loaded (but not necessary visible) in the ParmManager. + // However, this change made it impossible to unload parms if they + // were a dependency to an invisible VCParm. Hence, this new + // function was added which removes the mutable parm and the ISC + // parm(s) if none of them should be visible. + setParmsRemoveISCDeps(toBeLoaded, removeParms); + // statusHandler.debug("PASS " + (i + 1) // + " toBeLoaded before dependencies=" // + toBeLoaded.toString()); @@ -1164,12 +1206,6 @@ public abstract class AbstractParmManager implements IParmManager { } setParms(addParms, deletions); - if (iscInit != null) { - iscInit.cancel(); - } - iscInit = new ISCParmInitJob(dataManager, getDisplayedParms()); - iscInit.schedule(); - return; } @@ -1187,7 +1223,7 @@ public abstract class AbstractParmManager implements IParmManager { Collection modParms, Collection removeParms) { // only try to unload old undisplayed, if there are already parms // being removed. - if (removeParms.size() == 0) { + if (removeParms.isEmpty()) { return; }