Skip to content

Commit

Permalink
Fix Pipeline sync of source key (NOJIRA)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Jul 17, 2024
1 parent f326b5c commit 9b7edf2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/resources/locales/en_US/defaultType.po
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ msgstr "SAML Pairwise"
msgid "Identifiers.type.subjectid"
msgstr "SAML Subject"

# Because this was called "sorid" in v4, we keep that as the internal key
msgid "Identifiers.type.sorid"
msgstr "System of Record"
msgstr "Source Key"

msgid "Identifiers.type.uid"
msgstr "UID"
Expand Down
5 changes: 5 additions & 0 deletions app/src/Model/Table/ExternalIdentitySourcesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ public function retrieve(int $id, string $sourceKey): array {
// Inject the source key so every backend doesn't have to do this
$record['entity_data']['source_key'] = $sourceKey;

$record['entity_data']['identifiers'][] = [
'identifier' => $sourceKey,
'type' => 'sorid'
];

return $record;
}

Expand Down
15 changes: 10 additions & 5 deletions app/src/Model/Table/PipelinesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,8 @@ protected function syncExternalIdentity(
// We do rely on this block to process EIR related models,
// which have roleIdentifiers that allow us to match records.

foreach($externalIdentity->$amodel as $aentity) {
// $akey is just the index into the array
foreach($externalIdentity->$amodel as $akey => $aentity) {
if($aentity->id == $arecord['id']) {
// This is the record we mapped in the backend data
$this->Cos->People->ExternalIdentities->$model->patchEntity(
Expand Down Expand Up @@ -1217,7 +1218,7 @@ protected function syncExternalIdentity(
$aeirmodel = Inflector::underscore($eirmodel);

if(!empty($arecord[$aeirmodel])) {
// We have one or more Role related model is the mapped
// We have one or more Role related model in the mapped
// backend data, check for update vs insert.

foreach($arecord[$aeirmodel] as $aeirrecord) {
Expand Down Expand Up @@ -1251,9 +1252,13 @@ protected function syncExternalIdentity(
$this->Cos->People->ExternalIdentities->$model->$eirmodel->saveOrFail($newentity);
$this->llog('trace', "Added $eirmodel " . $newentity->id . " for $model " . $aentity->id);

// Inject the new entity so syncPerson sees it
$externalIdentity->$model->$eirmodel[] = $newentity;
$newEntities[$amodel][] = $newentity->id;
// Inject the new entity so syncPerson sees it.
// Note that $externalIdentity->$amodel is an array
// of ExternalIdentityRoles, so we need to attach the
// related model entity to the correct role.

$externalIdentity->$amodel[$akey]->$aeirmodel[] = $newentity;
$newEntities[$aeirmodel][] = $newentity->id;
}
}
}
Expand Down

0 comments on commit 9b7edf2

Please sign in to comment.