Files
Data-Coupler/CredentialManager/Models/DataCouplerProfileDto.cs
T
Alessio Dal Santo b9670ae426 [Feature] Implementato sistema di valori default per campi mapping
- Creato modello FieldMappingEntry per gestione unificata di field mapping e default values

- Aggiunta colonna DefaultValuesJson alla tabella DataCouplerProfile (max 4000 caratteri)

- Implementata UI con toggle per selezionare modalità Mapping o Default

- Supporto per 9 tipi di dati: string, int, long, decimal, double, float, boolean, datetime, datetimeoffset

- Aggiornata logica TransformRecordToRestEntity per applicare valori default dopo field mapping

- Implementata serializzazione/deserializzazione DefaultValues in DataCouplerProfileService

- Sistema completo di salvataggio/caricamento valori default nei profili

- Migrazione database AddDefaultValuesJsonToProfile creata e applicata
2026-02-16 14:42:03 +01:00

113 lines
3.8 KiB
C#

namespace CredentialManager.Models;
/// <summary>
/// DTO per la creazione/aggiornamento di un profilo DataCoupler
/// </summary>
public class DataCouplerProfileDto
{
public int? Id { get; set; }
public string Name { get; set; } = string.Empty;
public string? Description { get; set; }
// Informazioni sorgente
public string SourceType { get; set; } = string.Empty;
public int? SourceCredentialId { get; set; }
public string? SourceCredentialName { get; set; }
public string? SourceDatabaseName { get; set; }
public string? SourceSchema { get; set; }
public string? SourceTable { get; set; }
public string? SourceCustomQuery { get; set; }
public string? SourceFilePath { get; set; }
// Informazioni destinazione
public string DestinationType { get; set; } = string.Empty;
public int? DestinationCredentialId { get; set; }
public string? DestinationCredentialName { get; set; }
public string? DestinationSchema { get; set; }
public string? DestinationTable { get; set; }
public string? DestinationEndpoint { get; set; }
// Mapping dei campi
public List<FieldMappingDto>? FieldMappings { get; set; }
// Default values per campi destinazione (FieldName -> (Value, Type))
public Dictionary<string, (object? Value, string? Type)>? DefaultValues { get; set; }
// External ID Relationships per Salesforce
public List<ExternalIdRelationshipDto>? ExternalIdRelationships { get; set; }
// Configurazione chiave sorgente e associazioni
public string? SourceKeyField { get; set; }
public bool UseRecordAssociations { get; set; }
}
/// <summary>
/// DTO per il mapping dei campi
/// </summary>
public class FieldMappingDto
{
public string SourceField { get; set; } = string.Empty;
public string DestinationField { get; set; } = string.Empty;
public string? DataType { get; set; }
public bool IsKey { get; set; }
public bool IsRequired { get; set; }
public string? DefaultValue { get; set; }
public string? Transformation { get; set; }
/// <summary>
/// Lista di relazioni External ID associate a questo campo (per Salesforce)
/// </summary>
public List<ExternalIdRelationshipDto>? ExternalIdRelationships { get; set; }
}
/// <summary>
/// DTO per External ID Relationship (Salesforce)
/// </summary>
public class ExternalIdRelationshipDto
{
/// <summary>
/// Nome della relazione (es. "Account__r")
/// </summary>
public string RelationshipName { get; set; } = string.Empty;
/// <summary>
/// Nome dell'oggetto correlato (es. "Account")
/// </summary>
public string RelatedObjectName { get; set; } = string.Empty;
/// <summary>
/// Campo External ID dell'oggetto correlato (es. "Country__c")
/// </summary>
public string ExternalIdField { get; set; } = string.Empty;
/// <summary>
/// Campo sorgente da cui prendere il valore per l'External ID
/// </summary>
public string SourceField { get; set; } = string.Empty;
}
/// <summary>/// DTO per i valori di default
/// </summary>
public class DefaultValueDto
{
public object? Value { get; set; }
public string? Type { get; set; }
}
/// <summary>/// DTO per la visualizzazione di un profilo nella lista
/// </summary>
public class DataCouplerProfileSummaryDto
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string? Description { get; set; }
public string SourceType { get; set; } = string.Empty;
public string? SourceName { get; set; }
public string DestinationType { get; set; } = string.Empty;
public string? DestinationName { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? LastUsedAt { get; set; }
public string? CreatedBy { get; set; }
public bool IsActive { get; set; }
}