In last year’s blogs I did a several part series on the Data Exchange Framework or DEF. You can find that here. I decided to upgrade my DEF Reddit feed module to the latest versions of Sitecore and DEF to get more familiar with the changes.
The first thing I did to the solution after installing the new latest version of DEF into Sitecore 9 Update 1 was to replace the following files.
Code Changes:
Starting with BaseReadDataStepProcessor I noticed a slight change.
The following code:
protected override void ReadData(Endpoint endpoint, Sitecore.DataExchange.Models.PipelineStep pipelineStep, PipelineContext pipelineContext) {
Should now be:
protected override void ReadData(Endpoint endpoint, PipelineStep pipelineStep, PipelineContext pipelineContext, ILogger logger) {
As you can see from the above code PipelineContext was replaced with ILogger.
The function that adds the plugin has changed.
From this:
pipelineContext.Plugins.Add(dataSettings);
To this:
pipelineContext.AddPlugin(dataSettings);
In the RedditFeedValueReader the following method has changed since CanReadResult object is now ReadResult,
Original:
-
public CanReadResult CanRead(object source, DataAccessContext context) {
-
bool flag = source != null && source is RedditSharp.Things.Post;
-
return new CanReadResult() {
-
CanReadValue = flag
-
};
-
}
Change:
-
public ReadResult CanRead(object source, DataAccessContext context) {
-
bool flag = source != null && source is RedditSharp.Things.Post;
-
return new ReadResult(DateTime.Now) {
-
ReadValue = source, WasValueRead = flag,
-
};
-
}
In the RedditFeedFieldValueAccessorConverter class I noticed the following issue after upgrading.
After using DotPeek to take a look I found this method no longer exists. It looks like it has been renamed/replaced by ConvertResult. Also it has been set to protected vs public.
-
protected override ConvertResult < IValueAccessor > ConvertSupportedItem(ItemModel source) {
-
return this.PositiveResult((IValueAccessor) new ValueAccessor() {
-
ValueReader = this.GetValueReader(source), ValueWriter = this.GetValueWriter(source)
-
});
-
}
So, I converted by existing method and it works again.
-
protected override ConvertResult < IValueAccessor > ConvertSupportedItem(ItemModel source) {
-
var accessor = base.Convert(source);
-
if (accessor == null) {
-
return null;
-
}
-
var fieldName = base.GetStringValue(source, RedditFeedFieldValueValueAccessorItemModel.RedditFeedFieldName);
-
if (string.IsNullOrEmpty(fieldName)) {
-
return null;
-
}
-
if (string.IsNullOrEmpty(fieldName)) {
-
return null;
-
}
-
ValueWriter = this.GetValueWriter(source);
-
ValueReader = this.GetValueReader(source) ? ? new RedditFeedValueReader(fieldName);
-
if (ValueWriter == null) {
-
ValueWriter = new PropertyValueWriter(fieldName);
-
}
-
return this.PositiveResult((IValueAccessor) new ValueAccessor());
-
}
The way ids were set before is now a bit different.
Before I would set id’s using the following:
-
private static readonly Guid TemplateId = Guid.Parse(“{CE67E73A-40DF-4AB7-A7D3-2FD65E166E2E}”);
-
public RedditEndpointConverter(IItemModelRepository repository): base(repository) {
-
this.SupportedTemplateIds.Add(TemplateId);
-
}
I changed that and now just do this:
-
[SupportedIds(“{68BD9AAD-635F-40F3-9ACD-711662C59EEC}”)]
Sitecore Changes:
The value mapping has changed to a Treelist instead of a droplist.
The window that gave you updates while the batch process ran has changed. Now it links to a log file.
Those are the changes I made for now. Unfortunately, I am not able to run the process as I did before. It seems something else has changed. I am currently digging into that and have gone to Sitecore support for help. I will document the change in my next blog and also update the code repository so you can see the new changes.