Omaha #4575 vardict now HashMap intead of String
Change-Id: Icd6042a1d9b08d8a33afd41c65a530104bf01c8c Former-commit-id: bffc43fe836827b8cd871f037f0ede093b69a88f
This commit is contained in:
parent
31b96edb14
commit
958050610d
9 changed files with 58 additions and 63 deletions
|
@ -66,6 +66,7 @@
|
|||
# Jan 13, 2015 3955 randerso Added optional parameter to availableParms to specify desired databases.
|
||||
# Fixed createGrid to accept a DatabaseID for model
|
||||
# Apr 23, 2015 4259 njensen Updated for new JEP API
|
||||
# Jul 17, 2015 4575 njensen callSmartTool() and callProcedure() send HashMap for varDict
|
||||
########################################################################
|
||||
import types, string, time, sys
|
||||
from math import *
|
||||
|
@ -1010,7 +1011,7 @@ class SmartScript(BaseTool.BaseTool):
|
|||
else:
|
||||
emptyEditAreaFlag = False
|
||||
if varDict is not None:
|
||||
varDict = str(varDict)
|
||||
varDict = JUtil.pyValToJavaObj(varDict)
|
||||
|
||||
parm = self.getParm(self.__mutableID, elementName, "SFC")
|
||||
if timeRange is None:
|
||||
|
@ -1044,7 +1045,7 @@ class SmartScript(BaseTool.BaseTool):
|
|||
|
||||
from com.raytheon.viz.gfe.procedures import ProcedureUtil
|
||||
if varDict is not None:
|
||||
varDict = str(varDict)
|
||||
varDict = JUtil.pyValToJavaObj(varDict)
|
||||
|
||||
result = ProcedureUtil.callFromSmartScript(self.__dataMgr, name, editArea, timeRange, varDict)
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ import com.raytheon.viz.gfe.smartscript.FieldDefinition;
|
|||
* calls from python copying/casting to correct types
|
||||
* Feb 05, 2015 4089 njensen Replaced previous hardening with ensureResultType()
|
||||
* Apr 23, 2015 4259 njensen Updated for new JEP API
|
||||
* Jul 17, 2015 4575 njensen Changed varDict from String to Map
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -124,11 +125,13 @@ public abstract class BaseGfePyController extends PythonScriptController {
|
|||
* a string representation of a python dictionary
|
||||
* @throws JepException
|
||||
*/
|
||||
public void setVarDict(String varDict) throws JepException {
|
||||
public void setVarDict(Map<String, Object> varDict) throws JepException {
|
||||
if (varDict == null) {
|
||||
jep.eval("varDict = None");
|
||||
} else {
|
||||
jep.eval("varDict = " + varDict);
|
||||
jep.set("varDict", varDict);
|
||||
jep.eval("import JUtil");
|
||||
jep.eval("varDict = JUtil.javaObjToPyVal(varDict)");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,22 +160,6 @@ public abstract class BaseGfePyController extends PythonScriptController {
|
|||
return fieldDefs;
|
||||
}
|
||||
|
||||
public String transformVarDict(Map<String, Object> map) {
|
||||
String varDict = null;
|
||||
try {
|
||||
jep.eval("import JUtil");
|
||||
jep.set("varDictMap", map);
|
||||
jep.eval("temp = JUtil.javaMapToPyDict(varDictMap)");
|
||||
varDict = (String) jep.getValue("temp");
|
||||
jep.eval("varDictMap = None");
|
||||
jep.eval("temp = None");
|
||||
} catch (JepException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Exception while transforming varDict", e);
|
||||
}
|
||||
return varDict;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the python garbage collector. This should be run at the end of a
|
||||
* procedure or tool in case the custom python used tk. If the python used
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.viz.gfe.procedures;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData;
|
||||
|
@ -34,7 +35,8 @@ import com.raytheon.viz.gfe.smarttool.PreviewInfo;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 8, 2009 njensen Initial creation
|
||||
* Oct 08, 2009 njensen Initial creation
|
||||
* Jul 17, 2015 4575 njensen Changed varDict from String to Map
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -50,7 +52,7 @@ public class ProcedureRequest extends QueueJobRequest<Object> {
|
|||
|
||||
private TimeRange timeRange;
|
||||
|
||||
private String varDict;
|
||||
private Map<String, Object> varDict;
|
||||
|
||||
private PreviewInfo preview;
|
||||
|
||||
|
@ -93,11 +95,11 @@ public class ProcedureRequest extends QueueJobRequest<Object> {
|
|||
this.timeRange = timeRange;
|
||||
}
|
||||
|
||||
public String getVarDict() {
|
||||
public Map<String, Object> getVarDict() {
|
||||
return varDict;
|
||||
}
|
||||
|
||||
public void setVarDict(String varDict) {
|
||||
public void setVarDict(Map<String, Object> varDict) {
|
||||
this.varDict = varDict;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.viz.gfe.procedures;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
@ -38,6 +39,7 @@ import com.raytheon.viz.gfe.ui.runtimeui.SelectionDlg;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 09, 2010 njensen Initial creation
|
||||
* Dec 09, 2013 #2367 dgilling Use new ProcedureJobPool.
|
||||
* Jul 17, 2015 4575 njensen Changed varDict from String to Map
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -64,8 +66,7 @@ public class ProcedureSelectionDlg extends SelectionDlg {
|
|||
ProcedureRequest req = ProcedureUtil.buildProcedureRequest(name,
|
||||
dataMgr);
|
||||
if (req != null) {
|
||||
String varDict = dataMgr.getProcedureInterface()
|
||||
.transformVarDict(getValues());
|
||||
Map<String, Object> varDict = getValues();
|
||||
req.setVarDict(varDict);
|
||||
req.setPreview(pi);
|
||||
dataMgr.getProcedureJobPool().schedule(req);
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.raytheon.viz.gfe.smarttool.PreviewInfo;
|
|||
* Feb 09, 2010 njensen Initial creation
|
||||
* Apr 26, 2012 14748 ryu Use edit area and time range from preview info
|
||||
* Dec 09, 2013 #2367 dgilling Use new ProcedureJobPool.
|
||||
* Jul 17, 2015 4575 njensen Changed varDict from String to Map
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -79,7 +80,7 @@ public class ProcedureUtil {
|
|||
|
||||
public static Object callFromSmartScript(final DataManager dm,
|
||||
final String procName, ReferenceData editArea, TimeRange timeRange,
|
||||
String varDict) {
|
||||
Map<String, Object> varDict) {
|
||||
PreviewInfo pi = dm.getEditActionProcessor().prepareExecute(
|
||||
"Procedure", procName, editArea, timeRange, false);
|
||||
|
||||
|
@ -109,9 +110,7 @@ public class ProcedureUtil {
|
|||
Map<String, Object> resultMap = sd
|
||||
.getVarDictResult();
|
||||
if (resultMap != null) {
|
||||
String userVarDict = dm.getProcedureInterface()
|
||||
.transformVarDict(resultMap);
|
||||
req.setVarDict(userVarDict);
|
||||
req.setVarDict(resultMap);
|
||||
}
|
||||
} else {
|
||||
req.setVarDict(null);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.viz.gfe.smarttool;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -53,6 +54,7 @@ import com.raytheon.viz.gfe.ui.runtimeui.SelectionDlg;
|
|||
* Jun 25, 2013 16065 ryu Passing outerLevel to smart tool job.
|
||||
* Dec 10, 2013 2367 dgilling Use new SmartToolJobPool.
|
||||
* Jun 05, 2015 4259 njensen Removed LD_PRELOAD check
|
||||
* Jul 17, 2015 4575 njensen Changed varDict from String to Map
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -122,9 +124,9 @@ public class SmartUtil {
|
|||
|
||||
public static Object callFromSmartScript(final DataManager dm,
|
||||
final String toolName, final String elementName,
|
||||
ReferenceData editArea, TimeRange timeRange, String varDict,
|
||||
boolean emptyEditAreaFlag, List<String> passErrors,
|
||||
String missingDataMode, Parm parm) {
|
||||
ReferenceData editArea, TimeRange timeRange,
|
||||
Map<String, Object> varDict, boolean emptyEditAreaFlag,
|
||||
List<String> passErrors, String missingDataMode, Parm parm) {
|
||||
EditAction editAction = new EditAction(toolName, elementName,
|
||||
timeRange, editArea, emptyEditAreaFlag,
|
||||
MissingDataMode.valueFrom(missingDataMode));
|
||||
|
@ -161,14 +163,13 @@ public class SmartUtil {
|
|||
Map<String, Object> resultMap = sd
|
||||
.getVarDictResult();
|
||||
if (resultMap != null) {
|
||||
String userVarDict = dm.getSmartToolInterface()
|
||||
.transformVarDict(resultMap);
|
||||
req.setVarDict(userVarDict);
|
||||
req.setVarDict(resultMap);
|
||||
}
|
||||
} else {
|
||||
// set it to something so we don't trigger the null
|
||||
// == user cancelled below
|
||||
req.setVarDict("{}");
|
||||
req.setVarDict(Collections
|
||||
.<String, Object> emptyMap());
|
||||
}
|
||||
} catch (JepException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
|
|
|
@ -62,7 +62,7 @@ import com.raytheon.viz.gfe.smarttool.script.SmartToolController;
|
|||
|
||||
/**
|
||||
* Ported from Tool.py
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
|
@ -72,9 +72,10 @@ import com.raytheon.viz.gfe.smarttool.script.SmartToolController;
|
|||
* 02/14/2013 mnash Change QueryScript to use new Python concurrency
|
||||
* 02/20/2013 #1597 randerso Added logging to support GFE Performance metrics
|
||||
* 04/10/2013 16028 ryu Check for null seTime in execute()
|
||||
* Jul 17, 2015 4575 njensen Changed varDict from String to Map
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
@ -110,7 +111,7 @@ public class Tool {
|
|||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param aParmMgr
|
||||
* the parm manager
|
||||
* @param aToolName
|
||||
|
@ -143,7 +144,7 @@ public class Tool {
|
|||
|
||||
/**
|
||||
* Returns the objects that should be passed to the smart tool in python
|
||||
*
|
||||
*
|
||||
* @param args
|
||||
* the names of the arguments
|
||||
* @param gridTimeRange
|
||||
|
@ -226,7 +227,7 @@ public class Tool {
|
|||
|
||||
/**
|
||||
* Returns the attribute for a particular parm's name
|
||||
*
|
||||
*
|
||||
* @param arg
|
||||
* the name of the parm
|
||||
* @param attrStr
|
||||
|
@ -261,7 +262,7 @@ public class Tool {
|
|||
|
||||
/**
|
||||
* Returns the grid data for the specified parameters
|
||||
*
|
||||
*
|
||||
* @param arg
|
||||
* the name of the parm
|
||||
* @param mode
|
||||
|
@ -310,7 +311,7 @@ public class Tool {
|
|||
|
||||
/**
|
||||
* Returns the grid history corresponding to the parm name and time range
|
||||
*
|
||||
*
|
||||
* @param arg
|
||||
* the name of the parm
|
||||
* @param gridTimeRange
|
||||
|
@ -350,7 +351,7 @@ public class Tool {
|
|||
|
||||
/**
|
||||
* Returns the grid info corresponding to the parm name and time range
|
||||
*
|
||||
*
|
||||
* @param arg
|
||||
* the name of the parm
|
||||
* @param gridTimeRange
|
||||
|
@ -384,7 +385,7 @@ public class Tool {
|
|||
|
||||
/**
|
||||
* Executes a smart tool
|
||||
*
|
||||
*
|
||||
* @param toolName
|
||||
* the name of the tool
|
||||
* @param inputParm
|
||||
|
@ -397,9 +398,9 @@ public class Tool {
|
|||
* @throws SmartToolException
|
||||
*/
|
||||
public void execute(String toolName, Parm inputParm,
|
||||
final ReferenceData editArea, TimeRange timeRange, String varDict,
|
||||
MissingDataMode missingDataMode, IProgressMonitor monitor)
|
||||
throws SmartToolException {
|
||||
final ReferenceData editArea, TimeRange timeRange,
|
||||
Map<String, Object> varDict, MissingDataMode missingDataMode,
|
||||
IProgressMonitor monitor) throws SmartToolException {
|
||||
ITimer timer = TimeUtil.getTimer();
|
||||
timer.start();
|
||||
|
||||
|
@ -491,8 +492,8 @@ public class Tool {
|
|||
final Date timeInfluence;
|
||||
Date seTime = DataManagerUIFactory.getCurrentInstance()
|
||||
.getSpatialDisplayManager().getSpatialEditorTime();
|
||||
if (seTime != null &&
|
||||
grids.length == 1 && grid.getGridTime().contains(seTime)) {
|
||||
if (seTime != null && grids.length == 1
|
||||
&& grid.getGridTime().contains(seTime)) {
|
||||
timeInfluence = seTime;
|
||||
} else {
|
||||
timeInfluence = grid.getGridTime().getStart();
|
||||
|
@ -581,7 +582,7 @@ public class Tool {
|
|||
|
||||
/**
|
||||
* Executes the numeric smart tool
|
||||
*
|
||||
*
|
||||
* @param parmToEdit
|
||||
* the parm to edit
|
||||
* @param first
|
||||
|
@ -653,7 +654,7 @@ public class Tool {
|
|||
/**
|
||||
* Cleans up a smart tool execution or failure and displays any missing data
|
||||
* message
|
||||
*
|
||||
*
|
||||
* @param parmToEdit
|
||||
* the parm to edit
|
||||
* @param save
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.viz.gfe.smarttool.script;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import com.raytheon.uf.viz.core.jobs.QueueJobRequest;
|
||||
|
@ -27,7 +28,7 @@ import com.raytheon.viz.gfe.smarttool.PreviewInfo;
|
|||
|
||||
/**
|
||||
* Request to run a smart tool off the UI thread
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
|
@ -35,9 +36,10 @@ import com.raytheon.viz.gfe.smarttool.PreviewInfo;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 19, 2010 njensen Initial creation
|
||||
* Jun 25, 2013 16065 ryu Adding outerLevel attribute
|
||||
* Jul 17, 2015 4575 njensen Changed varDict from String to Map
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
@ -46,7 +48,7 @@ public class SmartToolRequest extends QueueJobRequest<Object> {
|
|||
|
||||
private Parm inputParm;
|
||||
|
||||
private String varDict;
|
||||
private Map<String, Object> varDict;
|
||||
|
||||
private PreviewInfo preview;
|
||||
|
||||
|
@ -75,11 +77,11 @@ public class SmartToolRequest extends QueueJobRequest<Object> {
|
|||
this.inputParm = inputParm;
|
||||
}
|
||||
|
||||
public String getVarDict() {
|
||||
public Map<String, Object> getVarDict() {
|
||||
return varDict;
|
||||
}
|
||||
|
||||
public void setVarDict(String varDict) {
|
||||
public void setVarDict(Map<String, Object> varDict) {
|
||||
this.varDict = varDict;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.viz.gfe.smarttool.script;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
@ -37,9 +38,10 @@ import com.raytheon.viz.gfe.ui.runtimeui.SelectionDlg;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 9, 2010 njensen Initial creation
|
||||
* Jun 25, 2013 16065 ryu Passing outerLevel to tool job
|
||||
* Dec 10, 2013 #2367 dgilling Use new SmartToolJobPool.
|
||||
* Feb 09, 2010 njensen Initial creation
|
||||
* Jun 25, 2013 16065 ryu Passing outerLevel to tool job
|
||||
* Dec 10, 2013 #2367 dgilling Use new SmartToolJobPool.
|
||||
* Jul 17, 2015 4575 njensen Changed varDict from String to Map
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -66,8 +68,7 @@ public class SmartToolSelectionDlg extends SelectionDlg {
|
|||
SmartToolRequest req = SmartUtil.buildSmartToolRequest(dataMgr, pi,
|
||||
true);
|
||||
if (req != null) {
|
||||
String varDict = dataMgr.getSmartToolInterface()
|
||||
.transformVarDict(getValues());
|
||||
Map<String, Object> varDict = getValues();
|
||||
req.setVarDict(varDict);
|
||||
dataMgr.getSmartToolJobPool().schedule(req);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue