CentraSite 10.7 | CentraSite Developer's Guide | Application Framework | Querying the Registry | Application Framework JAXR-Based Search
 
Application Framework JAXR-Based Search
Whereas the BeanPool interface takes care of the standard CRUD operations to the registry, the queries are performed using the Query interface (com.softwareag.centrasite.appl.framework.persistence.Query):
package com.softwareag.centrasite.appl.framework.persistence;
public interface Query<T extends RegistryBean> {
List<T> run(QueryContext pContext) throws JAXRException,
CSAppFrameworkException;
}
In order to do a query, one should implement this interface and place the querying routines in the run() method implementation. The query is then executed via BeanPool.run():
<T extends RegistryBean> List<T> run(Query<T> pQuery)
throws CSAppFrameworkException;
The returned data is then in the form of beans.
This mechanism still requires knowledge of JAXR. The benefit is that JAXR is isolated in this interface. Sample implementation of Query:
final Query<EntryCode> q = new Query<EntryCode>() {
public List<EntryCode> run(QueryContext context) throws JAXRException {
final RegistryAccessor regDAO = context.getRegistryAccessor();
final Concept concept = regDAO.findConceptByPath("CSAF-Taxonomy",
"/ClassificationInstances/EntryCodeType");
final List<EntryCode> result = new ArrayList<EntryCode>();
for (Concept c : (Collection<Concept>) concep.getChildrenConcepts()) {
try {
EntryCode ec = context.getCurrentBeanPool().read(EntryCode.class,
c.getKey().getId());
result.add(ec);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
return result;
}
};
List<RegistryBean> queryResult = getBeanPool().run(q);
In general, a Query would use the JAXR-based API to find and retrieve the data, and then the keys of registry objects that were found are passed to the BeanPool to build the beans. These beans are then returned as the result of the query execution.