Class PrometheusTableDefinition
java.lang.Object
io.github.tonywasher.joceanus.prometheus.database.PrometheusTableDefinition
Database field definition class. Maps each dataType to a database field.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSortOrder. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPrometheusTableDefinition(PrometheusJDBCDriver pDriver, String pName) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddBinaryColumn(MetisDataItem.MetisDataFieldId pId, int pLength) Add a binary column.Add a boolean column.Add a date column.addEncryptedColumn(MetisDataItem.MetisDataFieldId pId, int pLength) Add an encrypted column.Add an integer column.Add a long column.Add a money column.addNullBinaryColumn(MetisDataItem.MetisDataFieldId pId, int pLength) Add a binary column, which can be null.Add a boolean column, which can be null.Add a date column, which can be null.addNullEncryptedColumn(MetisDataItem.MetisDataFieldId pId, int pLength) Add an encrypted column, which can be null.Add an integer column, which can be null.Add a long column, which can be null.Add a money column, which can be null.Add a rate column, which can be null.Add a rate column, which can be null.Add a reference column, which can be null.addNullStringColumn(MetisDataItem.MetisDataFieldId pId, int pLength) Add a string column, which can be null.(package private) voidaddQuoteIfAllowed(StringBuilder pBuilder) Add quote if necessary.Add a rate column.Add a rate column.Add a reference column.addStringColumn(MetisDataItem.MetisDataFieldId pId, int pLength) Add a string column.protected voidClear values for table.byte[]Get Binary value for column.Get Boolean value for column.protected List<PrometheusColumnDefinition> Column Definitions array.protected StringBuild the count string for a table.protected StringBuild the create index string for the table.protected StringBuild the create table string for the table.Get Date value for column.protected StringBuild the delete string for a table.protected PrometheusJDBCDriverObtain the driver.protected StringBuild the drop index string for the table.protected StringBuild the drop table string for the table.protected StringBuild the insert string for a list of columns.Get Integer value for column.protected StringgetJoinString(char pChar, Integer pOffset) Build the Join string for the list of columns.protected StringBuild the load string for a list of columns.Get Long value for column.getMap()Obtain the column map.getMoneyValue(MetisDataItem.MetisDataFieldId pId, OceanusDataFormatter pFormatter) Get Money value for column.protected StringgetOrderString(char pChar, Integer pOffset) Build the Order string for the list of columns.getPriceValue(MetisDataItem.MetisDataFieldId pId, OceanusDataFormatter pFormatter) Get Price value for column.protected StringBuild the purge string for a table.getRateValue(MetisDataItem.MetisDataFieldId pId, OceanusDataFormatter pFormatter) Get Rate value for column.getRatioValue(MetisDataItem.MetisDataFieldId pId, OceanusDataFormatter pFormatter) Get Ratio value for column.protected List<PrometheusColumnDefinition> Sort List.Get String value for column.protected StringObtain the table name.getUnitsValue(MetisDataItem.MetisDataFieldId pId, OceanusDataFormatter pFormatter) Get Units value for column.protected StringBuild the update string for a list of columns.protected voidinsertValues(PreparedStatement pStmt) Insert values.protected booleanIs the table indexed.protected voidloadResults(ResultSet pResults) Load results.protected voidresolveReferences(List<PrometheusTableDataItem<?>> pTables) Locate reference.voidsetBinaryValue(MetisDataItem.MetisDataFieldId pId, byte[] pValue) Set Binary value for column.voidsetBooleanValue(MetisDataItem.MetisDataFieldId pId, Boolean pValue) Set Boolean value for column.voidsetDateValue(MetisDataItem.MetisDataFieldId pId, OceanusDate pValue) Set Date value for column.voidsetIntegerValue(MetisDataItem.MetisDataFieldId pId, Integer pValue) Set Integer value for column.voidsetLongValue(MetisDataItem.MetisDataFieldId pId, Long pValue) Set Long value for column.voidsetMoneyValue(MetisDataItem.MetisDataFieldId pId, OceanusMoney pValue) Set Money value for column.voidsetRateValue(MetisDataItem.MetisDataFieldId pId, OceanusRate pValue) Set Rate value for column.voidsetRatioValue(MetisDataItem.MetisDataFieldId pId, OceanusRatio pValue) Set Ratio value for column.protected voidNote that we have a sort on reference.voidsetStringValue(MetisDataItem.MetisDataFieldId pId, String pValue) Set String value for column.protected voidupdateValues(PreparedStatement pStmt) Update values.
-
Field Details
-
QUOTE_STRING
The quote string.- See Also:
-
STR_DESC
The Descending string.- See Also:
-
-
Constructor Details
-
PrometheusTableDefinition
Constructor.- Parameters:
pDriver- the driverpName- the table name
-
-
Method Details
-
getTableName
Obtain the table name.- Returns:
- the table name
-
getMap
Obtain the column map.- Returns:
- the map
-
isIndexed
protected boolean isIndexed()Is the table indexed.- Returns:
- true/false
-
getColumns
Column Definitions array.- Returns:
- the columns
-
getSortList
Sort List.- Returns:
- the sort list
-
getDriver
Obtain the driver.- Returns:
- the driver
-
setSortOnReference
protected void setSortOnReference()Note that we have a sort on reference. -
addReferenceColumn
public PrometheusColumnDefinition.PrometheusReferenceColumn addReferenceColumn(MetisDataItem.MetisDataFieldId pId, String pRef) Add a reference column.- Parameters:
pId- the column idpRef- the reference table- Returns:
- the reference column
-
addNullReferenceColumn
public PrometheusColumnDefinition.PrometheusReferenceColumn addNullReferenceColumn(MetisDataItem.MetisDataFieldId pId, String pRef) Add a reference column, which can be null.- Parameters:
pId- the column idpRef- the reference table- Returns:
- the reference column
-
addIntegerColumn
public PrometheusColumnDefinition.PrometheusIntegerColumn addIntegerColumn(MetisDataItem.MetisDataFieldId pId) Add an integer column.- Parameters:
pId- the column id- Returns:
- the integer column
-
addNullIntegerColumn
public PrometheusColumnDefinition.PrometheusIntegerColumn addNullIntegerColumn(MetisDataItem.MetisDataFieldId pId) Add an integer column, which can be null.- Parameters:
pId- the column id- Returns:
- the integer column
-
addLongColumn
public PrometheusColumnDefinition.PrometheusLongColumn addLongColumn(MetisDataItem.MetisDataFieldId pId) Add a long column.- Parameters:
pId- the column id- Returns:
- the long column
-
addNullLongColumn
public PrometheusColumnDefinition.PrometheusLongColumn addNullLongColumn(MetisDataItem.MetisDataFieldId pId) Add a long column, which can be null.- Parameters:
pId- the column id- Returns:
- the long column
-
addBooleanColumn
public PrometheusColumnDefinition.PrometheusBooleanColumn addBooleanColumn(MetisDataItem.MetisDataFieldId pId) Add a boolean column.- Parameters:
pId- the column id- Returns:
- the boolean column
-
addNullBooleanColumn
public PrometheusColumnDefinition.PrometheusBooleanColumn addNullBooleanColumn(MetisDataItem.MetisDataFieldId pId) Add a boolean column, which can be null.- Parameters:
pId- the column id- Returns:
- the boolean column
-
addDateColumn
public PrometheusColumnDefinition.PrometheusDateColumn addDateColumn(MetisDataItem.MetisDataFieldId pId) Add a date column.- Parameters:
pId- the column id- Returns:
- the date column
-
addNullDateColumn
public PrometheusColumnDefinition.PrometheusDateColumn addNullDateColumn(MetisDataItem.MetisDataFieldId pId) Add a date column, which can be null.- Parameters:
pId- the column id- Returns:
- the date column
-
addMoneyColumn
public PrometheusColumnDefinition.PrometheusMoneyColumn addMoneyColumn(MetisDataItem.MetisDataFieldId pId) Add a money column.- Parameters:
pId- the column id- Returns:
- the money column
-
addNullMoneyColumn
public PrometheusColumnDefinition.PrometheusMoneyColumn addNullMoneyColumn(MetisDataItem.MetisDataFieldId pId) Add a money column, which can be null.- Parameters:
pId- the column id- Returns:
- the money column
-
addRateColumn
public PrometheusColumnDefinition.PrometheusRateColumn addRateColumn(MetisDataItem.MetisDataFieldId pId) Add a rate column.- Parameters:
pId- the column id- Returns:
- the rate column
-
addNullRateColumn
public PrometheusColumnDefinition.PrometheusRateColumn addNullRateColumn(MetisDataItem.MetisDataFieldId pId) Add a rate column, which can be null.- Parameters:
pId- the column id- Returns:
- the rate column
-
addRatioColumn
public PrometheusColumnDefinition.PrometheusRatioColumn addRatioColumn(MetisDataItem.MetisDataFieldId pId) Add a rate column.- Parameters:
pId- the column id- Returns:
- the rate column
-
addNullRatioColumn
public PrometheusColumnDefinition.PrometheusRatioColumn addNullRatioColumn(MetisDataItem.MetisDataFieldId pId) Add a rate column, which can be null.- Parameters:
pId- the column id- Returns:
- the rate column
-
addBinaryColumn
public PrometheusColumnDefinition.PrometheusBinaryColumn addBinaryColumn(MetisDataItem.MetisDataFieldId pId, int pLength) Add a binary column.- Parameters:
pId- the column idpLength- the underlying (character) length- Returns:
- the binary column
-
addNullBinaryColumn
public PrometheusColumnDefinition.PrometheusBinaryColumn addNullBinaryColumn(MetisDataItem.MetisDataFieldId pId, int pLength) Add a binary column, which can be null.- Parameters:
pId- the column idpLength- the underlying (character) length- Returns:
- the binary column
-
addEncryptedColumn
public PrometheusColumnDefinition.PrometheusBinaryColumn addEncryptedColumn(MetisDataItem.MetisDataFieldId pId, int pLength) Add an encrypted column.- Parameters:
pId- the column idpLength- the underlying (character) length- Returns:
- the binary column
-
addNullEncryptedColumn
public PrometheusColumnDefinition.PrometheusBinaryColumn addNullEncryptedColumn(MetisDataItem.MetisDataFieldId pId, int pLength) Add an encrypted column, which can be null.- Parameters:
pId- the column idpLength- the underlying (character) length- Returns:
- the binary column
-
addStringColumn
public PrometheusColumnDefinition.PrometheusStringColumn addStringColumn(MetisDataItem.MetisDataFieldId pId, int pLength) Add a string column.- Parameters:
pId- the column idpLength- the character length- Returns:
- the binary column
-
addNullStringColumn
public PrometheusColumnDefinition.PrometheusStringColumn addNullStringColumn(MetisDataItem.MetisDataFieldId pId, int pLength) Add a string column, which can be null.- Parameters:
pId- the column idpLength- the character length- Returns:
- the binary column
-
resolveReferences
Locate reference.- Parameters:
pTables- the list of defined tables
-
loadResults
Load results.- Parameters:
pResults- the result set- Throws:
SQLException- on error
-
insertValues
Insert values.- Parameters:
pStmt- the statement- Throws:
SQLException- on errorOceanusException- on error
-
updateValues
Update values.- Parameters:
pStmt- the statement- Throws:
SQLException- on error
-
clearValues
protected void clearValues()Clear values for table. -
getIntegerValue
Get Integer value for column.- Parameters:
pId- the column id- Returns:
- the integer value
- Throws:
OceanusException- on error
-
getLongValue
Get Long value for column.- Parameters:
pId- the column id- Returns:
- the long value
- Throws:
OceanusException- on error
-
getDateValue
Get Date value for column.- Parameters:
pId- the column id- Returns:
- the Date value
- Throws:
OceanusException- on error
-
getBooleanValue
Get Boolean value for column.- Parameters:
pId- the column id- Returns:
- the boolean value
- Throws:
OceanusException- on error
-
getStringValue
Get String value for column.- Parameters:
pId- the column id- Returns:
- the String value
- Throws:
OceanusException- on error
-
getMoneyValue
public OceanusMoney getMoneyValue(MetisDataItem.MetisDataFieldId pId, OceanusDataFormatter pFormatter) throws OceanusException Get Money value for column.- Parameters:
pId- the column idpFormatter- the data formatter- Returns:
- the Money value
- Throws:
OceanusException- on error
-
getPriceValue
public OceanusPrice getPriceValue(MetisDataItem.MetisDataFieldId pId, OceanusDataFormatter pFormatter) throws OceanusException Get Price value for column.- Parameters:
pId- the column idpFormatter- the data formatter- Returns:
- the price value
- Throws:
OceanusException- on error
-
getRateValue
public OceanusRate getRateValue(MetisDataItem.MetisDataFieldId pId, OceanusDataFormatter pFormatter) throws OceanusException Get Rate value for column.- Parameters:
pId- the column idpFormatter- the data formatter- Returns:
- the rate value
- Throws:
OceanusException- on error
-
getUnitsValue
public OceanusUnits getUnitsValue(MetisDataItem.MetisDataFieldId pId, OceanusDataFormatter pFormatter) throws OceanusException Get Units value for column.- Parameters:
pId- the column idpFormatter- the data formatter- Returns:
- the Units value
- Throws:
OceanusException- on error
-
getRatioValue
public OceanusRatio getRatioValue(MetisDataItem.MetisDataFieldId pId, OceanusDataFormatter pFormatter) throws OceanusException Get Ratio value for column.- Parameters:
pId- the column idpFormatter- the data formatter- Returns:
- the Ratio value
- Throws:
OceanusException- on error
-
getBinaryValue
Get Binary value for column.- Parameters:
pId- the column id- Returns:
- the binary value
- Throws:
OceanusException- on error
-
setIntegerValue
public void setIntegerValue(MetisDataItem.MetisDataFieldId pId, Integer pValue) throws OceanusException Set Integer value for column.- Parameters:
pId- the column idpValue- the value- Throws:
OceanusException- on error
-
setLongValue
Set Long value for column.- Parameters:
pId- the column idpValue- the value- Throws:
OceanusException- on error
-
setBooleanValue
public void setBooleanValue(MetisDataItem.MetisDataFieldId pId, Boolean pValue) throws OceanusException Set Boolean value for column.- Parameters:
pId- the column idpValue- the value- Throws:
OceanusException- on error
-
setDateValue
public void setDateValue(MetisDataItem.MetisDataFieldId pId, OceanusDate pValue) throws OceanusException Set Date value for column.- Parameters:
pId- the column idpValue- the value- Throws:
OceanusException- on error
-
setStringValue
public void setStringValue(MetisDataItem.MetisDataFieldId pId, String pValue) throws OceanusException Set String value for column.- Parameters:
pId- the column idpValue- the value- Throws:
OceanusException- on error
-
setBinaryValue
public void setBinaryValue(MetisDataItem.MetisDataFieldId pId, byte[] pValue) throws OceanusException Set Binary value for column.- Parameters:
pId- the column idpValue- the value- Throws:
OceanusException- on error
-
setMoneyValue
public void setMoneyValue(MetisDataItem.MetisDataFieldId pId, OceanusMoney pValue) throws OceanusException Set Money value for column.- Parameters:
pId- the column idpValue- the value- Throws:
OceanusException- on error
-
setRateValue
public void setRateValue(MetisDataItem.MetisDataFieldId pId, OceanusRate pValue) throws OceanusException Set Rate value for column.- Parameters:
pId- the column idpValue- the value- Throws:
OceanusException- on error
-
setRatioValue
public void setRatioValue(MetisDataItem.MetisDataFieldId pId, OceanusRatio pValue) throws OceanusException Set Ratio value for column.- Parameters:
pId- the column idpValue- the value- Throws:
OceanusException- on error
-
getCreateTableString
Build the create table string for the table.- Returns:
- the SQL string
-
getCreateIndexString
Build the create index string for the table.- Returns:
- the SQL string
-
getDropTableString
Build the drop table string for the table.- Returns:
- the SQL string
-
getDropIndexString
Build the drop index string for the table.- Returns:
- the SQL string
-
getLoadString
Build the load string for a list of columns.- Returns:
- the SQL string
-
getJoinString
Build the Join string for the list of columns.- Parameters:
pChar- the character for this tablepOffset- the join offset- Returns:
- the SQL string
-
getOrderString
Build the Order string for the list of columns.- Parameters:
pChar- the character for this tablepOffset- the join offset- Returns:
- the SQL string
-
getInsertString
Build the insert string for a list of columns.- Returns:
- the SQL string
-
getUpdateString
Build the update string for a list of columns.- Returns:
- the SQL string
- Throws:
OceanusException- on error
-
getDeleteString
Build the delete string for a table.- Returns:
- the SQL string
-
getPurgeString
Build the purge string for a table.- Returns:
- the SQL string
-
getCountString
Build the count string for a table.- Returns:
- the SQL string
-
addQuoteIfAllowed
Add quote if necessary.- Parameters:
pBuilder- the builder
-