1
22
23 package com.liferay.portal.model.impl;
24
25 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.kernel.util.HtmlUtil;
28 import com.liferay.portal.model.Portlet;
29 import com.liferay.portal.model.PortletSoap;
30
31 import com.liferay.portlet.expando.model.ExpandoBridge;
32 import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
33
34 import java.io.Serializable;
35
36 import java.lang.reflect.Proxy;
37
38 import java.sql.Types;
39
40 import java.util.ArrayList;
41 import java.util.List;
42
43
63 public class PortletModelImpl extends BaseModelImpl {
64 public static final String TABLE_NAME = "Portlet";
65 public static final Object[][] TABLE_COLUMNS = {
66 { "id_", new Integer(Types.BIGINT) },
67
68
69 { "companyId", new Integer(Types.BIGINT) },
70
71
72 { "portletId", new Integer(Types.VARCHAR) },
73
74
75 { "roles", new Integer(Types.VARCHAR) },
76
77
78 { "active_", new Integer(Types.BOOLEAN) }
79 };
80 public static final String TABLE_SQL_CREATE = "create table Portlet (id_ LONG not null primary key,companyId LONG,portletId VARCHAR(200) null,roles STRING null,active_ BOOLEAN)";
81 public static final String TABLE_SQL_DROP = "drop table Portlet";
82 public static final String DATA_SOURCE = "liferayDataSource";
83 public static final String SESSION_FACTORY = "liferaySessionFactory";
84 public static final String TX_MANAGER = "liferayTransactionManager";
85 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86 "value.object.finder.cache.enabled.com.liferay.portal.model.Portlet"),
87 true);
88
89 public static Portlet toModel(PortletSoap soapModel) {
90 Portlet model = new PortletImpl();
91
92 model.setId(soapModel.getId());
93 model.setCompanyId(soapModel.getCompanyId());
94 model.setPortletId(soapModel.getPortletId());
95 model.setRoles(soapModel.getRoles());
96 model.setActive(soapModel.getActive());
97
98 return model;
99 }
100
101 public static List<Portlet> toModels(PortletSoap[] soapModels) {
102 List<Portlet> models = new ArrayList<Portlet>(soapModels.length);
103
104 for (PortletSoap soapModel : soapModels) {
105 models.add(toModel(soapModel));
106 }
107
108 return models;
109 }
110
111 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
112 "lock.expiration.time.com.liferay.portal.model.Portlet"));
113
114 public PortletModelImpl() {
115 }
116
117 public long getPrimaryKey() {
118 return _id;
119 }
120
121 public void setPrimaryKey(long pk) {
122 setId(pk);
123 }
124
125 public Serializable getPrimaryKeyObj() {
126 return new Long(_id);
127 }
128
129 public long getId() {
130 return _id;
131 }
132
133 public void setId(long id) {
134 if (id != _id) {
135 _id = id;
136 }
137 }
138
139 public long getCompanyId() {
140 return _companyId;
141 }
142
143 public void setCompanyId(long companyId) {
144 if (companyId != _companyId) {
145 _companyId = companyId;
146 }
147 }
148
149 public String getPortletId() {
150 return GetterUtil.getString(_portletId);
151 }
152
153 public void setPortletId(String portletId) {
154 if (((portletId == null) && (_portletId != null)) ||
155 ((portletId != null) && (_portletId == null)) ||
156 ((portletId != null) && (_portletId != null) &&
157 !portletId.equals(_portletId))) {
158 _portletId = portletId;
159 }
160 }
161
162 public String getRoles() {
163 return GetterUtil.getString(_roles);
164 }
165
166 public void setRoles(String roles) {
167 if (((roles == null) && (_roles != null)) ||
168 ((roles != null) && (_roles == null)) ||
169 ((roles != null) && (_roles != null) && !roles.equals(_roles))) {
170 _roles = roles;
171 }
172 }
173
174 public boolean getActive() {
175 return _active;
176 }
177
178 public boolean isActive() {
179 return _active;
180 }
181
182 public void setActive(boolean active) {
183 if (active != _active) {
184 _active = active;
185 }
186 }
187
188 public Portlet toEscapedModel() {
189 if (isEscapedModel()) {
190 return (Portlet)this;
191 }
192 else {
193 Portlet model = new PortletImpl();
194
195 model.setNew(isNew());
196 model.setEscapedModel(true);
197
198 model.setId(getId());
199 model.setCompanyId(getCompanyId());
200 model.setPortletId(HtmlUtil.escape(getPortletId()));
201 model.setRoles(HtmlUtil.escape(getRoles()));
202 model.setActive(getActive());
203
204 model = (Portlet)Proxy.newProxyInstance(Portlet.class.getClassLoader(),
205 new Class[] { Portlet.class },
206 new ReadOnlyBeanHandler(model));
207
208 return model;
209 }
210 }
211
212 public ExpandoBridge getExpandoBridge() {
213 if (_expandoBridge == null) {
214 _expandoBridge = new ExpandoBridgeImpl(Portlet.class.getName(),
215 getPrimaryKey());
216 }
217
218 return _expandoBridge;
219 }
220
221 public Object clone() {
222 PortletImpl clone = new PortletImpl();
223
224 clone.setId(getId());
225 clone.setCompanyId(getCompanyId());
226 clone.setPortletId(getPortletId());
227 clone.setRoles(getRoles());
228 clone.setActive(getActive());
229
230 return clone;
231 }
232
233 public int compareTo(Object obj) {
234 if (obj == null) {
235 return -1;
236 }
237
238 PortletImpl portlet = (PortletImpl)obj;
239
240 long pk = portlet.getPrimaryKey();
241
242 if (getPrimaryKey() < pk) {
243 return -1;
244 }
245 else if (getPrimaryKey() > pk) {
246 return 1;
247 }
248 else {
249 return 0;
250 }
251 }
252
253 public boolean equals(Object obj) {
254 if (obj == null) {
255 return false;
256 }
257
258 PortletImpl portlet = null;
259
260 try {
261 portlet = (PortletImpl)obj;
262 }
263 catch (ClassCastException cce) {
264 return false;
265 }
266
267 long pk = portlet.getPrimaryKey();
268
269 if (getPrimaryKey() == pk) {
270 return true;
271 }
272 else {
273 return false;
274 }
275 }
276
277 public int hashCode() {
278 return (int)getPrimaryKey();
279 }
280
281 private long _id;
282 private long _companyId;
283 private String _portletId;
284 private String _roles;
285 private boolean _active;
286 private transient ExpandoBridge _expandoBridge;
287 }