diff --git a/app/availableplugins/Transmogrify/config/schema/tables.json b/app/availableplugins/Transmogrify/config/schema/tables.json index a94e20d3f..85e1777b4 100644 --- a/app/availableplugins/Transmogrify/config/schema/tables.json +++ b/app/availableplugins/Transmogrify/config/schema/tables.json @@ -285,7 +285,7 @@ "fieldMap": { "org_identity_source_id": "external_identity_source_id", "redirect_on_duplicate": "redirect_on_duplicate", - "sp_type": "sp_mode", + "mva_delimiter": "&mapFromSpType", "default_affiliation_type_id": "&mapAffiliationType", "address_type_id": "&mapToDefaultAddressTypeId", "email_address_type_id": "&mapToDefaultEmailAddressTypeId", @@ -305,7 +305,8 @@ "env_identifier_sorid_login": null, "env_identifier_network_login": null, "duplicate_mode": null, - "default_affiliation": null + "default_affiliation": null, + "sp_type": null }, "dependencies": ["external_identity_sources", "types"] }, diff --git a/app/availableplugins/Transmogrify/src/Command/TransmogrifyCommand.php b/app/availableplugins/Transmogrify/src/Command/TransmogrifyCommand.php index dfa4f99fd..bc7a75215 100644 --- a/app/availableplugins/Transmogrify/src/Command/TransmogrifyCommand.php +++ b/app/availableplugins/Transmogrify/src/Command/TransmogrifyCommand.php @@ -498,6 +498,22 @@ public function execute(Arguments $args, ConsoleIo $io): int } $this->cmdPrinter->warning("Skipping $t record " . (string)$rowIdLabel . ": " . $e->getMessage()); // $this->cmdPrinter->pause(); + } catch (\Doctrine\DBAL\Exception\NotNullConstraintViolationException $e) { + $this->cache['error'] += 1; + if (isset($row['id'])) { + $this->cache['rejected'][$outboundQualifiedTableName][$row['id']] = $row; + } + $rowIdLabel = $row['id'] ?? ($this->tables[$t]['displayField'] ?? 'n/a'); + $this->cmdPrinter->error("Missing required field for $t record " . (string)$rowIdLabel . ". DB Error: " . $e->getMessage()); + $this->cmdPrinter->pause(); + } catch (\Doctrine\DBAL\Exception\InvalidFieldNameException $e) { + $this->cache['error'] += 1; + if (isset($row['id'])) { + $this->cache['rejected'][$outboundQualifiedTableName][$row['id']] = $row; + } + $rowIdLabel = $row['id'] ?? ($this->tables[$t]['displayField'] ?? 'n/a'); + $this->cmdPrinter->error("Schema mapping mismatch for $t. A mapped column doesn't exist. DB Error: " . $e->getMessage()); + $this->cmdPrinter->pause(); } catch (\Exception $e) { $this->cache['error'] += 1; if (isset($row['id'])) { @@ -570,15 +586,16 @@ public function execute(Arguments $args, ConsoleIo $io): int // Display total execution time $executionTime = microtime(true) - $this->startTime; - $hours = floor($executionTime / 3600); - $minutes = floor(($executionTime % 3600) / 60); - $seconds = $executionTime % 60; + $executionTimeInt = (int)$executionTime; + $hours = (int)floor($executionTimeInt / 3600); + $minutes = (int)floor(($executionTimeInt % 3600) / 60); + $seconds = $executionTimeInt % 60; $formatted = sprintf( '%02d:%02d:%02d', - (int)$hours, - (int)$minutes, - (int)$seconds + $hours, + $minutes, + $seconds ); $this->cmdPrinter->out(sprintf('Total execution time: %s (HH:MM:SS)', $formatted)); diff --git a/app/availableplugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php b/app/availableplugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php index 96b57d386..b58ccca3f 100644 --- a/app/availableplugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php +++ b/app/availableplugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php @@ -38,6 +38,7 @@ use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Transmogrify\Lib\Util\RawSqlQueries; use App\Lib\Enum\MatchStrategyEnum; +use EnvSource\Lib\Enum\EnvSourceSpModeEnum; /** * Encapsulates all type mapping logic and helpers (map_type + specific wrappers). @@ -944,6 +945,31 @@ protected function mapAlgorithmToPlugin(array $row): ?string }; } + + /** + * Map v4 SP type to v5 attribute separator character. + * + * Converts EnvSource SP mode enum to the appropriate delimiter: + * - Shibboleth uses semicolon (;) + * - SimpleSamlPhp uses comma (,) + * - Other/default uses semicolon (;) + * + * @param array $row Row data containing 'sp_type' from cm_env_sources + * @return string|null Delimiter character (';' or ',') + * @since COmanage Registry v5.3.0 + */ + protected function mapFromSpType(array $row): ?string + { + $spType = $row['sp_type'] ?? null; + + // Default to ';' (matching the UpgradeCommand behavior for legacy Other modes) + return match ($spType) { + EnvSourceSpModeEnum::Shibboleth => ';', + EnvSourceSpModeEnum::SimpleSamlPhp => ',', + default => ';', + }; + } + /** * Map a type value to its corresponding ID *