if (superScope.equals("All"))
all = true;
request.setAttribute("superScope", superScope);
request.setAttribute("subScope", subScope);
ListPreference listPreference = null;
ValueListParameters listParameters = null;
String moduleId = null;
String filterOnType = null;
if (subScope.equals("Appointment")) {
listPreference = userObject.getListPreference(subScope);
listParameters = ActionUtil.valueListParametersSetUp(listPreference, request,
ValueListConstants.APPOINTMENT_LIST_TYPE, ValueListConstants.appointmentViewMap, false);
moduleId = (String)moduleList.get("Activities");
if (all) {
filterOnType = " Type = " + ActivityVO.AT_APPOINTMENT;
final_Forward = ".view.activities.allappointmentslist";
} else {
filterOnType = " Type = " + ActivityVO.AT_APPOINTMENT + " AND Owner = " + individualId;
final_Forward = ".view.activities.myappointmentslist";
}
} else if (subScope.equals("Call")) {
listPreference = userObject.getListPreference(subScope);
listParameters = ActionUtil.valueListParametersSetUp(listPreference, request,
ValueListConstants.CALL_LIST_TYPE, ValueListConstants.callViewMap, false);
moduleId = (String)moduleList.get("Activities");
if (all) {
final_Forward = ".view.activities.allcallslist";
filterOnType = " Type = " + ActivityVO.AT_CALL;
} else {
final_Forward = ".view.activities.mycallslist";
filterOnType = " Type = " + ActivityVO.AT_CALL + " AND Owner = " + individualId;
}
} else if (subScope.equals("ForecastSales")) {
listPreference = userObject.getListPreference(subScope);
listParameters = ActionUtil.valueListParametersSetUp(listPreference, request,
ValueListConstants.FORECASTSALES_LIST_TYPE, ValueListConstants.forecastSalesViewMap,
false);
moduleId = (String)moduleList.get("Opportunities");
if (all) {
filterOnType = " activity.ActivityID= opportunity.ActivityID ";
final_Forward = ".view.activities.allforecastsaleslist";
} else {
final_Forward = ".view.activities.myforecastsaleslist";
filterOnType = " activity.ActivityID= opportunity.ActivityID AND opportunity.AccountManager = "
+ individualId;
}
} else if (subScope.equals("LiteratureFulfillment")) {
listPreference = userObject.getListPreference("LiteratureFulfillment");
listParameters = ActionUtil.valueListParametersSetUp(listPreference, request,
ValueListConstants.LITERATUREREQUEST_LIST_TYPE,
ValueListConstants.literatureRequestViewMap, false);
moduleId = (String)moduleList.get("LiteratureFulfilment");
if (all) {
final_Forward = ".view.activities.allliteraturerequestslist";
} else {
filterOnType = " activity.Owner = " + individualId
+ " AND literaturerequest.ActivityID = activity.ActivityID";
final_Forward = ".view.activities.myliteraturerequestslist";
}
} else if (subScope.equals("Meeting")) {
listPreference = userObject.getListPreference(subScope);
listParameters = ActionUtil.valueListParametersSetUp(listPreference, request,
ValueListConstants.MEETING_LIST_TYPE, ValueListConstants.meetingViewMap, false);
moduleId = (String)moduleList.get("Activities");
if (all) {
filterOnType = " Type = " + ActivityVO.AT_MEETING;
final_Forward = ".view.activities.allmeetingslist";
} else {
filterOnType = " Type = " + ActivityVO.AT_MEETING + " AND Owner = " + individualId;
final_Forward = ".view.activities.mymeetingslist";
}
} else if (subScope.equals("NextAction")) {
listPreference = userObject.getListPreference(subScope);
listParameters = ActionUtil.valueListParametersSetUp(listPreference, request,
ValueListConstants.NEXTACTION_LIST_TYPE, ValueListConstants.nextActionViewMap, false);
moduleId = (String)moduleList.get("Activities");
if (all) {
filterOnType = " Type = " + ActivityVO.AT_NEXTACTION;
final_Forward = ".view.activities.allnextactionslist";
} else {
filterOnType = " Type = " + ActivityVO.AT_NEXTACTION + " AND Owner = " + individualId;
final_Forward = ".view.activities.mynextactionslist";
}
} else if (subScope.equals("ToDo")) {
listPreference = userObject.getListPreference(subScope);
listParameters = ActionUtil.valueListParametersSetUp(listPreference, request,
ValueListConstants.TODO_LIST_TYPE, ValueListConstants.todoViewMap, false);
moduleId = (String)moduleList.get("Activities");
if (all) {
filterOnType = " Type = " + ActivityVO.AT_TODO;
final_Forward = ".view.activities.alltodoslist";
} else {
filterOnType = " Type = " + ActivityVO.AT_TODO + " AND Owner = " + individualId;
final_Forward = ".view.activities.mytodoslist";
}
} else if (subScope.equals("ActivityTask")) {
listPreference = userObject.getListPreference(subScope);
listParameters = ActionUtil.valueListParametersSetUp(listPreference, request,
ValueListConstants.TASK_LIST_TYPE, ValueListConstants.taskViewMap, false);
moduleId = (String)moduleList.get("Tasks");
if (all) {
filterOnType = " activity.Type = " + ActivityVO.AT_TASK;
final_Forward = ".view.activities.alltaskslist";
} else {
filterOnType = " activity.Type = " + ActivityVO.AT_TASK + " AND activity.Owner = "
+ individualId;
final_Forward = ".view.activities.mytaskslist";
}
} else {
subScope = "MultiActivity";
listPreference = userObject.getListPreference(subScope);
listParameters = ActionUtil.valueListParametersSetUp(listPreference, request,
ValueListConstants.ACTIVITY_LIST_TYPE, ValueListConstants.activityViewMap, false);
moduleId = (String)moduleList.get("Activities");
if (all) {
final_Forward = ".view.activities.allactivitylist";
filterOnType = " Type != 3 UNION ";
String opportunityFilter = EJBUtil.buildListFilterQuery(individualId, 30, "opportunity",
"OpportunityId", "activity.owner", "activityId");
filterOnType += opportunityFilter;
} else {
// We have to eleminate the forcast sale type for my all Activities
// We have to check wheather that opportunity is assigned to me
// for that reason we have to build the query seperatly and clubb
// it with normal query
filterOnType = " Owner = " + individualId + " AND Type != 3 ";
filterOnType += " UNION SELECT activity.ActivityId FROM opportunity, activity WHERE "
+ " activity.ActivityID= opportunity.ActivityID AND opportunity.AccountManager = "
+ individualId;
}
}
// Search handling
String filter = null;
String filterParameter = request.getParameter("filter");
if (filterParameter != null) {
filter = (String)session.getAttribute("listFilter");
request.setAttribute("appliedSearch", filterParameter);
if (filterOnType != null) {
filter = filter + " AND " + filterOnType;
// More ghettoness...
// But there's a fine line between ghetto and genius...
if (subScope.equals("ForecastSales") || subScope.equals("LiteratureFulfillment")
|| subScope.equals("ActivityTask"))
filter = filter.replaceFirst("FROM ", "FROM activity, ");
}
} else {
session.removeAttribute("listFilter");
if (filterOnType != null) {
if (subScope.equals("ForecastSales")) {
filter = "SELECT OpportunityId FROM opportunity, activity WHERE" + filterOnType;
} else if (subScope.equals("LiteratureFulfillment")) {
filter = "SELECT literaturerequest.ActivityId FROM literaturerequest, activity WHERE";
if (filterOnType != null) {
filter += filterOnType;
}
} else {
filter = "SELECT ActivityId FROM activity WHERE" + filterOnType;
}
}
}
listParameters.setFilter(filter);
// Get the list!
ValueListHome valueListHome = (ValueListHome)CVUtility.getHomeObject(
"com.centraview.valuelist.ValueListHome", "ValueList");
ValueList valueList = null;