Omaha #4246 Changes to support VCModules at base, site, and user levels
Change-Id: I995ad5c185ec8c5f0056f28f7e2e1c5b5d7395fc Former-commit-id:6731ad4200
[formerly 33c2ab1111deb0ede6a3196d889475bc69dd63d4] Former-commit-id:61cb550ad4
This commit is contained in:
parent
6dd691c77a
commit
e652eefaf5
6 changed files with 63 additions and 26 deletions
|
@ -20,7 +20,6 @@
|
|||
|
||||
package com.raytheon.viz.gfe.core.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -53,6 +52,8 @@ import com.raytheon.uf.common.dataplugin.gfe.server.notify.GridUpdateNotificatio
|
|||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.LockNotification;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
|
@ -146,6 +147,7 @@ import com.raytheon.viz.gfe.types.MutableInteger;
|
|||
* 10/08/2014 #3684 randerso Minor code optimization
|
||||
* 10/30/2014 #3775 randerso Changed to createMutableDb before getting initial database inventory
|
||||
* 01/13/2015 #3955 randerso Changed getProductDatabase() to return mutableDb for EditTopo
|
||||
* 03/12/2015 #4246 randerso Changes to support VCModules at base, site, and user levels
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -3093,30 +3095,52 @@ public class ParmManager implements IParmManager, IMessageClient {
|
|||
private List<VCModule> initVirtualCalcParmDefinitions() {
|
||||
// retrieve the inventory from the ifpServer
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationFile[] modules = pathMgr.listStaticFiles(
|
||||
LocalizationType.COMMON_STATIC,
|
||||
FileUtil.join("gfe", "vcmodule"), new String[] { "py" }, false,
|
||||
true);
|
||||
LocalizationContext[] contexts = new LocalizationContext[] {
|
||||
pathMgr.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.BASE),
|
||||
pathMgr.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.SITE),
|
||||
pathMgr.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.USER) };
|
||||
|
||||
List<VCModule> definitions = new ArrayList<VCModule>(modules.length);
|
||||
for (LocalizationFile mod : modules) {
|
||||
Map<String, LocalizationFile> modMap = new HashMap<>();
|
||||
for (LocalizationContext context : contexts) {
|
||||
LocalizationFile[] files = pathMgr.listFiles(context,
|
||||
FileUtil.join("gfe", "vcmodule"), new String[] { "py" },
|
||||
false, true);
|
||||
for (LocalizationFile lf : files) {
|
||||
try {
|
||||
String modName = lf.getFile(false).getName()
|
||||
.split("\\.(?=[^\\.]+$)")[0];
|
||||
modMap.put(modName, lf);
|
||||
} catch (LocalizationException e) {
|
||||
statusHandler.error(
|
||||
"Error getting local file name for VCModule " + lf,
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<VCModule> definitions = new ArrayList<VCModule>(modMap.size());
|
||||
for (Entry<String, LocalizationFile> entry : modMap.entrySet()) {
|
||||
String modName = entry.getKey();
|
||||
LocalizationFile modFile = entry.getValue();
|
||||
try {
|
||||
// gets the module from the ifpServer
|
||||
File textData = mod.getFile(true);
|
||||
modFile.getFile(true);
|
||||
|
||||
// create the VCModule
|
||||
statusHandler.debug("Loading VCModule: " + mod);
|
||||
VCModule m = new VCModule(dataManager, this, textData);
|
||||
statusHandler.debug("Loading VCModule: " + modFile);
|
||||
VCModule m = new VCModule(dataManager, this, modName);
|
||||
if (!m.isValid()) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error creating VCModule " + textData.getPath(),
|
||||
statusHandler.error("Error creating VCModule " + modFile,
|
||||
m.getErrorString());
|
||||
continue;
|
||||
}
|
||||
definitions.add(m);
|
||||
} catch (LocalizationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to retrieve VCMODULE " + mod.toString(), e);
|
||||
"Unable to retrieve VCMODULE " + modFile.toString(), e);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.viz.gfe.core.parm.vcparm;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -74,6 +73,7 @@ import com.raytheon.viz.gfe.core.parm.Parm;
|
|||
* performance.
|
||||
* Jan 22, 2013 #1515 dgilling Fix ClassCastException in
|
||||
* getMethodArgs().
|
||||
* Mar 12, 2015 #4246 randerso Changes to support VCModules at base, site, and user levels
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -161,10 +161,11 @@ public class VCModule {
|
|||
|
||||
private String id;
|
||||
|
||||
public VCModule(DataManager dataMgr, IParmManager parmMgr, final File module) {
|
||||
public VCModule(DataManager dataMgr, IParmManager parmMgr,
|
||||
final String module) {
|
||||
this.dataMgr = dataMgr;
|
||||
this.parmMgr = parmMgr;
|
||||
this.id = module.getName().split("\\.(?=[^\\.]+$)")[0];
|
||||
this.id = module;
|
||||
this.depParms = Collections.emptyList();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.raytheon.viz.gfe.core.DataManager;
|
|||
* Jan 08, 2013 1486 dgilling Support changes to BaseGfePyController.
|
||||
* Oct 14, 2014 3676 njensen Removed decodeGD(GridType) since it was
|
||||
* a copy of getNumpyResult()
|
||||
* Mar 12, 2015 #4246 randerso Changes to support VCModules at base, site, and user levels
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -72,7 +73,7 @@ public class VCModuleController extends BaseGfePyController {
|
|||
* the Java classloader to use for importing Java classes inside
|
||||
* python
|
||||
* @param dataMgr
|
||||
* TODO
|
||||
* the data manager for this gfe instance
|
||||
* @throws JepException
|
||||
*/
|
||||
protected VCModuleController(String aFilePath, String anIncludePath,
|
||||
|
@ -80,7 +81,8 @@ public class VCModuleController extends BaseGfePyController {
|
|||
super(aFilePath, anIncludePath, aClassLoader, dataMgr, CLASS_NAME);
|
||||
this.tempGridNames = new ArrayList<String>();
|
||||
|
||||
String scriptPath = GfePyIncludeUtil.getVCModulesIncludePath();
|
||||
String scriptPath = GfePyIncludeUtil.getVCModulesIncludePath(dataMgr
|
||||
.getSiteID());
|
||||
jep.eval(INTERFACE + " = VCModuleInterface('" + scriptPath + "')");
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.raytheon.viz.gfe.core.DataManager;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 20, 2011 dgilling Initial creation
|
||||
* Jul 08, 2014 3361 njensen Only build include path once
|
||||
* Mar 12, 2015 4246 randerso Changes to support VCModules at base, site, and user levels
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -74,10 +75,10 @@ public class VCModuleControllerFactory {
|
|||
throws JepException {
|
||||
synchronized (VCModuleController.class) {
|
||||
if (includePath == null) {
|
||||
includePath = PyUtil.buildJepIncludePath(
|
||||
GfePyIncludeUtil.getVCModUtilsIncludePath(),
|
||||
GfePyIncludeUtil.getVCModulesIncludePath(),
|
||||
GfePyIncludeUtil.getCommonPythonIncludePath());
|
||||
includePath = PyUtil.buildJepIncludePath(GfePyIncludeUtil
|
||||
.getVCModUtilsIncludePath(), GfePyIncludeUtil
|
||||
.getVCModulesIncludePath(dataMgr.getSiteID()),
|
||||
GfePyIncludeUtil.getCommonPythonIncludePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.raytheon.viz.gfe.core.DataManager;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 22, 2012 dgilling Initial creation
|
||||
* Mar 12, 2015 #4246 randerso Changes to support VCModules at base, site, and user levels
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -82,7 +83,7 @@ public class VCModuleJobPool {
|
|||
Boolean system, Integer priority) {
|
||||
jobList = new ArrayList<Job>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
PooledJob job = new PooledJob(name, null);
|
||||
PooledJob job = new PooledJob(name, dataMgr);
|
||||
if (system != null) {
|
||||
job.setSystem(system);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.raytheon.uf.common.util.FileUtil;
|
|||
* Sep 16, 2013 #1759 dgilling Move tests and autotests to GfeCavePyIncludeUtil.
|
||||
* Aug 22, 2014 #3500 bclement added python path in getConfigIncludePath()
|
||||
* Nov 11, 2014 #4953 randerso Changed COMMON_GFE to public
|
||||
* Mar 12, 2015 #4246 randerso Changes to support VCModules at base, site, and user levels
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
|
@ -359,9 +360,16 @@ public class GfePyIncludeUtil extends PythonIncludePathUtil {
|
|||
return PATH_MANAGER.getLocalizationFile(ctx, GFE_CONFIG);
|
||||
}
|
||||
|
||||
public static String getVCModulesIncludePath() {
|
||||
return getPath(PATH_MANAGER.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.BASE), VCMODULES);
|
||||
public static String getVCModulesIncludePath(String siteId) {
|
||||
String baseDir = getPath(PATH_MANAGER.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE),
|
||||
VCMODULES);
|
||||
String siteDir = getPath(PATH_MANAGER.getContextForSite(
|
||||
LocalizationType.COMMON_STATIC, siteId), VCMODULES);
|
||||
String userDir = getPath(PATH_MANAGER.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.USER),
|
||||
VCMODULES);
|
||||
return PyUtil.buildJepIncludePath(userDir, siteDir, baseDir);
|
||||
}
|
||||
|
||||
public static String getVCModUtilsIncludePath() {
|
||||
|
|
Loading…
Add table
Reference in a new issue