Skip to content

Commit

Permalink
orcid sources
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Nov 25, 2025
1 parent 6e831c5 commit 250f632
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 1 deletion.
23 changes: 23 additions & 0 deletions app/plugins/Transmogrify/config/schema/tables.json
Original file line number Diff line number Diff line change
Expand Up @@ -606,5 +606,28 @@
"reference_identifier": "reference_identifier",
"org_identity_source_record_id": "ext_identity_source_record_id"
}
},
"orcid_sources": {
"source": "cm_orcid_sources",
"displayField": "id",
"booleans": [
"scope_inherit"
],
"cache": ["external_identity_source_id", "server_id"],
"fieldMap": {
"org_identity_source_id": "external_identity_source_id",
"default_affiliation_type_id": "&mapToDefaultAffiliationTypeId",
"address_type_id": "&mapToDefaultAddressTypeId",
"email_address_type_id": "&mapToDefaultEmailAddressTypeId",
"name_type_id": "&mapToDefaultNameTypeId",
"telephone_number_type_id": "&mapToDefaultTelephoneNumberTypeId"
},
"addChangelog": true
},
"orcid_tokens": {
"source": "cm_orcid_tokens",
"displayField": "id",
"cache": ["orcid_identifier", "orcid_source_id"],
"addChangelog": true
}
}
6 changes: 5 additions & 1 deletion app/plugins/Transmogrify/src/Lib/Traits/CacheTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,21 @@ protected function findCoId(array $row): int
// Map External Identity -> Person -> CO
isset($row['external_identity_id']) => $this->getCoIdFromExternalIdentityId((int)$row['external_identity_id']),

isset($row['external_identity_source_id']) => $this->getCoIdFromExternalIdentitySourceId((int)$row['external_identity_source_id']),

isset($row['group_id']) => $this->getCoIdFromGroupId((int)$row['group_id']),

isset($row['match_server_id']) => $this->getCoIdFromMatchServer((int)$row['match_server_id']),

// Legacy/preRow: org_identity_id follows the same External Identity path
isset($row['org_identity_id']) => $this->getCoIdFromExternalIdentityId((int)$row['org_identity_id']),

isset($row['org_identity_source_id']) => $this->getCoIdFromExternalIdentitySourceId((int)$row['org_identity_source_id']),

isset($row['co_person_id']) => $this->getCoIdFromPersonId((int)$row['co_person_id']),

isset($row['co_group_id']) => $this->getCoIdFromGroupId((int)$row['co_group_id']),

isset($row['co_person_role_id']) => $this->getCoIdFromPersonRoleId((int)$row['co_person_role_id']),

default => null,
Expand Down
112 changes: 112 additions & 0 deletions app/plugins/Transmogrify/src/Lib/Traits/ManageDefaultsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,118 @@ protected function createOwnersGroups(): void
}
}

/**
* Map to the default affiliation type ID ("member") for the row's CO.
*
* Used when a row does not carry an explicit affiliation value but we want to
* refer to the standard "member" affiliation type within the same CO.
*
* @param array $row Row data from which CO ID can be derived
* @return int|null
*/
protected function mapToDefaultAffiliationTypeId(array $row): ?int
{
// Let CacheTrait::findCoId decide how to resolve the CO ID
$coId = $this->findCoId($row);

// Build a synthetic row with the default affiliation value
$defaultRow = [
'affiliation' => 'member',
];

// Use the generic type mapper to get the extended type ID
return $this->mapType(
$defaultRow,
'PersonRoles.affiliation_type',
$coId,
'affiliation'
);
}

/**
* Default Address type ID (adjust value if a different default is desired).
*
* @param array $row
* @return int|null
*/
protected function mapToDefaultAddressTypeId(array $row): ?int
{
$coId = $this->findCoId($row);

$defaultRow = [
'type' => 'office',
];

return $this->mapType(
$defaultRow,
'Addresses.type',
$coId
);
}

/**
* Default Email Address type ID.
*
* @param array $row
* @return int|null
*/
protected function mapToDefaultEmailAddressTypeId(array $row): ?int
{
$coId = $this->findCoId($row);

$defaultRow = [
'type' => 'official',
];

return $this->mapType(
$defaultRow,
'EmailAddresses.type',
$coId
);
}

/**
* Default Name type ID.
*
* @param array $row
* @return int|null
*/
protected function mapToDefaultNameTypeId(array $row): ?int
{
$coId = $this->findCoId($row);

$defaultRow = [
'type' => 'official',
];

return $this->mapType(
$defaultRow,
'Names.type',
$coId
);
}

/**
* Default Telephone Number type ID.
*
* @param array $row
* @return int|null
*/
protected function mapToDefaultTelephoneNumberTypeId(array $row): ?int
{
$coId = $this->findCoId($row);

$defaultRow = [
'type' => 'office',
];

return $this->mapType(
$defaultRow,
'TelephoneNumbers.type',
$coId
);
}

/**
* Insert default CO Settings for COs that don't have settings.
*
Expand Down

0 comments on commit 250f632

Please sign in to comment.