#Sitecore’s Data Exchange Framework Reddit Style Part 2

In part 1 you saw what items were created to for the data exchange process. Now I want to show you some of the backend so you can get a better picture on how they are connected. In this blog I will go over the Converters section. You can find the source code here for reference.

This is a snapshot of each folder that was created and the corresponding class file.

RedditFeedFieldValueAccessorConverter.cs

Let’s start with Value Access Converter. Below is the code.


The TemplateId ({68BD9AAD-635F-40F3-9ACD-711662C59EEC}) being set refers to the following template. This template inherits from the Value Accessor template installed by the DEF package.

So how this corresponds to Sitecore is simple. A Value Accessor Set item is created and the items underneath it use this template. In the RedditFeedFieldValueAccessorConverter class it is setup to get the value of that field using the combination of the template and the field name defined in the RedditFeedFieldValueValueAccesorItemModel. You will see how this is tied in to other parts of the DEF process as we go along.


In the code you will notice a ValueReader and a ValueWriter are defined. The ValueReader is used to read in the feed and match the fields for each Reddit blog item. That uses the RedditFeedValueReader class as you will see in another part of the blog. The ValueWriter defines a new PropertyValueWriter class. That class is part of the DEF and used to convert the field values.

RedditFeedValueReader.cs

This class will process the Reddit Post item and match field name with value. Title, AuthorName, SelfText etc… are field names in the Reddit feed. I believe you can name these differently, but I prefer to keep the same name as it is in the Reddit Post item.

RedditEndPoint.cs

The Reddit End Point will have the information for the Blog Path in Reddit. The TemplateId defined points to the RedditEndPoint template. Settings are returned and added to the plugin. The plugin is required to be implemented by the pipeline converter and processor.


This is the model plug in code:


This is values of the Reddit Endpoint. You can see that the Converter Type points to the RedditEndPoint class.

More about this later, but as you can see in the Reddit Pipeline Step the Reddit Endpoint is selected. Now you can see how this all ties together.

RedditEndPointConverter.cs

The converter is one of the most crucial parts of the DEF. This is what ties together the pipeline step of the DEF. The TemplateId is the template id of the Reddit Pipeline step. As you can see the endpoint settings are passed in to the pipeline step.


Looking in Sitecore you can see where they Converter Type points to the Endpoint Converter and also the Processor Type which will get called and receive the end point information and do the Reddit Feed processing. More about that in another blog though.

Hopefully you are seeing how some of this stuff is tied together. In part 3 of the blog I will talk a little about the models which will be a short blog. Part 4 I will get into the processor. Let me know if you have any questions.

#Sitecore’s Data Exchange Framework Reddit Style Part 1

Now that I have been using #Sitecore’s Data Exchange Framework it was time share my knowledge with the rest of the world. For this blog post I will break it up in various parts. Hopefully it will give you a good overview of the DEF and how powerful it can be. I have used for a few different things, but for this example I decided to create something somewhat unique. I will try to keep each blog as short as possible, but there is a lot to cover. I will eventually update each blog with a link to the finished Sitecore module and source code.

First thing you want to do is download the Data Exchange Framework. You can find it here. I installed both the Date Exchange Framework and the Sitecore Provider for Data Exchange Framework.

After that it is a simple right click on the Data Exchange item under System and simple add a new tenant. Below are some of the settings I created and used. This should give you a rough outline on what you should create when doing your DEF feed.

I will go into more detail, but after I was done adding all the stuff for my Reddit feed this is what it looked like:

Value Accessor Sets

  • Used to map feed values from the source
  • Used to map source values to Sitecore

Each Accessor set has a field. I made these fields the same names I was getting from the feed. It made things a little easier to remember. For the list of fields check out the RedditSharp API here.

For the Sitecore field you will use the fields of a template you create. In this case it will be a Reddit item template.

The field value is going to point to the item template of the Reddit feed item. I kept the field naming consistent with the feed.

Value Mapping Sets

To bring those together we will use a value mapping set. This will make the connection from the feed field to the Sitecore field.

Example setting:

Endpoints

In this example created a template that contains settings needed for the field. Template inherits from the endpoint base template. For the Sitecore endpoint I created and used the default values.

Feed Endpoint example:

The converter type points to a created method in the code behind. The method is used to retrieve the blog path.

Sitecore Endpoint example (defaulted values):

After the batch process runs all of the pipeline steps the following will be created in Sitecore. I will go into how this is created in other parts of the blog, but this will give you a picture of what happens. Keep in mind the DEF can be used to do more than just create Sitecore items. Lots of things like external SQL tables, CRMs, MongoDB etc… could be updated.

RedditList

In the next blog post I will talk about how things get tied together. It should make things more clear on why things are setup this way in this blog post. You can find it at Sitecore’s Data Exchange Framework Reddit Style Part 2.