Generating a unique number for registry entities

1. Overview

The Platform supports generating a unique number for a specific attribute of an entity. Each entity created via a business process receives a unique and user-friendly number. The number is generated when the entity is saved and is unique within the registry instance.

The entities may include documents such as certificates of completion and so on.

A data modeler can choose the entities for which a number should be generated and the attribute where it should be stored.

The number is generated according to the mask you specify. The mask may vary depending on the entities and business processes. You can specify a default mask template.

2. Configuration

The number generator feature is configured at the registry regulations' data model level, in the data-model directory.

A data modeler must do the following:

  1. Open the data-model directory in the registry regulations.

  2. Open the file for creating tables.

  3. Within the changeSet for creating a new table, find the <column> tag.

  4. Define the ext:autoGenerate attribute and a mask for generating numbers in the appropriate format within the <column> tag.

  5. Commit the changes to the registry regulations Gerrit repository. For details, see Applying changes to the regulations.

XML schema of using the ext:autoGenerate attribute
<createTable ...>
...
    <column name="column_name" type="TEXT" ext:autoGenerate="AA-{dd-MM-yyyy}-{SEQ}">
    </column>
...
</createTable>

AA-{dd-MM-yyyy}-{SEQ} is the template used to generate the number for the entity (such as a document or certificate), where:

  • The AA constant is the document code.

  • The {dd-MM-yyyy} variable is the date in Java format.

  • The {SEQ} variable is the sequence number. It is generated using the {SEQ} + 1 principle, meaning that each new document will have a unique number incremented by 1.

Example of generating numbers for certificates in the registry
<changeSet id="table auto generated number build" author="registry owner">
	<createTable tableName="entity_build_acts" ext:historyFlag="true" remarks="Registry type, building certificates">
		<column name="entity_id" type="UUID" defaultValueComputed="uuid_generate_v4()">
			<constraints nullable="false" primaryKey="true" primaryKeyName="pk_entity_build_acts"/>
		</column>
		<column name="build_number" type="TEXT">
			<constraints nullable="false"/>
		</column>
		<column name="section_number" type="TEXT" remarks="Section"/>
		<column name="flat_number" type="TEXT"/>
		<column name="auto_generated_number" type="TEXT" ext:autoGenerate="AA-{dd-MM-yyyy}-{SEQ}">
			<constraints nullable="false" unique="true"/>
		</column>
		<column name="build_type" type="UUID" remarks="IDs array">
			<constraints nullable="false"
						 foreignKeyName="fk_build_type"
						 referencedTableName="build_type"
						 referencedColumnNames="build_type_id"/>
		</column>
	</createTable>
</changeSet>

The system uses the Java Date Time Format to generate and validate the timestamp template.

The sequence of characters, the use of hyphens, and the letter case for days, months, and years are not important.

We recommend using the following Java Date Time format schemas when defining a template in the data model:

Table 1. Java date and time schemas and examples
Schema Example

dd-MM-yyyy hh:mm:ss

02-09-2022 06:07:59

YYYYMMDD hh:mm:ss

20220902 06:07:59

MM/dd/yyyy

09/02/2022

dd/MM/yyyy

02/09/2022

3. Using the ext:autoGenerate attribute in a business process

After deploying the regulations using the ext:autoGenerate attribute for the database table columns, the system generates a unique and user-friendly number for each document according to the defined template once a relevant business process is executed. This number is then stored in the registry database and can be used when generating analytical reports and so on.

Let’s consider an example of running a business process to generate a number in the officer portal.

  1. Sign in to the officer portal.

  2. Open the All services section.

  3. Start a corresponding business process.

    auto generate number 1

  4. Fill out the form and click Submit.

    auto generate number 2

  5. Sign the data you provided.

    auto generate number 3

  6. Once you sign the data, the system will generate the number for the newly created document and save it to the registry database.

    The number of the document matches the template defined in the data model at the regulations level: AA-{dd-MM-yyyy}-{SEQ}

    auto generate number 4

    In our example, the system generated a certificate number 4 with an AA code dated 09-14-2022.

  7. Click Submit to finish the process.