Fairly Positive

Mapping T4 SiteManager Content to Java Objects

In developing the Prospectus Editing Tool (PET) one of my goals was to try and abstract as much as possible from the underlying content store. If we decided to replace SiteManager (SM) as the University content management system in the very distant future, we’d only have a large amount of work to replace certain implementation classes rather than an unbelievably enormous amount of work. I also wanted the system to be easy to maintain, so that adding new fields to the CMS content types (templates) for the prospectus would be straight forward to support in PET.

I’m using pretty standard Java objects to model the domain, for example SubjectArea and UGProgramme, and these are abstracted away from how the content is structured in SM. Content in SM is made up of a number content elements (fields) and you access those by name:

1
ContentElement e1 = contentObj.get("UCAS Code")

I therefore developed a framework that would allow a developer to map a content element in SM to a field in a Java Object via a custom annotation:

1
2
@ContentField("UCAS Code")
private String ucasCode;

The framework happily creates new content and finding and updating existing content. Supporting a new SM content element means adding a new field in the Java object and annotating it with the name of the element (like the example above). You then need to update the JSP page from the view layer so that the form displays the content (with the help of some custom tag libraries). The abstraction mainly works, albeit does leak is some areas that need further attention. I’ll put flesh on the details in future posts.

Comments