The artefacts produced from the code table file of Rules of Code Table Merges, are a symbol definition file (Java class) and an SQL file.
The symbol definition file is a Java file containing constants for code table identifiers used in the code table XML file. This file can be used in conjunction with the curam.util.CodeTable interface to access code table information programmatically.
The Java file is generated to /build/svr/codetable/gen/<package> directory, where <package> is the package attribute specified in the codetable file. For example, package="curam.codetable" would result in the Java artefacts being placed in the /build/svr/codetable/gen/curam/codetable directory.
The code table SQL file contains inserts for the CodeTableHeader and CodeTableItem database tables. All SQL file artefacts are placed in a common directory: /build/svr/codetable/sql/.
These artefacts are best illustrated by example:
package curam.codetable; /** * Generated AcceptanceStatus codetable file. * */ public final class ACCEPTANCESTATUS { /** * TABLENAME=AcceptanceStatus. */ public static final String TABLENAME = new String("AcceptanceStatus"); /** * DEFAULTCODE=ACS1. */ public static final String DEFAULTCODE = new String("ACS1"); /** * Retrieves the defaultCode from the cache. * * @returns the default code value * * @throws curam.util.exception.AppException * Generic Exception Signature. * @throws curam.util.exception.InformationalException * Generic Exception Signature. */ public static String getDefaultCode() throws curam.util.exception.AppException, curam.util.exception.InformationalException { return curam.util.type.CodeTable.getDefaultItem(TABLENAME); } /** * ACS1=Accepted. */ public static final String ACCEPTED = new String("ACS1"); /** * ACS2=Provisional. */ public static final String PROVISIONAL = new String("ACS2"); /** * ACS3=Rejected. */ public static final String REJECTED = new String("ACS3"); /** * ACS4=Unknown. */ public static final String UNKNOWN = new String("ACS4"); }
It should be noted that this pattern of generation means that the Strings will not be interned by the Java compiler. This allows the dependency checking in the build scripts to operate correctly. If an empty string is provided for a Java Identifier the code is only mapped into persistent data (SQL file) and is not reflected in the Java artefacts.
The persistent data associated with code tables is generated into the common /build/svr/codetable/sql/ directory.
-- -- Cúram Code Table SQL Data File -- -- -- CODETABLE AcceptanceStatus -- INSERT INTO CodeTableItem (TABLENAME, CODE, DESCRIPTION, ANNOTATION, ISENABLED, SORTORDER, LOCALEIDENTIFIER, LASTWRITTEN) VALUES ('AcceptanceStatus', 'ACS1', 'Accepted', '', '1', 0, 'en_US', CURRENT_TIMESTAMP('')); INSERT INTO CodeTableItem (TABLENAME, CODE, DESCRIPTION, ANNOTATION, ISENABLED, SORTORDER, LOCALEIDENTIFIER, LASTWRITTEN) VALUES ('AcceptanceStatus', 'ACS2', 'Provisional', '', '1', 0, 'en_US', CURRENT_TIMESTAMP('')); INSERT INTO CodeTableItem (TABLENAME, CODE, DESCRIPTION, ANNOTATION, ISENABLED, SORTORDER, LOCALEIDENTIFIER, LASTWRITTEN) VALUES ('AcceptanceStatus', 'ACS3', 'Rejected', '', '1', 0, 'en_US', CURRENT_TIMESTAMP('')); INSERT INTO CodeTableItem (TABLENAME, CODE, DESCRIPTION, ANNOTATION, ISENABLED, SORTORDER, LOCALEIDENTIFIER, LASTWRITTEN) VALUES ('AcceptanceStatus', 'ACS1', 'Passed', '', '1', 0, 'en_GB', CURRENT_TIMESTAMP('')); INSERT INTO CodeTableItem (TABLENAME, CODE, DESCRIPTION, ANNOTATION, ISENABLED, SORTORDER, LOCALEIDENTIFIER, LASTWRITTEN) VALUES ('AcceptanceStatus', 'ACS2', 'Pending', '', '1', 0, 'en_GB', CURRENT_TIMESTAMP('')); INSERT INTO CodeTableItem (TABLENAME, CODE, DESCRIPTION, ANNOTATION, ISENABLED, SORTORDER, LOCALEIDENTIFIER, LASTWRITTEN) VALUES ('AcceptanceStatus', 'ACS3', 'Failed', '', '1', 0, 'en_GB', CURRENT_TIMESTAMP('')); INSERT INTO CodeTableItem (TABLENAME, CODE, DESCRIPTION, ANNOTATION, ISENABLED, SORTORDER, LOCALEIDENTIFIER, LASTWRITTEN) VALUES ('AcceptanceStatus', 'ACS4', 'Unknown', '', '1', 0, 'en', CURRENT_TIMESTAMP('')); INSERT INTO CodeTableHeader (TableName, TimeEntered, DefaultCode, LASTWRITTEN) VALUES ('AcceptanceStatus', CURRENT_TIMESTAMP(''), 'ACS1', CURRENT_TIMESTAMP(''));
Also, while generating the codetable SQL artefacts containing the contents for the CodeTableItem and CodeTableHeader database tables, the LASTWRITTEN field with an initial value will be populated. The initial value is a time stamp which is set to the time when the data is inserted into the database.
The same artefacts are produced for the code table file of Rules of Code Table Merges, also, because the file contains a <displaynames> element, additional artefacts are created, i.e. a properties file is generated for each <name> element it contains.
The ctgen target produces one properties file for each locale (composite of language and country attributes) and <name> element within the <displaynames> element of a code table definition. Locale is defined by the language and country attributes of the <name> element. These properties files define the display names associated with each code table in a code table hierarchy.
The properties files are generated into /build/svr/codetable/gen/. If no <displaynames> element is specified for a code table hierarchy, no properties file is generated, and a warning will be displayed. The name of the generated properties file consists of the code table name along with the locale. Since a code table name with spaces renders a properties file invalid and unlocalizable, any spaces specified in the code table name will be replaced with the underscore character.
The warning, i.e. warning where a <displaynames> element is not specified, is only treated as a warning and never an error, regardless of the setting of the property prp.warningstoerrors.
If the locale specified for the <name> element is not supported, then the ctgen will display a warning and no properties file for that locale will be generated.
The following is an example of properties files produced by the ctgen on the Rules of Code Table Merges. Each properties file is generated to /build/svr/codetable/gen/
CarMake=Car Make US
CarMake=Marque
CarMake=Car Make CustomGB
CarMake=Masinos Gamintojas
CarMake=Car Make Custom
CarModel=Car Model