Skip to content

Commit

Permalink
CFM-462_fix_orcid_source_changelog_unique (#329)
Browse files Browse the repository at this point in the history
* Add isUniqueChangelog rule. Fix OrcidSource token index issue.

* Fix review changes
  • Loading branch information
Ioannis authored Sep 2, 2025
1 parent 25b3e17 commit 70ace1f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 1 addition & 2 deletions app/plugins/OrcidSource/config/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
},
"indexes": {
"orcid_source_tokens_i1": {
"columns": [ "orcid_source_id", "orcid_identifier"],
"unique": true
"columns": [ "orcid_source_id", "orcid_identifier"]
},
"orcid_source_tokens_i2": { "columns": [ "orcid_identifier" ] },
"orcid_source_tokens_i3": { "needed": false, "columns": [ "orcid_source_id" ] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ msgstr "{0} was not found"
msgid "error.response.no_orcid"
msgstr "ORCID identifier missing from response."

msgid "error.exists"
msgstr "Orcid Token already exists with this Identifier"

msgid "field.OrcidSources.api_type"
msgstr "API Type"

Expand Down
19 changes: 19 additions & 0 deletions app/plugins/OrcidSource/src/Model/Table/OrcidTokensTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

namespace OrcidSource\Model\Table;

use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Utility\Security;
use Cake\Validation\Validator;
Expand Down Expand Up @@ -119,6 +120,24 @@ public function beforeMarshal(EventInterface $event, \ArrayObject $data, \ArrayO

}

/**
* Define business rules.
*
* @since COmanage Registry v5.2.0
* @param RulesChecker $rules RulesChecker object
* @return RulesChecker
*/

public function buildRules(RulesChecker $rules): RulesChecker {
$rules->add(
$rules->isUnique(
["orcid_source_id", "orcid_identifier"]),
__d('orcid_source', 'error.exists')
);

return $rules;
}

/**
* Unencrypt a value previously encrypted using salt
*
Expand Down

0 comments on commit 70ace1f

Please sign in to comment.