public abstract class CommonShell extends java.lang.Object implements UpgConstants
Generally speaking, the instance should provide the following methods:
setupInstance
(for standalone invokation),
setupNested
(for invokation from another configuration utility), and/or
endSetupInstance
.
process
must be overridden to provide the core functionality.
endProcessInstance
should be overridden.
To invoke from within MXServer, the calling routine must do the following:
constructor
that accepts the MXServer parameter.
setup
, passing the appropriate parameters.
process
.
endProcess
.
To invoke from another configuration utility class, the calling routine must do the following:
setupNested
, passing the appropriate parameters.
process
.
endProcess
.
The commandline parameters for CommonShell are as follows:
Parameter ID | Parameter Value | Description |
---|---|---|
-a | Database alias | This is optional.
If not specified, uses mxe.db.url from properties file.
The value is used in setupFromPropfile
when connecting to the database. If this class is invoked from within MXServer,
this parameter is not used.
|
-d | Directory for output file | This is optional.
If not specified, uses the MXServer "log" directory.
This value is used in endSetup .
If you do not want to specify -d and do not want the "log" directory,
then override createOutfile .
|
-e | (none) | This is optional. Indicates to execute all Sql statements.
If this is not specified, only the necessary Select stements will be executed.
Either -l, -e, or both must be specified.
This value is stored in the execute variable and is used in
doSql .
|
-f | Filename for properties file | This is optional.
If not specified, the default is maximo.properties.
The value is used in setupFromPropfile .
If this class is invoked from within MXServer, this parameter is not used.
Also see -k parameter to specify properties directory.
|
-h | (none) | Show help. If specified, a list of the possible standard commandline parameters will be printed to the screen, and the program will not run after that. |
-help | (none) | Same as -h .
|
-k | Directory for properties file | This is optional.
If this class is invoked from within MXServer, this parameter is not used.
Also see -f parameter to specify properties filename.
|
-l | (none) | This is optional. Indicates to write all Sql statements
the the logfile (except selects).
Either -l, -e, or both must be specified.
This value is stored in the log variable and is used in
doSql .
|
-o | Filename for output log | This is optional.
If not specified, uses classname + YYYY + MM (month) + DD + HH24 + MM (minutes) + SS.log .
For example: ConfigDB20021209100930.log .
|
-p | Password for database connection | This is optional.
If not specified, uses mxe.db.password from properties file, or "maximo".
The value is handled in setupFromPropfile
when connecting to the database. If this class is invoked from within MXServer,
this parameter is not used (the class calls
getSystemUserInfo ).
|
-u | Username for database connection | This is optional.
If not specified, uses mxe.db.user from properties file, or "maximo".
The value is handled in setupFromPropfile
when connecting to the database. If this class is invoked from within MXServer,
this parameter is not used (the class calls
getSystemUserInfo ).
|
Modifier and Type | Field and Description |
---|---|
java.io.PrintStream |
listStream
The print stream for the lis output.
|
DB2, doNotUpdateACTION, doNotUpdateALNDOMAIN, doNotUpdateAPPLICATIONAUTH, doNotUpdateAUTOKEY, doNotUpdateCONDITION, doNotUpdateCONTRACTPROPERTY, doNotUpdateCONTRACTTYPE, doNotUpdateCROSSOVERDOMAIN, doNotUpdateDOCTYPES, doNotUpdateLANGUAGE, doNotUpdateMAXAPPS, doNotUpdateMAXCONDDETAIL, doNotUpdateMAXCONTROLVALUE, doNotUpdateMAXDOMAIN, doNotUpdateMAXLOGAPPENDER, doNotUpdateMAXLOGGER, doNotUpdateMAXMENU, doNotUpdateMAXMESSAGES, doNotUpdateMAXMODULES, doNotUpdateMAXPROP, doNotUpdateMAXPROPVALUE, doNotUpdateMAXROLE, doNotUpdateMAXSEQUENCE, doNotUpdateMAXSERSECURITY, doNotUpdateMAXSERVICE, doNotUpdateMAXTABLEDOMAIN, doNotUpdateMAXVARS, doNotUpdateMAXVARTYPE, doNotUpdateMXCOLLAB, doNotUpdateMXCOLLABREF, doNotUpdateNUMERICDOMAIN, doNotUpdateNUMRANGEDOMAIN, doNotUpdatePORTLET, doNotUpdatePRICALC, doNotUpdateSECURITYRESTRICT, doNotUpdateSIGOPTION, doNotUpdateSYNONYMDOMAIN, doNotUpdateTAXTYPE, doNotUpdateWORKPRIORITY, doNotUpdateWORKTYPE, doNotUpdateWPEDITSETTING, messageCache, NEWONLY, OLDANDNEW, OLDONLY, ORACLE, SQLINET, SQLMICROSOFT, SQLSERVER, SYSDATATABLES, SYSTEMTABLES, UNKNOWN
Constructor and Description |
---|
CommonShell()
This constructor does nothing.
|
CommonShell(MXServer server)
This constructor accepts parameter for MXServer and
sets value for
mxs . |
Modifier and Type | Method and Description |
---|---|
void |
createOutfile(java.lang.String outdir,
java.lang.String outfile)
Create the output file (
outputFile and out ). |
void |
doCall(java.lang.String sql)
Execute a callable statement.
|
void |
doDB2TextSearchCall(java.lang.String sql)
For DB2 text search procedures (SYSPROC.SYSTS...).
|
void |
doSql(java.util.List list)
Loops through an array and calls
doSql for each element. |
void |
doSql(java.util.List list,
Util util)
Loops through an array and calls
doSql for each element. |
void |
doSql(java.lang.String sql)
Looks at params to determine whether the execute only, log only, or both execute and log.
|
void |
doSql(java.lang.String sql,
Util util)
Looks at params to determine whether the execute only, log only, or both execute and log.
|
void |
doWait(int milli)
Wait the specified number of milliseconds.
|
void |
endProcess(boolean errors)
Close the connection, deregister the driver.
|
void |
endProcessInstance()
Called from
endProcess for any additional end-process
functionality. |
void |
endSetup(java.lang.String outdir,
java.lang.String outfile,
java.util.HashMap params)
Finish setup tasks.
|
void |
endSetupInstance(java.lang.String outdir,
java.lang.String outfile,
java.util.HashMap params)
In CommonShell, this does nothing.
|
void |
execRuntime(java.lang.String arg)
Execute a runtime command on the O/S.
|
java.lang.String |
getDisplayMessage(java.lang.String errorkey)
Call
getDisplayMessage with null second param. |
java.lang.String |
getDisplayMessage(java.lang.String errorkey,
java.lang.Object[] params)
Error group is assumed to be "configdb".
|
java.io.File |
getOutfile()
Return the output file.
|
java.io.PrintStream |
getOutstream()
Return logfile.
|
java.lang.String |
getProperty(java.lang.String propName)
Get the property value from cache.
|
java.lang.String |
getRootDirName()
Get the name of the MXServer root directory.
|
void |
logSql(java.lang.String sql)
Records a sql statement to the log, and only the log.
|
abstract void |
process()
Main processing routine for this class.
|
static java.lang.String |
reformatForDB2(java.sql.Connection sqlCon,
java.lang.String sqlIn)
Reformat the nextval for DB2
|
static java.lang.String |
reformatForSqlsvr(java.sql.Connection sqlCon,
java.lang.String sql)
This method is used for reformatting the sql statement for Sql Server script.
|
void |
setConnection(java.sql.Connection inCon) |
void |
setDB2TextOutput(java.io.PrintStream out1,
java.io.PrintStream out2) |
void |
setup(java.util.HashMap params)
Master setup method (when not nested).
|
java.lang.String |
setupFromPropfile(java.lang.String propfile,
java.lang.String user,
java.lang.String password,
java.lang.String tempUrl,
java.lang.String rootDirName,
java.lang.String propdir)
Setup when not invoked directly from MXServer.
|
void |
setupInstance(java.util.HashMap params)
In CommonShell, this does nothing.
|
void |
setupNested(java.sql.Connection con,
Util util,
java.lang.String schemaOwner,
java.sql.Driver driver,
java.lang.String outdir,
boolean logparam,
boolean execparam,
java.util.HashMap params,
java.lang.String nestedUrl)
This version of setup is used when this class is invoked from another configuration utility
(for example, when ConfigDB is instanciated from Upgrade).
|
void |
setupNestedInstance(java.util.HashMap params)
In CommonShell, this does nothing.
|
void |
setUserLangCode(java.lang.String value) |
void |
showMsg(java.lang.String str)
Display a one-line "info" message to the console (or Logger)
and to the logfile.
|
void |
showMXException(MXApplicationException e)
Display a message to the console and to the logfile, including errorGroup and errorKey.
|
void |
showMXException(MXApplicationException e,
boolean infoOnly,
boolean hideErrorKey)
Display a message to the console and to the logfile, including errorGroup and errorKey.
|
public CommonShell()
public abstract void process() throws java.lang.Exception
Either setup
or setupNested
must be called prior to
process
.
java.lang.Exception
public void doSql(java.util.List list) throws java.lang.Exception
doSql
for each element.list
- Any instance or extension of AbstractList, including ArrayList, etc.java.lang.Exception
doSql(String)
public void doSql(java.util.List list, Util util) throws java.lang.Exception
doSql
for each element.list
- Any instance or extension of AbstractList, including ArrayList, etc.java.lang.Exception
doSql(String)
public void doSql(java.lang.String sql) throws java.lang.Exception
sql
- The Sql statementjava.lang.Exception
public void doSql(java.lang.String sql, Util util) throws java.lang.Exception
sql
- The Sql statementjava.lang.Exception
public void doCall(java.lang.String sql) throws java.lang.Exception
sql
- The statement, such as "{call maximo_ts_job_call}".java.lang.Exception
public void doDB2TextSearchCall(java.lang.String sql) throws java.lang.Exception
sql
- java.lang.Exception
public void doWait(int milli) throws java.lang.Exception
milli
- java.lang.Exception
public java.lang.String getProperty(java.lang.String propName)
This will not work for Maxinst, since properties will not yet exist on database.
propName
- Property namepublic static java.lang.String reformatForSqlsvr(java.sql.Connection sqlCon, java.lang.String sql) throws java.lang.Exception
This method is provided in CommonShell so that those processes that need it can reformat the Sql statement input to doSql before executing. It does not automatically reformat anything via the superclass.
sqlCon
- Connectionsql
- The original sql statement.java.lang.Exception
public static java.lang.String reformatForDB2(java.sql.Connection sqlCon, java.lang.String sqlIn) throws java.lang.Exception
sqlCon
- sqlIn
- java.lang.Exception
public void execRuntime(java.lang.String arg) throws java.lang.Exception
arg
- java.lang.Exception
public void showMXException(MXApplicationException e, boolean infoOnly, boolean hideErrorKey)
e
- The MXApplicationException; must have error group "configdb".infoOnly
- True if this is an Info message, False is this is an Error (or Warning) message.hideErrorKey
- True to hide the errorGroup and errorKey.
This would be True for messages such as the header of the Unlcvt output.getDisplayMessage(java.lang.String, java.lang.Object[])
public java.lang.String getDisplayMessage(java.lang.String errorkey, java.lang.Object[] params)
errorkey
- params
- public java.lang.String getDisplayMessage(java.lang.String errorkey)
getDisplayMessage
with null second param.
Error group is assumed to be "configdb".errorkey
- public void showMXException(MXApplicationException e)
e
- The MXApplicationException; must have error group "configdb".public void showMsg(java.lang.String str)
str
- The one-line message to be displayed.public final void logSql(java.lang.String sql)
sql
- The Sql to recordpublic void setup(java.util.HashMap params) throws java.lang.Exception
setup
or setupNested
must be called prior to
process
.
If an extension of CommonShell has more than the standard parameters,
the method setupInstance
or endSetupInstance
should be extended.
params
- HashMap of input parameters, where key = the parameter identifier
(for example, -u
) and value = the value of the parameter
(for example, SMITH
). If there is no value, it should equal
the empty string "". See javadocs for the list of parameters for this class.java.lang.Exception
setupFromPropfile(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
,
setupFromMXServer(java.lang.String)
,
loadMessageCache()
,
Util.getYes()
,
Util.getNo()
,
Util.dbIn
,
setupInstance(java.util.HashMap)
,
endSetup(java.lang.String, java.lang.String, java.util.HashMap)
public java.lang.String getRootDirName() throws java.lang.Exception
java.lang.Exception
public void setupInstance(java.util.HashMap params) throws java.lang.Exception
setup
after the standard
parameters have been loaded into cache.
If the output file name should be anything other than classname + ".log", the default value
outFileNameDefault
should be set here.
params
- HashMap of input parameters, where key = the parameter identifier
(for example, -u
) and value = the value of the parameter
(for example, SMITH
). If there is no value, it should equal
the empty string "". See javadocs for the list of parameters for this class.java.lang.Exception
public java.lang.String setupFromPropfile(java.lang.String propfile, java.lang.String user, java.lang.String password, java.lang.String tempUrl, java.lang.String rootDirName, java.lang.String propdir) throws java.lang.Exception
propfile
- Name of properties fileuser
- Username when not connecting via MXServer (optional). Must be a superuser.
Defaults to mxe.db.user.password
- Password when not connecting via MXServer (optional). Must be a superuser.
Defaults to mxe.db.password.tempUrl
- Database url (alias) (optional). Defaults to mxe.db.url.rootDirName
- The name of the MXServer root directory.propdir
- The name of the directory containing the properties file.java.lang.Exception
public void setupNested(java.sql.Connection con, Util util, java.lang.String schemaOwner, java.sql.Driver driver, java.lang.String outdir, boolean logparam, boolean execparam, java.util.HashMap params, java.lang.String nestedUrl) throws java.lang.Exception
setup
or setupNested
must be called prior to
process
.
If an extension of CommonShell has more than the standard parameters,
the method setupNestedInstance
or endSetupInstance
should be extended.
con
- Database connectionutil
- Util classschemaOwner
- The schema ownerdriver
- Database driveroutdir
- Output directorylogparam
- True for verbose logging, False to log only messages.execparam
- True to execute Sql, else False.params
- HashMap for any additional parameters required for the instance.
If no additional parameters are needed, this may be null or empty.nestedUrl
- Database url.java.lang.Exception
setupNestedInstance(java.util.HashMap)
,
endSetup(java.lang.String, java.lang.String, java.util.HashMap)
,
thisIsNested
public void setupNestedInstance(java.util.HashMap params) throws java.lang.Exception
setupNested
after the standard
parameters have been loaded into cache.params
- HashMap of any additional runtime parameters beyond those explicitly provided
via setupNested
, where key = the parameter identifier
(for example, -u
) and value = the value of the parameter
(for example, SMITH
). If there is no value, it should equal
the empty string "". See javadocs for the list of parameters for this class.java.lang.Exception
public void endSetup(java.lang.String outdir, java.lang.String outfile, java.util.HashMap params) throws java.lang.Exception
outdir
- Output directoryoutfile
- Output filenameparams
- HashMap of parameters.java.lang.Exception
createOutfile(java.lang.String, java.lang.String)
,
endSetupInstance(java.lang.String, java.lang.String, java.util.HashMap)
public void createOutfile(java.lang.String outdir, java.lang.String outfile) throws java.lang.Exception
outputFile
and out
).
If no -d parameter was specified, this defaults to the mxserver "log" directory,
unless this method is overridden in the instance.outdir
- The output directory.outfile
- The output filename.java.lang.Exception
public java.io.File getOutfile()
public java.io.PrintStream getOutstream()
out
public void endSetupInstance(java.lang.String outdir, java.lang.String outfile, java.util.HashMap params) throws java.lang.Exception
endSetup
after the standard
parameters have been loaded into cache.params
- HashMap of any additional runtime parameters, where key = the parameter identifier
(for example, -u
) and value = the value of the parameter
(for example, SMITH
). If there is no value, it should equal
the empty string "". See javadocs for the list of parameters for this class.java.lang.Exception
public void endProcess(boolean errors) throws java.lang.Exception
errors
- True if ended with errorsjava.lang.Exception
endProcessInstance()
public void endProcessInstance() throws java.lang.Exception
endProcess
for any additional end-process
functionality. Does nothing in CommonShell.java.lang.Exception
public void setDB2TextOutput(java.io.PrintStream out1, java.io.PrintStream out2)
public void setUserLangCode(java.lang.String value) throws java.lang.Exception
value
- The user's language code -- used only for running within an app in MXServer.java.lang.Exception
public void setConnection(java.sql.Connection inCon) throws java.lang.Exception
inCon
- The connection for use in special situations.java.lang.Exception