001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.bookmarks.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.util.PortalUtil;
025    
026    import com.liferay.portlet.bookmarks.model.BookmarksFolder;
027    import com.liferay.portlet.bookmarks.model.BookmarksFolderModel;
028    import com.liferay.portlet.bookmarks.model.BookmarksFolderSoap;
029    import com.liferay.portlet.expando.model.ExpandoBridge;
030    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * The base model implementation for the BookmarksFolder service. Represents a row in the "BookmarksFolder" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link com.liferay.portlet.bookmarks.model.BookmarksFolderModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link BookmarksFolderImpl}.
047     * </p>
048     *
049     * <p>
050     * Never modify or reference this class directly. All methods that expect a bookmarks folder model instance should use the {@link com.liferay.portlet.bookmarks.model.BookmarksFolder} interface instead.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see BookmarksFolderImpl
055     * @see com.liferay.portlet.bookmarks.model.BookmarksFolder
056     * @see com.liferay.portlet.bookmarks.model.BookmarksFolderModel
057     * @generated
058     */
059    public class BookmarksFolderModelImpl extends BaseModelImpl<BookmarksFolder>
060            implements BookmarksFolderModel {
061            public static final String TABLE_NAME = "BookmarksFolder";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "uuid_", new Integer(Types.VARCHAR) },
064                            { "folderId", new Integer(Types.BIGINT) },
065                            { "groupId", new Integer(Types.BIGINT) },
066                            { "companyId", new Integer(Types.BIGINT) },
067                            { "userId", new Integer(Types.BIGINT) },
068                            { "createDate", new Integer(Types.TIMESTAMP) },
069                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
070                            { "parentFolderId", new Integer(Types.BIGINT) },
071                            { "name", new Integer(Types.VARCHAR) },
072                            { "description", new Integer(Types.VARCHAR) }
073                    };
074            public static final String TABLE_SQL_CREATE = "create table BookmarksFolder (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)";
075            public static final String TABLE_SQL_DROP = "drop table BookmarksFolder";
076            public static final String ORDER_BY_JPQL = " ORDER BY bookmarksFolder.parentFolderId ASC, bookmarksFolder.name ASC";
077            public static final String ORDER_BY_SQL = " ORDER BY BookmarksFolder.parentFolderId ASC, BookmarksFolder.name ASC";
078            public static final String DATA_SOURCE = "liferayDataSource";
079            public static final String SESSION_FACTORY = "liferaySessionFactory";
080            public static final String TX_MANAGER = "liferayTransactionManager";
081            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082                                    "value.object.entity.cache.enabled.com.liferay.portlet.bookmarks.model.BookmarksFolder"),
083                            true);
084            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085                                    "value.object.finder.cache.enabled.com.liferay.portlet.bookmarks.model.BookmarksFolder"),
086                            true);
087    
088            /**
089             * Converts the soap model instance into a normal model instance.
090             *
091             * @param soapModel the soap model instance to convert
092             * @return the normal model instance
093             */
094            public static BookmarksFolder toModel(BookmarksFolderSoap soapModel) {
095                    BookmarksFolder model = new BookmarksFolderImpl();
096    
097                    model.setUuid(soapModel.getUuid());
098                    model.setFolderId(soapModel.getFolderId());
099                    model.setGroupId(soapModel.getGroupId());
100                    model.setCompanyId(soapModel.getCompanyId());
101                    model.setUserId(soapModel.getUserId());
102                    model.setCreateDate(soapModel.getCreateDate());
103                    model.setModifiedDate(soapModel.getModifiedDate());
104                    model.setParentFolderId(soapModel.getParentFolderId());
105                    model.setName(soapModel.getName());
106                    model.setDescription(soapModel.getDescription());
107    
108                    return model;
109            }
110    
111            /**
112             * Converts the soap model instances into normal model instances.
113             *
114             * @param soapModels the soap model instances to convert
115             * @return the normal model instances
116             */
117            public static List<BookmarksFolder> toModels(
118                    BookmarksFolderSoap[] soapModels) {
119                    List<BookmarksFolder> models = new ArrayList<BookmarksFolder>(soapModels.length);
120    
121                    for (BookmarksFolderSoap soapModel : soapModels) {
122                            models.add(toModel(soapModel));
123                    }
124    
125                    return models;
126            }
127    
128            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
129                                    "lock.expiration.time.com.liferay.portlet.bookmarks.model.BookmarksFolder"));
130    
131            public BookmarksFolderModelImpl() {
132            }
133    
134            public long getPrimaryKey() {
135                    return _folderId;
136            }
137    
138            public void setPrimaryKey(long pk) {
139                    setFolderId(pk);
140            }
141    
142            public Serializable getPrimaryKeyObj() {
143                    return new Long(_folderId);
144            }
145    
146            public String getUuid() {
147                    if (_uuid == null) {
148                            return StringPool.BLANK;
149                    }
150                    else {
151                            return _uuid;
152                    }
153            }
154    
155            public void setUuid(String uuid) {
156                    _uuid = uuid;
157    
158                    if (_originalUuid == null) {
159                            _originalUuid = uuid;
160                    }
161            }
162    
163            public String getOriginalUuid() {
164                    return GetterUtil.getString(_originalUuid);
165            }
166    
167            public long getFolderId() {
168                    return _folderId;
169            }
170    
171            public void setFolderId(long folderId) {
172                    _folderId = folderId;
173            }
174    
175            public long getGroupId() {
176                    return _groupId;
177            }
178    
179            public void setGroupId(long groupId) {
180                    _groupId = groupId;
181    
182                    if (!_setOriginalGroupId) {
183                            _setOriginalGroupId = true;
184    
185                            _originalGroupId = groupId;
186                    }
187            }
188    
189            public long getOriginalGroupId() {
190                    return _originalGroupId;
191            }
192    
193            public long getCompanyId() {
194                    return _companyId;
195            }
196    
197            public void setCompanyId(long companyId) {
198                    _companyId = companyId;
199            }
200    
201            public long getUserId() {
202                    return _userId;
203            }
204    
205            public void setUserId(long userId) {
206                    _userId = userId;
207            }
208    
209            public String getUserUuid() throws SystemException {
210                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
211            }
212    
213            public void setUserUuid(String userUuid) {
214                    _userUuid = userUuid;
215            }
216    
217            public Date getCreateDate() {
218                    return _createDate;
219            }
220    
221            public void setCreateDate(Date createDate) {
222                    _createDate = createDate;
223            }
224    
225            public Date getModifiedDate() {
226                    return _modifiedDate;
227            }
228    
229            public void setModifiedDate(Date modifiedDate) {
230                    _modifiedDate = modifiedDate;
231            }
232    
233            public long getParentFolderId() {
234                    return _parentFolderId;
235            }
236    
237            public void setParentFolderId(long parentFolderId) {
238                    _parentFolderId = parentFolderId;
239            }
240    
241            public String getName() {
242                    if (_name == null) {
243                            return StringPool.BLANK;
244                    }
245                    else {
246                            return _name;
247                    }
248            }
249    
250            public void setName(String name) {
251                    _name = name;
252            }
253    
254            public String getDescription() {
255                    if (_description == null) {
256                            return StringPool.BLANK;
257                    }
258                    else {
259                            return _description;
260                    }
261            }
262    
263            public void setDescription(String description) {
264                    _description = description;
265            }
266    
267            public BookmarksFolder toEscapedModel() {
268                    if (isEscapedModel()) {
269                            return (BookmarksFolder)this;
270                    }
271                    else {
272                            return (BookmarksFolder)Proxy.newProxyInstance(BookmarksFolder.class.getClassLoader(),
273                                    new Class[] { BookmarksFolder.class },
274                                    new AutoEscapeBeanHandler(this));
275                    }
276            }
277    
278            public ExpandoBridge getExpandoBridge() {
279                    if (_expandoBridge == null) {
280                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
281                                            BookmarksFolder.class.getName(), getPrimaryKey());
282                    }
283    
284                    return _expandoBridge;
285            }
286    
287            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
288                    getExpandoBridge().setAttributes(serviceContext);
289            }
290    
291            public Object clone() {
292                    BookmarksFolderImpl clone = new BookmarksFolderImpl();
293    
294                    clone.setUuid(getUuid());
295                    clone.setFolderId(getFolderId());
296                    clone.setGroupId(getGroupId());
297                    clone.setCompanyId(getCompanyId());
298                    clone.setUserId(getUserId());
299                    clone.setCreateDate(getCreateDate());
300                    clone.setModifiedDate(getModifiedDate());
301                    clone.setParentFolderId(getParentFolderId());
302                    clone.setName(getName());
303                    clone.setDescription(getDescription());
304    
305                    return clone;
306            }
307    
308            public int compareTo(BookmarksFolder bookmarksFolder) {
309                    int value = 0;
310    
311                    if (getParentFolderId() < bookmarksFolder.getParentFolderId()) {
312                            value = -1;
313                    }
314                    else if (getParentFolderId() > bookmarksFolder.getParentFolderId()) {
315                            value = 1;
316                    }
317                    else {
318                            value = 0;
319                    }
320    
321                    if (value != 0) {
322                            return value;
323                    }
324    
325                    value = getName().toLowerCase()
326                                            .compareTo(bookmarksFolder.getName().toLowerCase());
327    
328                    if (value != 0) {
329                            return value;
330                    }
331    
332                    return 0;
333            }
334    
335            public boolean equals(Object obj) {
336                    if (obj == null) {
337                            return false;
338                    }
339    
340                    BookmarksFolder bookmarksFolder = null;
341    
342                    try {
343                            bookmarksFolder = (BookmarksFolder)obj;
344                    }
345                    catch (ClassCastException cce) {
346                            return false;
347                    }
348    
349                    long pk = bookmarksFolder.getPrimaryKey();
350    
351                    if (getPrimaryKey() == pk) {
352                            return true;
353                    }
354                    else {
355                            return false;
356                    }
357            }
358    
359            public int hashCode() {
360                    return (int)getPrimaryKey();
361            }
362    
363            public String toString() {
364                    StringBundler sb = new StringBundler(21);
365    
366                    sb.append("{uuid=");
367                    sb.append(getUuid());
368                    sb.append(", folderId=");
369                    sb.append(getFolderId());
370                    sb.append(", groupId=");
371                    sb.append(getGroupId());
372                    sb.append(", companyId=");
373                    sb.append(getCompanyId());
374                    sb.append(", userId=");
375                    sb.append(getUserId());
376                    sb.append(", createDate=");
377                    sb.append(getCreateDate());
378                    sb.append(", modifiedDate=");
379                    sb.append(getModifiedDate());
380                    sb.append(", parentFolderId=");
381                    sb.append(getParentFolderId());
382                    sb.append(", name=");
383                    sb.append(getName());
384                    sb.append(", description=");
385                    sb.append(getDescription());
386                    sb.append("}");
387    
388                    return sb.toString();
389            }
390    
391            public String toXmlString() {
392                    StringBundler sb = new StringBundler(34);
393    
394                    sb.append("<model><model-name>");
395                    sb.append("com.liferay.portlet.bookmarks.model.BookmarksFolder");
396                    sb.append("</model-name>");
397    
398                    sb.append(
399                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
400                    sb.append(getUuid());
401                    sb.append("]]></column-value></column>");
402                    sb.append(
403                            "<column><column-name>folderId</column-name><column-value><![CDATA[");
404                    sb.append(getFolderId());
405                    sb.append("]]></column-value></column>");
406                    sb.append(
407                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
408                    sb.append(getGroupId());
409                    sb.append("]]></column-value></column>");
410                    sb.append(
411                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
412                    sb.append(getCompanyId());
413                    sb.append("]]></column-value></column>");
414                    sb.append(
415                            "<column><column-name>userId</column-name><column-value><![CDATA[");
416                    sb.append(getUserId());
417                    sb.append("]]></column-value></column>");
418                    sb.append(
419                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
420                    sb.append(getCreateDate());
421                    sb.append("]]></column-value></column>");
422                    sb.append(
423                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
424                    sb.append(getModifiedDate());
425                    sb.append("]]></column-value></column>");
426                    sb.append(
427                            "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
428                    sb.append(getParentFolderId());
429                    sb.append("]]></column-value></column>");
430                    sb.append(
431                            "<column><column-name>name</column-name><column-value><![CDATA[");
432                    sb.append(getName());
433                    sb.append("]]></column-value></column>");
434                    sb.append(
435                            "<column><column-name>description</column-name><column-value><![CDATA[");
436                    sb.append(getDescription());
437                    sb.append("]]></column-value></column>");
438    
439                    sb.append("</model>");
440    
441                    return sb.toString();
442            }
443    
444            private String _uuid;
445            private String _originalUuid;
446            private long _folderId;
447            private long _groupId;
448            private long _originalGroupId;
449            private boolean _setOriginalGroupId;
450            private long _companyId;
451            private long _userId;
452            private String _userUuid;
453            private Date _createDate;
454            private Date _modifiedDate;
455            private long _parentFolderId;
456            private String _name;
457            private String _description;
458            private transient ExpandoBridge _expandoBridge;
459    }