Reserve ID ranges for a custom extension

Reserve a unique range of IDs for the object types, properties and quality rules that a custom extension creates
Updated

Overview

Each object type, category, property and quality rule that an extension saves to the analysis schema needs an ID that no other extension uses. If two extensions installed together use the same IDs, the installation or the analysis fails. Reserve a range of IDs for your extension before you write its metamodel or its rules.

ID ranges

ID range Reserved for file_level value in the metamodel
Above 2,000,000 User Community and CAST Labs extensions client
1,500,000 to 2,000,000 Field consultants (legacy use only) prepackaged
1,000,000 to 1,500,000 Official CAST extensions builtin
0 to 1,000,000 CAST core products core

Custom extensions use IDs above 2,000,000.

How ranges are allocated

  • Ranges are allocated on a first come, first served basis.
  • IDs are allocated in blocks of 1,000, up to 10,000 per extension.
  • You can reserve ranges for object types, for quality rules, or for both.

Reserve a range

To reserve a range, contact Arnaud Garnier at CAST, who allocates ID ranges for custom extensions. Give the id of your extension, for example com.castsoftware.uc.nameoftheextension, and the number of blocks of 1,000 IDs that you need for object types, for quality rules, or for both.

Use the range in a metamodel

A Universal Analyzer metamodel does not use absolute IDs. Instead, it declares a file number, file_no, which selects a block of 1,000 IDs, and gives each category and type a relative ID, rid, within that block:

id = 2,000,000 + (1,000 x file_no) + rid

For example, a reserved range from 2,007,000 to 2,007,999 corresponds to file_no="7", and the type with rid="12" gets the ID 2,007,012. Declare the file number on the root element of the metamodel:

<?xml version="1.0" encoding="utf-8"?>
<metaModel file_level="client" file_no="7">
    <category name="MYLANG" rid="0">
        ...
    </category>
    <type name="MYLANG_Function" rid="1">
        ...
    </type>
</metaModel>
  • Set file_level to client, or omit it.
  • Use a different file_no for each metamodel file. Metamodels installed together with the same file number cause the installation to fail.

See Define the metamodel.

Use the range for quality rules

Quality rules use absolute IDs from a quality rule range. For example:

<?xml version='1.0' encoding='utf-8'?>
<root>
  <metric id='2008000' type='quality-rule' originalName='Avoid calling a function inside a loop' active='true' detached='false' ignored='false' />
  <metric id='2008002' type='quality-rule' originalName='Avoid hard-coded passwords' active='true' detached='false' ignored='false' />
</root>