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