# Read auxiliary controller URLs $auxDir = "fs-saas-company\src\main\java\com\fs\company\controller\company" $bridgeFile = "fs-saas-company\src\main\java\com\fs\company\controller\bridge\CompanyBridgeController.java" $auxUrls = @{} Get-ChildItem $auxDir -Filter "*Auxiliary*.java" | ForEach-Object { $content = Get-Content $_.FullName -Raw $matches = [regex]::Matches($content, '@GetMapping(?:\s*\(\s*\{([^}]+)\}\s*\)|\s*\(\s*"([^"]+)"\s*\))') foreach ($m in $matches) { $paths = if ($m.Groups[1].Success) { $m.Groups[1].Value } else { $m.Groups[2].Value } $pathList = $paths -split ',' | ForEach-Object { $_.Trim().Trim('"').Trim() } | Where-Object { $_ } foreach ($p in $pathList) { $auxUrls[$p] = $true } } } Write-Host "Auxiliary URLs: $($auxUrls.Count)" # Read bridge controller $lines = Get-Content $bridgeFile $output = [System.Collections.ArrayList]::new() $skipMode = $false $methodBraceCount = 0 $i = 0 while ($i -lt $lines.Count) { $line = $lines[$i] # Check for mapping annotations if ($line -match '@(GetMapping|PostMapping|PutMapping|DeleteMapping)') { # Extract all paths from this annotation (may span multiple lines) $annotationText = $line $startIdx = $i # Check if annotation spans multiple lines (no closing paren on this line) while ($annotationText -notmatch '\)' -and ($i + 1) -lt $lines.Count) { $i++ $annotationText += " " + $lines[$i] } # Extract paths $paths = @() $pathMatches = [regex]::Matches($annotationText, '"([^"]+)"') foreach ($pm in $pathMatches) { $paths += $pm.Groups[1].Value } # Check for conflicts $hasConflict = $false foreach ($p in $paths) { if ($auxUrls.ContainsKey($p)) { $hasConflict = $true break } } if ($hasConflict) { # Skip this entire method - find the method body and skip it # Move forward until we find the method body (look for opening brace) while ($i -lt $lines.Count -and $lines[$i] -notmatch '\{') { $i++ } if ($i -lt $lines.Count) { # Count braces to find end of method $braceCount = 0 $started = $false while ($i -lt $lines.Count) { $currentLine = $lines[$i] for ($c = 0; $c -lt $currentLine.Length; $c++) { if ($currentLine[$c] -eq '{') { $braceCount++; $started = $true } if ($currentLine[$c] -eq '}') { $braceCount-- } } $i++ if ($started -and $braceCount -le 0) { break } } } continue } } $output.Add($line) | Out-Null $i++ } # Replace safeListFromTable calls with empty data return $newOutput = [System.Collections.ArrayList]::new() foreach ($line in $output) { $newLine = $line if ($newLine -match 'safeListFromTable\(') { $newLine = $newLine -replace 'safeListFromTable\("[^"]+"\)', 'getDataTable(new java.util.ArrayList<>())' } $newOutput.Add($newLine) | Out-Null } # Remove GenericTableMapper import and field $finalOutput = [System.Collections.ArrayList]::new() $skipGenericImport = $false foreach ($line in $newOutput) { if ($line -match 'import com\.fs\.hisStore\.mapper\.GenericTableMapper') { continue } if ($line -match 'private GenericTableMapper genericTableMapper') { continue } # Remove the safeListFromTable method if ($line -match 'private TableDataInfo safeListFromTable') { # Skip until closing brace continue } $finalOutput.Add($line) | Out-Null } # Write output $result = $finalOutput -join "`n" [System.IO.File]::WriteAllText((Resolve-Path $bridgeFile).Path, $result, [System.Text.UTF8Encoding]::new($false)) Write-Host "Output lines: $($finalOutput.Count)"