/// <summary> /// Creates a collection of target operations for items to be published /// </summary> protected override IObservable <ICandidateOperation> CreateTargetOperationsStream(DateTime started, IPublishCandidateSource publishCandidateSource, IPublishValidator validator, PublishOptions jobOptions, IObservable <CandidateValidationContext> publishStream, IItemIndexService targetIndex, ITestableContentRepository testableContentRepository, IMediaRepository targetMediaRepository, IRequiredPublishFieldsResolver requiredPublishFieldsResolver, CancellationTokenSource errorSource, Guid targetId) { IObservable <CandidateValidationTargetContext> processingStream1 = this.CreateTargetProcessingStream(started, publishCandidateSource, validator, jobOptions, publishStream, targetIndex, testableContentRepository, targetMediaRepository, this._requiredPublishFieldsResolver, errorSource, targetId); RelatedNodesSourceProducer nodesSourceProducer = new RelatedNodesSourceProducer(processingStream1.Where <CandidateValidationTargetContext>((Func <CandidateValidationTargetContext, bool>)(ctx => ctx.IsValid)).Select <CandidateValidationTargetContext, ValidCandidateTargetContext>((Func <CandidateValidationTargetContext, ValidCandidateTargetContext>)(ctx => ctx.AsValid())), publishCandidateSource, validator, this._options.RelatedItemBatchSize, jobOptions.RelatedItems, jobOptions.GetDetectCloneSources(), errorSource, this._logger); IObservable <CandidateValidationTargetContext> processingStream2 = this.CreateTargetProcessingStream(started, publishCandidateSource, validator, jobOptions, (IObservable <CandidateValidationContext>)nodesSourceProducer, targetIndex, testableContentRepository, targetMediaRepository, this._requiredPublishFieldsResolver, errorSource, targetId); IConnectableObservable <CandidateValidationTargetContext> source = processingStream1.Merge <CandidateValidationTargetContext>(processingStream2).Publish <CandidateValidationTargetContext>(); source.Connect(); UpdatedCandidatesOperationsProducer operationsProducer1 = new UpdatedCandidatesOperationsProducer(source.Where <CandidateValidationTargetContext>((Func <CandidateValidationTargetContext, bool>)(ctx => ctx.IsValid)).Select <CandidateValidationTargetContext, ValidCandidateTargetContext>((Func <CandidateValidationTargetContext, ValidCandidateTargetContext>)(ctx => ctx.AsValid())), started, errorSource, this._loggerFactory.CreateLogger <UpdatedCandidatesOperationsProducer>()); MediaOperationsProducer operationsProducer2 = new MediaOperationsProducer(source.Where <CandidateValidationTargetContext>((Func <CandidateValidationTargetContext, bool>)(ctx => ctx.IsValid)).Select <CandidateValidationTargetContext, ValidCandidateTargetContext>((Func <CandidateValidationTargetContext, ValidCandidateTargetContext>)(ctx => ctx.AsValid())), targetMediaRepository, requiredPublishFieldsResolver.MediaFieldsIds, started, this._options.MediaBatchSize, errorSource, this._loggerFactory.CreateLogger <MediaOperationsProducer>()); IConnectableObservable <ICandidateOperation> connectableObservable = Observable.Merge <ICandidateOperation>(new IObservable <ICandidateOperation>[3] { (IObservable <ICandidateOperation>) new DeletedCandidateOperationsProducer(source.Where <CandidateValidationTargetContext>((Func <CandidateValidationTargetContext, bool>)(ctx => !ctx.IsValid)).Select <CandidateValidationTargetContext, Guid>((Func <CandidateValidationTargetContext, Guid>)(ctx => ctx.AsInvalid().Id)), targetIndex, started, this._options.DeletedItemsBatchSize, errorSource, this._sourceName, this._loggerFactory.CreateLogger <DeletedCandidateOperationsProducer>()), (IObservable <ICandidateOperation>)operationsProducer1, (IObservable <ICandidateOperation>)operationsProducer2 }).Publish <ICandidateOperation>(); connectableObservable.Connect(); return((IObservable <ICandidateOperation>)connectableObservable); }