Issue #2277 Got rid of all ScriptCreator references in raytheon code.
Change-Id: I255301d36da8546ef0850b3dc0b4d00ee0bfa002 Former-commit-id:edc4132489
[formerly661d47c894
] [formerly955db6a722
] [formerlyedc4132489
[formerly661d47c894
] [formerly955db6a722
] [formerly0faed07d58
[formerly955db6a722
[formerly 3183c0abb055acf02e255392f92402e84abd0e08]]]] Former-commit-id:0faed07d58
Former-commit-id:6e31e09169
[formerly08e85c8588
] [formerly c5a1abc09517db25e58f04d1007f4bad88829325 [formerly2a8d148a74
]] Former-commit-id: 6df3be285cdf2477fcc177d4a84df15cb38c2457 [formerly65d11c8e51
] Former-commit-id:f8d2a9770b
This commit is contained in:
parent
6c8356ef85
commit
9bff01dfe6
8 changed files with 42 additions and 555 deletions
|
@ -24,7 +24,6 @@
|
||||||
<extension-point id="units" name="units" schema="schema/units.exsd"/>
|
<extension-point id="units" name="units" schema="schema/units.exsd"/>
|
||||||
<extension-point id="descriptor" name="descriptor" schema="schema/descriptor.exsd"/>
|
<extension-point id="descriptor" name="descriptor" schema="schema/descriptor.exsd"/>
|
||||||
<extension-point id="renderingOrder" name="renderingOrder" schema="schema/renderingOrder.exsd"/>
|
<extension-point id="renderingOrder" name="renderingOrder" schema="schema/renderingOrder.exsd"/>
|
||||||
<extension-point id="scriptTemplate" name="Script Template Extension" schema="schema/scriptTemplate.exsd"/>
|
|
||||||
<extension-point id="graphicsFactory" name="graphics factory" schema="schema/graphicsFactory.exsd"/>
|
<extension-point id="graphicsFactory" name="graphics factory" schema="schema/graphicsFactory.exsd"/>
|
||||||
<extension-point id="classContext" name="classContext" schema="schema/classContext.exsd"/>
|
<extension-point id="classContext" name="classContext" schema="schema/classContext.exsd"/>
|
||||||
<extension-point id="userManager" name="userManager" schema="schema/userManager.exsd"/>
|
<extension-point id="userManager" name="userManager" schema="schema/userManager.exsd"/>
|
||||||
|
@ -39,14 +38,6 @@
|
||||||
id="com.raytheon.uf.viz.core.localization.LocalizationPreferences"
|
id="com.raytheon.uf.viz.core.localization.LocalizationPreferences"
|
||||||
name="Localization"/>
|
name="Localization"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
|
||||||
point="com.raytheon.uf.viz.core.scriptTemplate">
|
|
||||||
<scriptTemplate
|
|
||||||
pluginName="table"
|
|
||||||
scriptLibrary="TableRequest"
|
|
||||||
scriptTemplateFile="scriptTemplates/tableRequestTemplate.vm">
|
|
||||||
</scriptTemplate>
|
|
||||||
</extension>
|
|
||||||
<extension point="org.eclipse.ui.themes">
|
<extension point="org.eclipse.ui.themes">
|
||||||
<themeElementCategory
|
<themeElementCategory
|
||||||
id="com.raytheon.uf.viz.core.theme"
|
id="com.raytheon.uf.viz.core.theme"
|
||||||
|
|
|
@ -1,109 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<!-- Schema file written by PDE -->
|
|
||||||
<schema targetNamespace="com.raytheon.uf.viz.core" xmlns="http://www.w3.org/2001/XMLSchema">
|
|
||||||
<annotation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.schema plugin="com.raytheon.uf.viz.core" id="scriptTemplate" name="Script Template Extension"/>
|
|
||||||
</appinfo>
|
|
||||||
<documentation>
|
|
||||||
Defines an extension to register script generation capability
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
|
|
||||||
<element name="extension">
|
|
||||||
<annotation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.element />
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
<complexType>
|
|
||||||
<sequence>
|
|
||||||
<element ref="scriptTemplate" minOccurs="1" maxOccurs="unbounded"/>
|
|
||||||
</sequence>
|
|
||||||
<attribute name="point" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="id" type="string">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="name" type="string">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute translatable="true"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
</complexType>
|
|
||||||
</element>
|
|
||||||
|
|
||||||
<element name="scriptTemplate">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
The script template defines how a uEngine script is generated for a particular plugin.
|
|
||||||
|
|
||||||
scriptLibrary should be populated if the standard script template is to be used.
|
|
||||||
|
|
||||||
If custom script generation is desired, scriptTemplateFile can be set to a custom velocity template file.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
<complexType>
|
|
||||||
<attribute name="pluginName" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
The name of the plugin (e.g. 'plugin-satellite')
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="scriptLibrary" type="string">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
The script library to be used (e.g. ObsRequest)
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="scriptTemplateFile" type="string">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
The template file to use, otherwise null if standard template should be used.
|
|
||||||
</documentation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.attribute kind="resource"/>
|
|
||||||
</appinfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
</complexType>
|
|
||||||
</element>
|
|
||||||
|
|
||||||
<annotation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.section type="since"/>
|
|
||||||
</appinfo>
|
|
||||||
<documentation>
|
|
||||||
2008
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<annotation>
|
|
||||||
<appinfo>
|
|
||||||
<meta.section type="implementation"/>
|
|
||||||
</appinfo>
|
|
||||||
<documentation>
|
|
||||||
[
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
|
|
||||||
|
|
||||||
</schema>
|
|
|
@ -1,24 +1,4 @@
|
||||||
## The standard template gets all of its behavior from VM_global_library macros
|
## The standard template gets all of its behavior from VM_global_library macros
|
||||||
#if($mode == "select")
|
#if($mode == "select")
|
||||||
#standardSelect($scriptLibrary $maxRecords $scriptMetadata false)
|
#standardSelect($scriptLibrary $maxRecords $scriptMetadata false)
|
||||||
#elseif($mode == "catalog")
|
|
||||||
#standardCatalog($scriptLibrary $scriptMetadata)
|
|
||||||
#elseif($mode == "latestTime")
|
|
||||||
#standardLatestTime($scriptMetadata)
|
|
||||||
#elseif($mode == "plot")
|
|
||||||
#standardSelect($scriptLibrary $maxRecords $scriptMetadata true)
|
|
||||||
#elseif($mode == "dbquery")
|
|
||||||
#standardDbQuery($scriptMetadata)
|
|
||||||
#elseif($mode == "hqlquery")
|
|
||||||
#hqlQuery($scriptMetadata)
|
|
||||||
#elseif($mode == "sqlquery")
|
|
||||||
#sqlQuery($scriptMetadata)
|
|
||||||
#elseif($mode == "sqlstatement")
|
|
||||||
#sqlStatement($scriptMetadata)
|
|
||||||
#elseif($mode == "hqlstatement")
|
|
||||||
#hqlStatement($scriptMetadata)
|
|
||||||
#elseif($mode == "saveOrUpdateObject")
|
|
||||||
#saveOrUpdateObject($scriptMetadata)
|
|
||||||
#elseif($mode == "getRecordClass")
|
|
||||||
#getRecordClass($scriptMetadata)
|
|
||||||
#end
|
#end
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
|
|
||||||
#if($mode == "select")
|
|
||||||
import TableRequest
|
|
||||||
dataRequest = TableRequest.TableRequest('${scriptMetadata.get("databasename").constraintValue}',
|
|
||||||
'${scriptMetadata.get("classname").constraintValue}')
|
|
||||||
dataRequest.setCount(${maxRecords})
|
|
||||||
#foreach (${key} in ${scriptMetadata.keySet()})
|
|
||||||
#if(${key})
|
|
||||||
#if(${key} != "pluginName" && ${key} != "databasename" && ${key} != "classname")
|
|
||||||
#set($constraint = $scriptMetadata.get($key))
|
|
||||||
#if(${constraint.constraintType} == "IN")
|
|
||||||
dataRequest.addList("${key}", "${constraint.constraintValue}")
|
|
||||||
#elseif(${constraint.constraintType} == "LIKE")
|
|
||||||
dataRequest.addParameter("${key}", "${constraint.constraintValue}", "like")
|
|
||||||
#elseif ($constraint.constraintType == "ISNULL")
|
|
||||||
dataRequest.addParameter("${key}", "${constraint.constraintValue}", "isnull")
|
|
||||||
#else
|
|
||||||
dataRequest.addParameter("${key}", "${constraint.constraintValue}")
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
return dataRequest.execute()
|
|
||||||
#elseif($mode == "update")
|
|
||||||
import TableResponse
|
|
||||||
product = '''$scriptMetadata.get("rowname").constraintValue'''
|
|
||||||
#set($classname = $scriptMetadata.get("classname").constraintValue)
|
|
||||||
#set($databasename = $scriptMetadata.get("databasename").constraintValue)
|
|
||||||
dataResponse = TableResponse.TableResponse('${databasename}', '${classname}', product)
|
|
||||||
return dataResponse.execute()
|
|
||||||
#end
|
|
|
@ -22,25 +22,13 @@ package com.raytheon.uf.viz.core.catalog;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.FileLocator;
|
import org.eclipse.core.runtime.FileLocator;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
|
||||||
import org.eclipse.core.runtime.IContributor;
|
|
||||||
import org.eclipse.core.runtime.IExtension;
|
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
|
||||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.osgi.framework.Bundle;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
|
@ -71,6 +59,8 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
||||||
* 3/17/2008 933 grichard Added support for taf plugin.
|
* 3/17/2008 933 grichard Added support for taf plugin.
|
||||||
* 04/14/2008 chammack Complete refactor to Velocity
|
* 04/14/2008 chammack Complete refactor to Velocity
|
||||||
* Feb 15, 2013 1638 mschenke Created common VelocityManager for executing scripts
|
* Feb 15, 2013 1638 mschenke Created common VelocityManager for executing scripts
|
||||||
|
* Sep 12, 2013 2277 mschenke Remove references to this class and deleted unused
|
||||||
|
* functionality
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -79,150 +69,25 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class ScriptCreator {
|
public class ScriptCreator {
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
|
||||||
.getHandler(ScriptCreator.class);
|
|
||||||
|
|
||||||
private static final String DEFAULT_SCRIPT_LIBRARY = "BaseRequest";
|
private static String SCRIPT_LIBRARY = "BaseRequest";
|
||||||
|
|
||||||
/** The extension point where resources are defined */
|
private static File SCRIPT_TEMPLATE;
|
||||||
private static final String RESOURCE_EXTENSION = "com.raytheon.uf.viz.core.scriptTemplate";
|
|
||||||
|
|
||||||
private static final String PLUGINNAME_TAG = "pluginName";
|
|
||||||
|
|
||||||
private static final String SCRIPT_TEMPLATE_TAG = "scriptTemplateFile";
|
|
||||||
|
|
||||||
private static final String SCRIPT_LIBRARY_TAG = "scriptLibrary";
|
|
||||||
|
|
||||||
private static Map<String, ScriptProperties> pluginToLibraryMap;
|
|
||||||
|
|
||||||
private static File DEFAULT_TEMPLATE;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
DEFAULT_TEMPLATE = new File(FileLocator.resolve(
|
SCRIPT_TEMPLATE = new File(FileLocator.resolve(
|
||||||
FileLocator.find(Activator.getDefault().getBundle(),
|
FileLocator.find(Activator.getDefault().getBundle(),
|
||||||
new Path("scriptTemplates/standardTemplate.vm"),
|
new Path("scriptTemplates/standardTemplate.vm"),
|
||||||
null)).getPath());
|
null)).getPath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
statusHandler
|
UFStatus.getHandler(ScriptCreator.class)
|
||||||
.handle(Priority.CRITICAL,
|
.handle(Priority.CRITICAL,
|
||||||
"Unable to load the standard script template. Requesting products will not work until this is fixed.",
|
"Unable to load the standard script template. Requesting products will not work until this is fixed.",
|
||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ScriptProperties {
|
|
||||||
public File scriptTemplate;
|
|
||||||
|
|
||||||
public String scriptLibrary;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj == null || !(obj instanceof ScriptProperties)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScriptProperties props = (ScriptProperties) obj;
|
|
||||||
|
|
||||||
boolean part1 = (scriptTemplate == null && props.scriptTemplate == null)
|
|
||||||
|| (scriptTemplate != null && scriptTemplate
|
|
||||||
.equals(props.scriptTemplate));
|
|
||||||
|
|
||||||
boolean part2 = (scriptLibrary == null && props.scriptLibrary == null)
|
|
||||||
|| (scriptLibrary != null && scriptLibrary
|
|
||||||
.equals(props.scriptLibrary));
|
|
||||||
|
|
||||||
return part1 && part2;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "(Template: " + scriptTemplate + ", Library: "
|
|
||||||
+ scriptLibrary + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an internal representation of script properties extensions in
|
|
||||||
* memory
|
|
||||||
*/
|
|
||||||
private static synchronized void createPluginToLibraryMap() {
|
|
||||||
if (pluginToLibraryMap != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pluginToLibraryMap = new HashMap<String, ScriptProperties>();
|
|
||||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
|
||||||
|
|
||||||
IExtensionPoint point = registry.getExtensionPoint(RESOURCE_EXTENSION);
|
|
||||||
|
|
||||||
if (point == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
IExtension[] extensions = point.getExtensions();
|
|
||||||
|
|
||||||
List<IExtension> extensionList = new ArrayList<IExtension>();
|
|
||||||
extensionList.addAll(Arrays.asList(extensions));
|
|
||||||
|
|
||||||
for (int i = 0; i < extensionList.size(); i++) {
|
|
||||||
IConfigurationElement[] config = extensionList.get(i)
|
|
||||||
.getConfigurationElements();
|
|
||||||
|
|
||||||
for (int j = 0; j < config.length; j++) {
|
|
||||||
String pluginName = config[j].getAttribute(PLUGINNAME_TAG);
|
|
||||||
String template = config[j].getAttribute(SCRIPT_TEMPLATE_TAG);
|
|
||||||
String library = config[j].getAttribute(SCRIPT_LIBRARY_TAG);
|
|
||||||
IContributor contrib = extensionList.get(i).getContributor();
|
|
||||||
Bundle bundle = Platform.getBundle(contrib.getName());
|
|
||||||
File templateFile = null;
|
|
||||||
try {
|
|
||||||
if (template != null) {
|
|
||||||
URL url = FileLocator.find(bundle, new Path(template),
|
|
||||||
null);
|
|
||||||
if (url == null) {
|
|
||||||
String message = "Error opening the script template for: "
|
|
||||||
+ pluginName;
|
|
||||||
statusHandler.handle(Priority.PROBLEM, message);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
templateFile = new File(FileLocator.resolve(url)
|
|
||||||
.getPath());
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
|
||||||
"Error opening resource", e);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pluginName != null) {
|
|
||||||
ScriptProperties newValue = new ScriptProperties();
|
|
||||||
newValue.scriptLibrary = library;
|
|
||||||
newValue.scriptTemplate = templateFile;
|
|
||||||
|
|
||||||
ScriptProperties existingValue = pluginToLibraryMap
|
|
||||||
.get(pluginName);
|
|
||||||
if (existingValue != null) {
|
|
||||||
// If duplicates, warn to log, and use the first value.
|
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
|
||||||
"Duplicate value for plugin registry: "
|
|
||||||
+ pluginName + " had value: "
|
|
||||||
+ existingValue + ", new value: "
|
|
||||||
+ newValue + ". Ignoring new value.");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
pluginToLibraryMap.put(pluginName, newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a script from a LayerProperty class, with mode "select"
|
* Create a script from a LayerProperty class, with mode "select"
|
||||||
*
|
*
|
||||||
|
@ -237,50 +102,8 @@ public class ScriptCreator {
|
||||||
*/
|
*/
|
||||||
public static String createScript(LayerProperty layerProperty)
|
public static String createScript(LayerProperty layerProperty)
|
||||||
throws VizException {
|
throws VizException {
|
||||||
return createScript(layerProperty, "select");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a script from a LayerProperty class with a mode
|
|
||||||
*
|
|
||||||
* The mode is a user definable concept, but typically "select", "catalog"
|
|
||||||
* and "update" are valid values, however script templates may implement
|
|
||||||
* anything they choose to.
|
|
||||||
*
|
|
||||||
* @param layerProperty
|
|
||||||
* the layer property
|
|
||||||
* @param mode
|
|
||||||
* the mode
|
|
||||||
* @return the script
|
|
||||||
* @throws VizException
|
|
||||||
* an exception if generation fails.
|
|
||||||
*/
|
|
||||||
public static String createScript(LayerProperty layerProperty, String mode)
|
|
||||||
throws VizException {
|
|
||||||
if (mode.equals("update") || mode.equals("catalog")
|
|
||||||
|| mode.equals("plot")) {
|
|
||||||
return createScript(layerProperty.getEntryQueryParameters(false),
|
|
||||||
layerProperty.getNumberOfImages(), mode);
|
|
||||||
}
|
|
||||||
return createScript(layerProperty.getEntryQueryParameters(true),
|
return createScript(layerProperty.getEntryQueryParameters(true),
|
||||||
layerProperty.getNumberOfImages(), mode);
|
layerProperty.getNumberOfImages(), "select");
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a script from a LayerProperty class, with mode "update"
|
|
||||||
*
|
|
||||||
* This is a convenience method for the more general
|
|
||||||
* createImageScript(LayerProperty, String).
|
|
||||||
*
|
|
||||||
* @param layerProperty
|
|
||||||
* the layer property
|
|
||||||
* @return the script object
|
|
||||||
* @throws VizException
|
|
||||||
* an exception if generation fails.
|
|
||||||
*/
|
|
||||||
public static String createUpdateScript(LayerProperty layerProperty)
|
|
||||||
throws VizException {
|
|
||||||
return createScript(layerProperty, "update");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -297,56 +120,27 @@ public class ScriptCreator {
|
||||||
* @throws VizException
|
* @throws VizException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static String createScript(
|
private static String createScript(
|
||||||
Map<String, RequestConstraint> queryTerms, int maxRecords,
|
|
||||||
String mode) throws VizException {
|
|
||||||
|
|
||||||
String plugin = queryTerms.get("pluginName").getConstraintValue();
|
|
||||||
|
|
||||||
if (plugin == null) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Metadata does not contain pluginName, which is required.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return createScript(plugin, queryTerms, maxRecords, mode);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String createScript(String templateName,
|
|
||||||
Map<String, RequestConstraint> queryTerms, int maxRecords,
|
Map<String, RequestConstraint> queryTerms, int maxRecords,
|
||||||
String mode) throws VizException {
|
String mode) throws VizException {
|
||||||
|
|
||||||
// long t0 = System.currentTimeMillis();
|
// long t0 = System.currentTimeMillis();
|
||||||
|
|
||||||
createPluginToLibraryMap();
|
if (SCRIPT_TEMPLATE == null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
if (templateName == null) {
|
"ScriptCreator did not initialize properly");
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"No templateName, which is required.");
|
|
||||||
}
|
|
||||||
|
|
||||||
ScriptProperties props = pluginToLibraryMap.get(templateName);
|
|
||||||
|
|
||||||
if (props == null) {
|
|
||||||
props = new ScriptProperties();
|
|
||||||
props.scriptLibrary = DEFAULT_SCRIPT_LIBRARY;
|
|
||||||
}
|
|
||||||
|
|
||||||
File stringTemplate = props.scriptTemplate;
|
|
||||||
if (stringTemplate == null) {
|
|
||||||
stringTemplate = DEFAULT_TEMPLATE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> templateObjects = new HashMap<String, Object>();
|
Map<String, Object> templateObjects = new HashMap<String, Object>();
|
||||||
templateObjects.put("scriptMetadata", queryTerms);
|
templateObjects.put("scriptMetadata", queryTerms);
|
||||||
templateObjects.put("maxRecords", maxRecords);
|
templateObjects.put("maxRecords", maxRecords);
|
||||||
templateObjects.put("scriptLibrary", props.scriptLibrary);
|
templateObjects.put("scriptLibrary", SCRIPT_LIBRARY);
|
||||||
templateObjects.put("mode", mode);
|
templateObjects.put("mode", mode);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String script = VelocityManager.executeTemplate(
|
String script = VelocityManager.executeTemplate(
|
||||||
stringTemplate,
|
SCRIPT_TEMPLATE,
|
||||||
DEFAULT_TEMPLATE.getParentFile(),
|
SCRIPT_TEMPLATE.getParentFile(),
|
||||||
new File(FileUtil.join(LocalizationManager.getUserDir(),
|
new File(FileUtil.join(LocalizationManager.getUserDir(),
|
||||||
"logs")), templateObjects);
|
"logs")), templateObjects);
|
||||||
// System.out.println("Script gen: "
|
// System.out.println("Script gen: "
|
||||||
|
|
|
@ -66,34 +66,6 @@
|
||||||
resourceType="PLAN_VIEW">
|
resourceType="PLAN_VIEW">
|
||||||
</resource>
|
</resource>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
|
||||||
point="com.raytheon.uf.viz.core.scriptTemplate">
|
|
||||||
<scriptTemplate
|
|
||||||
pluginName="obs"
|
|
||||||
scriptLibrary="ObsRequest">
|
|
||||||
</scriptTemplate>
|
|
||||||
<scriptTemplate
|
|
||||||
pluginName="sfcobs"
|
|
||||||
scriptLibrary="SfcObsRequest">
|
|
||||||
</scriptTemplate>
|
|
||||||
<scriptTemplate
|
|
||||||
pluginName="fssobs"
|
|
||||||
scriptLibrary="FSSObsRequest">
|
|
||||||
</scriptTemplate>
|
|
||||||
<scriptTemplate
|
|
||||||
pluginName="bufrua"
|
|
||||||
scriptLibrary="UARequest">
|
|
||||||
</scriptTemplate>
|
|
||||||
<scriptTemplate
|
|
||||||
pluginName="profiler"
|
|
||||||
scriptLibrary="ProfilerRequest">
|
|
||||||
</scriptTemplate>
|
|
||||||
<scriptTemplate
|
|
||||||
pluginName="pointdata"
|
|
||||||
scriptTemplateFile="scriptTemplates/pointData.vm">
|
|
||||||
</scriptTemplate>
|
|
||||||
</extension>
|
|
||||||
|
|
||||||
<extension
|
<extension
|
||||||
point="com.raytheon.uf.viz.localization.localizationpath">
|
point="com.raytheon.uf.viz.localization.localizationpath">
|
||||||
<path
|
<path
|
||||||
|
|
|
@ -21,26 +21,17 @@ package com.raytheon.viz.texteditor.util;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
import com.raytheon.uf.common.dataplugin.text.request.StdTextProductServerRequest;
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct;
|
|
||||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
|
||||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
|
||||||
import com.raytheon.uf.common.site.SiteMap;
|
import com.raytheon.uf.common.site.SiteMap;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
import com.raytheon.uf.common.time.SimulatedTime;
|
import com.raytheon.uf.common.time.SimulatedTime;
|
||||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
|
||||||
import com.raytheon.uf.viz.core.catalog.ScriptCreator;
|
|
||||||
import com.raytheon.uf.viz.core.comm.Loader;
|
|
||||||
import com.raytheon.uf.viz.core.exception.VizException;
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
||||||
import com.raytheon.viz.core.mode.CAVEMode;
|
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||||
import com.raytheon.viz.texteditor.StdTextProductFactory;
|
|
||||||
import com.raytheon.viz.texteditor.msgs.IAviationObserver;
|
import com.raytheon.viz.texteditor.msgs.IAviationObserver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,63 +85,19 @@ public class AviationTextUtility implements IAviationObserver {
|
||||||
currentDate, "\n", "WRK" + "TAF");
|
currentDate, "\n", "WRK" + "TAF");
|
||||||
// System.out.println("Current header: " + currentHeader);
|
// System.out.println("Current header: " + currentHeader);
|
||||||
|
|
||||||
// New up request constraint for table request and
|
StdTextProductServerRequest request = new StdTextProductServerRequest();
|
||||||
// also of the classname of the table for the request
|
request.setWmoid(siteWmoId);
|
||||||
RequestConstraint rcTable = new RequestConstraint("table");
|
request.setSite(siteName);
|
||||||
String tableDatabaseName = "fxa";
|
request.setCccid(siteNode);
|
||||||
String tableClassName = StdTextProduct.class.getName();
|
request.setNnnid("WRK");
|
||||||
|
request.setXxxid("TAF");
|
||||||
|
request.setHdrtime(currentDate);
|
||||||
|
request.setBbbid("NOR");
|
||||||
|
request.setCreatetime(System.currentTimeMillis());
|
||||||
|
request.setProduct(currentHeader + "\n" + tmpStr);
|
||||||
|
|
||||||
RequestConstraint rcDatabase = new RequestConstraint(tableDatabaseName);
|
|
||||||
RequestConstraint rcClass = new RequestConstraint(tableClassName);
|
|
||||||
// New up request constraint for table response using the
|
|
||||||
// tmpStr editor content after marshalling this string to
|
|
||||||
// XML format via the Util class.
|
|
||||||
// New up a StdTextProduct, then set the product component
|
|
||||||
// to the tmpStr that represents the new content.
|
|
||||||
|
|
||||||
StdTextProduct tmpProd = StdTextProductFactory.getInstance(CAVEMode
|
|
||||||
.getMode());
|
|
||||||
tmpProd.setWmoid(siteWmoId);
|
|
||||||
tmpProd.setSite(siteName);
|
|
||||||
tmpProd.setCccid(siteNode);
|
|
||||||
tmpProd.setNnnid("WRK");
|
|
||||||
tmpProd.setXxxid("TAF");
|
|
||||||
tmpProd.setHdrtime(currentDate);
|
|
||||||
tmpProd.setBbbid("NOR");
|
|
||||||
tmpProd.setRefTime(System.currentTimeMillis());
|
|
||||||
tmpProd.setProduct(currentHeader + "\n" + tmpStr);
|
|
||||||
|
|
||||||
RequestConstraint rcRow;
|
|
||||||
try {
|
try {
|
||||||
rcRow = new RequestConstraint(
|
ThriftClient.sendRequest(request);
|
||||||
SerializationUtil.marshalToXml(tmpProd));
|
|
||||||
} catch (JAXBException e) {
|
|
||||||
statusHandler.handle(Priority.PROBLEM, "Error serializing data", e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// New up hash map and populate with entry query
|
|
||||||
// parameters before newing up layer property
|
|
||||||
HashMap<String, RequestConstraint> query = new HashMap<String, RequestConstraint>();
|
|
||||||
query.put("pluginName", rcTable);
|
|
||||||
query.put("databasename", rcDatabase);
|
|
||||||
query.put("classname", rcClass);
|
|
||||||
query.put("rowname", rcRow);
|
|
||||||
// New up layer property and set then entry parameters
|
|
||||||
LayerProperty lpParm = new LayerProperty();
|
|
||||||
try {
|
|
||||||
lpParm.setEntryQueryParameters(query, false);
|
|
||||||
// Create Image <Any> Script for table request
|
|
||||||
String tableScript = ScriptCreator.createUpdateScript(lpParm);
|
|
||||||
// Capture the script to the console for now...
|
|
||||||
// System.out.printf("The update script is: %n%s%n", tableScript);
|
|
||||||
// Later call loadData method to run the script...
|
|
||||||
// For now, mouse the script in to the AWIPS Test Driver
|
|
||||||
// Interface through the Request/Response Message dialog.
|
|
||||||
// List<IMarshallable> list;
|
|
||||||
// list = Loader.loadData(tableScript, 10000);
|
|
||||||
Loader.loadData(tableScript, 10000);
|
|
||||||
// textEditor.insert(((StdTextProduct) (list.get(0)))
|
|
||||||
// .getProduct());
|
|
||||||
} catch (VizException e1) {
|
} catch (VizException e1) {
|
||||||
statusHandler.handle(Priority.PROBLEM, "Error retrieving metadata",
|
statusHandler.handle(Priority.PROBLEM, "Error retrieving metadata",
|
||||||
e1);
|
e1);
|
||||||
|
|
|
@ -24,27 +24,16 @@ import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
import com.raytheon.uf.common.dataplugin.text.request.StdTextProductServerRequest;
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct;
|
|
||||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
|
||||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
import com.raytheon.uf.common.time.SimulatedTime;
|
import com.raytheon.uf.common.time.SimulatedTime;
|
||||||
import com.raytheon.uf.edex.wmo.message.WMOHeader;
|
import com.raytheon.uf.edex.wmo.message.WMOHeader;
|
||||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
|
||||||
import com.raytheon.uf.viz.core.catalog.ScriptCreator;
|
|
||||||
import com.raytheon.uf.viz.core.comm.Loader;
|
|
||||||
import com.raytheon.uf.viz.core.exception.VizException;
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
import com.raytheon.uf.viz.core.status.StatusConstants;
|
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||||
import com.raytheon.viz.core.mode.CAVEMode;
|
|
||||||
import com.raytheon.viz.texteditor.Activator;
|
|
||||||
import com.raytheon.viz.texteditor.StdTextProductFactory;
|
|
||||||
import com.raytheon.viz.texteditor.msgs.IRadarObserver;
|
import com.raytheon.viz.texteditor.msgs.IRadarObserver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,7 +57,8 @@ import com.raytheon.viz.texteditor.msgs.IRadarObserver;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RadarTextUtility implements IRadarObserver {
|
public class RadarTextUtility implements IRadarObserver {
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(RadarTextUtility.class);
|
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(RadarTextUtility.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveRadarTextProd(String textProd) {
|
public void saveRadarTextProd(String textProd) {
|
||||||
|
@ -115,66 +105,19 @@ public class RadarTextUtility implements IRadarObserver {
|
||||||
|
|
||||||
// System.out.println("Current header: " + currentHeader);
|
// System.out.println("Current header: " + currentHeader);
|
||||||
|
|
||||||
// New up request constraint for table request and
|
StdTextProductServerRequest request = new StdTextProductServerRequest();
|
||||||
// also of the classname of the table for the request
|
request.setWmoid(wmoId);
|
||||||
RequestConstraint rcTable = new RequestConstraint("table");
|
request.setSite(siteId);
|
||||||
String tableDatabaseName = "fxa";
|
request.setCccid(siteNode);
|
||||||
String tableClassName = StdTextProduct.class.getName();
|
request.setNnnid(category);
|
||||||
|
request.setXxxid(designator);
|
||||||
|
request.setHdrtime(currentDate);
|
||||||
|
request.setBbbid("NOR");
|
||||||
|
request.setCreatetime(System.currentTimeMillis());
|
||||||
|
request.setProduct(currentHeader + "\n" + strBldr.toString());
|
||||||
|
|
||||||
RequestConstraint rcDatabase = new RequestConstraint(
|
|
||||||
tableDatabaseName);
|
|
||||||
RequestConstraint rcClass = new RequestConstraint(tableClassName);
|
|
||||||
// New up request constraint for table response using the
|
|
||||||
// tmpStr editor content after marshalling this string to
|
|
||||||
// XML format via the Util class.
|
|
||||||
// New up a StdTextProduct, then set the product component
|
|
||||||
// to the tmpStr that represents the new content.
|
|
||||||
|
|
||||||
StdTextProduct tmpProd = StdTextProductFactory.getInstance(CAVEMode
|
|
||||||
.getMode());
|
|
||||||
tmpProd.setWmoid(wmoId);
|
|
||||||
tmpProd.setSite(siteId);
|
|
||||||
tmpProd.setCccid(siteNode);
|
|
||||||
tmpProd.setNnnid(category);
|
|
||||||
tmpProd.setXxxid(designator);
|
|
||||||
tmpProd.setHdrtime(currentDate);
|
|
||||||
tmpProd.setBbbid("NOR");
|
|
||||||
tmpProd.setRefTime(System.currentTimeMillis());
|
|
||||||
tmpProd.setProduct(currentHeader + "\n" + strBldr.toString());
|
|
||||||
|
|
||||||
RequestConstraint rcRow;
|
|
||||||
try {
|
try {
|
||||||
rcRow = new RequestConstraint(
|
ThriftClient.sendRequest(request);
|
||||||
SerializationUtil.marshalToXml(tmpProd));
|
|
||||||
} catch (JAXBException e) {
|
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
|
||||||
"Error serializing data", e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// New up hash map and populate with entry query
|
|
||||||
// parameters before newing up layer property
|
|
||||||
HashMap<String, RequestConstraint> query = new HashMap<String, RequestConstraint>();
|
|
||||||
query.put("pluginName", rcTable);
|
|
||||||
query.put("databasename", rcDatabase);
|
|
||||||
query.put("classname", rcClass);
|
|
||||||
query.put("rowname", rcRow);
|
|
||||||
// New up layer property and set then entry parameters
|
|
||||||
LayerProperty lpParm = new LayerProperty();
|
|
||||||
try {
|
|
||||||
lpParm.setEntryQueryParameters(query, false);
|
|
||||||
// Create Image <Any> Script for table request
|
|
||||||
String tableScript = ScriptCreator.createUpdateScript(lpParm);
|
|
||||||
// Capture the script to the console for now...
|
|
||||||
// System.out.printf("The update script is: %n%s%n",
|
|
||||||
// tableScript);
|
|
||||||
// Later call loadData method to run the script...
|
|
||||||
// For now, mouse the script in to the AWIPS Test Driver
|
|
||||||
// Interface through the Request/Response Message dialog.
|
|
||||||
// List<IMarshallable> list;
|
|
||||||
// list = Loader.loadData(tableScript, 10000);
|
|
||||||
Loader.loadData(tableScript, 10000);
|
|
||||||
// textEditor.insert(((StdTextProduct) (list.get(0)))
|
|
||||||
// .getProduct());
|
|
||||||
} catch (VizException e1) {
|
} catch (VizException e1) {
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
"Error retrieving metadata", e1);
|
"Error retrieving metadata", e1);
|
||||||
|
|
Loading…
Add table
Reference in a new issue