Skip to content

Commit

Permalink
Add allow_empty to IdentifierAssignments (CFM-57)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Apr 6, 2024
1 parent b79bb24 commit 5c2b72e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/config/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@
"identifier_type_id": { "type": "integer", "foreignkey": { "table": "types", "column": "id" }, "notnull": false },
"login": { "type": "boolean" },
"email_address_type_id": { "type": "integer", "foreignkey": { "table": "types", "column": "id" }, "notnull": false },
"allow_empty": { "type": "boolean" },
"ordr": {}
},
"indexes": {
Expand Down
6 changes: 6 additions & 0 deletions app/resources/locales/en_US/field.po
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,12 @@ msgstr "{0} Owners"
msgid "Groups.owners_group_id"
msgstr "Owners Group"

msgid "IdentifierAssignments.allow_empty"
msgstr "Allow Empty"

msgid "IdentifierAssignments.allow_empty.desc"
msgstr "If set and the Identifier Assignment does not generate an Identifier, Pipeline processing will be allowed to continue"

msgid "IdentifierAssignments.email_address_type_id"
msgstr "Email Address Type"

Expand Down
11 changes: 10 additions & 1 deletion app/src/Model/Table/IdentifierAssignmentsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,16 @@ public function assign(
catch(\Exception $e) {
$this->llog('debug', "Identifier '".$ia->description."' assignment failed for $entityType $entityId: " . $e->getMessage());
$ret['errors'][$ia->description] = $e->getMessage();
$cxn->rollback();

if(isset($ia->allow_empty) && $ia->allow_empty) {
// Failure of this Identifier Assignment does not throw an Exception,
// but we'll report it in the error set since we don't have another place
// to put it
$this->llog('debug', "Identifier '".$ia->description."' assignment allow_empty is true, will not rollback");
} else {
// Failure of this Identifier Assignment will cause (eg) a Pipeline to fail
$cxn->rollback();
}
}
} else {
$this->llog('trace', "Identifier '".$ia->description."' already assigned for $entityType $entityId");
Expand Down
2 changes: 2 additions & 0 deletions app/templates/IdentifierAssignments/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,7 @@ if($vv_action == 'add' || $vv_action == 'edit') {

print $this->Field->control('group_id');

print $this->Field->control('allow_empty');

print $this->Field->control('ordr');
}

0 comments on commit 5c2b72e

Please sign in to comment.