// this matches what we have in SourceDataCookerReference - it's not 100% necessary, // but it's a nice to have for testing some scenarios // public void DefaultAdditionalValidation( IDataExtensionDependencyStateSupport dependencyStateSupport, IDataExtensionReference reference) { if (reference is IDataCookerReference dataCookerReference) { if (!StringComparer.Ordinal.Equals(dataCookerReference.Path.SourceParserId, this.Path.SourceParserId)) { dependencyStateSupport.AddError("Wrong source parser!"); dependencyStateSupport.UpdateAvailability(DataExtensionAvailability.Error); } } else if (reference is IDataProcessorReference dataProcessorReference) { dependencyStateSupport.AddError( $"A source data cooker may not depend on a data processor: {dataProcessorReference.Id}"); dependencyStateSupport.UpdateAvailability(DataExtensionAvailability.Error); } else { dependencyStateSupport.AddError( $"A requested dependency on an unknown data extension type is not supported: {reference.Name}"); dependencyStateSupport.UpdateAvailability(DataExtensionAvailability.Error); } }
/// <summary> /// Update the availability for the target data extension based on one of its required /// data extension's availability. /// </summary> /// <param name="requiredDataExtension"> /// The required extension. /// </param> /// <param name="extensionId"> /// Data extension Id. /// </param> private void UpdateAvailabilityFromRequiredExtension( IDataExtensionReference requiredDataExtension, string extensionId) { Debug.Assert(requiredDataExtension != null, nameof(requiredDataExtension)); Debug.Assert(!string.IsNullOrWhiteSpace(extensionId)); switch (requiredDataExtension.Availability) { case DataExtensionAvailability.Undetermined: this.errors.Add("Internal error encountered."); this.UpdateAvailability(DataExtensionAvailability.Error); break; case DataExtensionAvailability.Error: this.UpdateAvailability(DataExtensionAvailability.IndirectError); this.errors.Add($"An error occurred in a required data cooker path: {extensionId}."); break; case DataExtensionAvailability.MissingRequirement: this.UpdateAvailability(DataExtensionAvailability.MissingIndirectRequirement); break; case DataExtensionAvailability.MissingIndirectRequirement: this.UpdateAvailability(this.Availability = DataExtensionAvailability.MissingIndirectRequirement); break; } }
private void ProcessRequiredExtension( IDataExtensionReference reference, string extensionId, IDataExtensionRepository availableDataExtensions) { Guard.NotNull(reference, nameof(reference)); Guard.NotNull(availableDataExtensions, nameof(availableDataExtensions)); Debug.Assert(!string.IsNullOrWhiteSpace(extensionId)); if (reference.Availability == DataExtensionAvailability.Undetermined) { reference.ProcessDependencies(availableDataExtensions); } if (reference.Availability != DataExtensionAvailability.Error) { this.dependencyReferences.AddRequiredExtensionReferences(reference.DependencyReferences); } Debug.Assert( reference.Availability != DataExtensionAvailability.Undetermined, $"{nameof(this.ProcessDependencies)} returned without establishing Availability."); this.UpdateAvailabilityFromRequiredExtension(reference, extensionId); this.target.PerformAdditionalDataExtensionValidation(this, reference); }
public override void PerformAdditionalDataExtensionValidation( IDataExtensionDependencyStateSupport dependencyStateSupport, IDataExtensionReference requiredDataExtension) { Guard.NotNull(dependencyStateSupport, nameof(dependencyStateSupport)); Guard.NotNull(requiredDataExtension, nameof(requiredDataExtension)); Debug.Assert(!string.IsNullOrWhiteSpace(this.Path.SourceParserId)); // a source data cooker may not rely on any other source // a source data cooker may not rely on a non-source data cooker // a source data cooker may not rely on data processors if (requiredDataExtension is IDataCookerReference dataCookerReference) { if (!StringComparer.Ordinal.Equals(this.Path.SourceParserId, dataCookerReference.Path.SourceParserId)) { dependencyStateSupport.AddError("A source data cooker may not depend on data cookers from " + $"other sources: {this.Type}"); dependencyStateSupport.UpdateAvailability(DataExtensionAvailability.Error); } else if (!(requiredDataExtension is SourceDataCookerReference)) { dependencyStateSupport.AddError( $"Data cooker {dataCookerReference.Path} referenced by {this.Path} is unrecognized."); } if (ProductionStrategy == DataProductionStrategy.AsRequired) { if (((SourceDataCookerReference)requiredDataExtension).ProductionStrategy != DataProductionStrategy.AsRequired) { throw new InvalidOperationException( $"A SourceCooker whose {nameof(DataProductionStrategy)} is " + $"{nameof(DataProductionStrategy.AsRequired)} can only consume SourceCookers whose " + $"{nameof(DataProductionStrategy)} is also {nameof(DataProductionStrategy.AsRequired)}."); } } } else if (requiredDataExtension is IDataProcessorReference dataProcessorReference) { dependencyStateSupport.AddError( $"A source data cooker may not depend on a data processor: {dataProcessorReference.Id}"); dependencyStateSupport.UpdateAvailability(DataExtensionAvailability.Error); } else { dependencyStateSupport.AddError( $"A requested dependency on an unknown data extension type is not supported: {requiredDataExtension.Name}"); dependencyStateSupport.UpdateAvailability(DataExtensionAvailability.Error); } }
public override void PerformAdditionalDataExtensionValidation( IDataExtensionDependencyStateSupport dependencyStateSupport, IDataExtensionReference requiredDataExtension) { if (this.UseDefaultValidation) { this.DefaultAdditionalValidation(dependencyStateSupport, requiredDataExtension); } else { base.PerformAdditionalDataExtensionValidation( dependencyStateSupport, requiredDataExtension); } }
/// <inheritdoc/> public virtual void PerformAdditionalDataExtensionValidation( IDataExtensionDependencyStateSupport dependencyStateSupport, IDataExtensionReference requiredDataCooker) { }
public virtual void PerformAdditionalDataExtensionValidation( IDataExtensionDependencyStateSupport dependencyStateSupport, IDataExtensionReference requiredDataExtension) { this.performAdditionalDataExtensionValidation?.Invoke(dependencyStateSupport, requiredDataExtension); }
public void PerformAdditionalDataExtensionValidation( IDataExtensionDependencyStateSupport dependencyStateSupport, IDataExtensionReference requiredDataCooker) { this.validationAction?.Invoke(dependencyStateSupport, requiredDataCooker); }