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  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.Date;
40  import java.util.List;
41  
42  /**
43   * <a href="PortletItemModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>PortletItem</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portal.service.model.PortletItem
58   * @see com.liferay.portal.service.model.PortletItemModel
59   * @see com.liferay.portal.service.model.impl.PortletItemImpl
60   *
61   */
62  public class PortletItemModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "PortletItem";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "portletItemId", new Integer(Types.BIGINT) },
66              
67  
68              { "groupId", new Integer(Types.BIGINT) },
69              
70  
71              { "companyId", new Integer(Types.BIGINT) },
72              
73  
74              { "userId", new Integer(Types.BIGINT) },
75              
76  
77              { "userName", new Integer(Types.VARCHAR) },
78              
79  
80              { "createDate", new Integer(Types.TIMESTAMP) },
81              
82  
83              { "modifiedDate", new Integer(Types.TIMESTAMP) },
84              
85  
86              { "name", new Integer(Types.VARCHAR) },
87              
88  
89              { "portletId", new Integer(Types.VARCHAR) },
90              
91  
92              { "classNameId", new Integer(Types.BIGINT) }
93          };
94      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)";
95      public static final String TABLE_SQL_DROP = "drop table PortletItem";
96      public static final String DATA_SOURCE = "liferayDataSource";
97      public static final String SESSION_FACTORY = "liferaySessionFactory";
98      public static final String TX_MANAGER = "liferayTransactionManager";
99      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
100                 "value.object.finder.cache.enabled.com.liferay.portal.model.PortletItem"),
101             true);
102 
103     public static PortletItem toModel(PortletItemSoap soapModel) {
104         PortletItem model = new PortletItemImpl();
105 
106         model.setPortletItemId(soapModel.getPortletItemId());
107         model.setGroupId(soapModel.getGroupId());
108         model.setCompanyId(soapModel.getCompanyId());
109         model.setUserId(soapModel.getUserId());
110         model.setUserName(soapModel.getUserName());
111         model.setCreateDate(soapModel.getCreateDate());
112         model.setModifiedDate(soapModel.getModifiedDate());
113         model.setName(soapModel.getName());
114         model.setPortletId(soapModel.getPortletId());
115         model.setClassNameId(soapModel.getClassNameId());
116 
117         return model;
118     }
119 
120     public static List<PortletItem> toModels(PortletItemSoap[] soapModels) {
121         List<PortletItem> models = new ArrayList<PortletItem>(soapModels.length);
122 
123         for (PortletItemSoap soapModel : soapModels) {
124             models.add(toModel(soapModel));
125         }
126 
127         return models;
128     }
129 
130     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
131                 "lock.expiration.time.com.liferay.portal.model.PortletItem"));
132 
133     public PortletItemModelImpl() {
134     }
135 
136     public long getPrimaryKey() {
137         return _portletItemId;
138     }
139 
140     public void setPrimaryKey(long pk) {
141         setPortletItemId(pk);
142     }
143 
144     public Serializable getPrimaryKeyObj() {
145         return new Long(_portletItemId);
146     }
147 
148     public long getPortletItemId() {
149         return _portletItemId;
150     }
151 
152     public void setPortletItemId(long portletItemId) {
153         if (portletItemId != _portletItemId) {
154             _portletItemId = portletItemId;
155         }
156     }
157 
158     public long getGroupId() {
159         return _groupId;
160     }
161 
162     public void setGroupId(long groupId) {
163         if (groupId != _groupId) {
164             _groupId = groupId;
165         }
166     }
167 
168     public long getCompanyId() {
169         return _companyId;
170     }
171 
172     public void setCompanyId(long companyId) {
173         if (companyId != _companyId) {
174             _companyId = companyId;
175         }
176     }
177 
178     public long getUserId() {
179         return _userId;
180     }
181 
182     public void setUserId(long userId) {
183         if (userId != _userId) {
184             _userId = userId;
185         }
186     }
187 
188     public String getUserName() {
189         return GetterUtil.getString(_userName);
190     }
191 
192     public void setUserName(String userName) {
193         if (((userName == null) && (_userName != null)) ||
194                 ((userName != null) && (_userName == null)) ||
195                 ((userName != null) && (_userName != null) &&
196                 !userName.equals(_userName))) {
197             _userName = userName;
198         }
199     }
200 
201     public Date getCreateDate() {
202         return _createDate;
203     }
204 
205     public void setCreateDate(Date createDate) {
206         if (((createDate == null) && (_createDate != null)) ||
207                 ((createDate != null) && (_createDate == null)) ||
208                 ((createDate != null) && (_createDate != null) &&
209                 !createDate.equals(_createDate))) {
210             _createDate = createDate;
211         }
212     }
213 
214     public Date getModifiedDate() {
215         return _modifiedDate;
216     }
217 
218     public void setModifiedDate(Date modifiedDate) {
219         if (((modifiedDate == null) && (_modifiedDate != null)) ||
220                 ((modifiedDate != null) && (_modifiedDate == null)) ||
221                 ((modifiedDate != null) && (_modifiedDate != null) &&
222                 !modifiedDate.equals(_modifiedDate))) {
223             _modifiedDate = modifiedDate;
224         }
225     }
226 
227     public String getName() {
228         return GetterUtil.getString(_name);
229     }
230 
231     public void setName(String name) {
232         if (((name == null) && (_name != null)) ||
233                 ((name != null) && (_name == null)) ||
234                 ((name != null) && (_name != null) && !name.equals(_name))) {
235             _name = name;
236         }
237     }
238 
239     public String getPortletId() {
240         return GetterUtil.getString(_portletId);
241     }
242 
243     public void setPortletId(String portletId) {
244         if (((portletId == null) && (_portletId != null)) ||
245                 ((portletId != null) && (_portletId == null)) ||
246                 ((portletId != null) && (_portletId != null) &&
247                 !portletId.equals(_portletId))) {
248             _portletId = portletId;
249         }
250     }
251 
252     public String getClassName() {
253         return PortalUtil.getClassName(getClassNameId());
254     }
255 
256     public long getClassNameId() {
257         return _classNameId;
258     }
259 
260     public void setClassNameId(long classNameId) {
261         if (classNameId != _classNameId) {
262             _classNameId = classNameId;
263         }
264     }
265 
266     public PortletItem toEscapedModel() {
267         if (isEscapedModel()) {
268             return (PortletItem)this;
269         }
270         else {
271             PortletItem model = new PortletItemImpl();
272 
273             model.setEscapedModel(true);
274 
275             model.setPortletItemId(getPortletItemId());
276             model.setGroupId(getGroupId());
277             model.setCompanyId(getCompanyId());
278             model.setUserId(getUserId());
279             model.setUserName(HtmlUtil.escape(getUserName()));
280             model.setCreateDate(getCreateDate());
281             model.setModifiedDate(getModifiedDate());
282             model.setName(HtmlUtil.escape(getName()));
283             model.setPortletId(HtmlUtil.escape(getPortletId()));
284             model.setClassNameId(getClassNameId());
285 
286             model = (PortletItem)Proxy.newProxyInstance(PortletItem.class.getClassLoader(),
287                     new Class[] { PortletItem.class },
288                     new ReadOnlyBeanHandler(model));
289 
290             return model;
291         }
292     }
293 
294     public Object clone() {
295         PortletItemImpl clone = new PortletItemImpl();
296 
297         clone.setPortletItemId(getPortletItemId());
298         clone.setGroupId(getGroupId());
299         clone.setCompanyId(getCompanyId());
300         clone.setUserId(getUserId());
301         clone.setUserName(getUserName());
302         clone.setCreateDate(getCreateDate());
303         clone.setModifiedDate(getModifiedDate());
304         clone.setName(getName());
305         clone.setPortletId(getPortletId());
306         clone.setClassNameId(getClassNameId());
307 
308         return clone;
309     }
310 
311     public int compareTo(Object obj) {
312         if (obj == null) {
313             return -1;
314         }
315 
316         PortletItemImpl portletItem = (PortletItemImpl)obj;
317 
318         long pk = portletItem.getPrimaryKey();
319 
320         if (getPrimaryKey() < pk) {
321             return -1;
322         }
323         else if (getPrimaryKey() > pk) {
324             return 1;
325         }
326         else {
327             return 0;
328         }
329     }
330 
331     public boolean equals(Object obj) {
332         if (obj == null) {
333             return false;
334         }
335 
336         PortletItemImpl portletItem = null;
337 
338         try {
339             portletItem = (PortletItemImpl)obj;
340         }
341         catch (ClassCastException cce) {
342             return false;
343         }
344 
345         long pk = portletItem.getPrimaryKey();
346 
347         if (getPrimaryKey() == pk) {
348             return true;
349         }
350         else {
351             return false;
352         }
353     }
354 
355     public int hashCode() {
356         return (int)getPrimaryKey();
357     }
358 
359     private long _portletItemId;
360     private long _groupId;
361     private long _companyId;
362     private long _userId;
363     private String _userName;
364     private Date _createDate;
365     private Date _modifiedDate;
366     private String _name;
367     private String _portletId;
368     private long _classNameId;
369 }