示例#1
0
        protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep)
        {
            var settings = new EndpointSettings
            {
                EndpointFrom = ConvertReferenceToModel <Endpoint>(source, TemplateFieldEndpointFrom)
            };

            pipelineStep.AddPlugin(settings);

            IPlugin readDataSettings = GetReadDataSettings(source);

            if (readDataSettings == null)
            {
                return;
            }
            pipelineStep.AddPlugin(readDataSettings);
        }
示例#2
0
        private void AddEndpointSettings(ItemModel source, PipelineStep pipelineStep)
        {
            var settings = new EndpointSettings
            {
                EndpointFrom = base.ConvertReferenceToModel <Endpoint>(source, RedditReadStepItemModel.EndpointFrom)
            };

            pipelineStep.AddPlugin(settings);
        }
        protected void AddReadResourceDataSettings(ItemModel source, PipelineStep pipelineStep)
        {
            var readResourceDataSettings = new ReadResourceDataSettings
            {
                PathExpression = this.GetStringValue(source, ReadResourceDataPipelineStepItemModel.PathExpression)
            };

            pipelineStep.AddPlugin <ReadResourceDataSettings>(readResourceDataSettings);
        }
示例#4
0
        protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep)
        {
            base.AddPlugins(source, pipelineStep);
            var settings = new JsonSettings()
            {
                JPath = GetStringValue(source, JPathFieldName)
            };

            pipelineStep.AddPlugin(settings);
        }
        protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep)
        {
            var settings = new EndpointSettings
            {
                EndpointFrom = this.ConvertReferenceToModel <Sitecore.DataExchange.Models.Endpoint>(source, "Endpoint"),
            };

            pipelineStep.AddPlugin(settings);

            // convert the Sitecore item fields to a plugin object
            var pipelineSettings = new ReadPaginatedJsonApiStepSettings
            {
                MaxCount       = this.GetIntValue(source, "Max Count"),
                Page           = this.GetIntValue(source, "Page"),
                Offset         = this.GetIntValue(source, "Offset"),
                ResultsPerPage = this.GetIntValue(source, "Results Per Page")
            };

            // add this plugin to the pipeline step
            pipelineStep.AddPlugin(pipelineSettings);
        }
        private void AddEndpointSettings(ItemModel source, PipelineStep pipelineStep)
        {
            var settings     = new EndpointSettings();
            var endpointFrom =
                base.ConvertReferenceToModel <Endpoint>(source,
                                                        IWordpress_Pipeline_Step_Constants.EndpointFrom_FieldName);//WordPressStepItemModel.EndpointFrom);

            if (endpointFrom != null)
            {
                settings.EndpointFrom = endpointFrom;
            }
            pipelineStep.AddPlugin(settings);
        }
        public void AddResourceSettings(ItemModel source, PipelineStep pipelineStep)
        {
            var resourceSettings = this.ConvertReferenceToModel <ResourceSettings>(source, BaseResourceEndpointPipelineStepItemModel.Resource);

            if (resourceSettings == null)
            {
                Context.Logger.Error("No resource was specified for the pipeline step. (item: {0}, field: {1})", source.GetItemId(), Templates.BaseResourceEndpointPipelineStep.FieldNames.Resource);
            }
            else
            {
                pipelineStep.AddPlugin <ResourceSettings>(resourceSettings);
            }
        }
        public void NoIterableDataSettingsPluginAddedToPipelineContextWhenNoEndpointIsSetOnTheEndpointSettingsPlugin()
        {
            var pipelineStep = new PipelineStep {
                Enabled = true
            };

            pipelineStep.AddPlugin(new EndpointSettings());
            var pipelineContext = new PipelineContext(new PipelineBatchContext());
            var logger          = Substitute.For <ILogger>();
            var processor       = new ReadTextFileStepProcessor();

            processor.StartProcessing(pipelineStep, pipelineContext, logger);
            Assert.Null(pipelineContext.GetPlugin <IterableDataSettings>());
        }
        protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep)
        {
            //
            //create the plugin
            var settings = new EndpointSettings
            {
                //
                //populate the plugin using values from the item
                EndpointFrom = this.ConvertReferenceToModel <Endpoint>(source, TemplateFieldEndpointFrom)
            };

            //
            //add the plugin to the pipeline step
            pipelineStep.AddPlugin(settings);
        }
        public void IterableDataSettingsPluginAddedToPipelineContext()
        {
            var builder = new StringBuilder();

            builder.AppendLine("a-b-c");
            builder.AppendLine("1-2-3");
            var fileName = Path.GetTempFileName();

            File.WriteAllText(fileName, builder.ToString());
            var textFileSettings = new TextFileSettings
            {
                Path = fileName,
                ColumnHeadersInFirstLine = false,
                ColumnSeparator          = "-"
            };
            var endpointFrom = new Endpoint();

            endpointFrom.AddPlugin(textFileSettings);
            var pipelineStep = new PipelineStep {
                Enabled = true
            };

            pipelineStep.AddPlugin(new EndpointSettings {
                EndpointFrom = endpointFrom
            });
            var pipelineContext = new PipelineContext(new PipelineBatchContext());
            var logger          = Substitute.For <ILogger>();
            var processor       = new ReadTextFileStepProcessor();

            processor.StartProcessing(pipelineStep, pipelineContext, logger);
            var dataSettings = pipelineContext.GetPlugin <IterableDataSettings>();

            Assert.NotNull(dataSettings);
            Assert.NotNull(dataSettings.Data);
            var count = 0;

            foreach (var data in dataSettings.Data)
            {
                Assert.NotNull(data);
                Assert.IsType <string[]>(data);
                var dataAsArray = data as string[];
                Assert.NotNull(dataAsArray);
                Assert.Equal(3, dataAsArray.Length);
                count++;
            }
            Assert.Equal(2, count);
            File.Delete(fileName);
        }
        public void AddEndpointSettings(ItemModel source, PipelineStep pipelineStep)
        {
            var endpointSettings = new EndpointSettings();
            var model            = this.ConvertReferenceToModel <Endpoint>(source, BaseEndpointPipelineStepItemModel.EndpointFrom);

            if (model != null)
            {
                endpointSettings.EndpointFrom = model;
            }

            if (endpointSettings.EndpointFrom == null)
            {
                Context.Logger.Error("No endpoint from was specified for the pipeline step. (item: {0}, field: {1})", source.GetItemId(), Templates.BaseEndpointPipelineStep.FieldNames.EndpointFrom);
            }

            pipelineStep.AddPlugin <EndpointSettings>(endpointSettings);
        }