Class PropertyUtil |
Utility support class for use when implementing a persistent Property class. The methods include those that are likely to need overriding, depending on the specifics of the underlying database. The versions provided here are known to work the PostgreSQL versions 9.6+. This class may need to be overridden to support other SQL databases.
Details |
Constructor |
PropertyUtil(tableName:"property_table")
Methods: |
tableName | name of new table |
Reference a different table name.
SQL string for clearing all properties |
Return an SQL command for clearing all properties from the Property table.
SQL string for creating a table if it doesn't exist |
Return an SQL command for creating the Property table if it doesn't already exist. Note: Works with PostgreSQL 9.6+ but may need to be overridden and called from code that first determines if the table exists or not in other languages. Uses the IF NOT EXISTS option on the CREATE TABLE command.
SQL string for fetching all property names |
Return an SQL command for fetching all property names in the table.
SQL string for fetching all properties |
Return an SQL command for fetching all properties from the Property table.
pName | Property name |
SQL string for fetching property value as a JSON string |
Return an SQL command for fetching a property value from the Property table.
current property table name |
Produce the current property table name.
table containing propertyname and propertynalue descriptions |
Produce a table of the fields in the table. May need overriding. Generally, there are just two fields: the propertyname and the propertyvalue. The propertyname can be assumed to be less than 256 characters (because no sane person would want to use a longer one!) but the propertyvalue should support arbitrary-length text since it's going to hold the JSON encoding of an arbitrary Unicon entity. For PostgreSQL this means using TEXT datatype. Other DBs might need some other datatype.
insertPropertySQL(pName, pValue)
pName | Property name |
SQL string for doing an upsert of (pName,pValue) pair |
Return an SQL command for doing an upsert into the Property table. Note: Works with PostgreSQL 9.6+ but may need to be overridden for other databases.
pName | name of property to remove |
SQL string for clearing all properties |
Return an SQL command for removing a property from the Property table.
Fields: |