001    /**
002     * Copyright (c) 2000-2012 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.ProxyUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    import com.liferay.portal.kernel.util.StringPool;
023    import com.liferay.portal.model.CacheModel;
024    import com.liferay.portal.model.impl.BaseModelImpl;
025    import com.liferay.portal.service.ServiceContext;
026    import com.liferay.portal.util.PortalUtil;
027    
028    import com.liferay.portlet.asset.model.AssetLink;
029    import com.liferay.portlet.asset.model.AssetLinkModel;
030    import com.liferay.portlet.expando.model.ExpandoBridge;
031    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
032    
033    import java.io.Serializable;
034    
035    import java.sql.Types;
036    
037    import java.util.Date;
038    
039    /**
040     * The base model implementation for the AssetLink service. Represents a row in the "AssetLink" database table, with each column mapped to a property of this class.
041     *
042     * <p>
043     * This implementation and its corresponding interface {@link com.liferay.portlet.asset.model.AssetLinkModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AssetLinkImpl}.
044     * </p>
045     *
046     * @author Brian Wing Shun Chan
047     * @see AssetLinkImpl
048     * @see com.liferay.portlet.asset.model.AssetLink
049     * @see com.liferay.portlet.asset.model.AssetLinkModel
050     * @generated
051     */
052    public class AssetLinkModelImpl extends BaseModelImpl<AssetLink>
053            implements AssetLinkModel {
054            /*
055             * NOTE FOR DEVELOPERS:
056             *
057             * Never modify or reference this class directly. All methods that expect a asset link model instance should use the {@link com.liferay.portlet.asset.model.AssetLink} interface instead.
058             */
059            public static final String TABLE_NAME = "AssetLink";
060            public static final Object[][] TABLE_COLUMNS = {
061                            { "linkId", Types.BIGINT },
062                            { "companyId", Types.BIGINT },
063                            { "userId", Types.BIGINT },
064                            { "userName", Types.VARCHAR },
065                            { "createDate", Types.TIMESTAMP },
066                            { "entryId1", Types.BIGINT },
067                            { "entryId2", Types.BIGINT },
068                            { "type_", Types.INTEGER },
069                            { "weight", Types.INTEGER }
070                    };
071            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)";
072            public static final String TABLE_SQL_DROP = "drop table AssetLink";
073            public static final String ORDER_BY_JPQL = " ORDER BY assetLink.weight ASC";
074            public static final String ORDER_BY_SQL = " ORDER BY AssetLink.weight ASC";
075            public static final String DATA_SOURCE = "liferayDataSource";
076            public static final String SESSION_FACTORY = "liferaySessionFactory";
077            public static final String TX_MANAGER = "liferayTransactionManager";
078            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetLink"),
080                            true);
081            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082                                    "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetLink"),
083                            true);
084            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085                                    "value.object.column.bitmask.enabled.com.liferay.portlet.asset.model.AssetLink"),
086                            true);
087            public static long ENTRYID1_COLUMN_BITMASK = 1L;
088            public static long ENTRYID2_COLUMN_BITMASK = 2L;
089            public static long TYPE_COLUMN_BITMASK = 4L;
090            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
091                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetLink"));
092    
093            public AssetLinkModelImpl() {
094            }
095    
096            public long getPrimaryKey() {
097                    return _linkId;
098            }
099    
100            public void setPrimaryKey(long primaryKey) {
101                    setLinkId(primaryKey);
102            }
103    
104            public Serializable getPrimaryKeyObj() {
105                    return new Long(_linkId);
106            }
107    
108            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
109                    setPrimaryKey(((Long)primaryKeyObj).longValue());
110            }
111    
112            public Class<?> getModelClass() {
113                    return AssetLink.class;
114            }
115    
116            public String getModelClassName() {
117                    return AssetLink.class.getName();
118            }
119    
120            public long getLinkId() {
121                    return _linkId;
122            }
123    
124            public void setLinkId(long linkId) {
125                    _linkId = linkId;
126            }
127    
128            public long getCompanyId() {
129                    return _companyId;
130            }
131    
132            public void setCompanyId(long companyId) {
133                    _companyId = companyId;
134            }
135    
136            public long getUserId() {
137                    return _userId;
138            }
139    
140            public void setUserId(long userId) {
141                    _userId = userId;
142            }
143    
144            public String getUserUuid() throws SystemException {
145                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
146            }
147    
148            public void setUserUuid(String userUuid) {
149                    _userUuid = userUuid;
150            }
151    
152            public String getUserName() {
153                    if (_userName == null) {
154                            return StringPool.BLANK;
155                    }
156                    else {
157                            return _userName;
158                    }
159            }
160    
161            public void setUserName(String userName) {
162                    _userName = userName;
163            }
164    
165            public Date getCreateDate() {
166                    return _createDate;
167            }
168    
169            public void setCreateDate(Date createDate) {
170                    _createDate = createDate;
171            }
172    
173            public long getEntryId1() {
174                    return _entryId1;
175            }
176    
177            public void setEntryId1(long entryId1) {
178                    _columnBitmask |= ENTRYID1_COLUMN_BITMASK;
179    
180                    if (!_setOriginalEntryId1) {
181                            _setOriginalEntryId1 = true;
182    
183                            _originalEntryId1 = _entryId1;
184                    }
185    
186                    _entryId1 = entryId1;
187            }
188    
189            public long getOriginalEntryId1() {
190                    return _originalEntryId1;
191            }
192    
193            public long getEntryId2() {
194                    return _entryId2;
195            }
196    
197            public void setEntryId2(long entryId2) {
198                    _columnBitmask |= ENTRYID2_COLUMN_BITMASK;
199    
200                    if (!_setOriginalEntryId2) {
201                            _setOriginalEntryId2 = true;
202    
203                            _originalEntryId2 = _entryId2;
204                    }
205    
206                    _entryId2 = entryId2;
207            }
208    
209            public long getOriginalEntryId2() {
210                    return _originalEntryId2;
211            }
212    
213            public int getType() {
214                    return _type;
215            }
216    
217            public void setType(int type) {
218                    _columnBitmask |= TYPE_COLUMN_BITMASK;
219    
220                    if (!_setOriginalType) {
221                            _setOriginalType = true;
222    
223                            _originalType = _type;
224                    }
225    
226                    _type = type;
227            }
228    
229            public int getOriginalType() {
230                    return _originalType;
231            }
232    
233            public int getWeight() {
234                    return _weight;
235            }
236    
237            public void setWeight(int weight) {
238                    _columnBitmask = -1L;
239    
240                    _weight = weight;
241            }
242    
243            public long getColumnBitmask() {
244                    return _columnBitmask;
245            }
246    
247            @Override
248            public AssetLink toEscapedModel() {
249                    if (_escapedModelProxy == null) {
250                            _escapedModelProxy = (AssetLink)ProxyUtil.newProxyInstance(_classLoader,
251                                            _escapedModelProxyInterfaces,
252                                            new AutoEscapeBeanHandler(this));
253                    }
254    
255                    return _escapedModelProxy;
256            }
257    
258            @Override
259            public ExpandoBridge getExpandoBridge() {
260                    if (_expandoBridge == null) {
261                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
262                                            AssetLink.class.getName(), getPrimaryKey());
263                    }
264    
265                    return _expandoBridge;
266            }
267    
268            @Override
269            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
270                    getExpandoBridge().setAttributes(serviceContext);
271            }
272    
273            @Override
274            public Object clone() {
275                    AssetLinkImpl assetLinkImpl = new AssetLinkImpl();
276    
277                    assetLinkImpl.setLinkId(getLinkId());
278                    assetLinkImpl.setCompanyId(getCompanyId());
279                    assetLinkImpl.setUserId(getUserId());
280                    assetLinkImpl.setUserName(getUserName());
281                    assetLinkImpl.setCreateDate(getCreateDate());
282                    assetLinkImpl.setEntryId1(getEntryId1());
283                    assetLinkImpl.setEntryId2(getEntryId2());
284                    assetLinkImpl.setType(getType());
285                    assetLinkImpl.setWeight(getWeight());
286    
287                    assetLinkImpl.resetOriginalValues();
288    
289                    return assetLinkImpl;
290            }
291    
292            public int compareTo(AssetLink assetLink) {
293                    int value = 0;
294    
295                    if (getWeight() < assetLink.getWeight()) {
296                            value = -1;
297                    }
298                    else if (getWeight() > assetLink.getWeight()) {
299                            value = 1;
300                    }
301                    else {
302                            value = 0;
303                    }
304    
305                    if (value != 0) {
306                            return value;
307                    }
308    
309                    return 0;
310            }
311    
312            @Override
313            public boolean equals(Object obj) {
314                    if (obj == null) {
315                            return false;
316                    }
317    
318                    AssetLink assetLink = null;
319    
320                    try {
321                            assetLink = (AssetLink)obj;
322                    }
323                    catch (ClassCastException cce) {
324                            return false;
325                    }
326    
327                    long primaryKey = assetLink.getPrimaryKey();
328    
329                    if (getPrimaryKey() == primaryKey) {
330                            return true;
331                    }
332                    else {
333                            return false;
334                    }
335            }
336    
337            @Override
338            public int hashCode() {
339                    return (int)getPrimaryKey();
340            }
341    
342            @Override
343            public void resetOriginalValues() {
344                    AssetLinkModelImpl assetLinkModelImpl = this;
345    
346                    assetLinkModelImpl._originalEntryId1 = assetLinkModelImpl._entryId1;
347    
348                    assetLinkModelImpl._setOriginalEntryId1 = false;
349    
350                    assetLinkModelImpl._originalEntryId2 = assetLinkModelImpl._entryId2;
351    
352                    assetLinkModelImpl._setOriginalEntryId2 = false;
353    
354                    assetLinkModelImpl._originalType = assetLinkModelImpl._type;
355    
356                    assetLinkModelImpl._setOriginalType = false;
357    
358                    assetLinkModelImpl._columnBitmask = 0;
359            }
360    
361            @Override
362            public CacheModel<AssetLink> toCacheModel() {
363                    AssetLinkCacheModel assetLinkCacheModel = new AssetLinkCacheModel();
364    
365                    assetLinkCacheModel.linkId = getLinkId();
366    
367                    assetLinkCacheModel.companyId = getCompanyId();
368    
369                    assetLinkCacheModel.userId = getUserId();
370    
371                    assetLinkCacheModel.userName = getUserName();
372    
373                    String userName = assetLinkCacheModel.userName;
374    
375                    if ((userName != null) && (userName.length() == 0)) {
376                            assetLinkCacheModel.userName = null;
377                    }
378    
379                    Date createDate = getCreateDate();
380    
381                    if (createDate != null) {
382                            assetLinkCacheModel.createDate = createDate.getTime();
383                    }
384                    else {
385                            assetLinkCacheModel.createDate = Long.MIN_VALUE;
386                    }
387    
388                    assetLinkCacheModel.entryId1 = getEntryId1();
389    
390                    assetLinkCacheModel.entryId2 = getEntryId2();
391    
392                    assetLinkCacheModel.type = getType();
393    
394                    assetLinkCacheModel.weight = getWeight();
395    
396                    return assetLinkCacheModel;
397            }
398    
399            @Override
400            public String toString() {
401                    StringBundler sb = new StringBundler(19);
402    
403                    sb.append("{linkId=");
404                    sb.append(getLinkId());
405                    sb.append(", companyId=");
406                    sb.append(getCompanyId());
407                    sb.append(", userId=");
408                    sb.append(getUserId());
409                    sb.append(", userName=");
410                    sb.append(getUserName());
411                    sb.append(", createDate=");
412                    sb.append(getCreateDate());
413                    sb.append(", entryId1=");
414                    sb.append(getEntryId1());
415                    sb.append(", entryId2=");
416                    sb.append(getEntryId2());
417                    sb.append(", type=");
418                    sb.append(getType());
419                    sb.append(", weight=");
420                    sb.append(getWeight());
421                    sb.append("}");
422    
423                    return sb.toString();
424            }
425    
426            public String toXmlString() {
427                    StringBundler sb = new StringBundler(31);
428    
429                    sb.append("<model><model-name>");
430                    sb.append("com.liferay.portlet.asset.model.AssetLink");
431                    sb.append("</model-name>");
432    
433                    sb.append(
434                            "<column><column-name>linkId</column-name><column-value><![CDATA[");
435                    sb.append(getLinkId());
436                    sb.append("]]></column-value></column>");
437                    sb.append(
438                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
439                    sb.append(getCompanyId());
440                    sb.append("]]></column-value></column>");
441                    sb.append(
442                            "<column><column-name>userId</column-name><column-value><![CDATA[");
443                    sb.append(getUserId());
444                    sb.append("]]></column-value></column>");
445                    sb.append(
446                            "<column><column-name>userName</column-name><column-value><![CDATA[");
447                    sb.append(getUserName());
448                    sb.append("]]></column-value></column>");
449                    sb.append(
450                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
451                    sb.append(getCreateDate());
452                    sb.append("]]></column-value></column>");
453                    sb.append(
454                            "<column><column-name>entryId1</column-name><column-value><![CDATA[");
455                    sb.append(getEntryId1());
456                    sb.append("]]></column-value></column>");
457                    sb.append(
458                            "<column><column-name>entryId2</column-name><column-value><![CDATA[");
459                    sb.append(getEntryId2());
460                    sb.append("]]></column-value></column>");
461                    sb.append(
462                            "<column><column-name>type</column-name><column-value><![CDATA[");
463                    sb.append(getType());
464                    sb.append("]]></column-value></column>");
465                    sb.append(
466                            "<column><column-name>weight</column-name><column-value><![CDATA[");
467                    sb.append(getWeight());
468                    sb.append("]]></column-value></column>");
469    
470                    sb.append("</model>");
471    
472                    return sb.toString();
473            }
474    
475            private static ClassLoader _classLoader = AssetLink.class.getClassLoader();
476            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
477                            AssetLink.class
478                    };
479            private long _linkId;
480            private long _companyId;
481            private long _userId;
482            private String _userUuid;
483            private String _userName;
484            private Date _createDate;
485            private long _entryId1;
486            private long _originalEntryId1;
487            private boolean _setOriginalEntryId1;
488            private long _entryId2;
489            private long _originalEntryId2;
490            private boolean _setOriginalEntryId2;
491            private int _type;
492            private int _originalType;
493            private boolean _setOriginalType;
494            private int _weight;
495            private transient ExpandoBridge _expandoBridge;
496            private long _columnBitmask;
497            private AssetLink _escapedModelProxy;
498    }