1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.imagegallery.model.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.HtmlUtil;
21  import com.liferay.portal.kernel.util.StringBundler;
22  import com.liferay.portal.model.impl.BaseModelImpl;
23  import com.liferay.portal.util.PortalUtil;
24  
25  import com.liferay.portlet.imagegallery.model.IGFolder;
26  import com.liferay.portlet.imagegallery.model.IGFolderSoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.Date;
36  import java.util.List;
37  
38  /**
39   * <a href="IGFolderModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This interface is a model that represents the IGFolder table in the
48   * database.
49   * </p>
50   *
51   * @author    Brian Wing Shun Chan
52   * @see       IGFolderImpl
53   * @see       com.liferay.portlet.imagegallery.model.IGFolder
54   * @see       com.liferay.portlet.imagegallery.model.IGFolderModel
55   * @generated
56   */
57  public class IGFolderModelImpl extends BaseModelImpl<IGFolder> {
58      public static final String TABLE_NAME = "IGFolder";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "uuid_", new Integer(Types.VARCHAR) },
61              { "folderId", new Integer(Types.BIGINT) },
62              { "groupId", new Integer(Types.BIGINT) },
63              { "companyId", new Integer(Types.BIGINT) },
64              { "userId", new Integer(Types.BIGINT) },
65              { "createDate", new Integer(Types.TIMESTAMP) },
66              { "modifiedDate", new Integer(Types.TIMESTAMP) },
67              { "parentFolderId", new Integer(Types.BIGINT) },
68              { "name", new Integer(Types.VARCHAR) },
69              { "description", new Integer(Types.VARCHAR) }
70          };
71      public static final String TABLE_SQL_CREATE = "create table IGFolder (uuid_ VARCHAR(75) null,folderId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,createDate DATE null,modifiedDate DATE null,parentFolderId LONG,name VARCHAR(75) null,description STRING null)";
72      public static final String TABLE_SQL_DROP = "drop table IGFolder";
73      public static final String ORDER_BY_JPQL = " ORDER BY igFolder.folderId ASC, igFolder.name ASC";
74      public static final String ORDER_BY_SQL = " ORDER BY IGFolder.folderId ASC, IGFolder.name ASC";
75      public static final String DATA_SOURCE = "liferayDataSource";
76      public static final String SESSION_FACTORY = "liferaySessionFactory";
77      public static final String TX_MANAGER = "liferayTransactionManager";
78      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.entity.cache.enabled.com.liferay.portlet.imagegallery.model.IGFolder"),
80              true);
81      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
82                  "value.object.finder.cache.enabled.com.liferay.portlet.imagegallery.model.IGFolder"),
83              true);
84  
85      public static IGFolder toModel(IGFolderSoap soapModel) {
86          IGFolder model = new IGFolderImpl();
87  
88          model.setUuid(soapModel.getUuid());
89          model.setFolderId(soapModel.getFolderId());
90          model.setGroupId(soapModel.getGroupId());
91          model.setCompanyId(soapModel.getCompanyId());
92          model.setUserId(soapModel.getUserId());
93          model.setCreateDate(soapModel.getCreateDate());
94          model.setModifiedDate(soapModel.getModifiedDate());
95          model.setParentFolderId(soapModel.getParentFolderId());
96          model.setName(soapModel.getName());
97          model.setDescription(soapModel.getDescription());
98  
99          return model;
100     }
101 
102     public static List<IGFolder> toModels(IGFolderSoap[] soapModels) {
103         List<IGFolder> models = new ArrayList<IGFolder>(soapModels.length);
104 
105         for (IGFolderSoap soapModel : soapModels) {
106             models.add(toModel(soapModel));
107         }
108 
109         return models;
110     }
111 
112     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
113                 "lock.expiration.time.com.liferay.portlet.imagegallery.model.IGFolder"));
114 
115     public IGFolderModelImpl() {
116     }
117 
118     public long getPrimaryKey() {
119         return _folderId;
120     }
121 
122     public void setPrimaryKey(long pk) {
123         setFolderId(pk);
124     }
125 
126     public Serializable getPrimaryKeyObj() {
127         return new Long(_folderId);
128     }
129 
130     public String getUuid() {
131         return GetterUtil.getString(_uuid);
132     }
133 
134     public void setUuid(String uuid) {
135         _uuid = uuid;
136 
137         if (_originalUuid == null) {
138             _originalUuid = uuid;
139         }
140     }
141 
142     public String getOriginalUuid() {
143         return GetterUtil.getString(_originalUuid);
144     }
145 
146     public long getFolderId() {
147         return _folderId;
148     }
149 
150     public void setFolderId(long folderId) {
151         _folderId = folderId;
152     }
153 
154     public long getGroupId() {
155         return _groupId;
156     }
157 
158     public void setGroupId(long groupId) {
159         _groupId = groupId;
160 
161         if (!_setOriginalGroupId) {
162             _setOriginalGroupId = true;
163 
164             _originalGroupId = groupId;
165         }
166     }
167 
168     public long getOriginalGroupId() {
169         return _originalGroupId;
170     }
171 
172     public long getCompanyId() {
173         return _companyId;
174     }
175 
176     public void setCompanyId(long companyId) {
177         _companyId = companyId;
178     }
179 
180     public long getUserId() {
181         return _userId;
182     }
183 
184     public void setUserId(long userId) {
185         _userId = userId;
186     }
187 
188     public String getUserUuid() throws SystemException {
189         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
190     }
191 
192     public void setUserUuid(String userUuid) {
193         _userUuid = userUuid;
194     }
195 
196     public Date getCreateDate() {
197         return _createDate;
198     }
199 
200     public void setCreateDate(Date createDate) {
201         _createDate = createDate;
202     }
203 
204     public Date getModifiedDate() {
205         return _modifiedDate;
206     }
207 
208     public void setModifiedDate(Date modifiedDate) {
209         _modifiedDate = modifiedDate;
210     }
211 
212     public long getParentFolderId() {
213         return _parentFolderId;
214     }
215 
216     public void setParentFolderId(long parentFolderId) {
217         _parentFolderId = parentFolderId;
218 
219         if (!_setOriginalParentFolderId) {
220             _setOriginalParentFolderId = true;
221 
222             _originalParentFolderId = parentFolderId;
223         }
224     }
225 
226     public long getOriginalParentFolderId() {
227         return _originalParentFolderId;
228     }
229 
230     public String getName() {
231         return GetterUtil.getString(_name);
232     }
233 
234     public void setName(String name) {
235         _name = name;
236 
237         if (_originalName == null) {
238             _originalName = name;
239         }
240     }
241 
242     public String getOriginalName() {
243         return GetterUtil.getString(_originalName);
244     }
245 
246     public String getDescription() {
247         return GetterUtil.getString(_description);
248     }
249 
250     public void setDescription(String description) {
251         _description = description;
252     }
253 
254     public IGFolder toEscapedModel() {
255         if (isEscapedModel()) {
256             return (IGFolder)this;
257         }
258         else {
259             IGFolder model = new IGFolderImpl();
260 
261             model.setNew(isNew());
262             model.setEscapedModel(true);
263 
264             model.setUuid(HtmlUtil.escape(getUuid()));
265             model.setFolderId(getFolderId());
266             model.setGroupId(getGroupId());
267             model.setCompanyId(getCompanyId());
268             model.setUserId(getUserId());
269             model.setCreateDate(getCreateDate());
270             model.setModifiedDate(getModifiedDate());
271             model.setParentFolderId(getParentFolderId());
272             model.setName(HtmlUtil.escape(getName()));
273             model.setDescription(HtmlUtil.escape(getDescription()));
274 
275             model = (IGFolder)Proxy.newProxyInstance(IGFolder.class.getClassLoader(),
276                     new Class[] { IGFolder.class },
277                     new ReadOnlyBeanHandler(model));
278 
279             return model;
280         }
281     }
282 
283     public Object clone() {
284         IGFolderImpl clone = new IGFolderImpl();
285 
286         clone.setUuid(getUuid());
287         clone.setFolderId(getFolderId());
288         clone.setGroupId(getGroupId());
289         clone.setCompanyId(getCompanyId());
290         clone.setUserId(getUserId());
291         clone.setCreateDate(getCreateDate());
292         clone.setModifiedDate(getModifiedDate());
293         clone.setParentFolderId(getParentFolderId());
294         clone.setName(getName());
295         clone.setDescription(getDescription());
296 
297         return clone;
298     }
299 
300     public int compareTo(IGFolder igFolder) {
301         int value = 0;
302 
303         if (getFolderId() < igFolder.getFolderId()) {
304             value = -1;
305         }
306         else if (getFolderId() > igFolder.getFolderId()) {
307             value = 1;
308         }
309         else {
310             value = 0;
311         }
312 
313         if (value != 0) {
314             return value;
315         }
316 
317         value = getName().toLowerCase()
318                     .compareTo(igFolder.getName().toLowerCase());
319 
320         if (value != 0) {
321             return value;
322         }
323 
324         return 0;
325     }
326 
327     public boolean equals(Object obj) {
328         if (obj == null) {
329             return false;
330         }
331 
332         IGFolder igFolder = null;
333 
334         try {
335             igFolder = (IGFolder)obj;
336         }
337         catch (ClassCastException cce) {
338             return false;
339         }
340 
341         long pk = igFolder.getPrimaryKey();
342 
343         if (getPrimaryKey() == pk) {
344             return true;
345         }
346         else {
347             return false;
348         }
349     }
350 
351     public int hashCode() {
352         return (int)getPrimaryKey();
353     }
354 
355     public String toString() {
356         StringBundler sb = new StringBundler(21);
357 
358         sb.append("{uuid=");
359         sb.append(getUuid());
360         sb.append(", folderId=");
361         sb.append(getFolderId());
362         sb.append(", groupId=");
363         sb.append(getGroupId());
364         sb.append(", companyId=");
365         sb.append(getCompanyId());
366         sb.append(", userId=");
367         sb.append(getUserId());
368         sb.append(", createDate=");
369         sb.append(getCreateDate());
370         sb.append(", modifiedDate=");
371         sb.append(getModifiedDate());
372         sb.append(", parentFolderId=");
373         sb.append(getParentFolderId());
374         sb.append(", name=");
375         sb.append(getName());
376         sb.append(", description=");
377         sb.append(getDescription());
378         sb.append("}");
379 
380         return sb.toString();
381     }
382 
383     public String toXmlString() {
384         StringBundler sb = new StringBundler(34);
385 
386         sb.append("<model><model-name>");
387         sb.append("com.liferay.portlet.imagegallery.model.IGFolder");
388         sb.append("</model-name>");
389 
390         sb.append(
391             "<column><column-name>uuid</column-name><column-value><![CDATA[");
392         sb.append(getUuid());
393         sb.append("]]></column-value></column>");
394         sb.append(
395             "<column><column-name>folderId</column-name><column-value><![CDATA[");
396         sb.append(getFolderId());
397         sb.append("]]></column-value></column>");
398         sb.append(
399             "<column><column-name>groupId</column-name><column-value><![CDATA[");
400         sb.append(getGroupId());
401         sb.append("]]></column-value></column>");
402         sb.append(
403             "<column><column-name>companyId</column-name><column-value><![CDATA[");
404         sb.append(getCompanyId());
405         sb.append("]]></column-value></column>");
406         sb.append(
407             "<column><column-name>userId</column-name><column-value><![CDATA[");
408         sb.append(getUserId());
409         sb.append("]]></column-value></column>");
410         sb.append(
411             "<column><column-name>createDate</column-name><column-value><![CDATA[");
412         sb.append(getCreateDate());
413         sb.append("]]></column-value></column>");
414         sb.append(
415             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
416         sb.append(getModifiedDate());
417         sb.append("]]></column-value></column>");
418         sb.append(
419             "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
420         sb.append(getParentFolderId());
421         sb.append("]]></column-value></column>");
422         sb.append(
423             "<column><column-name>name</column-name><column-value><![CDATA[");
424         sb.append(getName());
425         sb.append("]]></column-value></column>");
426         sb.append(
427             "<column><column-name>description</column-name><column-value><![CDATA[");
428         sb.append(getDescription());
429         sb.append("]]></column-value></column>");
430 
431         sb.append("</model>");
432 
433         return sb.toString();
434     }
435 
436     private String _uuid;
437     private String _originalUuid;
438     private long _folderId;
439     private long _groupId;
440     private long _originalGroupId;
441     private boolean _setOriginalGroupId;
442     private long _companyId;
443     private long _userId;
444     private String _userUuid;
445     private Date _createDate;
446     private Date _modifiedDate;
447     private long _parentFolderId;
448     private long _originalParentFolderId;
449     private boolean _setOriginalParentFolderId;
450     private String _name;
451     private String _originalName;
452     private String _description;
453 }