External data in Orchard

Topics: Customizing Orchard, General, Writing modules
Mar 24, 2015 at 10:50 AM
Edited Mar 24, 2015 at 11:33 AM
We have an external system and we would like the data from that system to be available in Orchard. We have a web service (REST API) for this system to get the data and we have already created a module with services to call that web service.

So far we've been synchronizing all the data to Orchard, but this is not working for us. We want to make the data directly available in Orchard. This system works very similar to Orchard, it has content types, content items and fields. But it doesn't have anything like parts, only fields.

We would like to make it so that we can use most of the awesome Orchard functionality (such as widgets, queries/projections, workflows etc) and only the data from the external system. We don't want to have to make a content item in Orchard for every item in the external system, we want Orchard to get all it's content items directly from that external system. I've been doing some research and have only found topics/articles from 2011 so far. For example, this solution is easy to implement, but then we don't have actual content items in Orchard, so we can't do anything with the data besides showing it on a simple page.

I also thought I could use events of the ContentHandler for this, but then it seems like I will need to create a (empty) content item in Orchard for every item in the external system.

On other topics I have seen people talk about implementing an IRepository, it seems like I should do this, but I don't really know how it works and how to start with that (I can't find any examples, they only say that you should only use that if you want to fully direct part storage somewhere else). I have been looking the the Orchard code of (I)Repository and DefaultContentManager (at first I thought I might have to implement an IContentManager), but so far the IRepository seems a bit too complicated for me, I have no idea how to start implementing it and I'm not sure that's even the correct course of action. For example, the default Repository class does everything via the Session property, but I don't understand what that is exactly and if I need to keep using it in my implementation or if I have to replace that with my webservice calls, or something different...

So could someone help me get started with this? Confirm whether I should use an IRepository or something else and give me some pointers and/or small examples on how to use it?
Mar 24, 2015 at 2:32 PM
Edited Mar 24, 2015 at 2:33 PM
I'm starting to understand it a little better. Please correct me if I'm wrong with any of this.

The Session property from Repository is a NHibernate class. Looks like the Session.Get(), for example, gets an item from the database via NHibernate, so I think I have to replace that with my own method to get an item from my webservice.

Also, it looks like I will also have to make my own IContentQuery derived class if I want to be able to use Orchard queries for my external content, because the DefaultContentQuery also uses NHibernate methods to query in the database.