feat: Implementato supporto per query custom nei profili Data Coupler

- Aggiunto campo SourceCustomQuery al modello DataCouplerProfile e DTO
- Creata migrazione database per la nuova colonna SourceCustomQuery
- Aggiornato DataCouplerProfileService per gestire il mapping della query custom
- Modificato ProfileSaver per includere la query custom nel salvataggio
- Implementata logica di caricamento profili con supporto query custom:
  * Popolamento automatico della textbox con query salvata
  * Validazione ed esecuzione automatica della query al caricamento
  * Caricamento anteprima dati e mapping dopo validazione query
  * Gestione priorità: query custom ha precedenza sulla selezione tabella
- Aggiornato DataCoupler.razor per passare la query custom al ProfileSaver
- Corretto salvataggio profili esistenti per includere SourceCustomQuery

Il sistema ora permette di salvare e ripristinare completamente le configurazioni
con query SQL personalizzate, mantenendo il comportamento esistente per le
This commit is contained in:
2025-07-05 21:56:13 +02:00
parent 7d2961702c
commit ee3c251b08
13 changed files with 419 additions and 4 deletions
+36 -4
View File
@@ -257,18 +257,48 @@ public partial class DataCoupler : ComponentBase
Logger.LogInformation("Stato dopo connessione database - Connected: {Connected}, Tables: {TableCount}",
isDatabaseConnected, availableTableNames.Count);
// Seleziona la tabella se specificata e se la connessione è riuscita
if (!string.IsNullOrEmpty(profile.SourceTable) && isDatabaseConnected)
// Gestisci la query custom se specificata nel profilo
if (!string.IsNullOrEmpty(profile.SourceCustomQuery) && isDatabaseConnected)
{
Logger.LogInformation("Caricamento query custom dal profilo: {Query}", profile.SourceCustomQuery);
// Imposta la modalità query custom
useCustomQuery = true;
customQuery = profile.SourceCustomQuery;
// Valida ed esegui la query
await ValidateCustomQuery();
if (isQueryValid)
{
Logger.LogInformation("Query custom caricata e validata con successo");
// Carica l'anteprima dei dati
await LoadQueryPreview();
Logger.LogInformation("Anteprima dati della query custom caricata");
}
else
{
Logger.LogWarning("La query custom dal profilo non è valida: {ValidationMessage}", queryValidationMessage);
}
}
// Seleziona la tabella se specificata e se la connessione è riuscita (solo se non c'è una query custom)
else if (!string.IsNullOrEmpty(profile.SourceTable) && isDatabaseConnected)
{
Logger.LogInformation("Selezione tabella: {Table}", profile.SourceTable);
await SelectTable(profile.SourceTable);
Logger.LogInformation("Tabella selezionata: {SelectedTable}, Schema caricato: {SchemaLoaded}",
selectedTable, databaseTables.ContainsKey(profile.SourceTable));
}
else if (string.IsNullOrEmpty(profile.SourceCustomQuery) && string.IsNullOrEmpty(profile.SourceTable))
{
Logger.LogInformation("Nessuna tabella o query custom specificata nel profilo");
}
else
{
Logger.LogWarning("Impossibile selezionare tabella - Table: {Table}, Connected: {Connected}",
profile.SourceTable, isDatabaseConnected);
Logger.LogWarning("Impossibile selezionare tabella o caricare query custom - Table: {Table}, Query: {Query}, Connected: {Connected}",
profile.SourceTable, profile.SourceCustomQuery, isDatabaseConnected);
}
}
else
@@ -454,6 +484,7 @@ public partial class DataCoupler : ComponentBase
existingProfile.SourceCredentialId = profile.SourceCredentialId;
existingProfile.SourceSchema = profile.SourceSchema;
existingProfile.SourceTable = profile.SourceTable;
existingProfile.SourceCustomQuery = profile.SourceCustomQuery;
existingProfile.SourceFilePath = profile.SourceFilePath;
existingProfile.DestinationType = profile.DestinationType;
existingProfile.DestinationCredentialId = profile.DestinationCredentialId;
@@ -486,6 +517,7 @@ public partial class DataCoupler : ComponentBase
existingProfile.SourceCredentialId = profile.SourceCredentialId;
existingProfile.SourceSchema = profile.SourceSchema;
existingProfile.SourceTable = profile.SourceTable;
existingProfile.SourceCustomQuery = profile.SourceCustomQuery;
existingProfile.SourceFilePath = profile.SourceFilePath;
existingProfile.DestinationType = profile.DestinationType;
existingProfile.DestinationCredentialId = profile.DestinationCredentialId;