Understanding the data model of composite applications
Introduction
The composite application data model is very similar to the model on Websphere Portal for applications. Understanding the model is key to creating great applications. You access the model using the Topology Handler
Api's in Lotus Expeditor.
You have three basic levels of data:
Application
|_Pages
|_Components
A page in the client platform is equivalent to an Eclipse perspective. The page id (which can be accessed from the Page
class) is actually the Eclipse perspective Id. You can use the Eclipse API's to show a page using that same id. The components have a similar mapping. Most components, not all, are equivalent to Eclipse views. The secondary Id of the view is used as the unique Id for the component. You can get a handle to the preferences of a component by using the secondary Id of a view part. Here is some sample code that shows how to get that secondary Id from a view part:
IViewPart view;
String secondaryId = view.getViewSite().getSecondaryId();
Each level has preferences and properties that can be entered in the Composite Application editor and then accessed using the Topology Handler API's. You can start by getting a handle to the Topology service. Creating helper methods in your plugin somewhere to get the service will help out. The service can always be null so you need to check for that when getting the service object.
ServiceTracker thTracker = null;
thTracker = new ServiceTracker(context, TopologyHandler.class.getName(), null);
thTracker.open();
public TopologyHandler getTopologyService(){
if (thTracker != null)
return (TopologyHandler )thTracker.getService();
else
return null;
}
Getting a list of all applications
You may want to know what applications are installed. This could be helpful if you are trying to find a specific component or page installed into the system. Each application has a unique identifier called a GUID - Global Unique Identifier.
String[] guids = handler.getApplicationGUIDs();
After you get the list of guid's you can iterate through the Ids and call the TopologyHandler method getApplicationNavigationTree()
which returns you a Navigation
object. From there you can get references to all of the pages and components for a given application.
Getting the page object from a perspective id
Since the perspective id is the same as a page id you can use the TopologyHandler API getNavigation()
to get an object for the current page. For instance, say you are in some code where you have no handle to the current composite application page. You can query the Eclipse workbench API's to get the current perspective, then get its perspective Id and use that same string to retrieve the Page object form the getNavigation() method.
String pageId = workbenchpage.getPerspective().getId()
Page np = (Page)handler.getNavigation(pageId);
Accessing a components data area
One of the great things about this model is you can store preferences at all three levels - then access those preferences to drive things like the user interface (fonts, colors), connection information, or any initialization data.
TopologyHandler th = MyPlugin.getDefault().getTopologyService();
if (th == null) return;
ComponentData data = th.getComponentData(view.getViewSite().getSecondaryId());
if (data == null) return;
String[] myPreference = data.getPreference("my preference");
if (myPreference == null || myPreference.length ==0)
return;
Resources
Need support?
This wiki is designed to provide valuable information to help you, but it does not replace other technical support services. Refer the following resources for more information.