Export sequence
When an inRiver entity is added, the information is exported starting from a given entity and then using breadth-first-traverse to traverse its outbound links. If an entity is edited, only that entity and its immediate Resource children are exported.
When an entity is deleted, all the child entities referred by the outbound links are deleted using inverted breadth first traverse: breadth first search but processing the last leaf node level first and up.
When an entity is added
Following image shows the order in which entities will be exported, when an entity is added to the channel: Suppose the Electronincs ChannelNode is added to the Litium Studio Channel. Note that after Phones (Product group in Litium Studio) its the TVs that will be created, and so on.

The main traversing logic is contained in the \Src\Litium.Studio.AddOns.Inriver\Publisher.cs :: private void LinkAdded(Link inboundLink) method. Code is reproduced below for reference.
/// <summary>
/// Links the added.
/// </summary>
/// <param name="inboundLink"> The inbound link. </param>
private void LinkAdded(Link inboundLink)
{
var execQue = new Queue<Link>();
var relationships = new HashSet<RelationshipNode>();
execQue.Enqueue(inboundLink);
while (execQue.Count > 0)
{
Link current = execQue.Dequeue();
if (ConnectorSettings.ExcludedLinkTypes.Contains(current.LinkType.Id))
{
continue;
}
ILinkService linkService = current.GetLinkService();
switch (linkService.LinkTypeBehaviour)
{
case LinkTypeBehaviour.Assortment:
case LinkTypeBehaviour.ProductGroup:
case LinkTypeBehaviour.Product:
case LinkTypeBehaviour.Variant:
case LinkTypeBehaviour.PackagedArticle:
case LinkTypeBehaviour.InformationOrResource:
List<IEntityUri> publishingNodes = UriService.AddStructureLinkToCache(current);
foreach (var publishingNode in publishingNodes)
{
IntegrationLogger.Write(LogLevel.Information, string.Format("Hippo: Exporting uri '{0}', (linkTypeBehaviour='{1}', LinkTypeId='{2}')", publishingNode.GetUriDisplayName(), linkService.LinkTypeBehaviour, publishingNode.LinkTypeId));
linkService.ExportEntity(publishingNode);
}
break;
case LinkTypeBehaviour.ProductGroupProductGroupRelationship:
case LinkTypeBehaviour.ProductGroupProductRelationship:
case LinkTypeBehaviour.ProductProductGroupRelationship:
case LinkTypeBehaviour.ProductProductRelationship:
IEnumerable<RelationshipNode> currentRelationships = UriService.AddRelationshipLinkToCache(current);
relationships.UnionWith(currentRelationships);
//do not take the children of relationship link targets, continue to next link.
continue;
}
Entity targetEntity = EntityCache[current.Target];
if (targetEntity == null)
{
continue;
}
targetEntity.LoadLinks();
foreach (Link outboundLink in targetEntity.OutboundLinks.Where(x => !x.Inactive))
{
execQue.Enqueue(outboundLink);
}
}
//now that all the entities are exported, process relationships.
//this is done last to makesure that when relationships are executed, its entity objects are already imported.
foreach (RelationshipNode item in relationships)
{
ExportRelationship(item);
}
DataService.SaveDataItems();
}
As seen above, all the outbound links are divided into two categories: The structure links are links that will be processed in breadth-first-traverse down the node tree. The relationship links are processed at the end. This is to ensure that when relationships are created, its source and target nodes (products or product groups) are already created.
When an entity is deleted
When a entity is deleted, the traverse order is exactly the reverse of above. First any relationships are deleted. Then the entity is deleted.