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