Skip to content

[libraries] Refactor PSCID configuration to use template strings - #11196

Open
HachemJ wants to merge 12 commits into
aces:mainfrom
HachemJ:PscidTemplateStructure
Open

HachemJ wants to merge 12 commits into
aces:mainfrom
HachemJ:PscidTemplateStructure

Conversation

@HachemJ

@HachemJ HachemJ commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Brief summary of changes

This PR starts implementing the identifier template strings proposed in the following GitHub Discussion #9036.

It updates the existing PSCID structure configuration to support template strings while keeping the current identifier generation behaviour unchanged.

The existing Candidate tests were updated to work with the new structure, and a new test suite was added for PSCIDGenerator to cover the different template options and generation cases.

Testing instructions (if applicable)

<!-- Sequential numeric (default format) -->
<PSCID>
    <generation>sequential</generation>
    <structure>TEST-{SEQUENCE:4}</structure>
</PSCID>

Expected : TEST-0000

<!-- Sequential numeric boundary -->
<PSCID>
    <generation>sequential</generation>
    <structure>TEST-{SEQUENCE:4}</structure>
</PSCID>

Existing PSCID : TEST-0099
Expected : TEST-0100

<!-- Sequential alpha (default minimum) -->
<PSCID>
    <generation>sequential</generation>
    <structure>ALPHA-{SEQUENCE:4,FORMAT:alpha}</structure>
</PSCID>

Expected : ALPHA-AAAA

<!-- Sequential alpha boundary -->
<PSCID>
    <generation>sequential</generation>
    <structure>ALPHA-{SEQUENCE:4,FORMAT:alpha}</structure>
</PSCID>

Existing PSCID : ALPHA-AAAZ
Expected : ALPHA-AABA

<!-- Sequential alpha near default maximum -->
<PSCID>
    <generation>sequential</generation>
    <structure>ALPHA-{SEQUENCE:4,FORMAT:alpha}</structure>
</PSCID>

Existing PSCID : ALPHA-ZZZX
Expected : ALPHA-ZZZY

<!-- Sequential alpha default maximum exceeded -->
<PSCID>
    <generation>sequential</generation>
    <structure>ALPHA-{SEQUENCE:4,FORMAT:alpha}</structure>
</PSCID>

Existing PSCID : ALPHA-ZZZY
Expected : Error!
Cannot create new identifier because all valid identifiers are in use!

<!-- Random numeric -->
<PSCID>
    <generation>random</generation>
    <structure>RAND-{RANDOM:4,FORMAT:numeric}</structure>
</PSCID>

Expected : RAND-#### where # is a random digit from 0 to 9.
e.g. : RAND-3966, RAND-2971, RAND-0427

<!-- Random alpha -->
<PSCID>
    <generation>random</generation>
    <structure>RANDALPHA-{RANDOM:4,FORMAT:alpha}</structure>
</PSCID>

Expected : RANDALPHA-XXXX where X is a random letter from A-Z.
e.g. : RANDALPHA-JRMK, RANDALPHA-ZJZP, RANDALPHA-IZCH

<!-- Random alphanumeric -->
<PSCID>
    <generation>random</generation>
    <structure>RANDALPHANUM-{RANDOM:4,FORMAT:alphanumeric}</structure>
</PSCID>

Expected : RANDALPHANUM-XXXX where X is a random character from 0-9 or A-Z.
e.g. : RANDALPHANUM-KZLK, RANDALPHANUM-0U0W, RANDALPHANUM-1234

<!-- Numeric padding -->
<PSCID>
    <generation>sequential</generation>
    <structure>PAD-{SEQUENCE:4,FORMAT:numeric,PADDING:2,MIN:1}</structure>
</PSCID>

Expected : PAD-2221

<!-- Invalid numeric padding -->
<PSCID>
    <generation>sequential</generation>
    <structure>PAD-{SEQUENCE:4,FORMAT:numeric,PADDING:X,MIN:1}</structure>
</PSCID>

Expected : Error!
Padding character must be part of the configured alphabet.

<!-- Alpha padding -->
<PSCID>
    <generation>sequential</generation>
    <structure>PADALPHA-{SEQUENCE:4,FORMAT:alpha,PADDING:X,MIN:A}</structure>
</PSCID>

Expected : PADALPHA-XXXA

<!-- MIN/MAX -->
<PSCID>
    <generation>sequential</generation>
    <structure>MAXTEST-{SEQUENCE:4,FORMAT:numeric,MIN:1,MAX:3}</structure>
</PSCID>

Existing PSCIDs : MAXTEST-0001, MAXTEST-0002
Expected : Error!
Cannot create new identifier because all valid identifiers are in use!

<!-- Site alias -->
<PSCID>
    <generation>sequential</generation>
    <structure>{SITE:ALIAS}{SEQUENCE:4,FORMAT:numeric}</structure>
</PSCID>

Expected (Site: Data Coordinating Center): DCC0703 -> DCC0704 
(Site: Montreal): MTL0166

<!-- Project alias -->
<PSCID>
    <generation>sequential</generation>
    <structure>{PROJECT:ALIAS}{SEQUENCE:4,FORMAT:numeric}</structure>
</PSCID>

Expected (Project: Pumpernickel): PUMP0000 -> PUMP0001
(Project: DCP): DCP0000

<!-- Generation mismatch: sequential with RANDOM template -->
<PSCID>
    <generation>sequential</generation>
    <structure>MISMATCH-{RANDOM:4,FORMAT:numeric}</structure>
</PSCID>

Expected : Error!
Generation methods do not match.

<!-- Generation mismatch: random with SEQUENCE template -->
<PSCID>
    <generation>random</generation>
    <structure>MISMATCH-{SEQUENCE:4,FORMAT:numeric}</structure>
</PSCID>

Expected : Error!
Generation methods do not match.

@github-actions github-actions Bot added the Language: PHP PR or issue that update PHP code label Sep 8, 2026
@github-actions github-actions Bot added the Module: api PR or issue related to api module label Sep 11, 2026
@CamilleBeau CamilleBeau added the State: Needs work PR awaiting additional work by the author to proceed label Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language: PHP PR or issue that update PHP code Module: api PR or issue related to api module State: Needs work PR awaiting additional work by the author to proceed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants