001    /**
002     * Copyright (c) 2000-2013 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    import java.util.HashMap;
039    import java.util.Map;
040    
041    /**
042     * 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.
043     *
044     * <p>
045     * 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}.
046     * </p>
047     *
048     * @author Brian Wing Shun Chan
049     * @see AssetLinkImpl
050     * @see com.liferay.portlet.asset.model.AssetLink
051     * @see com.liferay.portlet.asset.model.AssetLinkModel
052     * @generated
053     */
054    public class AssetLinkModelImpl extends BaseModelImpl<AssetLink>
055            implements AssetLinkModel {
056            /*
057             * NOTE FOR DEVELOPERS:
058             *
059             * 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.
060             */
061            public static final String TABLE_NAME = "AssetLink";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "linkId", Types.BIGINT },
064                            { "companyId", Types.BIGINT },
065                            { "userId", Types.BIGINT },
066                            { "userName", Types.VARCHAR },
067                            { "createDate", Types.TIMESTAMP },
068                            { "entryId1", Types.BIGINT },
069                            { "entryId2", Types.BIGINT },
070                            { "type_", Types.INTEGER },
071                            { "weight", Types.INTEGER }
072                    };
073            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)";
074            public static final String TABLE_SQL_DROP = "drop table AssetLink";
075            public static final String ORDER_BY_JPQL = " ORDER BY assetLink.weight ASC";
076            public static final String ORDER_BY_SQL = " ORDER BY AssetLink.weight ASC";
077            public static final String DATA_SOURCE = "liferayDataSource";
078            public static final String SESSION_FACTORY = "liferaySessionFactory";
079            public static final String TX_MANAGER = "liferayTransactionManager";
080            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081                                    "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetLink"),
082                            true);
083            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084                                    "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetLink"),
085                            true);
086            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087                                    "value.object.column.bitmask.enabled.com.liferay.portlet.asset.model.AssetLink"),
088                            true);
089            public static long ENTRYID1_COLUMN_BITMASK = 1L;
090            public static long ENTRYID2_COLUMN_BITMASK = 2L;
091            public static long TYPE_COLUMN_BITMASK = 4L;
092            public static long WEIGHT_COLUMN_BITMASK = 8L;
093            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
094                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetLink"));
095    
096            public AssetLinkModelImpl() {
097            }
098    
099            @Override
100            public long getPrimaryKey() {
101                    return _linkId;
102            }
103    
104            @Override
105            public void setPrimaryKey(long primaryKey) {
106                    setLinkId(primaryKey);
107            }
108    
109            @Override
110            public Serializable getPrimaryKeyObj() {
111                    return _linkId;
112            }
113    
114            @Override
115            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
116                    setPrimaryKey(((Long)primaryKeyObj).longValue());
117            }
118    
119            @Override
120            public Class<?> getModelClass() {
121                    return AssetLink.class;
122            }
123    
124            @Override
125            public String getModelClassName() {
126                    return AssetLink.class.getName();
127            }
128    
129            @Override
130            public Map<String, Object> getModelAttributes() {
131                    Map<String, Object> attributes = new HashMap<String, Object>();
132    
133                    attributes.put("linkId", getLinkId());
134                    attributes.put("companyId", getCompanyId());
135                    attributes.put("userId", getUserId());
136                    attributes.put("userName", getUserName());
137                    attributes.put("createDate", getCreateDate());
138                    attributes.put("entryId1", getEntryId1());
139                    attributes.put("entryId2", getEntryId2());
140                    attributes.put("type", getType());
141                    attributes.put("weight", getWeight());
142    
143                    return attributes;
144            }
145    
146            @Override
147            public void setModelAttributes(Map<String, Object> attributes) {
148                    Long linkId = (Long)attributes.get("linkId");
149    
150                    if (linkId != null) {
151                            setLinkId(linkId);
152                    }
153    
154                    Long companyId = (Long)attributes.get("companyId");
155    
156                    if (companyId != null) {
157                            setCompanyId(companyId);
158                    }
159    
160                    Long userId = (Long)attributes.get("userId");
161    
162                    if (userId != null) {
163                            setUserId(userId);
164                    }
165    
166                    String userName = (String)attributes.get("userName");
167    
168                    if (userName != null) {
169                            setUserName(userName);
170                    }
171    
172                    Date createDate = (Date)attributes.get("createDate");
173    
174                    if (createDate != null) {
175                            setCreateDate(createDate);
176                    }
177    
178                    Long entryId1 = (Long)attributes.get("entryId1");
179    
180                    if (entryId1 != null) {
181                            setEntryId1(entryId1);
182                    }
183    
184                    Long entryId2 = (Long)attributes.get("entryId2");
185    
186                    if (entryId2 != null) {
187                            setEntryId2(entryId2);
188                    }
189    
190                    Integer type = (Integer)attributes.get("type");
191    
192                    if (type != null) {
193                            setType(type);
194                    }
195    
196                    Integer weight = (Integer)attributes.get("weight");
197    
198                    if (weight != null) {
199                            setWeight(weight);
200                    }
201            }
202    
203            @Override
204            public long getLinkId() {
205                    return _linkId;
206            }
207    
208            @Override
209            public void setLinkId(long linkId) {
210                    _linkId = linkId;
211            }
212    
213            @Override
214            public long getCompanyId() {
215                    return _companyId;
216            }
217    
218            @Override
219            public void setCompanyId(long companyId) {
220                    _companyId = companyId;
221            }
222    
223            @Override
224            public long getUserId() {
225                    return _userId;
226            }
227    
228            @Override
229            public void setUserId(long userId) {
230                    _userId = userId;
231            }
232    
233            @Override
234            public String getUserUuid() throws SystemException {
235                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
236            }
237    
238            @Override
239            public void setUserUuid(String userUuid) {
240                    _userUuid = userUuid;
241            }
242    
243            @Override
244            public String getUserName() {
245                    if (_userName == null) {
246                            return StringPool.BLANK;
247                    }
248                    else {
249                            return _userName;
250                    }
251            }
252    
253            @Override
254            public void setUserName(String userName) {
255                    _userName = userName;
256            }
257    
258            @Override
259            public Date getCreateDate() {
260                    return _createDate;
261            }
262    
263            @Override
264            public void setCreateDate(Date createDate) {
265                    _createDate = createDate;
266            }
267    
268            @Override
269            public long getEntryId1() {
270                    return _entryId1;
271            }
272    
273            @Override
274            public void setEntryId1(long entryId1) {
275                    _columnBitmask |= ENTRYID1_COLUMN_BITMASK;
276    
277                    if (!_setOriginalEntryId1) {
278                            _setOriginalEntryId1 = true;
279    
280                            _originalEntryId1 = _entryId1;
281                    }
282    
283                    _entryId1 = entryId1;
284            }
285    
286            public long getOriginalEntryId1() {
287                    return _originalEntryId1;
288            }
289    
290            @Override
291            public long getEntryId2() {
292                    return _entryId2;
293            }
294    
295            @Override
296            public void setEntryId2(long entryId2) {
297                    _columnBitmask |= ENTRYID2_COLUMN_BITMASK;
298    
299                    if (!_setOriginalEntryId2) {
300                            _setOriginalEntryId2 = true;
301    
302                            _originalEntryId2 = _entryId2;
303                    }
304    
305                    _entryId2 = entryId2;
306            }
307    
308            public long getOriginalEntryId2() {
309                    return _originalEntryId2;
310            }
311    
312            @Override
313            public int getType() {
314                    return _type;
315            }
316    
317            @Override
318            public void setType(int type) {
319                    _columnBitmask |= TYPE_COLUMN_BITMASK;
320    
321                    if (!_setOriginalType) {
322                            _setOriginalType = true;
323    
324                            _originalType = _type;
325                    }
326    
327                    _type = type;
328            }
329    
330            public int getOriginalType() {
331                    return _originalType;
332            }
333    
334            @Override
335            public int getWeight() {
336                    return _weight;
337            }
338    
339            @Override
340            public void setWeight(int weight) {
341                    _columnBitmask = -1L;
342    
343                    _weight = weight;
344            }
345    
346            public long getColumnBitmask() {
347                    return _columnBitmask;
348            }
349    
350            @Override
351            public ExpandoBridge getExpandoBridge() {
352                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
353                            AssetLink.class.getName(), getPrimaryKey());
354            }
355    
356            @Override
357            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
358                    ExpandoBridge expandoBridge = getExpandoBridge();
359    
360                    expandoBridge.setAttributes(serviceContext);
361            }
362    
363            @Override
364            public AssetLink toEscapedModel() {
365                    if (_escapedModel == null) {
366                            _escapedModel = (AssetLink)ProxyUtil.newProxyInstance(_classLoader,
367                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
368                    }
369    
370                    return _escapedModel;
371            }
372    
373            @Override
374            public Object clone() {
375                    AssetLinkImpl assetLinkImpl = new AssetLinkImpl();
376    
377                    assetLinkImpl.setLinkId(getLinkId());
378                    assetLinkImpl.setCompanyId(getCompanyId());
379                    assetLinkImpl.setUserId(getUserId());
380                    assetLinkImpl.setUserName(getUserName());
381                    assetLinkImpl.setCreateDate(getCreateDate());
382                    assetLinkImpl.setEntryId1(getEntryId1());
383                    assetLinkImpl.setEntryId2(getEntryId2());
384                    assetLinkImpl.setType(getType());
385                    assetLinkImpl.setWeight(getWeight());
386    
387                    assetLinkImpl.resetOriginalValues();
388    
389                    return assetLinkImpl;
390            }
391    
392            @Override
393            public int compareTo(AssetLink assetLink) {
394                    int value = 0;
395    
396                    if (getWeight() < assetLink.getWeight()) {
397                            value = -1;
398                    }
399                    else if (getWeight() > assetLink.getWeight()) {
400                            value = 1;
401                    }
402                    else {
403                            value = 0;
404                    }
405    
406                    if (value != 0) {
407                            return value;
408                    }
409    
410                    return 0;
411            }
412    
413            @Override
414            public boolean equals(Object obj) {
415                    if (this == obj) {
416                            return true;
417                    }
418    
419                    if (!(obj instanceof AssetLink)) {
420                            return false;
421                    }
422    
423                    AssetLink assetLink = (AssetLink)obj;
424    
425                    long primaryKey = assetLink.getPrimaryKey();
426    
427                    if (getPrimaryKey() == primaryKey) {
428                            return true;
429                    }
430                    else {
431                            return false;
432                    }
433            }
434    
435            @Override
436            public int hashCode() {
437                    return (int)getPrimaryKey();
438            }
439    
440            @Override
441            public void resetOriginalValues() {
442                    AssetLinkModelImpl assetLinkModelImpl = this;
443    
444                    assetLinkModelImpl._originalEntryId1 = assetLinkModelImpl._entryId1;
445    
446                    assetLinkModelImpl._setOriginalEntryId1 = false;
447    
448                    assetLinkModelImpl._originalEntryId2 = assetLinkModelImpl._entryId2;
449    
450                    assetLinkModelImpl._setOriginalEntryId2 = false;
451    
452                    assetLinkModelImpl._originalType = assetLinkModelImpl._type;
453    
454                    assetLinkModelImpl._setOriginalType = false;
455    
456                    assetLinkModelImpl._columnBitmask = 0;
457            }
458    
459            @Override
460            public CacheModel<AssetLink> toCacheModel() {
461                    AssetLinkCacheModel assetLinkCacheModel = new AssetLinkCacheModel();
462    
463                    assetLinkCacheModel.linkId = getLinkId();
464    
465                    assetLinkCacheModel.companyId = getCompanyId();
466    
467                    assetLinkCacheModel.userId = getUserId();
468    
469                    assetLinkCacheModel.userName = getUserName();
470    
471                    String userName = assetLinkCacheModel.userName;
472    
473                    if ((userName != null) && (userName.length() == 0)) {
474                            assetLinkCacheModel.userName = null;
475                    }
476    
477                    Date createDate = getCreateDate();
478    
479                    if (createDate != null) {
480                            assetLinkCacheModel.createDate = createDate.getTime();
481                    }
482                    else {
483                            assetLinkCacheModel.createDate = Long.MIN_VALUE;
484                    }
485    
486                    assetLinkCacheModel.entryId1 = getEntryId1();
487    
488                    assetLinkCacheModel.entryId2 = getEntryId2();
489    
490                    assetLinkCacheModel.type = getType();
491    
492                    assetLinkCacheModel.weight = getWeight();
493    
494                    return assetLinkCacheModel;
495            }
496    
497            @Override
498            public String toString() {
499                    StringBundler sb = new StringBundler(19);
500    
501                    sb.append("{linkId=");
502                    sb.append(getLinkId());
503                    sb.append(", companyId=");
504                    sb.append(getCompanyId());
505                    sb.append(", userId=");
506                    sb.append(getUserId());
507                    sb.append(", userName=");
508                    sb.append(getUserName());
509                    sb.append(", createDate=");
510                    sb.append(getCreateDate());
511                    sb.append(", entryId1=");
512                    sb.append(getEntryId1());
513                    sb.append(", entryId2=");
514                    sb.append(getEntryId2());
515                    sb.append(", type=");
516                    sb.append(getType());
517                    sb.append(", weight=");
518                    sb.append(getWeight());
519                    sb.append("}");
520    
521                    return sb.toString();
522            }
523    
524            @Override
525            public String toXmlString() {
526                    StringBundler sb = new StringBundler(31);
527    
528                    sb.append("<model><model-name>");
529                    sb.append("com.liferay.portlet.asset.model.AssetLink");
530                    sb.append("</model-name>");
531    
532                    sb.append(
533                            "<column><column-name>linkId</column-name><column-value><![CDATA[");
534                    sb.append(getLinkId());
535                    sb.append("]]></column-value></column>");
536                    sb.append(
537                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
538                    sb.append(getCompanyId());
539                    sb.append("]]></column-value></column>");
540                    sb.append(
541                            "<column><column-name>userId</column-name><column-value><![CDATA[");
542                    sb.append(getUserId());
543                    sb.append("]]></column-value></column>");
544                    sb.append(
545                            "<column><column-name>userName</column-name><column-value><![CDATA[");
546                    sb.append(getUserName());
547                    sb.append("]]></column-value></column>");
548                    sb.append(
549                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
550                    sb.append(getCreateDate());
551                    sb.append("]]></column-value></column>");
552                    sb.append(
553                            "<column><column-name>entryId1</column-name><column-value><![CDATA[");
554                    sb.append(getEntryId1());
555                    sb.append("]]></column-value></column>");
556                    sb.append(
557                            "<column><column-name>entryId2</column-name><column-value><![CDATA[");
558                    sb.append(getEntryId2());
559                    sb.append("]]></column-value></column>");
560                    sb.append(
561                            "<column><column-name>type</column-name><column-value><![CDATA[");
562                    sb.append(getType());
563                    sb.append("]]></column-value></column>");
564                    sb.append(
565                            "<column><column-name>weight</column-name><column-value><![CDATA[");
566                    sb.append(getWeight());
567                    sb.append("]]></column-value></column>");
568    
569                    sb.append("</model>");
570    
571                    return sb.toString();
572            }
573    
574            private static ClassLoader _classLoader = AssetLink.class.getClassLoader();
575            private static Class<?>[] _escapedModelInterfaces = new Class[] {
576                            AssetLink.class
577                    };
578            private long _linkId;
579            private long _companyId;
580            private long _userId;
581            private String _userUuid;
582            private String _userName;
583            private Date _createDate;
584            private long _entryId1;
585            private long _originalEntryId1;
586            private boolean _setOriginalEntryId1;
587            private long _entryId2;
588            private long _originalEntryId2;
589            private boolean _setOriginalEntryId2;
590            private int _type;
591            private int _originalType;
592            private boolean _setOriginalType;
593            private int _weight;
594            private long _columnBitmask;
595            private AssetLink _escapedModel;
596    }