long start = 0L;
if (logger.isDebugEnabled()) {
start = System.currentTimeMillis();
}
HttpSession session = request.getSession(true);
// Check the session for an existing error message (possibly from the delete
// handler)
ActionErrors allErrors = (ActionErrors)session.getAttribute("listErrorMessage");
if (allErrors != null) {
saveErrors(request, allErrors);
session.removeAttribute("listErrorMessage");
}
// Check wheather the actionType is it Lookup or not
String actionType = (String)request.getParameter("actionType");
String listScope = request.getParameter("listScope");
if (listScope != null && listScope.equals("ALL")) {
finalForward = ".view.support.tickets.all.list";
listScope = "ALL";
} else {
finalForward = ".view.support.tickets.my.list";
listScope = "MY";
}
if (actionType != null && actionType.equals("lookup")) {
listScope = "ALL";
}
UserObject userObject = (UserObject)session.getAttribute("userobject");
int individualId = userObject.getIndividualID();
ListPreference listPreference = userObject.getListPreference("Ticket");
ListView view = listPreference.getListView(String.valueOf(listPreference.getDefaultView()));
ValueListParameters listParameters = null;
ValueListParameters requestListParameters = (ValueListParameters)request.getAttribute("listParameters");
if (requestListParameters == null) // build up new Parameters
{
listParameters = new ValueListParameters(ValueListConstants.TICKET_LIST_TYPE, listPreference.getRecordsPerPage(), 1);
} else { // paging or sorting or something, use the parameters from the
// request.
listParameters = requestListParameters;
}
if (listParameters.getSortColumn() == 0) {
FieldDescriptor sortField = (FieldDescriptor)ValueListConstants.ticketViewMap.get(listPreference.getSortElement());
listParameters.setSortColumn(sortField.getQueryIndex());
if (listPreference.getsortOrder()) {
listParameters.setSortDirection("ASC");
} else {
listParameters.setSortDirection("DESC");
}
}
String filter = null;
String filterParameter = request.getParameter("filter");
if (filterParameter != null) {
filter = (String)session.getAttribute("listFilter");
if (listScope != null && listScope.equalsIgnoreCase("MY")) {
filter += " AND assignedto = " + individualId + " AND ocstatus = 'OPEN'";
}
request.setAttribute("appliedSearch", filterParameter);
} else {
if (listScope != null && listScope.equalsIgnoreCase("MY")) {
filter = " SELECT ticketid FROM ticket WHERE assignedto = " + individualId + " AND ocstatus = 'OPEN'";
}
session.removeAttribute("listFilter");
}
listParameters.setFilter(filter);
// TODO remove crappy map between old views and new views.
Vector viewColumns = view.getColumns();
ArrayList columns = new ArrayList();
// We the Action Type is Ticket's Lookup then we must have
// to set the columns which we are going to look
if (actionType != null && actionType.equals("lookup")) {
Vector lookupViewColumns = new Vector();
lookupViewColumns.add("Number");
lookupViewColumns.add("Subject");
lookupViewColumns.add("Entity");
ActionUtil.mapOldView(columns, lookupViewColumns, ValueListConstants.TICKET_LIST_TYPE);
listParameters.setRecordsPerPage(100);
finalForward = ".view.support.ticketslookup";
} else {
ActionUtil.mapOldView(columns, viewColumns, ValueListConstants.TICKET_LIST_TYPE);
}
listParameters.setColumns(columns);
// Get the list!
ValueListHome valueListHome = (ValueListHome)CVUtility.getHomeObject("com.centraview.valuelist.ValueListHome", "ValueList");
ValueList valueList = null;
try {
valueList = valueListHome.create();
} catch (CreateException e) {
logger.error("[execute] Exception thrown.", e);
throw new ServletException(e);
}
valueList.setDataSource(dataSource);
ValueListVO listObject = valueList.getValueList(individualId, listParameters);
session.setAttribute("ticketPieChartParams", listParameters);
session.setAttribute("ticketBarChartParams", listParameters);
ArrayList buttonList = new ArrayList();
// For the searchBar
String moduleID = (String)moduleList.get("Ticket");
ValueListDisplay displayParameters = null;