001    /**
002     * Copyright (c) 2000-2011 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.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                    _weight = weight;
239            }
240    
241            public long getColumnBitmask() {
242                    return _columnBitmask;
243            }
244    
245            @Override
246            public AssetLink toEscapedModel() {
247                    if (_escapedModelProxy == null) {
248                            _escapedModelProxy = (AssetLink)ProxyUtil.newProxyInstance(_classLoader,
249                                            _escapedModelProxyInterfaces,
250                                            new AutoEscapeBeanHandler(this));
251                    }
252    
253                    return _escapedModelProxy;
254            }
255    
256            @Override
257            public ExpandoBridge getExpandoBridge() {
258                    if (_expandoBridge == null) {
259                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
260                                            AssetLink.class.getName(), getPrimaryKey());
261                    }
262    
263                    return _expandoBridge;
264            }
265    
266            @Override
267            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
268                    getExpandoBridge().setAttributes(serviceContext);
269            }
270    
271            @Override
272            public Object clone() {
273                    AssetLinkImpl assetLinkImpl = new AssetLinkImpl();
274    
275                    assetLinkImpl.setLinkId(getLinkId());
276                    assetLinkImpl.setCompanyId(getCompanyId());
277                    assetLinkImpl.setUserId(getUserId());
278                    assetLinkImpl.setUserName(getUserName());
279                    assetLinkImpl.setCreateDate(getCreateDate());
280                    assetLinkImpl.setEntryId1(getEntryId1());
281                    assetLinkImpl.setEntryId2(getEntryId2());
282                    assetLinkImpl.setType(getType());
283                    assetLinkImpl.setWeight(getWeight());
284    
285                    assetLinkImpl.resetOriginalValues();
286    
287                    return assetLinkImpl;
288            }
289    
290            public int compareTo(AssetLink assetLink) {
291                    int value = 0;
292    
293                    if (getWeight() < assetLink.getWeight()) {
294                            value = -1;
295                    }
296                    else if (getWeight() > assetLink.getWeight()) {
297                            value = 1;
298                    }
299                    else {
300                            value = 0;
301                    }
302    
303                    if (value != 0) {
304                            return value;
305                    }
306    
307                    return 0;
308            }
309    
310            @Override
311            public boolean equals(Object obj) {
312                    if (obj == null) {
313                            return false;
314                    }
315    
316                    AssetLink assetLink = null;
317    
318                    try {
319                            assetLink = (AssetLink)obj;
320                    }
321                    catch (ClassCastException cce) {
322                            return false;
323                    }
324    
325                    long primaryKey = assetLink.getPrimaryKey();
326    
327                    if (getPrimaryKey() == primaryKey) {
328                            return true;
329                    }
330                    else {
331                            return false;
332                    }
333            }
334    
335            @Override
336            public int hashCode() {
337                    return (int)getPrimaryKey();
338            }
339    
340            @Override
341            public void resetOriginalValues() {
342                    AssetLinkModelImpl assetLinkModelImpl = this;
343    
344                    assetLinkModelImpl._originalEntryId1 = assetLinkModelImpl._entryId1;
345    
346                    assetLinkModelImpl._setOriginalEntryId1 = false;
347    
348                    assetLinkModelImpl._originalEntryId2 = assetLinkModelImpl._entryId2;
349    
350                    assetLinkModelImpl._setOriginalEntryId2 = false;
351    
352                    assetLinkModelImpl._originalType = assetLinkModelImpl._type;
353    
354                    assetLinkModelImpl._setOriginalType = false;
355    
356                    assetLinkModelImpl._columnBitmask = 0;
357            }
358    
359            @Override
360            public CacheModel<AssetLink> toCacheModel() {
361                    AssetLinkCacheModel assetLinkCacheModel = new AssetLinkCacheModel();
362    
363                    assetLinkCacheModel.linkId = getLinkId();
364    
365                    assetLinkCacheModel.companyId = getCompanyId();
366    
367                    assetLinkCacheModel.userId = getUserId();
368    
369                    assetLinkCacheModel.userName = getUserName();
370    
371                    String userName = assetLinkCacheModel.userName;
372    
373                    if ((userName != null) && (userName.length() == 0)) {
374                            assetLinkCacheModel.userName = null;
375                    }
376    
377                    Date createDate = getCreateDate();
378    
379                    if (createDate != null) {
380                            assetLinkCacheModel.createDate = createDate.getTime();
381                    }
382                    else {
383                            assetLinkCacheModel.createDate = Long.MIN_VALUE;
384                    }
385    
386                    assetLinkCacheModel.entryId1 = getEntryId1();
387    
388                    assetLinkCacheModel.entryId2 = getEntryId2();
389    
390                    assetLinkCacheModel.type = getType();
391    
392                    assetLinkCacheModel.weight = getWeight();
393    
394                    return assetLinkCacheModel;
395            }
396    
397            @Override
398            public String toString() {
399                    StringBundler sb = new StringBundler(19);
400    
401                    sb.append("{linkId=");
402                    sb.append(getLinkId());
403                    sb.append(", companyId=");
404                    sb.append(getCompanyId());
405                    sb.append(", userId=");
406                    sb.append(getUserId());
407                    sb.append(", userName=");
408                    sb.append(getUserName());
409                    sb.append(", createDate=");
410                    sb.append(getCreateDate());
411                    sb.append(", entryId1=");
412                    sb.append(getEntryId1());
413                    sb.append(", entryId2=");
414                    sb.append(getEntryId2());
415                    sb.append(", type=");
416                    sb.append(getType());
417                    sb.append(", weight=");
418                    sb.append(getWeight());
419                    sb.append("}");
420    
421                    return sb.toString();
422            }
423    
424            public String toXmlString() {
425                    StringBundler sb = new StringBundler(31);
426    
427                    sb.append("<model><model-name>");
428                    sb.append("com.liferay.portlet.asset.model.AssetLink");
429                    sb.append("</model-name>");
430    
431                    sb.append(
432                            "<column><column-name>linkId</column-name><column-value><![CDATA[");
433                    sb.append(getLinkId());
434                    sb.append("]]></column-value></column>");
435                    sb.append(
436                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
437                    sb.append(getCompanyId());
438                    sb.append("]]></column-value></column>");
439                    sb.append(
440                            "<column><column-name>userId</column-name><column-value><![CDATA[");
441                    sb.append(getUserId());
442                    sb.append("]]></column-value></column>");
443                    sb.append(
444                            "<column><column-name>userName</column-name><column-value><![CDATA[");
445                    sb.append(getUserName());
446                    sb.append("]]></column-value></column>");
447                    sb.append(
448                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
449                    sb.append(getCreateDate());
450                    sb.append("]]></column-value></column>");
451                    sb.append(
452                            "<column><column-name>entryId1</column-name><column-value><![CDATA[");
453                    sb.append(getEntryId1());
454                    sb.append("]]></column-value></column>");
455                    sb.append(
456                            "<column><column-name>entryId2</column-name><column-value><![CDATA[");
457                    sb.append(getEntryId2());
458                    sb.append("]]></column-value></column>");
459                    sb.append(
460                            "<column><column-name>type</column-name><column-value><![CDATA[");
461                    sb.append(getType());
462                    sb.append("]]></column-value></column>");
463                    sb.append(
464                            "<column><column-name>weight</column-name><column-value><![CDATA[");
465                    sb.append(getWeight());
466                    sb.append("]]></column-value></column>");
467    
468                    sb.append("</model>");
469    
470                    return sb.toString();
471            }
472    
473            private static ClassLoader _classLoader = AssetLink.class.getClassLoader();
474            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
475                            AssetLink.class
476                    };
477            private long _linkId;
478            private long _companyId;
479            private long _userId;
480            private String _userUuid;
481            private String _userName;
482            private Date _createDate;
483            private long _entryId1;
484            private long _originalEntryId1;
485            private boolean _setOriginalEntryId1;
486            private long _entryId2;
487            private long _originalEntryId2;
488            private boolean _setOriginalEntryId2;
489            private int _type;
490            private int _originalType;
491            private boolean _setOriginalType;
492            private int _weight;
493            private transient ExpandoBridge _expandoBridge;
494            private long _columnBitmask;
495            private AssetLink _escapedModelProxy;
496    }