diff --git a/app/plugins/Transmogrify/config/schema/tables.json b/app/plugins/Transmogrify/config/schema/tables.json index 634189241..232eb640c 100644 --- a/app/plugins/Transmogrify/config/schema/tables.json +++ b/app/plugins/Transmogrify/config/schema/tables.json @@ -1,8 +1,10 @@ { "__COMMENT__": "Template for adding new table configurations to the Transmogrify mapping. Keys starting with double underscores (__) are ignored by processors and exist only for documentation.", "__EXAMPLE_TABLE_TEMPLATE__": { - "__INSTRUCTIONS__": "Copy this object, rename the key to your logical table name (eg, 'my_items'), and adjust values. Do NOT leave this example enabled in production.", - "__INSTRUCTIONS__": "When mapping legacy type fields, call the function-based mapper (eg, &map...Type) before configuring null for the old column name. The mapper still needs the original source column value, and performNoMapping() will unset that column once it sees a null mapping. In other words, always place the null mapping for the old column after the new field’s function mapping so the mapper can read the legacy value before it is removed.", + "__INSTRUCTIONS_1__": "Copy this object, rename the key to your logical table name (eg, 'my_items'), and adjust values. Do NOT leave this example enabled in production.", + "__INSTRUCTIONS_2__": "When mapping legacy type fields, call the function-based mapper (eg, &map...Type) before configuring null for the old column name. The mapper still needs the original source column value, and performNoMapping() will unset that column once it sees a null mapping. In other words, always place the null mapping for the old column after the new field’s function mapping so the mapper can read the legacy value before it is removed.", + "__INSTRUCTIONS_3__": "Columns new to v5 (not in v4) should be omitted entirely from the configuration.", + "__INSTRUCTIONS_4__": "Columns present in v4 but dropped in v5 must be mapped to null to be unset, and these mappings must go at the end of the fieldMap list.", "source": "cm_my_items", "displayField": "name", "addChangelog": true, @@ -19,7 +21,7 @@ "preRow": "beforeInsertMyItemRow", "postRow": "afterInsertMyItemRow", "fieldMap": { - "id": null, + "id": "id", "co_id": "co_id", "name": "name", "description": "details", @@ -566,6 +568,25 @@ }, "dependencies": ["groups"] }, + "provisioning_targets": { + "source": "cm_co_provisioning_targets", + "displayField": "description", + "fieldMap": { + "plugin": "&mapProvisionerPlugin", + "provision_co_group_id": "provisioning_group_id", + "skip_org_identity_source_id": null + }, + "dependencies": ["groups"] + }, + "sql_provisioners": { + "source": "cm_co_sql_provisioner_targets", + "displayField": "provisioning_target_id", + "plugin": "ApiConnector", + "fieldMap": { + "co_provisioning_target_id": "provisioning_target_id" + }, + "addChangelog": true + }, "group_members": { "source": "cm_co_group_members", "displayField": "id", diff --git a/app/plugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php b/app/plugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php index bba1f973c..96b57d386 100644 --- a/app/plugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php +++ b/app/plugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php @@ -37,7 +37,7 @@ use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Transmogrify\Lib\Util\RawSqlQueries; -use \App\Lib\Enum\MatchStrategyEnum; +use App\Lib\Enum\MatchStrategyEnum; /** * Encapsulates all type mapping logic and helpers (map_type + specific wrappers). @@ -306,7 +306,12 @@ protected function mapPlugin(array $row, string $suffix, string $context): ?stri $connector = $base . 'Connector'; if ($base !== '' && in_array($connector, $available, true)) { - return $connector . '.' . $pluralTable; + if ($base !== '' && in_array($connector, $available, true)) { + $mapped = $connector . '.' . $pluralTable; + if (\Cake\Core\App::className($mapped, 'Model/Table', 'Table') !== null) { + return $mapped; + } + } } // No mapping found @@ -346,6 +351,20 @@ protected function mapAuthenticatorPlugin(array $row): ?string return $this->mapPlugin($row, 'Authenticator', 'Authenticator'); } + /** + * Map v4 Provisioner plugin name to v5 plugin model path. + * + * Examples: + * LdapProvisioner -> LdapConnector.LdapProvisioner + * + * @param array $row Row data containing 'plugin' + * @return string|null + */ + protected function mapProvisionerPlugin(array $row): ?string + { + return $this->mapPlugin($row, 'Provisioner', 'Provisioner'); + } + /** * Map email type to corresponding type ID