001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.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.PortletItem;
023    import com.liferay.portal.model.PortletItemModel;
024    import com.liferay.portal.service.ServiceContext;
025    import com.liferay.portal.util.PortalUtil;
026    
027    import com.liferay.portlet.expando.model.ExpandoBridge;
028    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
029    
030    import java.io.Serializable;
031    
032    import java.lang.reflect.Proxy;
033    
034    import java.sql.Types;
035    
036    import java.util.Date;
037    
038    /**
039     * The base model implementation for the PortletItem service. Represents a row in the "PortletItem" database table, with each column mapped to a property of this class.
040     *
041     * <p>
042     * This implementation and its corresponding interface {@link com.liferay.portal.model.PortletItemModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PortletItemImpl}.
043     * </p>
044     *
045     * <p>
046     * Never modify or reference this class directly. All methods that expect a portlet item model instance should use the {@link com.liferay.portal.model.PortletItem} interface instead.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see PortletItemImpl
051     * @see com.liferay.portal.model.PortletItem
052     * @see com.liferay.portal.model.PortletItemModel
053     * @generated
054     */
055    public class PortletItemModelImpl extends BaseModelImpl<PortletItem>
056            implements PortletItemModel {
057            public static final String TABLE_NAME = "PortletItem";
058            public static final Object[][] TABLE_COLUMNS = {
059                            { "portletItemId", new Integer(Types.BIGINT) },
060                            { "groupId", new Integer(Types.BIGINT) },
061                            { "companyId", new Integer(Types.BIGINT) },
062                            { "userId", new Integer(Types.BIGINT) },
063                            { "userName", new Integer(Types.VARCHAR) },
064                            { "createDate", new Integer(Types.TIMESTAMP) },
065                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
066                            { "name", new Integer(Types.VARCHAR) },
067                            { "portletId", new Integer(Types.VARCHAR) },
068                            { "classNameId", new Integer(Types.BIGINT) }
069                    };
070            public static final String TABLE_SQL_CREATE = "create table PortletItem (portletItemId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,name VARCHAR(75) null,portletId VARCHAR(75) null,classNameId LONG)";
071            public static final String TABLE_SQL_DROP = "drop table PortletItem";
072            public static final String DATA_SOURCE = "liferayDataSource";
073            public static final String SESSION_FACTORY = "liferaySessionFactory";
074            public static final String TX_MANAGER = "liferayTransactionManager";
075            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.entity.cache.enabled.com.liferay.portal.model.PortletItem"),
077                            true);
078            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.finder.cache.enabled.com.liferay.portal.model.PortletItem"),
080                            true);
081            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
082                                    "lock.expiration.time.com.liferay.portal.model.PortletItem"));
083    
084            public PortletItemModelImpl() {
085            }
086    
087            public long getPrimaryKey() {
088                    return _portletItemId;
089            }
090    
091            public void setPrimaryKey(long pk) {
092                    setPortletItemId(pk);
093            }
094    
095            public Serializable getPrimaryKeyObj() {
096                    return new Long(_portletItemId);
097            }
098    
099            public long getPortletItemId() {
100                    return _portletItemId;
101            }
102    
103            public void setPortletItemId(long portletItemId) {
104                    _portletItemId = portletItemId;
105            }
106    
107            public long getGroupId() {
108                    return _groupId;
109            }
110    
111            public void setGroupId(long groupId) {
112                    _groupId = groupId;
113    
114                    if (!_setOriginalGroupId) {
115                            _setOriginalGroupId = true;
116    
117                            _originalGroupId = groupId;
118                    }
119            }
120    
121            public long getOriginalGroupId() {
122                    return _originalGroupId;
123            }
124    
125            public long getCompanyId() {
126                    return _companyId;
127            }
128    
129            public void setCompanyId(long companyId) {
130                    _companyId = companyId;
131            }
132    
133            public long getUserId() {
134                    return _userId;
135            }
136    
137            public void setUserId(long userId) {
138                    _userId = userId;
139            }
140    
141            public String getUserUuid() throws SystemException {
142                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
143            }
144    
145            public void setUserUuid(String userUuid) {
146                    _userUuid = userUuid;
147            }
148    
149            public String getUserName() {
150                    if (_userName == null) {
151                            return StringPool.BLANK;
152                    }
153                    else {
154                            return _userName;
155                    }
156            }
157    
158            public void setUserName(String userName) {
159                    _userName = userName;
160            }
161    
162            public Date getCreateDate() {
163                    return _createDate;
164            }
165    
166            public void setCreateDate(Date createDate) {
167                    _createDate = createDate;
168            }
169    
170            public Date getModifiedDate() {
171                    return _modifiedDate;
172            }
173    
174            public void setModifiedDate(Date modifiedDate) {
175                    _modifiedDate = modifiedDate;
176            }
177    
178            public String getName() {
179                    if (_name == null) {
180                            return StringPool.BLANK;
181                    }
182                    else {
183                            return _name;
184                    }
185            }
186    
187            public void setName(String name) {
188                    _name = name;
189    
190                    if (_originalName == null) {
191                            _originalName = name;
192                    }
193            }
194    
195            public String getOriginalName() {
196                    return GetterUtil.getString(_originalName);
197            }
198    
199            public String getPortletId() {
200                    if (_portletId == null) {
201                            return StringPool.BLANK;
202                    }
203                    else {
204                            return _portletId;
205                    }
206            }
207    
208            public void setPortletId(String portletId) {
209                    _portletId = portletId;
210    
211                    if (_originalPortletId == null) {
212                            _originalPortletId = portletId;
213                    }
214            }
215    
216            public String getOriginalPortletId() {
217                    return GetterUtil.getString(_originalPortletId);
218            }
219    
220            public String getClassName() {
221                    if (getClassNameId() <= 0) {
222                            return StringPool.BLANK;
223                    }
224    
225                    return PortalUtil.getClassName(getClassNameId());
226            }
227    
228            public long getClassNameId() {
229                    return _classNameId;
230            }
231    
232            public void setClassNameId(long classNameId) {
233                    _classNameId = classNameId;
234    
235                    if (!_setOriginalClassNameId) {
236                            _setOriginalClassNameId = true;
237    
238                            _originalClassNameId = classNameId;
239                    }
240            }
241    
242            public long getOriginalClassNameId() {
243                    return _originalClassNameId;
244            }
245    
246            public PortletItem toEscapedModel() {
247                    if (isEscapedModel()) {
248                            return (PortletItem)this;
249                    }
250                    else {
251                            return (PortletItem)Proxy.newProxyInstance(PortletItem.class.getClassLoader(),
252                                    new Class[] { PortletItem.class },
253                                    new AutoEscapeBeanHandler(this));
254                    }
255            }
256    
257            public ExpandoBridge getExpandoBridge() {
258                    if (_expandoBridge == null) {
259                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
260                                            PortletItem.class.getName(), getPrimaryKey());
261                    }
262    
263                    return _expandoBridge;
264            }
265    
266            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
267                    getExpandoBridge().setAttributes(serviceContext);
268            }
269    
270            public Object clone() {
271                    PortletItemImpl clone = new PortletItemImpl();
272    
273                    clone.setPortletItemId(getPortletItemId());
274                    clone.setGroupId(getGroupId());
275                    clone.setCompanyId(getCompanyId());
276                    clone.setUserId(getUserId());
277                    clone.setUserName(getUserName());
278                    clone.setCreateDate(getCreateDate());
279                    clone.setModifiedDate(getModifiedDate());
280                    clone.setName(getName());
281                    clone.setPortletId(getPortletId());
282                    clone.setClassNameId(getClassNameId());
283    
284                    return clone;
285            }
286    
287            public int compareTo(PortletItem portletItem) {
288                    long pk = portletItem.getPrimaryKey();
289    
290                    if (getPrimaryKey() < pk) {
291                            return -1;
292                    }
293                    else if (getPrimaryKey() > pk) {
294                            return 1;
295                    }
296                    else {
297                            return 0;
298                    }
299            }
300    
301            public boolean equals(Object obj) {
302                    if (obj == null) {
303                            return false;
304                    }
305    
306                    PortletItem portletItem = null;
307    
308                    try {
309                            portletItem = (PortletItem)obj;
310                    }
311                    catch (ClassCastException cce) {
312                            return false;
313                    }
314    
315                    long pk = portletItem.getPrimaryKey();
316    
317                    if (getPrimaryKey() == pk) {
318                            return true;
319                    }
320                    else {
321                            return false;
322                    }
323            }
324    
325            public int hashCode() {
326                    return (int)getPrimaryKey();
327            }
328    
329            public String toString() {
330                    StringBundler sb = new StringBundler(21);
331    
332                    sb.append("{portletItemId=");
333                    sb.append(getPortletItemId());
334                    sb.append(", groupId=");
335                    sb.append(getGroupId());
336                    sb.append(", companyId=");
337                    sb.append(getCompanyId());
338                    sb.append(", userId=");
339                    sb.append(getUserId());
340                    sb.append(", userName=");
341                    sb.append(getUserName());
342                    sb.append(", createDate=");
343                    sb.append(getCreateDate());
344                    sb.append(", modifiedDate=");
345                    sb.append(getModifiedDate());
346                    sb.append(", name=");
347                    sb.append(getName());
348                    sb.append(", portletId=");
349                    sb.append(getPortletId());
350                    sb.append(", classNameId=");
351                    sb.append(getClassNameId());
352                    sb.append("}");
353    
354                    return sb.toString();
355            }
356    
357            public String toXmlString() {
358                    StringBundler sb = new StringBundler(34);
359    
360                    sb.append("<model><model-name>");
361                    sb.append("com.liferay.portal.model.PortletItem");
362                    sb.append("</model-name>");
363    
364                    sb.append(
365                            "<column><column-name>portletItemId</column-name><column-value><![CDATA[");
366                    sb.append(getPortletItemId());
367                    sb.append("]]></column-value></column>");
368                    sb.append(
369                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
370                    sb.append(getGroupId());
371                    sb.append("]]></column-value></column>");
372                    sb.append(
373                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
374                    sb.append(getCompanyId());
375                    sb.append("]]></column-value></column>");
376                    sb.append(
377                            "<column><column-name>userId</column-name><column-value><![CDATA[");
378                    sb.append(getUserId());
379                    sb.append("]]></column-value></column>");
380                    sb.append(
381                            "<column><column-name>userName</column-name><column-value><![CDATA[");
382                    sb.append(getUserName());
383                    sb.append("]]></column-value></column>");
384                    sb.append(
385                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
386                    sb.append(getCreateDate());
387                    sb.append("]]></column-value></column>");
388                    sb.append(
389                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
390                    sb.append(getModifiedDate());
391                    sb.append("]]></column-value></column>");
392                    sb.append(
393                            "<column><column-name>name</column-name><column-value><![CDATA[");
394                    sb.append(getName());
395                    sb.append("]]></column-value></column>");
396                    sb.append(
397                            "<column><column-name>portletId</column-name><column-value><![CDATA[");
398                    sb.append(getPortletId());
399                    sb.append("]]></column-value></column>");
400                    sb.append(
401                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
402                    sb.append(getClassNameId());
403                    sb.append("]]></column-value></column>");
404    
405                    sb.append("</model>");
406    
407                    return sb.toString();
408            }
409    
410            private long _portletItemId;
411            private long _groupId;
412            private long _originalGroupId;
413            private boolean _setOriginalGroupId;
414            private long _companyId;
415            private long _userId;
416            private String _userUuid;
417            private String _userName;
418            private Date _createDate;
419            private Date _modifiedDate;
420            private String _name;
421            private String _originalName;
422            private String _portletId;
423            private String _originalPortletId;
424            private long _classNameId;
425            private long _originalClassNameId;
426            private boolean _setOriginalClassNameId;
427            private transient ExpandoBridge _expandoBridge;
428    }