Merge "ASM #14739 - Fix callSmartTool() to return with updated varDict" into asm_16.1.1
Former-commit-id: 90cfdc7a1385d1e99a4237c31dc4c01e3f905a97
This commit is contained in:
commit
c7737cf711
5 changed files with 58 additions and 10 deletions
|
@ -65,6 +65,7 @@
|
|||
# time regardless of setting of os.environ['TZ']
|
||||
# Jan 13, 2015 3955 randerso Added optional parameter to availableParms to specify desired databases.
|
||||
# Fixed createGrid to accept a DatabaseID for model
|
||||
# Jul 07, 2015 14739 ryu Modified callSmartTool to return with updated varDict.
|
||||
########################################################################
|
||||
import types, string, time, sys
|
||||
from math import *
|
||||
|
@ -1017,8 +1018,13 @@ class SmartScript(BaseTool.BaseTool):
|
|||
emptyEditAreaFlag = True
|
||||
else:
|
||||
emptyEditAreaFlag = False
|
||||
|
||||
if varDict is not None:
|
||||
varDict = str(varDict)
|
||||
from java.lang import String
|
||||
varDictList = ArrayList()
|
||||
varDictList.add(String(str(varDict)))
|
||||
else:
|
||||
varDictList = None
|
||||
|
||||
parm = self.getParm(self.__mutableID, elementName, "SFC")
|
||||
if timeRange is None:
|
||||
|
@ -1030,9 +1036,14 @@ class SmartScript(BaseTool.BaseTool):
|
|||
from com.raytheon.viz.gfe.smarttool import SmartUtil
|
||||
|
||||
result = SmartUtil.callFromSmartScript(self.__dataMgr, toolName, elementName, editArea,
|
||||
timeRange, varDict, emptyEditAreaFlag,
|
||||
timeRange, varDictList, emptyEditAreaFlag,
|
||||
JUtil.pylistToJavaStringList(passErrors),
|
||||
missingDataMode, parm)
|
||||
|
||||
if varDict is not None:
|
||||
newDict = eval(str(varDictList.get(0)))
|
||||
varDict.clear()
|
||||
varDict.update(newDict)
|
||||
|
||||
if result:
|
||||
raise Exceptions.EditActionError(errorType="Error", errorInfo=str(result))
|
||||
|
|
|
@ -52,6 +52,7 @@ import com.raytheon.viz.gfe.smartscript.FieldDefinition;
|
|||
* hardened it by separating jep.getValue()
|
||||
* calls from python copying/casting to correct types
|
||||
* Feb 05, 2015 4089 njensen Replaced previous hardening with ensureResultType()
|
||||
* Jul 07, 2015 14739 ryu Added getVarDict().
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -132,6 +133,24 @@ public abstract class BaseGfePyController extends PythonScriptController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a module's varDict (variable list inputs)
|
||||
*
|
||||
* @return a string representation of a python dictionary
|
||||
*/
|
||||
public String getVarDict() {
|
||||
String varDict = null;
|
||||
try {
|
||||
jep.eval("temp = str(varDict)");
|
||||
varDict = (String) jep.getValue("temp");
|
||||
jep.eval("temp = None");
|
||||
} catch (JepException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Exception while getting varDict", e);
|
||||
}
|
||||
return varDict;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a module's varDict (variable list inputs), or sets the varDict
|
||||
* to an empty dictionary if there is not a variable list
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.viz.gfe.core.DataManager;
|
||||
import com.raytheon.viz.gfe.core.DataManagerUIFactory;
|
||||
import com.raytheon.viz.gfe.core.parm.Parm;
|
||||
import com.raytheon.viz.gfe.smartscript.FieldDefinition;
|
||||
import com.raytheon.viz.gfe.smarttool.script.SmartToolBlockingSelectionDlg;
|
||||
|
@ -52,6 +53,7 @@ import com.raytheon.viz.gfe.ui.runtimeui.SelectionDlg;
|
|||
* Nov 15, 2012 1298 rferrel Changes for non-blocking prcedures.
|
||||
* Jun 25, 2013 16065 ryu Passing outerLevel to smart tool job.
|
||||
* Dec 10, 2013 #2367 dgilling Use new SmartToolJobPool.
|
||||
* Jul 07, 2015 14739 ryu Modified callFromSmartScript() to return with updated varDict.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -89,7 +91,7 @@ public class SmartUtil {
|
|||
}
|
||||
|
||||
public static void runTool(String toolName) {
|
||||
DataManager dm = DataManager.getCurrentInstance();
|
||||
DataManager dm = DataManagerUIFactory.getCurrentInstance();
|
||||
List<FieldDefinition> varList = null;
|
||||
try {
|
||||
varList = dm.getSmartToolInterface().getVarDictWidgets(toolName);
|
||||
|
@ -138,7 +140,7 @@ public class SmartUtil {
|
|||
|
||||
public static Object callFromSmartScript(final DataManager dm,
|
||||
final String toolName, final String elementName,
|
||||
ReferenceData editArea, TimeRange timeRange, String varDict,
|
||||
ReferenceData editArea, TimeRange timeRange, List<String> varDictList,
|
||||
boolean emptyEditAreaFlag, List<String> passErrors,
|
||||
String missingDataMode, Parm parm) {
|
||||
EditAction editAction = new EditAction(toolName, elementName,
|
||||
|
@ -148,8 +150,8 @@ public class SmartUtil {
|
|||
final SmartToolRequest req = SmartUtil.buildSmartToolRequest(dm, pi,
|
||||
false);
|
||||
|
||||
if (varDict != null) {
|
||||
req.setVarDict(varDict);
|
||||
if (varDictList != null) {
|
||||
req.setVarDict(varDictList.get(0));
|
||||
} else {
|
||||
VizApp.runSync(new Runnable() {
|
||||
@Override
|
||||
|
@ -196,6 +198,12 @@ public class SmartUtil {
|
|||
}
|
||||
|
||||
dm.getSmartToolJobPool().schedule(req);
|
||||
return req.getResult();
|
||||
Object result = req.getResult();
|
||||
|
||||
if (varDictList != null) {
|
||||
varDictList.set(0, req.getVarDict());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ 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()
|
||||
* 07/07/2015 14739 ryu Modified execute() to return with updated varDict.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -397,7 +398,7 @@ public class Tool {
|
|||
* @throws SmartToolException
|
||||
*/
|
||||
public void execute(String toolName, Parm inputParm,
|
||||
final ReferenceData editArea, TimeRange timeRange, String varDict,
|
||||
final ReferenceData editArea, TimeRange timeRange, List<String> varDictList,
|
||||
MissingDataMode missingDataMode, IProgressMonitor monitor)
|
||||
throws SmartToolException {
|
||||
ITimer timer = TimeUtil.getTimer();
|
||||
|
@ -461,7 +462,7 @@ public class Tool {
|
|||
boolean saveParams = false;
|
||||
|
||||
try {
|
||||
tool.setVarDict(varDict);
|
||||
tool.setVarDict(varDictList.get(0));
|
||||
// # PreProcess Tool
|
||||
handlePreAndPostProcess("preProcessTool", null, timeRange,
|
||||
editArea, dataMode);
|
||||
|
@ -559,6 +560,9 @@ public class Tool {
|
|||
handlePreAndPostProcess("postProcessTool", null, timeRange,
|
||||
trueEditArea, dataMode);
|
||||
saveParams = true;
|
||||
|
||||
// reset varDict
|
||||
varDictList.set(0, tool.getVarDict());
|
||||
} catch (SmartToolException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
} catch (JepException e) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.viz.gfe.smarttool.script;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
@ -52,6 +53,7 @@ import com.raytheon.viz.gfe.smarttool.Tool;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 09, 2013 #2367 dgilling Initial creation
|
||||
* Jul 07, 2015 14739 ryu Modified execute() to retrieve updated varDict after tool execution.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -356,9 +358,13 @@ public class SmartToolJobPool {
|
|||
}
|
||||
Tool tool = new Tool(dataMgr.getParmManager(), request
|
||||
.getPreview().getParm(), ea.getItemName(), python);
|
||||
List<String> varDictList = new ArrayList<String>(1);
|
||||
varDictList.add(request.getVarDict());
|
||||
tool.execute(ea.getItemName(), request.getPreview().getParm(),
|
||||
ea.getRefSet(), ea.getTimeRange(),
|
||||
request.getVarDict(), ea.getMissingDataMode(), monitor);
|
||||
varDictList, ea.getMissingDataMode(), monitor);
|
||||
//reset varDict
|
||||
request.setVarDict(varDictList.get(0));
|
||||
pjStatus = Status.OK_STATUS;
|
||||
} catch (SmartToolException e) {
|
||||
pjStatus = new Status(IStatus.WARNING, Activator.PLUGIN_ID,
|
||||
|
|
Loading…
Add table
Reference in a new issue