public WordpressEndpointConverter(IItemModelRepository repository) : base(repository)
 {
     //
     //identify the template an item must be based
     //on in order for the converter to be able to
     //convert the item
     this.SupportedTemplateIds.Add(TemplateId);
 }
        protected override ItemModel CreateItemModel(object identifierObject, IItemModelRepository repository, ResolveSitecoreItemSettings settings, PipelineContext pipelineContext, ILogger logger, string language = null, int version = 0)
        {
            var parentItemId = this.GetParentItemIdForNewItem(repository, settings, pipelineContext, logger);
            var itemModel    = base.CreateItemModel(identifierObject, repository, settings, pipelineContext, logger, language, version);

            if (itemModel != null)
            {
                itemModel[ItemModel.ParentID] = parentItemId;
            }

            return(itemModel);
        }
        private ItemModel CreateNewItem(object identifierObject, IItemModelRepository repository, ResolveSitecoreItemSettings settings, ILogger logger, PipelineContext pipelineContext, string language)
        {
            IValueReader valueReader = this.GetValueReader(settings.ItemNameValueAccessor);

            if (valueReader == null)
            {
                return((ItemModel)null);
            }
            DataAccessContext context       = new DataAccessContext();
            string            validItemName = this.ConvertValueToValidItemName(this.ReadValue(identifierObject, valueReader, context), logger, pipelineContext);

            if (validItemName == null)
            {
                return((ItemModel)null);
            }


            Guid id = repository.Create(validItemName, settings.TemplateForNewItem, settings.ParentItemIdItem, language);

            return(repository.Get(id, (string)null, 0));
        }
        public bool Sync()
        {
            try
            {
                Guid pipelineItemId = Guid.Parse(SalesforceDefPipelineBatchId);
                IItemModelRepository itemModelRepo          = Sitecore.DataExchange.Context.ItemModelRepository;
                ItemModel            pipelineBatchItemModel = itemModelRepo.Get(pipelineItemId);
                var                  converter            = pipelineBatchItemModel.GetConverter <PipelineBatch>(Sitecore.DataExchange.Context.ItemModelRepository);
                var                  convertResult        = converter.Convert(pipelineBatchItemModel);
                PipelineBatch        pipelineBatch        = convertResult.ConvertedValue;
                PipelineBatchContext pipelineBatchContext = new PipelineBatchContext();
                var                  runner = new InProcessPipelineBatchRunner();
                runner.RunAsync(pipelineBatch, pipelineBatchContext);

                Log.Info("Successfully synced xConnect contact to Salesforce on session end via DEF", this);
                return(true);
            }
            catch (Exception ex)
            {
                Log.Error($"Error syncing xConnect contact to Salesforce on session end via DEF. PipelineBatchId = {SalesforceDefPipelineBatchId}", ex, this);
                return(false);
            }
        }
Пример #5
0
 public SitecoreReferenceFieldValueReaderConverter(IItemModelRepository repository) : base(repository)
 {
 }
Пример #6
0
 public JsonPathValueAccessorConverter(IItemModelRepository repository)
     : base(repository)
 {
 }
Пример #7
0
 public FormEntryIdentifierValueAccessorConverter(IItemModelRepository repository) : base(repository)
 {
 }
 public ImageValueAccessorConverterML(IItemModelRepository repository) : base(repository)
 {
     this.SupportedTemplateIds.Add(TemplateId);
 }
 public JsonNodeValueReaderConverter(IItemModelRepository repository, ILogger logger) : base(repository, logger)
 {
 }
Пример #10
0
 public ItemModelProjectBuilder(IItemModelRepository itemModelRepository)
 {
     this.ItemModelRepository = itemModelRepository;
 }
Пример #11
0
 public ReadResourceDataStepConverter(IItemModelRepository repository) : base(repository)
 {
     this.SupportedTemplateIds.Add(Templates.ReadResourceDataPipelineStep.TemplateId);
 }
Пример #12
0
 protected BasePipelineStepWithEndpointAndIdentifierConverter(IItemModelRepository repository)
     : base(repository)
 {
 }
 public IterateAndRunPipelineAndStoreResultsStepConverter(IItemModelRepository repository)
     : base(repository)
 {
 }
Пример #14
0
        public RssFeedStepConverter(IItemModelRepository repository) : base(repository)
        {
            var templateId = Guid.Parse(Settings.GetSetting("DEF.RssFeedStepConverter.Id"));

            this.SupportedTemplateIds.Add(templateId);
        }
 public WordPressStepConverter(IItemModelRepository repository) : base(repository)
 {
     this.SupportedTemplateIds.Add(TemplateId);
 }
Пример #16
0
 public MapChildRecordsToFacetCollectionConverter(IItemModelRepository repository)
     : base(repository)
 {
     this.SupportedTemplateIds.Add(TemplateId);
 }
        protected override object ResolveObject(object identifierValue, Endpoint endpoint, PipelineStep pipelineStep, PipelineContext pipelineContext)
        {
            if (identifierValue == null)
            {
                throw new ArgumentException("The value cannot be null.", "identifierValue");
            }
            if (endpoint == null)
            {
                throw new ArgumentNullException("endpoint");
            }
            if (pipelineStep == null)
            {
                throw new ArgumentNullException("pipelineStep");
            }
            if (pipelineContext == null)
            {
                throw new ArgumentNullException("pipelineContext");
            }
            ItemModelRepositorySettings repositorySettings = endpoint.GetItemModelRepositorySettings();

            if (repositorySettings == null)
            {
                return((object)null);
            }
            IItemModelRepository itemModelRepository = repositorySettings.ItemModelRepository;

            if (itemModelRepository == null)
            {
                return((object)null);
            }
            ResolveSitecoreItemSettings sitecoreItemSettings = pipelineStep.GetResolveSitecoreItemSettings();

            if (sitecoreItemSettings == null)
            {
                return((object)null);
            }
            ResolveObjectSettings resolveObjectSettings = pipelineStep.GetResolveObjectSettings();

            if (resolveObjectSettings == null)
            {
                return((object)null);
            }

            ResolveSitecoreItemWithLanguageSettings languageSettings = pipelineStep.GetPlugin <ResolveSitecoreItemWithLanguageSettings>();

            if (languageSettings == null)
            {
                return((ItemModel)null);
            }



            ItemModel sourceAsItemModel = this.GetSourceObjectAsItemModel(pipelineStep, pipelineContext);

            if (sourceAsItemModel == null)
            {
                return((ItemModel)null);
            }

            var language = sourceAsItemModel[languageSettings.LanguageField].ToString();

            ILogger logger = pipelineContext.Logger;
            RepositoryObjectStatus status = RepositoryObjectStatus.DoesNotExist;
            ItemModel itemModel           = this.DoSearch(identifierValue, sitecoreItemSettings, itemModelRepository, logger, pipelineContext);

            if (itemModel != null)
            {
                this.Log(new Action <string>(pipelineContext.Logger.Debug), pipelineContext, "Item was resolved.", string.Format("identifier: {0}", identifierValue), string.Format("item id: {0}", itemModel["ItemID"]));
                Sitecore.Diagnostics.Log.Error($"Item was resolved with identifierValue: {identifierValue} item id: {itemModel["ItemID"]}", this);
                status = RepositoryObjectStatus.Exists;
            }

            if (itemModel == null && !resolveObjectSettings.DoNotCreateIfObjectNotResolved)
            {
                this.Log(new Action <string>(logger.Debug), pipelineContext, "Item was not resolved. Will create it.", string.Format("identifier: {0}", identifierValue));
                Sitecore.Diagnostics.Log.Error($"Item was not resolved. Will create it: {identifierValue} ", this);

                itemModel = this.CreateNewItem(this.GetIdentifierObject(pipelineStep, pipelineContext), itemModelRepository, sitecoreItemSettings, logger, pipelineContext, language);
                if (itemModel == null)
                {
                    this.Log(new Action <string>(logger.Error), pipelineContext, "Unable to create new item.", string.Format("identifier: {0}", identifierValue));
                    Sitecore.Diagnostics.Log.Error($"Unable to create new item with identifierValue: {identifierValue} ", this);
                }
                else
                {
                    this.Log(new Action <string>(logger.Debug), pipelineContext, "New item was created.", string.Format("identifier: {0}", identifierValue));
                    Sitecore.Diagnostics.Log.Info($"Create new item with identifierValue: {identifierValue} ", this);
                }
            }
            this.SetRepositoryStatusSettings(status, pipelineContext);
            return((object)itemModel);
        }
 public GitHubTrendingViewsAccessorConverter(IItemModelRepository repository) : base(repository)
 {
 }
 public AuditDictionaryStepConverter(IItemModelRepository repository)
     : base(repository)
 {
     this.SupportedTemplateIds.Add(TemplateId);
 }
 public GroupIterableDataStepConverter(IItemModelRepository repository)
     : base(repository)
 {
     this.SupportedTemplateIds.Add(TemplateId);
 }
 public PropertyValueAccessorConverter(IItemModelRepository repository) : base(repository)
 {
     SupportedTemplateIds.Add(TemplateId);
 }
Пример #22
0
 protected BasePluginPipelineStepConverter(IItemModelRepository repository) : base(repository)
 {
 }
 public JsonNodeValueReaderConverter(IItemModelRepository repository) : base(repository)
 {
 }
 public ReadEntityFromContextStepConverter(IItemModelRepository repository) : base(repository)
 {
 }
Пример #25
0
 public BooleanToCheckboxValueReaderConverter(IItemModelRepository repository)
     : base(repository)
 {
 }
Пример #26
0
 public FileEnpointConverter(IItemModelRepository repository) : base(repository)
 {
 }
Пример #27
0
 public ReadXMLDataStepConverter(IItemModelRepository repository) : base(repository)
 {
     this.SupportedTemplateIds.Add(TemplateId);
 }
        protected virtual ItemModel DoSearch(object value, ResolveSitecoreItemSettings resolveItemSettings, IItemModelRepository repository, ILogger logger, PipelineContext pipelineContext)
        {
            SitecoreItemFieldReader valueReader = this.GetValueReader(resolveItemSettings.MatchingFieldValueAccessor) as SitecoreItemFieldReader;

            if (valueReader == null)
            {
                this.Log(new Action <string>(logger.Error), pipelineContext, "The matching field value accessor is not a valid Sitecore item field reader.");
                Sitecore.Diagnostics.Log.Error($"The matching field value accessor is not a valid Sitecore item field reader:", this);
                return((ItemModel)null);
            }
            string str = this.ConvertValueForSearch(value);

            this.Log(new Action <string>(logger.Debug), pipelineContext, "Value converted for search.", string.Format("field: {0}", (object)valueReader.FieldName), string.Format("original value: {0}", value), string.Format("converted value: {0}", (object)str));
            this.Log(new Action <string>(logger.Debug), pipelineContext, "Starting search for item.", string.Format("field: {0}", (object)valueReader.FieldName), string.Format("value: {0}", (object)str));
            IEnumerable <ItemModel> source = null;

            try
            {
                source = repository.Search(new ItemSearchSettings()
                {
                    SearchFilters =
                    {
                        new SearchFilter()
                        {
                            FieldName = valueReader.FieldName,
                            Value     = str
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                Sitecore.Diagnostics.Log.Error($"Error occurred while searching in repository FieldName: {valueReader.FieldName} and value: {str}", ex);
                return((ItemModel)null);
            }
            if (source == null)
            {
                return((ItemModel)null);
            }

            //Fixing a bug that Search would return any item with same name, regardless of where it is.
            foreach (var item in source)
            {
                //quick check of Templates
                if (item.GetTemplateId().Equals(resolveItemSettings.TemplateForNewItem))
                {
                    //Could consider also check path is under root folder.
                    var db         = Sitecore.Data.Database.GetDatabase("master");
                    var scItem     = db.GetItem(new Sitecore.Data.ID(item.GetItemId()));
                    var parentItem = db.GetItem(new Sitecore.Data.ID(resolveItemSettings.ParentItemIdItem));
                    if (scItem.Paths.IsDescendantOf(parentItem))
                    {
                        return(item);
                    }
                }
            }

            return((ItemModel)null);
        }
Пример #29
0
 public GitHubStarCountAccessorConverter(IItemModelRepository repository) : base(repository)
 {
 }
 public CompositeValueReaderConverter(IItemModelRepository repository) : base(repository)
 {
 }