DXA's Generic Topic Entity Model (Java)
The DefaultModelBuilder class maps Tridion Docs content to a Generic Topic Entity Model.
By default, DXA maps Topics published from Tridion Docs to the Generic Topic Entity Model. In a subsequent step, DXA transforms these generic models into Strongly Typed Topic Models.
The following Java code excerpt demonstrates how the DefaultModelBuilder class maps Tridion Docs content to a Generic Topic Entity Model:
@SemanticEntity("Topic")
public class GenericTopic extends AbstractEntityModel {
/**
* Gets or sets the topic title.
*/
@SemanticProperty("topicTitle")
private String topicTitle;
/**
* Gets or sets the topic body.
* The topic body is an XHTML fragment which contains _all_ DITA properties (incl. title, body, related-links, nested topics)
*/
@SemanticProperty("topicBody")
private String topicBody;
public GenericTopic() {
}
public GenericTopic(String topicTitle, String topicBody) {
this.topicTitle = topicTitle;
this.topicBody = topicBody;
}
public String getTopicTitle() {
return topicTitle;
}
public void setTopicTitle(String topicTitle) {
this.topicTitle = topicTitle;
}
public String getTopicBody() {
return topicBody;
}
public void setTopicBody(String topicBody) {
this.topicBody = topicBody;
}
}
The first SemanticProperty maps the topicTitle field to the TopicTitle property. Similarly, the second SemanticProperty maps the topicBody field to the TopicBody property. The topicBody field is XHTML that contains all DITA properties.
After creating the Generic Topic Models, a second model builder, the StronglyTypedTopicBuilder class, will transform them into Strongly Typed Topic Models.