public class ScriptFacades
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private DbHelper |
_dbHelper
The _db helper.
|
private java.lang.String |
_driverName
The _driver name.
|
private java.lang.String |
_hostName
The _host name.
|
private org.apache.log4j.Logger |
_logger
The _logger.
|
private java.lang.String |
_passwordString
The _password string.
|
private java.util.Properties |
_props
The _props.
|
private PublishSupportObject |
_pso
The _pso.
|
private DbTable |
_table
The _table.
|
private java.lang.String |
_tableList
The _table list.
|
private java.lang.String |
_userName
The _user name.
|
private java.lang.String |
_visibility_dev2
The _visibility_dev2.
|
private java.lang.String |
_visibility_scripting
The _visibility_scripting.
|
static java.lang.String |
SQL_MACRO_WRAPPER
The Constant SQL_MACRO_WRAPPER.
|
Constructor and Description |
---|
ScriptFacades()
Instantiates a new script facades.
|
Modifier and Type | Method and Description |
---|---|
void |
addAlert(AlertInfoObject alertObj)
Add the AlertInfoObject and return its ID.
|
private boolean |
checkLegalDbNames(java.lang.String tableName)
Check to see that this table is on the list of "approved" tables.
|
private void |
connect(java.lang.String dbName)
Methods for Database interaction.
|
java.lang.String |
convertXml(java.lang.String dashXml,
java.lang.String mappingXml)
Does string substitution in the dashXml based on the mappingXml.
|
protected void |
createDashTemplateTable()
Creates Table_dash_templates if it doesn't exist already.
|
boolean |
createVisTable(java.lang.String scriptName,
int roleId,
int userId,
java.lang.String tableName,
DbTable tableData)
Creates a table in visibility_dev 2 and updates the appropriate tables so that the data
visualizer can read and display it.
|
boolean |
createVisTable2(int roleId,
int userId,
java.lang.String tableName,
java.util.List<java.lang.Object[]> data)
wrapper method to create a table in Visiblity.
|
DbTable |
dbQuery(java.lang.String sqlString)
Runs a free form SQL string against the visibility_dev2 database.
|
DbTable |
dbQuery(java.lang.String dbName,
java.lang.String sqlString)
Runs a free form SQL string against a passed-in database.
|
DbTable |
dbStoredProc(java.lang.String databaseName,
java.lang.String procName)
Db stored proc.
|
DbTable |
dbStoredQuery(java.lang.String queryName)
Runs a named stored query and return results in DbTable format.
|
java.lang.String |
dbTableToSolrXML(DbTable table)
Db table to solr xml.
|
java.util.List<AlertInfoObject> |
getAlertList()
Gets the alert list.
|
java.util.List<java.lang.String> |
getColumn(DbTable table,
java.lang.String columnName)
Gets the column.
|
java.util.List<java.lang.String> |
getColumn(java.lang.String columnName)
Gets the column.
|
java.util.HashMap<java.lang.String,java.lang.String> |
getDashTemplateXml(java.lang.String dashName)
Get the dashboard template description xml.
|
java.lang.String |
getDashXml(java.lang.String dashName)
Get the dashboard description xml.
|
java.util.List<java.lang.String> |
getHeaders()
*
Get the headers of the current table.
|
java.util.List<java.lang.String> |
getHeaders(DbTable table)
*
Get a list of headers as Strings.
|
java.lang.String[] |
getLegalDbNames()
Gets the legal db names.
|
java.lang.String[] |
getMethodList()
Gets the method list.
|
int |
getRoleId(java.lang.String roleName)
Get the id number of the role from table_roless.
|
SQLResult |
getSavedSQLs()
*
Returns a list of all the queries in the SQL table.
|
SQLResult |
getStoredQueries()
get an SQLResult containing all the queries stored in the table_queries in visibility_scripting.
|
java.util.List<java.util.List<java.lang.String>> |
getTable()
*
Get the current table as a list of list
|
java.util.List<java.util.List<java.lang.String>> |
getTable(DbTable table)
*
Return the table as a list of list
|
int |
getUserId(java.lang.String userLogin)
Get the id number of the user from table_users.
|
static java.lang.String |
getVersion()
Gets the version string (e.g.
|
static void |
main(java.lang.String[] args)
The main method.
|
private void |
outputPrettyXml(org.dom4j.Document doc,
java.io.Writer out)
Output pretty xml.
|
java.util.ArrayList |
parseResultSet(java.sql.ResultSet rs)
Parse a result set into a list of lists, where the first list is the
column headings and the subsequent lists contain the data.
|
void |
publishXml(java.lang.String urlStr,
java.lang.String xmlStr)
Create an entry in visibility_scripting.table_publish.
|
java.lang.String |
readXml(java.lang.String urlStr)
Return the content of an url as a String.
|
boolean |
runPrecompiledInsert(java.lang.String schemaName,
java.lang.String tableName,
java.util.HashMap<java.lang.String,java.lang.String> valueMap)
set up and run a precompiled insert for a table.
|
java.lang.Boolean |
runPythonScript(java.lang.String scriptName)
Run python script.
|
SQLResult |
runSQLStrings(java.lang.String databaseName,
java.lang.String sqlList,
java.lang.String macrosXML)
run list of SQLs on MySQL database, return results accordingly.
|
java.lang.Boolean |
saveMacros(java.lang.String queryName,
java.util.HashMap<java.lang.String,java.lang.String> valueMap)
Store macros for the named query.
|
java.lang.Boolean |
saveMacrosXML(java.lang.String queryName,
java.lang.String xml)
Saves XML that contains variable names and values.
|
java.lang.Boolean |
saveSQLs(java.lang.String queryName,
java.lang.String databaseName,
java.lang.String SQLs,
java.lang.String xml)
Add or update a query in table_queries.
|
boolean |
setDashTemplateXml(java.lang.String dashName,
java.lang.String xmlTemplate,
java.lang.String xmlVariables)
Place template and variables xml into a line in the table_dash_templates table.
|
void |
setDebugDatabases()
Sets the debug databases.
|
void |
setReleaseDatabases()
Sets the release databases.
|
private void |
setup()
Setup.
|
void |
unPublishXml(java.lang.String urlStr)
Turn off the publishing, above.
|
private java.lang.String _hostName
private java.lang.String _driverName
private java.lang.String _userName
private java.lang.String _passwordString
private java.lang.String _tableList
private java.lang.String _visibility_dev2
private java.lang.String _visibility_scripting
private DbTable _table
private org.apache.log4j.Logger _logger
private java.util.Properties _props
private DbHelper _dbHelper
private PublishSupportObject _pso
public static final java.lang.String SQL_MACRO_WRAPPER
public void setDebugDatabases()
public void setReleaseDatabases()
private void setup()
public java.lang.String[] getMethodList()
public java.lang.String readXml(java.lang.String urlStr)
urlStr
- the url strpublic void publishXml(java.lang.String urlStr, java.lang.String xmlStr)
urlStr
- the url strxmlStr
- the xml strpublic void addAlert(AlertInfoObject alertObj)
alertObj
- the alert objpublic java.util.List<AlertInfoObject> getAlertList()
public void unPublishXml(java.lang.String urlStr)
urlStr
- the url strprivate boolean checkLegalDbNames(java.lang.String tableName)
tableName
- the table namepublic java.lang.String[] getLegalDbNames()
private void connect(java.lang.String dbName)
dbName
- the db namepublic boolean runPrecompiledInsert(java.lang.String schemaName, java.lang.String tableName, java.util.HashMap<java.lang.String,java.lang.String> valueMap)
schemaName
- - the name of the database. Must be a 'legally accessible' db from VSStableName
- - the name of the table. Can be anything in the db, so be careful!valueMap
- - contains key/value pairs that should match the columns in the tablepublic DbTable dbStoredProc(java.lang.String databaseName, java.lang.String procName)
databaseName
- the database nameprocName
- the proc namepublic DbTable dbStoredQuery(java.lang.String queryName)
queryName
- the query namepublic DbTable dbQuery(java.lang.String sqlString)
sqlString
- - the SQL querypublic DbTable dbQuery(java.lang.String dbName, java.lang.String sqlString)
dbName
- - the database namesqlString
- - the SQL querypublic java.util.List<java.lang.String> getHeaders()
public java.util.List<java.lang.String> getHeaders(DbTable table)
table
- - the table that we want the headers toopublic java.util.List<java.util.List<java.lang.String>> getTable()
public java.util.List<java.util.List<java.lang.String>> getTable(DbTable table)
table
- the tablepublic java.util.List<java.lang.String> getColumn(java.lang.String columnName)
columnName
- the column name we're trying to findpublic java.util.List<java.lang.String> getColumn(DbTable table, java.lang.String columnName)
table
- the table the column is incolumnName
- the column name we're trying to findprivate void outputPrettyXml(org.dom4j.Document doc, java.io.Writer out)
doc
- the docout
- the output Writerpublic java.lang.String dbTableToSolrXML(DbTable table)
table
- the DbTable to convertpublic SQLResult runSQLStrings(java.lang.String databaseName, java.lang.String sqlList, java.lang.String macrosXML)
databaseName
- the database namesqlList
- a set of SQL commands:
"select * from #table1# left join #table2#"macrosXML
- the macros xml:
"public SQLResult getStoredQueries()
public java.util.ArrayList parseResultSet(java.sql.ResultSet rs) throws java.sql.SQLException
rs
- the ResultSet to Parsejava.sql.SQLException
- the SQL exceptionpublic java.lang.Boolean saveSQLs(java.lang.String queryName, java.lang.String databaseName, java.lang.String SQLs, java.lang.String xml)
queryName
- the query namedatabaseName
- the database nameSQLs
- the SQL queryxml
- macro xmlpublic java.lang.Boolean saveMacros(java.lang.String queryName, java.util.HashMap<java.lang.String,java.lang.String> valueMap)
queryName
- the query that uses this macrovalueMap
- the value map that contains the macro NAME and VALUEpublic java.lang.Boolean saveMacrosXML(java.lang.String queryName, java.lang.String xml)
queryName
- - the name that's stored in the query dbxml
- - the xml shown abovepublic SQLResult getSavedSQLs()
public boolean createVisTable2(int roleId, int userId, java.lang.String tableName, java.util.List<java.lang.Object[]> data)
roleId
- - the role guid of the user as returned by getRoleId()userId
- - the guid of the user as returned by getUserId()tableName
- - the name of the table to be createddata
- - a list containing the data to be written to the DB. All values are strings.
first row contains the header, rests are datapublic boolean createVisTable(java.lang.String scriptName, int roleId, int userId, java.lang.String tableName, DbTable tableData)
scriptName
- the script name (unused)roleId
- - the role guid of the user as returned by getRoleId()userId
- - the guid of the user as returned by getUserId()tableName
- - the name of the table to be createdtableData
- - a DbTable containing the data to be written to the DB. All values are strings.protected void createDashTemplateTable() throws java.lang.Exception
java.lang.Exception
- the exceptionpublic java.lang.String getDashXml(java.lang.String dashName)
dashName
- - the name of the dashboard in table_dashboardspublic java.util.HashMap<java.lang.String,java.lang.String> getDashTemplateXml(java.lang.String dashName)
dashName
- the name of the dashboard in table_dash_templatespublic java.lang.String convertXml(java.lang.String dashXml, java.lang.String mappingXml)
dashXml
- - the xml to be convertedmappingXml
- - the xml cotaining the mappings described abovepublic boolean setDashTemplateXml(java.lang.String dashName, java.lang.String xmlTemplate, java.lang.String xmlVariables)
dashName
- the dash namexmlTemplate
- - the dashboard xml that contains the variables to be replacedxmlVariables
- - the xml that contains the variables as described abovepublic int getRoleId(java.lang.String roleName)
roleName
- the role namepublic int getUserId(java.lang.String userLogin)
userLogin
- the user loginpublic static java.lang.String getVersion()
public java.lang.Boolean runPythonScript(java.lang.String scriptName)
scriptName
- the name of the script in the script tablepublic static void main(java.lang.String[] args) throws java.lang.Exception
args
- the argumentsjava.lang.Exception
- the exception