// 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);
     }
 }
예제 #2
0
        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);
            }
        }