* @throws Exception If any exception occurred
*/
public static ListIFace getList(ServiceIFace service, SourceBean request, SourceBean response) throws Exception {
PaginatorIFace paginator = new GenericPaginator();
InitializerIFace serviceInitializer = (InitializerIFace) service;
RequestContextIFace serviceRequestContext = (RequestContextIFace) service;
int pagedRows = 10;
SourceBean rowsSourceBean = null;
SourceBean config = serviceInitializer.getConfig();
if (config != null) {
pagedRows = Integer.parseInt((String) serviceInitializer.getConfig().getAttribute("ROWS"));
paginator.setPageSize(pagedRows);
String pool = (String) serviceInitializer.getConfig().getAttribute("POOL");
SourceBean statement = (SourceBean) serviceInitializer.getConfig().getAttribute("QUERIES.SELECT_QUERY");
rowsSourceBean =
(SourceBean) QueryExecutor.executeQuery(
serviceRequestContext.getRequestContainer(),
serviceRequestContext.getResponseContainer(),
pool,
statement,
"SELECT");
} else {
// in case the query is dinamically created, the config SourceBean is in response
config = (SourceBean) response.getAttribute("CONFIG");
pagedRows = Integer.parseInt((String) config.getAttribute("ROWS"));
paginator.setPageSize(pagedRows);
String pool = (String) config.getAttribute("POOL");
String statement = (String) ((SourceBean) config.getAttribute("QUERIES.SELECT_QUERY")).getAttribute("statement");
rowsSourceBean = (SourceBean) executeSelect(serviceRequestContext
.getRequestContainer(), serviceRequestContext
.getResponseContainer(), pool, statement);
}
List rowsVector = null;
if (rowsSourceBean != null)
rowsVector = rowsSourceBean.getAttributeAsList(DataRow.ROW_TAG);
if ((rowsSourceBean == null)) {//|| (rowsVector.size() == 0)) {
EMFErrorHandler engErrorHandler = serviceRequestContext.getErrorHandler();
engErrorHandler.addError(new EMFUserError(EMFErrorSeverity.INFORMATION, 10001));
} // if ((rowsSourceBean == null) || (rowsVector.size() == 0))
else
for (int i = 0; i < rowsVector.size(); i++)
paginator.addRow(rowsVector.get(i));
// chiamo la funzione di ricerca nelle colonne (se non vi sono dati di ricerca la funzione
// non esegue nessuna operazione)
// SearchTextInList.search(request, response, pagedRows, rowsVector);
ListIFace list = new GenericList();
list.setPaginator(paginator);
// list.addStaticData(firstData);
// filter the list
String valuefilter = (String) request.getAttribute(SpagoBIConstants.VALUE_FILTER);
// if((valuefilter!=null) && !(valuefilter.trim().equals(""))) {
// list = filterList(list, valuefilter, request);
// }
if (valuefilter != null) {
String columnfilter = (String) request
.getAttribute(SpagoBIConstants.COLUMN_FILTER);
String typeFilter = (String) request
.getAttribute(SpagoBIConstants.TYPE_FILTER);
String typeValueFilter = (String) request
.getAttribute(SpagoBIConstants.TYPE_VALUE_FILTER);
list = filterList(list, valuefilter, typeValueFilter, columnfilter, typeFilter, serviceRequestContext.getErrorHandler());
}
return list;
} // public static ListIFace getList(ServiceIFace service, SourceBean