1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
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.PortletItem;
29  import com.liferay.portal.model.PortletItemSoap;
30  import com.liferay.portal.util.PortalUtil;
31  import com.liferay.portal.util.PropsUtil;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.Date;
41  import java.util.List;
42  
43  /**
44   * <a href="PortletItemModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>PortletItem</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portal.service.model.PortletItem
59   * @see com.liferay.portal.service.model.PortletItemModel
60   * @see com.liferay.portal.service.model.impl.PortletItemImpl
61   *
62   */
63  public class PortletItemModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "PortletItem";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "portletItemId", new Integer(Types.BIGINT) },
67              
68  
69              { "groupId", new Integer(Types.BIGINT) },
70              
71  
72              { "companyId", new Integer(Types.BIGINT) },
73              
74  
75              { "userId", new Integer(Types.BIGINT) },
76              
77  
78              { "userName", new Integer(Types.VARCHAR) },
79              
80  
81              { "createDate", new Integer(Types.TIMESTAMP) },
82              
83  
84              { "modifiedDate", new Integer(Types.TIMESTAMP) },
85              
86  
87              { "name", new Integer(Types.VARCHAR) },
88              
89  
90              { "portletId", new Integer(Types.VARCHAR) },
91              
92  
93              { "classNameId", new Integer(Types.BIGINT) }
94          };
95      public static final String TABLE_SQL_CREATE = "create table PortletItem (portletItemId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,name VARCHAR(75) null,portletId VARCHAR(75) null,classNameId LONG)";
96      public static final String TABLE_SQL_DROP = "drop table PortletItem";
97      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
98                  "value.object.finder.cache.enabled.com.liferay.portal.model.PortletItem"),
99              true);
100 
101     public static PortletItem toModel(PortletItemSoap soapModel) {
102         PortletItem model = new PortletItemImpl();
103 
104         model.setPortletItemId(soapModel.getPortletItemId());
105         model.setGroupId(soapModel.getGroupId());
106         model.setCompanyId(soapModel.getCompanyId());
107         model.setUserId(soapModel.getUserId());
108         model.setUserName(soapModel.getUserName());
109         model.setCreateDate(soapModel.getCreateDate());
110         model.setModifiedDate(soapModel.getModifiedDate());
111         model.setName(soapModel.getName());
112         model.setPortletId(soapModel.getPortletId());
113         model.setClassNameId(soapModel.getClassNameId());
114 
115         return model;
116     }
117 
118     public static List<PortletItem> toModels(PortletItemSoap[] soapModels) {
119         List<PortletItem> models = new ArrayList<PortletItem>(soapModels.length);
120 
121         for (PortletItemSoap soapModel : soapModels) {
122             models.add(toModel(soapModel));
123         }
124 
125         return models;
126     }
127 
128     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
129                 "lock.expiration.time.com.liferay.portal.model.PortletItem"));
130 
131     public PortletItemModelImpl() {
132     }
133 
134     public long getPrimaryKey() {
135         return _portletItemId;
136     }
137 
138     public void setPrimaryKey(long pk) {
139         setPortletItemId(pk);
140     }
141 
142     public Serializable getPrimaryKeyObj() {
143         return new Long(_portletItemId);
144     }
145 
146     public long getPortletItemId() {
147         return _portletItemId;
148     }
149 
150     public void setPortletItemId(long portletItemId) {
151         if (portletItemId != _portletItemId) {
152             _portletItemId = portletItemId;
153         }
154     }
155 
156     public long getGroupId() {
157         return _groupId;
158     }
159 
160     public void setGroupId(long groupId) {
161         if (groupId != _groupId) {
162             _groupId = groupId;
163         }
164     }
165 
166     public long getCompanyId() {
167         return _companyId;
168     }
169 
170     public void setCompanyId(long companyId) {
171         if (companyId != _companyId) {
172             _companyId = companyId;
173         }
174     }
175 
176     public long getUserId() {
177         return _userId;
178     }
179 
180     public void setUserId(long userId) {
181         if (userId != _userId) {
182             _userId = userId;
183         }
184     }
185 
186     public String getUserName() {
187         return GetterUtil.getString(_userName);
188     }
189 
190     public void setUserName(String userName) {
191         if (((userName == null) && (_userName != null)) ||
192                 ((userName != null) && (_userName == null)) ||
193                 ((userName != null) && (_userName != null) &&
194                 !userName.equals(_userName))) {
195             _userName = userName;
196         }
197     }
198 
199     public Date getCreateDate() {
200         return _createDate;
201     }
202 
203     public void setCreateDate(Date createDate) {
204         if (((createDate == null) && (_createDate != null)) ||
205                 ((createDate != null) && (_createDate == null)) ||
206                 ((createDate != null) && (_createDate != null) &&
207                 !createDate.equals(_createDate))) {
208             _createDate = createDate;
209         }
210     }
211 
212     public Date getModifiedDate() {
213         return _modifiedDate;
214     }
215 
216     public void setModifiedDate(Date modifiedDate) {
217         if (((modifiedDate == null) && (_modifiedDate != null)) ||
218                 ((modifiedDate != null) && (_modifiedDate == null)) ||
219                 ((modifiedDate != null) && (_modifiedDate != null) &&
220                 !modifiedDate.equals(_modifiedDate))) {
221             _modifiedDate = modifiedDate;
222         }
223     }
224 
225     public String getName() {
226         return GetterUtil.getString(_name);
227     }
228 
229     public void setName(String name) {
230         if (((name == null) && (_name != null)) ||
231                 ((name != null) && (_name == null)) ||
232                 ((name != null) && (_name != null) && !name.equals(_name))) {
233             _name = name;
234         }
235     }
236 
237     public String getPortletId() {
238         return GetterUtil.getString(_portletId);
239     }
240 
241     public void setPortletId(String portletId) {
242         if (((portletId == null) && (_portletId != null)) ||
243                 ((portletId != null) && (_portletId == null)) ||
244                 ((portletId != null) && (_portletId != null) &&
245                 !portletId.equals(_portletId))) {
246             _portletId = portletId;
247         }
248     }
249 
250     public String getClassName() {
251         return PortalUtil.getClassName(getClassNameId());
252     }
253 
254     public long getClassNameId() {
255         return _classNameId;
256     }
257 
258     public void setClassNameId(long classNameId) {
259         if (classNameId != _classNameId) {
260             _classNameId = classNameId;
261         }
262     }
263 
264     public PortletItem toEscapedModel() {
265         if (isEscapedModel()) {
266             return (PortletItem)this;
267         }
268         else {
269             PortletItem model = new PortletItemImpl();
270 
271             model.setEscapedModel(true);
272 
273             model.setPortletItemId(getPortletItemId());
274             model.setGroupId(getGroupId());
275             model.setCompanyId(getCompanyId());
276             model.setUserId(getUserId());
277             model.setUserName(HtmlUtil.escape(getUserName()));
278             model.setCreateDate(getCreateDate());
279             model.setModifiedDate(getModifiedDate());
280             model.setName(HtmlUtil.escape(getName()));
281             model.setPortletId(HtmlUtil.escape(getPortletId()));
282             model.setClassNameId(getClassNameId());
283 
284             model = (PortletItem)Proxy.newProxyInstance(PortletItem.class.getClassLoader(),
285                     new Class[] { PortletItem.class },
286                     new ReadOnlyBeanHandler(model));
287 
288             return model;
289         }
290     }
291 
292     public Object clone() {
293         PortletItemImpl clone = new PortletItemImpl();
294 
295         clone.setPortletItemId(getPortletItemId());
296         clone.setGroupId(getGroupId());
297         clone.setCompanyId(getCompanyId());
298         clone.setUserId(getUserId());
299         clone.setUserName(getUserName());
300         clone.setCreateDate(getCreateDate());
301         clone.setModifiedDate(getModifiedDate());
302         clone.setName(getName());
303         clone.setPortletId(getPortletId());
304         clone.setClassNameId(getClassNameId());
305 
306         return clone;
307     }
308 
309     public int compareTo(Object obj) {
310         if (obj == null) {
311             return -1;
312         }
313 
314         PortletItemImpl portletItem = (PortletItemImpl)obj;
315 
316         long pk = portletItem.getPrimaryKey();
317 
318         if (getPrimaryKey() < pk) {
319             return -1;
320         }
321         else if (getPrimaryKey() > pk) {
322             return 1;
323         }
324         else {
325             return 0;
326         }
327     }
328 
329     public boolean equals(Object obj) {
330         if (obj == null) {
331             return false;
332         }
333 
334         PortletItemImpl portletItem = null;
335 
336         try {
337             portletItem = (PortletItemImpl)obj;
338         }
339         catch (ClassCastException cce) {
340             return false;
341         }
342 
343         long pk = portletItem.getPrimaryKey();
344 
345         if (getPrimaryKey() == pk) {
346             return true;
347         }
348         else {
349             return false;
350         }
351     }
352 
353     public int hashCode() {
354         return (int)getPrimaryKey();
355     }
356 
357     private long _portletItemId;
358     private long _groupId;
359     private long _companyId;
360     private long _userId;
361     private String _userName;
362     private Date _createDate;
363     private Date _modifiedDate;
364     private String _name;
365     private String _portletId;
366     private long _classNameId;
367 }