*/
public static ListIFace getList(ServiceIFace service, SourceBean request, SourceBean response) throws Exception {
Session aSession = null;
Transaction tx = null;
PaginatorIFace paginator = new GenericPaginator();
String currentFieldOrder = (request.getAttribute("FIELD_ORDER") == null || ((String)request.getAttribute("FIELD_ORDER")).equals(""))?"":(String)request.getAttribute("FIELD_ORDER");
if (currentFieldOrder.equals("")){
currentFieldOrder = "DESCR";
request.delAttribute("FIELD_ORDER");
request.setAttribute("FIELD_ORDER", currentFieldOrder);
}
String currentTypOrder = (request.getAttribute("TYPE_ORDER") == null || ((String)request.getAttribute("TYPE_ORDER")).equals(""))?"":(String)request.getAttribute("TYPE_ORDER");
if (currentTypOrder.equals("")){
currentTypOrder = " ASC";
request.delAttribute("TYPE_ORDER");
request.setAttribute("TYPE_ORDER",currentTypOrder);
}
InitializerIFace serviceInitializer = (InitializerIFace) service;
RequestContextIFace serviceRequestContext = (RequestContextIFace) service;
int pagedRows = 10;
SourceBean rowsSourceBean = null;
pagedRows = Integer.parseInt((String) serviceInitializer.getConfig().getAttribute("ROWS"));
paginator.setPageSize(pagedRows);
SourceBean statement = (SourceBean) serviceInitializer.getConfig().getAttribute("QUERIES.SELECT_QUERY");
try {
aSession = HibernateUtil.currentSession();
tx = aSession.beginTransaction();
Connection jdbcConnection = aSession.connection();
DataConnection dataConnection = getDataConnection(jdbcConnection);
rowsSourceBean =
(SourceBean) DelegatedQueryExecutor.executeQuery(
serviceRequestContext.getRequestContainer(),
serviceRequestContext.getResponseContainer(),
dataConnection,
statement,
"SELECT");
} catch (HibernateException he) {
logException(he);
if (tx != null)
tx.rollback();
throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
} finally {
if (aSession != null) {
if (aSession.isOpen()) aSession.close();
}
}
List rowsVector = null;
if (rowsSourceBean != null)
rowsVector = rowsSourceBean.getAttributeAsList(DataRow.ROW_TAG);
if (rowsSourceBean == null) {
EMFErrorHandler engErrorHandler = serviceRequestContext.getErrorHandler();
engErrorHandler.addError(new EMFUserError(EMFErrorSeverity.INFORMATION, 10001));
}
else
for (int i = 0; i < rowsVector.size(); i++)
paginator.addRow(rowsVector.get(i));
ListIFace list = new GenericList();
list.setPaginator(paginator);
// filter the list