Class PropertyUtil

Summary

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.

Superclasses:
Object

Package:
propertydb
File:
pdb_util.icn
Methods:
changeTableName, clearAllSQL, describeTableSQL, fetchAllNamesSQL, fetchAllSQL, fetchPropertySQL, getPropertyTableName, getTableFieldsDesc, insertPropertySQL, removePropertySQL

Methods inherited from Object:
Type, className, clone, equals, fieldNames, genMethods, getField, get_class, get_class_name, get_id, hasField, hasMethod, hash_code, instanceOf, invoke, is_instance, setField, to_string

Fields:
dbu, pdbTableName

Source code.

Details
Constructor

PropertyUtil(tableName:"property_table")

Methods:

changeTableName(tableName)

Parameter:
tableName
name of new table

Reference a different table name.


clearAllSQL()

Returns:
SQL string for clearing all properties

Return an SQL command for clearing all properties from the Property table.


describeTableSQL()

Returns:
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.


fetchAllNamesSQL()

Returns:
SQL string for fetching all property names

Return an SQL command for fetching all property names in the table.


fetchAllSQL()

Returns:
SQL string for fetching all properties

Return an SQL command for fetching all properties from the Property table.


fetchPropertySQL(pName)

Parameter:
pName
Property name
Returns:
SQL string for fetching property value as a JSON string

Return an SQL command for fetching a property value from the Property table.


getPropertyTableName()

Returns:
current property table name

Produce the current property table name.


getTableFieldsDesc()

Returns:
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)

Parameter:
pName
Property name
Returns:
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.


removePropertySQL(pName)

Parameter:
pName
name of property to remove
Returns:
SQL string for clearing all properties

Return an SQL command for removing a property from the Property table.


Fields:
dbu

pdbTableName


This page produced by UniDoc on 2021/04/15 @ 23:59:53.