Package mondrian.tui
Class CmdRunner
java.lang.Object
mondrian.tui.CmdRunner
Command line utility which reads and executes MDX commands.
TODO: describe how to use this class.
- Author:
- Richard Emberson
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidappendCube(StringBuilder buf) protected static voidappendEcho(StringBuilder buf) protected static voidappendError(StringBuilder buf) protected static voidappendExit(StringBuilder buf) protected static voidappendExpr(StringBuilder buf) protected static voidappendFile(StringBuilder buf) protected static voidappendFunc(StringBuilder buf) protected static voidappendIndent(StringBuilder buf, int i) protected static voidappendList(StringBuilder buf) protected static voidappendLog(StringBuilder buf) protected static voidappendParam(StringBuilder buf) protected static voidappendSet(StringBuilder buf) protected voidcommandLoop(boolean interactive) protected voidcommandLoop(File file) protected voidcommandLoop(Reader in, boolean interactive) The Command Loop where lines are read from the InputStream and interpreted.protected voidcommandLoop(String mdxCmd, boolean interactive) protected voidExecutes a query and returns the result as a string.protected StringexecuteCube(String mdxCmd) voidexecuteCubeCommand(String cubename, String command, StringBuilder buf) protected StringexecuteEcho(String mdxCmd) protected StringexecuteError(String mdxCmd) protected StringexecuteExpr(String mdxCmd) protected StringexecuteFile(String mdxCmd) protected StringexecuteFunc(String mdxCmd) protected static StringexecuteHelp(String mdxCmd) protected StringexecuteList(String mdxCmd) protected StringexecuteLog(String mdxCmd) protected StringexecuteMdxCmd(String mdxCmd) protected StringexecuteParam(String mdxCmd) protected StringexecuteSet(String mdxCmd) protected static StringGets a connection to Mondrian.getConnection(boolean fresh) Gets a Mondrian connection, creating a new one if fresh is true.getConnectString(boolean fresh) protected static StringCube[]getCubes()protected static Stringprotected static Stringprotected static Stringprotected static Stringprotected static intgetLine(Reader reader, StringBuilder line) Read the next line of input.org.olap4j.OlapConnectionGets an olap4j connection, creating a new one if fresh is true.longbooleanlonghighCardToString(Result result) Converts aResultobject to a string printing to standard output directly, without buffering.static booleanstatic booleanisProperty(String propertyName) voidlistCubeAttribues(String name, StringBuilder buf) voidstatic voidlistParam(String name, StringBuilder buf) static voidstatic voidstatic voidlistProperty(String propertyName, StringBuilder buf) static voidvoidloadParameter(Query query, Parameter param) voidloadParameters(Query query) protected static voidloadPropertiesFromFile(String propFile) static voidvoidvoidmondrian.tui.CmdRunner.ExprparseParameter(String value) protected voidprotected voidprintResults(String resultString) protected voidprocessSoapXmla(File file, int validateXmlaResponse) This is called to process a file containing XMLA as the contents of SOAP xml.protected voidprocessXmla(File file, int validateXmlaResponce) This is called to process a file containing XMLA xml.protected static intreadBlock(Reader reader, StringBuilder line, int offset, String startDelim, String endDelim, boolean allowEscape, boolean addToBuf, StringBuilder buf, int i) Start of a delimted block, read all of it even if it spans more than one line adding each line'sto the buffer. protected static StringGather up a line ending in '\n' or EOF.protected static intreadString(Reader reader, StringBuilder line, int offset, StringBuilder buf, int i) Start of a string, read all of it even if it spans more than one line adding each line'sto the buffer. protected StringExecutes a query and returns the result.<T> TrunQuery(String queryString, Util.Functor1<T, org.olap4j.CellSet> f) Executes a query and processes the result using a callback.voidsetCubeAttribute(String cubename, String name, String value, StringBuilder buf) static voidsetParameter(String name, String value) static booleansetProperty(String name, String value) voidsetTimeQueries(boolean timeQueries) Converts aResultobject to a stringprotected static voidusage(String msg, PrintStream out) Prints a usage message.
-
Constructor Details
-
CmdRunner
Creates aCmdRunner.- Parameters:
options- Option set, or null to use default optionsout- Output writer, or null to useSystem.out.
-
-
Method Details
-
setTimeQueries
public void setTimeQueries(boolean timeQueries) -
getTimeQueries
public boolean getTimeQueries() -
getQueryTime
public long getQueryTime() -
getTotalQueryTime
public long getTotalQueryTime() -
noCubeCaching
public void noCubeCaching() -
listPropertyNames
-
listPropertiesAll
-
listProperty
-
isProperty
-
setProperty
-
loadParameters
-
loadParameter
-
parseParameter
-
listParameterNameValues
-
listParam
-
isParam
-
setParameter
-
getCubes
-
getCube
-
listCubeName
-
listCubeAttribues
-
executeCubeCommand
-
setCubeAttribute
-
execute
Executes a query and returns the result as a string.- Parameters:
queryString- MDX query text- Returns:
- result String
-
runQuery
Executes a query and returns the result.- Parameters:
queryString- MDX query text- Returns:
- a
Resultobject
-
runQuery
Executes a query and processes the result using a callback.- Parameters:
queryString- MDX query text
-
toString
Converts aResultobject to a string- Returns:
- String version of mondrian Result object.
-
highCardToString
Converts aResultobject to a string printing to standard output directly, without buffering.- Returns:
- null String since output is dump directly to stdout.
-
makeConnectString
public void makeConnectString() -
getConnection
Gets a connection to Mondrian.- Returns:
- Mondrian
Connection
-
getConnection
Gets a Mondrian connection, creating a new one if fresh is true.- Returns:
- mondrian Connection.
-
getOlapConnection
Gets an olap4j connection, creating a new one if fresh is true.- Returns:
- mondrian Connection.
- Throws:
SQLException
-
getConnectString
-
getConnectString
-
debug
-
getConnectStringProperty
-
getJdbcURLProperty
-
getJdbcUserProperty
-
getJdbcPasswordProperty
-
getCatalogURLProperty
-
getJdbcDriversProperty
-
commandLoop
- Throws:
IOException
-
commandLoop
- Throws:
IOException
-
commandLoop
- Throws:
IOException
-
commandLoop
The Command Loop where lines are read from the InputStream and interpreted. If interactive then prompts are printed.- Parameters:
in- Input reader (preferably buffered)interactive- Whether the session is interactive
-
printResults
-
printQueryTime
protected void printQueryTime() -
readLine
Gather up a line ending in '\n' or EOF. Returns null if at EOF. Strip out comments. If a comment character appears within a string then its not a comment. Strings are defined with "\"" or "'" characters. Also, a string can span more than one line (a nice little complication). So, if we read a string, then we consume the whole string as part of the "line" returned, including EOL characters. If an escape character is seen '\\', then it and the next character is added to the line regardless of what the next character is.- Throws:
IOException
-
getLine
Read the next line of input. Return the terminating character, -1 for end of file, or \n or \r. Add \n and \r to the end of the buffer to be included in strings and comment blocks.- Throws:
IOException
-
readString
protected static int readString(Reader reader, StringBuilder line, int offset, StringBuilder buf, int i) throws IOException Start of a string, read all of it even if it spans more than one line adding each line'sto the buffer. - Throws:
IOException
-
readBlock
protected static int readBlock(Reader reader, StringBuilder line, int offset, String startDelim, String endDelim, boolean allowEscape, boolean addToBuf, StringBuilder buf, int i) throws IOException Start of a delimted block, read all of it even if it spans more than one line adding each line'sto the buffer. A delimited block is a delimited comment (/\* ... *\/), or a string. - Throws:
IOException
-
processSoapXmla
This is called to process a file containing XMLA as the contents of SOAP xml.- Throws:
Exception
-
processXmla
This is called to process a file containing XMLA xml.- Throws:
Exception
-
executeHelp
-
appendIndent
-
appendSet
-
executeSet
-
appendLog
-
executeLog
-
appendFile
-
executeFile
-
appendList
-
executeList
-
appendFunc
-
executeFunc
-
appendParam
-
executeParam
-
appendCube
-
executeCube
-
appendError
-
executeError
-
appendEcho
-
executeEcho
-
appendExpr
-
executeExpr
-
appendExit
-
reExecuteMdxCmd
-
executeMdxCmd
-
loadPropertiesFromFile
- Throws:
IOException
-
usage
Prints a usage message.- Parameters:
msg- Prefix to the messageout- Output stream
-
main
- Throws:
Exception
-