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.asset.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.asset.model.AssetLink;
027    import com.liferay.portlet.asset.model.AssetLinkModel;
028    import com.liferay.portlet.expando.model.ExpandoBridge;
029    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
030    
031    import java.io.Serializable;
032    
033    import java.lang.reflect.Proxy;
034    
035    import java.sql.Types;
036    
037    import java.util.Date;
038    
039    /**
040     * <p>
041     * This interface is a model that represents the AssetLink table in the
042     * database.
043     * </p>
044     *
045     * @author    Brian Wing Shun Chan
046     * @see       AssetLinkImpl
047     * @see       com.liferay.portlet.asset.model.AssetLink
048     * @see       com.liferay.portlet.asset.model.AssetLinkModel
049     * @generated
050     */
051    public class AssetLinkModelImpl extends BaseModelImpl<AssetLink>
052            implements AssetLinkModel {
053            public static final String TABLE_NAME = "AssetLink";
054            public static final Object[][] TABLE_COLUMNS = {
055                            { "linkId", new Integer(Types.BIGINT) },
056                            { "companyId", new Integer(Types.BIGINT) },
057                            { "userId", new Integer(Types.BIGINT) },
058                            { "userName", new Integer(Types.VARCHAR) },
059                            { "createDate", new Integer(Types.TIMESTAMP) },
060                            { "entryId1", new Integer(Types.BIGINT) },
061                            { "entryId2", new Integer(Types.BIGINT) },
062                            { "type_", new Integer(Types.INTEGER) },
063                            { "weight", new Integer(Types.INTEGER) }
064                    };
065            public static final String TABLE_SQL_CREATE = "create table AssetLink (linkId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,entryId1 LONG,entryId2 LONG,type_ INTEGER,weight INTEGER)";
066            public static final String TABLE_SQL_DROP = "drop table AssetLink";
067            public static final String ORDER_BY_JPQL = " ORDER BY assetLink.weight ASC";
068            public static final String ORDER_BY_SQL = " ORDER BY AssetLink.weight ASC";
069            public static final String DATA_SOURCE = "liferayDataSource";
070            public static final String SESSION_FACTORY = "liferaySessionFactory";
071            public static final String TX_MANAGER = "liferayTransactionManager";
072            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073                                    "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetLink"),
074                            true);
075            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetLink"),
077                            true);
078            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
079                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetLink"));
080    
081            public AssetLinkModelImpl() {
082            }
083    
084            public long getPrimaryKey() {
085                    return _linkId;
086            }
087    
088            public void setPrimaryKey(long pk) {
089                    setLinkId(pk);
090            }
091    
092            public Serializable getPrimaryKeyObj() {
093                    return new Long(_linkId);
094            }
095    
096            public long getLinkId() {
097                    return _linkId;
098            }
099    
100            public void setLinkId(long linkId) {
101                    _linkId = linkId;
102            }
103    
104            public long getCompanyId() {
105                    return _companyId;
106            }
107    
108            public void setCompanyId(long companyId) {
109                    _companyId = companyId;
110            }
111    
112            public long getUserId() {
113                    return _userId;
114            }
115    
116            public void setUserId(long userId) {
117                    _userId = userId;
118            }
119    
120            public String getUserUuid() throws SystemException {
121                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
122            }
123    
124            public void setUserUuid(String userUuid) {
125                    _userUuid = userUuid;
126            }
127    
128            public String getUserName() {
129                    if (_userName == null) {
130                            return StringPool.BLANK;
131                    }
132                    else {
133                            return _userName;
134                    }
135            }
136    
137            public void setUserName(String userName) {
138                    _userName = userName;
139            }
140    
141            public Date getCreateDate() {
142                    return _createDate;
143            }
144    
145            public void setCreateDate(Date createDate) {
146                    _createDate = createDate;
147            }
148    
149            public long getEntryId1() {
150                    return _entryId1;
151            }
152    
153            public void setEntryId1(long entryId1) {
154                    _entryId1 = entryId1;
155            }
156    
157            public long getEntryId2() {
158                    return _entryId2;
159            }
160    
161            public void setEntryId2(long entryId2) {
162                    _entryId2 = entryId2;
163            }
164    
165            public int getType() {
166                    return _type;
167            }
168    
169            public void setType(int type) {
170                    _type = type;
171            }
172    
173            public int getWeight() {
174                    return _weight;
175            }
176    
177            public void setWeight(int weight) {
178                    _weight = weight;
179            }
180    
181            public AssetLink toEscapedModel() {
182                    if (isEscapedModel()) {
183                            return (AssetLink)this;
184                    }
185                    else {
186                            return (AssetLink)Proxy.newProxyInstance(AssetLink.class.getClassLoader(),
187                                    new Class[] { AssetLink.class }, new AutoEscapeBeanHandler(this));
188                    }
189            }
190    
191            public ExpandoBridge getExpandoBridge() {
192                    if (_expandoBridge == null) {
193                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
194                                            AssetLink.class.getName(), getPrimaryKey());
195                    }
196    
197                    return _expandoBridge;
198            }
199    
200            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
201                    getExpandoBridge().setAttributes(serviceContext);
202            }
203    
204            public Object clone() {
205                    AssetLinkImpl clone = new AssetLinkImpl();
206    
207                    clone.setLinkId(getLinkId());
208                    clone.setCompanyId(getCompanyId());
209                    clone.setUserId(getUserId());
210                    clone.setUserName(getUserName());
211                    clone.setCreateDate(getCreateDate());
212                    clone.setEntryId1(getEntryId1());
213                    clone.setEntryId2(getEntryId2());
214                    clone.setType(getType());
215                    clone.setWeight(getWeight());
216    
217                    return clone;
218            }
219    
220            public int compareTo(AssetLink assetLink) {
221                    int value = 0;
222    
223                    if (getWeight() < assetLink.getWeight()) {
224                            value = -1;
225                    }
226                    else if (getWeight() > assetLink.getWeight()) {
227                            value = 1;
228                    }
229                    else {
230                            value = 0;
231                    }
232    
233                    if (value != 0) {
234                            return value;
235                    }
236    
237                    return 0;
238            }
239    
240            public boolean equals(Object obj) {
241                    if (obj == null) {
242                            return false;
243                    }
244    
245                    AssetLink assetLink = null;
246    
247                    try {
248                            assetLink = (AssetLink)obj;
249                    }
250                    catch (ClassCastException cce) {
251                            return false;
252                    }
253    
254                    long pk = assetLink.getPrimaryKey();
255    
256                    if (getPrimaryKey() == pk) {
257                            return true;
258                    }
259                    else {
260                            return false;
261                    }
262            }
263    
264            public int hashCode() {
265                    return (int)getPrimaryKey();
266            }
267    
268            public String toString() {
269                    StringBundler sb = new StringBundler(19);
270    
271                    sb.append("{linkId=");
272                    sb.append(getLinkId());
273                    sb.append(", companyId=");
274                    sb.append(getCompanyId());
275                    sb.append(", userId=");
276                    sb.append(getUserId());
277                    sb.append(", userName=");
278                    sb.append(getUserName());
279                    sb.append(", createDate=");
280                    sb.append(getCreateDate());
281                    sb.append(", entryId1=");
282                    sb.append(getEntryId1());
283                    sb.append(", entryId2=");
284                    sb.append(getEntryId2());
285                    sb.append(", type=");
286                    sb.append(getType());
287                    sb.append(", weight=");
288                    sb.append(getWeight());
289                    sb.append("}");
290    
291                    return sb.toString();
292            }
293    
294            public String toXmlString() {
295                    StringBundler sb = new StringBundler(31);
296    
297                    sb.append("<model><model-name>");
298                    sb.append("com.liferay.portlet.asset.model.AssetLink");
299                    sb.append("</model-name>");
300    
301                    sb.append(
302                            "<column><column-name>linkId</column-name><column-value><![CDATA[");
303                    sb.append(getLinkId());
304                    sb.append("]]></column-value></column>");
305                    sb.append(
306                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
307                    sb.append(getCompanyId());
308                    sb.append("]]></column-value></column>");
309                    sb.append(
310                            "<column><column-name>userId</column-name><column-value><![CDATA[");
311                    sb.append(getUserId());
312                    sb.append("]]></column-value></column>");
313                    sb.append(
314                            "<column><column-name>userName</column-name><column-value><![CDATA[");
315                    sb.append(getUserName());
316                    sb.append("]]></column-value></column>");
317                    sb.append(
318                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
319                    sb.append(getCreateDate());
320                    sb.append("]]></column-value></column>");
321                    sb.append(
322                            "<column><column-name>entryId1</column-name><column-value><![CDATA[");
323                    sb.append(getEntryId1());
324                    sb.append("]]></column-value></column>");
325                    sb.append(
326                            "<column><column-name>entryId2</column-name><column-value><![CDATA[");
327                    sb.append(getEntryId2());
328                    sb.append("]]></column-value></column>");
329                    sb.append(
330                            "<column><column-name>type</column-name><column-value><![CDATA[");
331                    sb.append(getType());
332                    sb.append("]]></column-value></column>");
333                    sb.append(
334                            "<column><column-name>weight</column-name><column-value><![CDATA[");
335                    sb.append(getWeight());
336                    sb.append("]]></column-value></column>");
337    
338                    sb.append("</model>");
339    
340                    return sb.toString();
341            }
342    
343            private long _linkId;
344            private long _companyId;
345            private long _userId;
346            private String _userUuid;
347            private String _userName;
348            private Date _createDate;
349            private long _entryId1;
350            private long _entryId2;
351            private int _type;
352            private int _weight;
353            private transient ExpandoBridge _expandoBridge;
354    }