1   /**
2    * Copyright (c) 2000-2009 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.portlet.imagegallery.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.impl.BaseModelImpl;
29  
30  import com.liferay.portlet.imagegallery.model.IGFolder;
31  import com.liferay.portlet.imagegallery.model.IGFolderSoap;
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="IGFolderModelImpl.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>IGFolder</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.imagegallery.model.IGFolder
59   * @see com.liferay.portlet.imagegallery.model.IGFolderModel
60   * @see com.liferay.portlet.imagegallery.model.impl.IGFolderImpl
61   *
62   */
63  public class IGFolderModelImpl extends BaseModelImpl<IGFolder> {
64      public static final String TABLE_NAME = "IGFolder";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "uuid_", new Integer(Types.VARCHAR) },
67              
68  
69              { "folderId", new Integer(Types.BIGINT) },
70              
71  
72              { "groupId", new Integer(Types.BIGINT) },
73              
74  
75              { "companyId", new Integer(Types.BIGINT) },
76              
77  
78              { "userId", new Integer(Types.BIGINT) },
79              
80  
81              { "createDate", new Integer(Types.TIMESTAMP) },
82              
83  
84              { "modifiedDate", new Integer(Types.TIMESTAMP) },
85              
86  
87              { "parentFolderId", new Integer(Types.BIGINT) },
88              
89  
90              { "name", new Integer(Types.VARCHAR) },
91              
92  
93              { "description", new Integer(Types.VARCHAR) }
94          };
95      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)";
96      public static final String TABLE_SQL_DROP = "drop table IGFolder";
97      public static final String DATA_SOURCE = "liferayDataSource";
98      public static final String SESSION_FACTORY = "liferaySessionFactory";
99      public static final String TX_MANAGER = "liferayTransactionManager";
100     public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
101                 "value.object.entity.cache.enabled.com.liferay.portlet.imagegallery.model.IGFolder"),
102             true);
103     public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
104                 "value.object.finder.cache.enabled.com.liferay.portlet.imagegallery.model.IGFolder"),
105             true);
106 
107     public static IGFolder toModel(IGFolderSoap soapModel) {
108         IGFolder model = new IGFolderImpl();
109 
110         model.setUuid(soapModel.getUuid());
111         model.setFolderId(soapModel.getFolderId());
112         model.setGroupId(soapModel.getGroupId());
113         model.setCompanyId(soapModel.getCompanyId());
114         model.setUserId(soapModel.getUserId());
115         model.setCreateDate(soapModel.getCreateDate());
116         model.setModifiedDate(soapModel.getModifiedDate());
117         model.setParentFolderId(soapModel.getParentFolderId());
118         model.setName(soapModel.getName());
119         model.setDescription(soapModel.getDescription());
120 
121         return model;
122     }
123 
124     public static List<IGFolder> toModels(IGFolderSoap[] soapModels) {
125         List<IGFolder> models = new ArrayList<IGFolder>(soapModels.length);
126 
127         for (IGFolderSoap soapModel : soapModels) {
128             models.add(toModel(soapModel));
129         }
130 
131         return models;
132     }
133 
134     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
135                 "lock.expiration.time.com.liferay.portlet.imagegallery.model.IGFolder"));
136 
137     public IGFolderModelImpl() {
138     }
139 
140     public long getPrimaryKey() {
141         return _folderId;
142     }
143 
144     public void setPrimaryKey(long pk) {
145         setFolderId(pk);
146     }
147 
148     public Serializable getPrimaryKeyObj() {
149         return new Long(_folderId);
150     }
151 
152     public String getUuid() {
153         return GetterUtil.getString(_uuid);
154     }
155 
156     public void setUuid(String uuid) {
157         _uuid = uuid;
158 
159         if (_originalUuid == null) {
160             _originalUuid = uuid;
161         }
162     }
163 
164     public String getOriginalUuid() {
165         return GetterUtil.getString(_originalUuid);
166     }
167 
168     public long getFolderId() {
169         return _folderId;
170     }
171 
172     public void setFolderId(long folderId) {
173         _folderId = folderId;
174     }
175 
176     public long getGroupId() {
177         return _groupId;
178     }
179 
180     public void setGroupId(long groupId) {
181         _groupId = groupId;
182 
183         if (!_setOriginalGroupId) {
184             _setOriginalGroupId = true;
185 
186             _originalGroupId = groupId;
187         }
188     }
189 
190     public long getOriginalGroupId() {
191         return _originalGroupId;
192     }
193 
194     public long getCompanyId() {
195         return _companyId;
196     }
197 
198     public void setCompanyId(long companyId) {
199         _companyId = companyId;
200     }
201 
202     public long getUserId() {
203         return _userId;
204     }
205 
206     public void setUserId(long userId) {
207         _userId = userId;
208     }
209 
210     public Date getCreateDate() {
211         return _createDate;
212     }
213 
214     public void setCreateDate(Date createDate) {
215         _createDate = createDate;
216     }
217 
218     public Date getModifiedDate() {
219         return _modifiedDate;
220     }
221 
222     public void setModifiedDate(Date modifiedDate) {
223         _modifiedDate = modifiedDate;
224     }
225 
226     public long getParentFolderId() {
227         return _parentFolderId;
228     }
229 
230     public void setParentFolderId(long parentFolderId) {
231         _parentFolderId = parentFolderId;
232 
233         if (!_setOriginalParentFolderId) {
234             _setOriginalParentFolderId = true;
235 
236             _originalParentFolderId = parentFolderId;
237         }
238     }
239 
240     public long getOriginalParentFolderId() {
241         return _originalParentFolderId;
242     }
243 
244     public String getName() {
245         return GetterUtil.getString(_name);
246     }
247 
248     public void setName(String name) {
249         _name = name;
250 
251         if (_originalName == null) {
252             _originalName = name;
253         }
254     }
255 
256     public String getOriginalName() {
257         return GetterUtil.getString(_originalName);
258     }
259 
260     public String getDescription() {
261         return GetterUtil.getString(_description);
262     }
263 
264     public void setDescription(String description) {
265         _description = description;
266     }
267 
268     public IGFolder toEscapedModel() {
269         if (isEscapedModel()) {
270             return (IGFolder)this;
271         }
272         else {
273             IGFolder model = new IGFolderImpl();
274 
275             model.setNew(isNew());
276             model.setEscapedModel(true);
277 
278             model.setUuid(HtmlUtil.escape(getUuid()));
279             model.setFolderId(getFolderId());
280             model.setGroupId(getGroupId());
281             model.setCompanyId(getCompanyId());
282             model.setUserId(getUserId());
283             model.setCreateDate(getCreateDate());
284             model.setModifiedDate(getModifiedDate());
285             model.setParentFolderId(getParentFolderId());
286             model.setName(HtmlUtil.escape(getName()));
287             model.setDescription(HtmlUtil.escape(getDescription()));
288 
289             model = (IGFolder)Proxy.newProxyInstance(IGFolder.class.getClassLoader(),
290                     new Class[] { IGFolder.class },
291                     new ReadOnlyBeanHandler(model));
292 
293             return model;
294         }
295     }
296 
297     public Object clone() {
298         IGFolderImpl clone = new IGFolderImpl();
299 
300         clone.setUuid(getUuid());
301         clone.setFolderId(getFolderId());
302         clone.setGroupId(getGroupId());
303         clone.setCompanyId(getCompanyId());
304         clone.setUserId(getUserId());
305         clone.setCreateDate(getCreateDate());
306         clone.setModifiedDate(getModifiedDate());
307         clone.setParentFolderId(getParentFolderId());
308         clone.setName(getName());
309         clone.setDescription(getDescription());
310 
311         return clone;
312     }
313 
314     public int compareTo(IGFolder igFolder) {
315         int value = 0;
316 
317         if (getFolderId() < igFolder.getFolderId()) {
318             value = -1;
319         }
320         else if (getFolderId() > igFolder.getFolderId()) {
321             value = 1;
322         }
323         else {
324             value = 0;
325         }
326 
327         if (value != 0) {
328             return value;
329         }
330 
331         value = getName().toLowerCase()
332                     .compareTo(igFolder.getName().toLowerCase());
333 
334         if (value != 0) {
335             return value;
336         }
337 
338         return 0;
339     }
340 
341     public boolean equals(Object obj) {
342         if (obj == null) {
343             return false;
344         }
345 
346         IGFolder igFolder = null;
347 
348         try {
349             igFolder = (IGFolder)obj;
350         }
351         catch (ClassCastException cce) {
352             return false;
353         }
354 
355         long pk = igFolder.getPrimaryKey();
356 
357         if (getPrimaryKey() == pk) {
358             return true;
359         }
360         else {
361             return false;
362         }
363     }
364 
365     public int hashCode() {
366         return (int)getPrimaryKey();
367     }
368 
369     public String toString() {
370         StringBuilder sb = new StringBuilder();
371 
372         sb.append("{uuid=");
373         sb.append(getUuid());
374         sb.append(", folderId=");
375         sb.append(getFolderId());
376         sb.append(", groupId=");
377         sb.append(getGroupId());
378         sb.append(", companyId=");
379         sb.append(getCompanyId());
380         sb.append(", userId=");
381         sb.append(getUserId());
382         sb.append(", createDate=");
383         sb.append(getCreateDate());
384         sb.append(", modifiedDate=");
385         sb.append(getModifiedDate());
386         sb.append(", parentFolderId=");
387         sb.append(getParentFolderId());
388         sb.append(", name=");
389         sb.append(getName());
390         sb.append(", description=");
391         sb.append(getDescription());
392         sb.append("}");
393 
394         return sb.toString();
395     }
396 
397     public String toXmlString() {
398         StringBuilder sb = new StringBuilder();
399 
400         sb.append("<model><model-name>");
401         sb.append("com.liferay.portlet.imagegallery.model.IGFolder");
402         sb.append("</model-name>");
403 
404         sb.append(
405             "<column><column-name>uuid</column-name><column-value><![CDATA[");
406         sb.append(getUuid());
407         sb.append("]]></column-value></column>");
408         sb.append(
409             "<column><column-name>folderId</column-name><column-value><![CDATA[");
410         sb.append(getFolderId());
411         sb.append("]]></column-value></column>");
412         sb.append(
413             "<column><column-name>groupId</column-name><column-value><![CDATA[");
414         sb.append(getGroupId());
415         sb.append("]]></column-value></column>");
416         sb.append(
417             "<column><column-name>companyId</column-name><column-value><![CDATA[");
418         sb.append(getCompanyId());
419         sb.append("]]></column-value></column>");
420         sb.append(
421             "<column><column-name>userId</column-name><column-value><![CDATA[");
422         sb.append(getUserId());
423         sb.append("]]></column-value></column>");
424         sb.append(
425             "<column><column-name>createDate</column-name><column-value><![CDATA[");
426         sb.append(getCreateDate());
427         sb.append("]]></column-value></column>");
428         sb.append(
429             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
430         sb.append(getModifiedDate());
431         sb.append("]]></column-value></column>");
432         sb.append(
433             "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
434         sb.append(getParentFolderId());
435         sb.append("]]></column-value></column>");
436         sb.append(
437             "<column><column-name>name</column-name><column-value><![CDATA[");
438         sb.append(getName());
439         sb.append("]]></column-value></column>");
440         sb.append(
441             "<column><column-name>description</column-name><column-value><![CDATA[");
442         sb.append(getDescription());
443         sb.append("]]></column-value></column>");
444 
445         sb.append("</model>");
446 
447         return sb.toString();
448     }
449 
450     private String _uuid;
451     private String _originalUuid;
452     private long _folderId;
453     private long _groupId;
454     private long _originalGroupId;
455     private boolean _setOriginalGroupId;
456     private long _companyId;
457     private long _userId;
458     private Date _createDate;
459     private Date _modifiedDate;
460     private long _parentFolderId;
461     private long _originalParentFolderId;
462     private boolean _setOriginalParentFolderId;
463     private String _name;
464     private String _originalName;
465     private String _description;
466 }