You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

SlimDAO

Instead of using a static object relational database mapping, MIB Explorer uses its own lightweight and easy configurable database mapping mechanism called SlimDAO.
Basically a SlimDAO DB mapping configuration file contains SQL statements and their fragments in an XML file. Because the SQL dialects of different databases often differ only for special statements, like sequence and constraint creation, SlimDAO supports statement inheritance.
A SQL statement (or a complete script) can be defined in the default context „." and overwritten in a specific context whose name matches the JDBC driver class name for the database whose SQL dialect differs from the default context's dialect (e.g., org.postgresql.Driver for a PostgreSQL database).
Each statement and script in the mapping configuration has a unique name within its context. MIB Explorer will lookup a statement by its name. The name is hard-coded. The supported statement names are defined by the default context in the Monitor2DB.xml file from the db-monitor directory.
A statement is defined for example by the following construct:

    <statement name="select.monitor.by.id">
      SELECT * FROM @INSERT[SCHEMA].MXP_MONITOR
		 WHERE ID = @VALUE[ID]
    </statement>

During runtime, MIB Explorer uses the statement to get monitor data from the database. It replaces the constructs of the pattern

@<TAG>[<PARAM_LIST>]

with the corresponding values as described by the table following this section. The resulting SQL statement would then be executed on the DB server as follows:

SELECT * FROM MXP.MXP_MONITOR WHERE ID = ?

The question mark ? is a placeholder for the value within the prepared statement. The value will be inserted by the JDBC driver when the prepared statement is being executed. MIB Explorer sets the value for the statement by replacing the @VALUEID reference with the ? in the statement and setting the statements first parameter value to the value of ID (for example 2).

Tag

Description

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="9b61ceb8-83a9-4f15-bbe0-b16a2b737d16"><ac:plain-text-body><![CDATA[

@VALUE[<param>]

Replace the tag by
]]></ac:plain-text-body></ac:structured-macro>
Example:? in the statement and set the value of the prepared parameter to the value of the MIB Explorer variable with name <param>.

SELECT ID FROM MXP.MXP_MONITOR WHERE NAME = @VALUE\[NAME\]

will be rendered to

SELECT ID FROM MXP.MXP_MONITOR WHERE NAME = ?

where ? is assigned with the value of the MIB Explorer variable NAME when the statement is being executed.

@INSERT<param>

Replace the tag by the value of MIB Explorer variable with name <param>

Example:

SELECT ID FROM MXP.MXP_MONITOR WHERE NAME = '@INSERT[NAME]'

will be rendered to

SELECT ID FROM MXP.MXP_MONITOR WHERE NAME = 'MyMonitor'

if the variable NAME has the string value MyMonitor.

@USE<statementName>

Replace the tag with the rendered content of the statement with name :<statementName> of the same context.

Example:

<statement name="select.id"> \\
SELECT ID \\
</statement> \\
<statement name="select.monitor.id.by.name"> \\
@USE[select.id] FROM MXP.MXP_MONITOR WHERE NAME = @VALUE[NAME] \\
</statement>

will be rendered to

SELECT ID FROM MXP.MXP_MONITOR WHERE NAME = 'MyMonitor'

if the variable NAME has the string value MyMonitor.

@IF<stmt>,<test>,<value>..

Replace the tag with the statement with name <stmt> if the condition <test> is true for the MIB Explorer variable references <value1> through <valueN>. The supported tests are listed in table Table 16 on page 144.

Example:

<statement name="monitor.dataset.by.id"> \\
SELECT * FROM MXP.MXP_MONITORDATASET WHERE MONITOR_ID = @VALUE\[ID\] \\
@IF\[and.nameOrDataType,not-null,NAME,DATATYPE\] \\
ORDER BY MONITOR_ID,DATATYPE \\
</statement> \\
<statement name="and.nameOrDataType"> \\
AND (NAME = @VALUE\[NAME\] OR DATATYPE = @VALUE\[DATATYPE\]) \\
</statement>

will be rendered to

SELECT * FROM MXP.MXP_MONITORDATASET WHERE MONITOR_ID = ? AND (NAME = ? OR DATATYPE = ?) ORDER BY MONITOR_ID,DATATYPE

if the MIB Explorer variables NAME and DATATYPE are not null.

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="37d44aaf-e25b-4108-9f75-be456afed881"><ac:plain-text-body><![CDATA[

@IFELSE[<stmtTrue>, <stmtFalse>,<test>, <value>..]

Replace the tag with the statement with name
]]></ac:plain-text-body></ac:structured-macro>
Example:<stmtTrue> if the condition <test> is true for the MIB Explorer variable references <value1> through <valueN>. Otherwise, replace the tag with the statement with name <stmtFalse>. The supported tests are listed in table Table 16 on page 144. <statement name="monitor.dataset.by.id">
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e6f8a5c9-0a8d-487b-bcf9-e1ecf3da29b7"><ac:plain-text-body><![CDATA[SELECT * FROM MXP.MXP_MONITORDATASET WHERE MONITOR_ID = @VALUE[ID]
]]></ac:plain-text-body></ac:structured-macro>
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="ac44d1a7-0523-47d3-87bf-3daf8c65e84e"><ac:plain-text-body><![CDATA[@IFELSE[dataTypeNotNull,dataTypeNull,not-null,DATATYPE]
]]></ac:plain-text-body></ac:structured-macro>
</statement>
<statement name="dataTypeNull">
AND DATATYPE IS NULL
</statement>
<statement name="dataTypeNotNull">
AND DATATYPE IS NOT NULL
</statement>will be rendered toSELECT * FROM MXP.MXP_MONITORDATASET WHERE MONITOR_ID = ? AND DATATYPE IS NOT NULLif the MIB Explorer variablesDATATYPE is not null. Otherwise, the statement would be rendered as: SELECT * FROM MXP.MXP_MONITORDATASET WHERE MONITOR_ID = ? AND DATATYPE IS NULL

  • No labels