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