001
014
015 package com.liferay.portal.lar.backgroundtask;
016
017 import com.liferay.portal.kernel.util.Constants;
018 import com.liferay.portal.kernel.util.Validator;
019
020 import java.io.Serializable;
021
022 import java.util.Date;
023 import java.util.HashMap;
024 import java.util.Map;
025
026
029 public class BackgroundTaskContextMapFactory {
030
031 public static Map<String, Serializable> buildTaskContextMap(
032 long userId, long groupId, boolean privateLayout, long[] layoutIds,
033 Map<String, String[]> parameterMap, String cmd, Date startDate,
034 Date endDate, String fileName) {
035
036 Map<String, Serializable> taskContextMap =
037 new HashMap<String, Serializable>();
038
039 if (cmd != null) {
040 taskContextMap.put(Constants.CMD, cmd);
041 }
042
043 if (endDate != null) {
044 taskContextMap.put("endDate", endDate);
045 }
046
047 taskContextMap.put("fileName", fileName);
048 taskContextMap.put("groupId", groupId);
049
050 if ((layoutIds != null) && (layoutIds.length > 0)) {
051 taskContextMap.put("layoutIds", layoutIds);
052 }
053
054 if (parameterMap != null) {
055 HashMap<String, String[]> serializableParameterMap =
056 new HashMap<String, String[]>(parameterMap);
057
058 taskContextMap.put("parameterMap", serializableParameterMap);
059 }
060
061 taskContextMap.put("privateLayout", privateLayout);
062
063 if (startDate != null) {
064 taskContextMap.put("startDate", startDate);
065 }
066
067 taskContextMap.put("userId", userId);
068
069 return taskContextMap;
070 }
071
072 public static Map<String, Serializable> buildTaskContextMap(
073 long userId, long plid, long groupId, String portletId,
074 Map<String, String[]> parameterMap, String cmd, Date startDate,
075 Date endDate, String fileName) {
076
077 Map<String, Serializable> taskContextMap =
078 new HashMap<String, Serializable>();
079
080 if (cmd != null) {
081 taskContextMap.put(Constants.CMD, cmd);
082 }
083
084 if (endDate != null) {
085 taskContextMap.put("endDate", endDate);
086 }
087
088 taskContextMap.put("fileName", fileName);
089 taskContextMap.put("groupId", groupId);
090
091 if (parameterMap != null) {
092 HashMap<String, String[]> serializableParameterMap =
093 new HashMap<String, String[]>(parameterMap);
094
095 taskContextMap.put("parameterMap", serializableParameterMap);
096 }
097
098 taskContextMap.put("plid", plid);
099
100 if (Validator.isNotNull(portletId)) {
101 taskContextMap.put("portletId", portletId);
102 }
103
104 if (startDate != null) {
105 taskContextMap.put("startDate", startDate);
106 }
107
108 taskContextMap.put("userId", userId);
109
110 return taskContextMap;
111 }
112
113 }