We have a Content Type that generates a relation within a relation.
The relationship is Section -> Group - >Link
While it works fine when the user creates a content instance through the UI, I need to find a way of creating instances via the API.
Below is the code I use to create the first relation (Section to Group) and it works fine. However, I don't know how to create the relation below this (Group to Link).
Any comments or suggetions would be a huge favour.
- - - - - - - - - - - - - - - - - - - -
//First Relationship Name
String relationName = "first-relationship-name";
//Create a content type reference
ContentTypeRef contentTypeRef = (ContentTypeRef)ci.getObjectTypeRef();
//Create a new content relation instance
ContentRelationInstance[] relations = new ContentRelationInstance[relation.size()];
//Loop through each relation
for (int i = 0; i < lstContentID.size(); ++i)
{
//Create the relation
relations[i] = new ContentRelationInstance(contentTypeRef);
//Set the relation values
relations[i].setAttributeValue("attribute-name", "General Name" + lstContentID.get(i));
}
//Assign the associations to the parent instance
ci.setRelations(relationName, relations);
- - - - - - - - - - - - - - - - - - - -