1
22
23 package com.liferay.portal.kernel.lar;
24
25 import com.liferay.portal.kernel.util.StringMaker;
26 import com.liferay.portal.kernel.util.StringPool;
27 import com.liferay.portal.kernel.zip.ZipReader;
28 import com.liferay.portal.kernel.zip.ZipWriter;
29
30 import java.io.Serializable;
31
32 import java.util.Map;
33 import java.util.Set;
34
35
47 public class PortletDataContext implements Serializable {
48
49 public PortletDataContext(long companyId, long groupId, Map parameterMap,
50 Set primaryKeys, ZipReader zipReader) {
51
52 _companyId = companyId;
53 _groupId = groupId;
54 _parameterMap = parameterMap;
55 _primaryKeys = primaryKeys;
56 _zipReader = zipReader;
57 _zipWriter = null;
58 }
59
60 public PortletDataContext(long companyId, long groupId, Map parameterMap,
61 Set primaryKeys, ZipWriter zipWriter) {
62
63 _companyId = companyId;
64 _groupId = groupId;
65 _parameterMap = parameterMap;
66 _primaryKeys = primaryKeys;
67 _zipReader = null;
68 _zipWriter = zipWriter;
69 }
70
71 public long getCompanyId() {
72 return _companyId;
73 }
74
75 public long getGroupId() {
76 return _groupId;
77 }
78
79 public long getPlid() {
80 return _plid;
81 }
82
83 public void setPlid(long plid) {
84 _plid = plid;
85 }
86
87 public Map getParameterMap() {
88 return _parameterMap;
89 }
90
91 public Set getPrimaryKeys() {
92 return _primaryKeys;
93 }
94
95 public boolean addPrimaryKey(Class classObj, Object primaryKey) {
96 boolean value = hasPrimaryKey(classObj, primaryKey);
97
98 if (!value) {
99 _primaryKeys.add(getPrimaryKeyString(classObj, primaryKey));
100 }
101
102 return value;
103 }
104
105 public boolean hasPrimaryKey(Class classObj, Object primaryKey) {
106 return _primaryKeys.contains(getPrimaryKeyString(classObj, primaryKey));
107 }
108
109 public ZipReader getZipReader() {
110 return _zipReader;
111 }
112
113 public ZipWriter getZipWriter() {
114 return _zipWriter;
115 }
116
117 protected String getPrimaryKeyString(Class classObj, Object primaryKey) {
118 StringMaker sm = new StringMaker();
119
120 sm.append(classObj.getName());
121 sm.append(StringPool.POUND);
122 sm.append(primaryKey);
123
124 return sm.toString();
125 }
126
127 private long _companyId;
128 private long _groupId;
129 private long _plid;
130 private Map _parameterMap;
131 private Set _primaryKeys;
132 private ZipReader _zipReader;
133 private ZipWriter _zipWriter;
134
135 }