Skip to content

CFM-462_fix_orcid_source_changelog_unique #329

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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