Skip to content

Commit

Permalink
EnvSources transmogrification. Improve MVA mappers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Nov 30, 2025
1 parent f45182a commit 611d90e
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 4 deletions.
30 changes: 30 additions & 0 deletions app/plugins/Transmogrify/config/schema/tables.json
Original file line number Diff line number Diff line change
Expand Up @@ -629,5 +629,35 @@
"displayField": "id",
"cache": ["orcid_identifier", "orcid_source_id"],
"addChangelog": true
},
"env_sources": {
"source": "cm_env_sources",
"displayField": "id",
"addChangelog": true,
"fieldMap": {
"org_identity_source_id": "external_identity_source_id",
"duplicate_mode": null,
"redirect_on_duplicate": "redirect_on_duplicate",
"sp_type": "sp_mode",
"default_affiliation_type_id": "&mapAffiliationType",
"default_affiliation": null,
"address_type_id": "&mapToDefaultAddressTypeId",
"email_address_type_id": "&mapToDefaultEmailAddressTypeId",
"name_type_id": "&mapToDefaultNameTypeId",
"telephone_number_type_id": "&mapToDefaultTelephoneNumberTypeId",
"env_o": "env_organization",
"env_ou": "env_department",
"env_identifier_eppn_login": null,
"env_identifier_eptid_login": null,
"env_identifier_epuid_login": null,
"env_identifier_oidcsub_login": null,
"env_identifier_orcid": null,
"env_identifier_orcid_login": null,
"env_identifier_samlpairwiseid_login": null,
"env_identifier_samlsubjectid_login": null,
"env_identifier_sorid": "env_identifier_sourcekey",
"env_identifier_sorid_login": null,
"env_identifier_network_login": null
}
}
}
12 changes: 12 additions & 0 deletions app/plugins/Transmogrify/src/Lib/Traits/CacheTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ private function getCoIdFromExternalIdentityId(int $externalIdentityId): ?int
return $personId !== null ? $this->getCoIdFromPersonId($personId) : null;
}

/**
* Resolve a CO ID starting from an External Identity Source (or legacy OrgIdentitySource) ID via cache.
*
* @param int $externalIdentitySourceId
* @return int|null
*/
private function getCoIdFromExternalIdentitySourceId(int $externalIdentitySourceId): ?int
{
$coId = $this->cache['external_identity_sources']['id'][$externalIdentitySourceId]['co_id'] ?? null;
return $coId !== null ? (int)$coId : null;
}

/**
* Resolve a CO ID from a Match Server ID via cache.
*
Expand Down
39 changes: 35 additions & 4 deletions app/plugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@

use App\Lib\Enum\PetitionStatusEnum;
use Cake\ORM\TableRegistry;
use Cake\Utility\Inflector;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Transmogrify\Lib\Util\RawSqlQueries;
use Cake\Utility\Inflector;
use \App\Lib\Enum\MatchStrategyEnum;

/**
* Encapsulates all type mapping logic and helpers (map_type + specific wrappers).
Expand Down Expand Up @@ -175,14 +176,22 @@ protected function mapAddressType(array $row): ?int
*/
protected function mapAffiliationType(array $row, ?int $coId = null): ?int
{
$type = 'affiliation';
if (isset($row['default_affiliation'])) {
$type = 'default_affiliation';
} else if (isset($row['sync_affiliation'])) {
$type = 'sync_affiliation';
}

return $this->mapType(
$row,
'PersonRoles.affiliation_type',
$coId ?? $this->findCoId($row),
'affiliation'
$type
);
}


/**
* Map v4 External Identity Source plugin name to v5 plugin model path.
*
Expand Down Expand Up @@ -254,7 +263,17 @@ protected function mapExternalIdentitySourcePlugin(array $row): ?string
*/
protected function mapEmailType(array $row): ?int
{
return $this->mapType($row, 'EmailAddresses.type', $this->findCoId($row));
$type = 'type';
if (isset($row['match_type']) && $row['match_strategy'] === MatchStrategyEnum::EmailAddress) {
$type = 'match_type';
}

return $this->mapType(
$row,
'EmailAddresses.type',
$this->findCoId($row),
$type
);
}

/**
Expand Down Expand Up @@ -332,7 +351,19 @@ protected function mapHistoricPetitionViewerId(array $row): ?int
*/
protected function mapIdentifierType(array $row): ?int
{
return $this->mapType($row, 'Identifiers.type', $this->findCoId($row));
$type = 'type';
if (isset($row['sync_identifier_type'])) {
$type = 'sync_identifier_type';
} else if (isset($row['match_type']) && $row['match_strategy'] === MatchStrategyEnum::Identifier) {
$type = 'match_type';
}

return $this->mapType(
$row,
'Identifiers.type',
$this->findCoId($row),
$type
);
}


Expand Down

0 comments on commit 611d90e

Please sign in to comment.