Class DefaultSQLStatementTransformer
java.lang.Object
net.simplace.sim.io.FWSimIOAdapter
net.simplace.sim.io.resources.FWSimInputAdapter
net.simplace.sim.io.resources.FWSimResourceTransformer
net.simplace.sim.transformers.DefaultSQLStatementTransformer
- All Implemented Interfaces:
FWSimFieldContainer
Transforms resource data with an SQL statement (child
statement, may contain ${...}
tokens) on the tables of the resources cached in the database (see dbcache). The result set becomes
the cache of the transformer.
Component Variables
| Content Type | Name | Description | Data Type | Unit | Min Value | Max Value | Default Value |
|---|---|---|---|---|---|---|---|
| constant | statement | - | CHAR | - | - |
- Author:
- Andreas Enders
-
Nested Class Summary
Nested classes/interfaces inherited from class FWSimIOAdapter
FWSimIOAdapter.FREQUENCE -
Field Summary
FieldsFields inherited from class FWSimResourceTransformer
iFieldMap, iIntColumnMap, iLastInputValuesMap, iLastProjectID, iLastUniqueID, iPoolName, iSourceNameFields inherited from class FWSimInputAdapter
iJexlScript, iShouldCacheToDBFields inherited from class FWSimIOAdapter
iArrayMode, iFieldcount, iFrequence, iHeaderVariables, iInterface, iJexlRule, iKeyMap, iName, iOrderNumber, iProcessTime, iResourceElement, iSession, iSourceKey -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for instantiation via reflection (documentation).DefaultSQLStatementTransformer(FWSimSession aSession, Integer aOrderNumber) Creates the transformer without element (seeFWSimResourceTransformer(FWSimSession, Integer)).DefaultSQLStatementTransformer(FWSimSession aSession, org.jdom2.Element aResourceElement, Integer aOrderNumber) Creates the transformer from itstransformelement; the statement is executed on the connection pool of the transformer. -
Method Summary
Modifier and TypeMethodDescriptionHashMap<String, FWSimVariable<?>> Creates the input variablestatement, which is used if no statement element is given.voidfillVarMap(FWSimVarMap aSimVarMap) Deprecated.not used (and not usable, see note)Returnsres.getData(FWSimVarMap aVarMap) Executes the statement and reads the result set into a new cache.protected ResultSetgetResultSet(FWSimVarMap aVarMap) Replaces the tokens in the statement (taken from the variablestatementif no element was given) and executes it.voidupdateFields(FWObservable aObservable) Takes the statement from the form fieldSQL-Statement.Methods inherited from class FWSimResourceTransformer
addVariable, createFormFields, createResourceTransformer, createResourceTransformer, createResourceTransformer, createResourceTransformer, createSimTransformer, getCreateFormXML, getEditFormXML, getSourceResourceCache, getVariable, isUpdated, toDocXML, toXMLMethods inherited from class FWSimInputAdapter
getInputVariables, getJexlScript, getOutputVariables, getVarMap, isTransformer, setFrequenceAndRule, shouldCacheToDB, toHTMLTablestringMethods inherited from class FWSimIOAdapter
addProcessTime, checkCondition, createFormFields, finalize, getFieldMap, getFrequence, getHeaderVariables, getHeaderXML, getInterface, getJexlRule, getKeyMap, getName, getOrderNumber, isArrayMode, isConditionCheck, removeVariable, setInterface, setOrderNumber, toString, writeHeaderList
-
Field Details
-
iStatement
the SQL statement, may contain tokens
-
-
Constructor Details
-
DefaultSQLStatementTransformer
public DefaultSQLStatementTransformer(FWSimSession aSession, org.jdom2.Element aResourceElement, Integer aOrderNumber) Creates the transformer from itstransformelement; the statement is executed on the connection pool of the transformer.- Parameters:
aSession- the sessionaResourceElement- thetransformelementaOrderNumber- order number of the transformer
-
DefaultSQLStatementTransformer
public DefaultSQLStatementTransformer()Constructor for instantiation via reflection (documentation). -
DefaultSQLStatementTransformer
Creates the transformer without element (seeFWSimResourceTransformer(FWSimSession, Integer)).- Parameters:
aSession- the sessionaOrderNumber- order number of the transformer
-
-
Method Details
-
createVariables
Creates the input variablestatement, which is used if no statement element is given.- Specified by:
createVariablesin interfaceFWSimFieldContainer- Overrides:
createVariablesin classFWSimIOAdapter- Returns:
- the variables, keyed by name
- See Also:
-
getData
Executes the statement and reads the result set into a new cache.- Specified by:
getDatain classFWSimInputAdapter- Parameters:
aVarMap- variable map of the simulation (e.g. for the key values of the rule)- Returns:
- the cache containing the data read
- Throws:
MissingSimResourceException- if the data cannot be read- See Also:
-
getResultSet
Replaces the tokens in the statement (taken from the variablestatementif no element was given) and executes it.Note: the connection is returned to the pool in
finally, before the result set is read by the caller. This is intended: reading may need a second connection from the same pool (caching to the database, PROJECT_DATA), which would fail for a pool size of 1. The caller closes result set and statement after reading.- Parameters:
aVarMap- variable map for replacing the tokens- Returns:
- the result set of the statement
- Throws:
MissingSimResourceException- if the statement fails
-
fillVarMap
Deprecated.not used (and not usable, see note)Executes the statement and sets the values of the result (from the third column on) directly to the variable map. SQL errors are logged.Note: relies on
iIntColumnMap, which is never filled, so this method fails with aNullPointerException.- Overrides:
fillVarMapin classFWSimResourceTransformer- Parameters:
aSimVarMap- variable map of the simulation
-
getContentType
Returnsres.- Specified by:
getContentTypein interfaceFWSimFieldContainer- Overrides:
getContentTypein classFWSimInputAdapter- Returns:
- the content type of the variables of this container (e.g.
sys,mgm) - See Also:
-
updateFields
Takes the statement from the form fieldSQL-Statement.- Specified by:
updateFieldsin classFWSimResourceTransformer- Parameters:
aObservable- the form data- See Also:
-