001    /**
002     * Copyright (c) 2000-present 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.portal.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
020    import com.liferay.portal.kernel.exception.PortalException;
021    import com.liferay.portal.kernel.util.GetterUtil;
022    import com.liferay.portal.kernel.util.ProxyUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
025    import com.liferay.portal.model.CacheModel;
026    import com.liferay.portal.model.User;
027    import com.liferay.portal.model.UserIdMapper;
028    import com.liferay.portal.model.UserIdMapperModel;
029    import com.liferay.portal.service.ServiceContext;
030    import com.liferay.portal.service.UserLocalServiceUtil;
031    
032    import com.liferay.portlet.expando.model.ExpandoBridge;
033    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
034    
035    import java.io.Serializable;
036    
037    import java.sql.Types;
038    
039    import java.util.HashMap;
040    import java.util.Map;
041    
042    /**
043     * The base model implementation for the UserIdMapper service. Represents a row in the "UserIdMapper" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link UserIdMapperModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link UserIdMapperImpl}.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see UserIdMapperImpl
051     * @see UserIdMapper
052     * @see UserIdMapperModel
053     * @generated
054     */
055    @ProviderType
056    public class UserIdMapperModelImpl extends BaseModelImpl<UserIdMapper>
057            implements UserIdMapperModel {
058            /*
059             * NOTE FOR DEVELOPERS:
060             *
061             * Never modify or reference this class directly. All methods that expect a user ID mapper model instance should use the {@link UserIdMapper} interface instead.
062             */
063            public static final String TABLE_NAME = "UserIdMapper";
064            public static final Object[][] TABLE_COLUMNS = {
065                            { "mvccVersion", Types.BIGINT },
066                            { "userIdMapperId", Types.BIGINT },
067                            { "userId", Types.BIGINT },
068                            { "type_", Types.VARCHAR },
069                            { "description", Types.VARCHAR },
070                            { "externalUserId", Types.VARCHAR }
071                    };
072            public static final Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();
073    
074            static {
075                    TABLE_COLUMNS_MAP.put("mvccVersion", Types.BIGINT);
076                    TABLE_COLUMNS_MAP.put("userIdMapperId", Types.BIGINT);
077                    TABLE_COLUMNS_MAP.put("userId", Types.BIGINT);
078                    TABLE_COLUMNS_MAP.put("type_", Types.VARCHAR);
079                    TABLE_COLUMNS_MAP.put("description", Types.VARCHAR);
080                    TABLE_COLUMNS_MAP.put("externalUserId", Types.VARCHAR);
081            }
082    
083            public static final String TABLE_SQL_CREATE = "create table UserIdMapper (mvccVersion LONG default 0,userIdMapperId LONG not null primary key,userId LONG,type_ VARCHAR(75) null,description VARCHAR(75) null,externalUserId VARCHAR(75) null)";
084            public static final String TABLE_SQL_DROP = "drop table UserIdMapper";
085            public static final String ORDER_BY_JPQL = " ORDER BY userIdMapper.userIdMapperId ASC";
086            public static final String ORDER_BY_SQL = " ORDER BY UserIdMapper.userIdMapperId ASC";
087            public static final String DATA_SOURCE = "liferayDataSource";
088            public static final String SESSION_FACTORY = "liferaySessionFactory";
089            public static final String TX_MANAGER = "liferayTransactionManager";
090            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
091                                    "value.object.entity.cache.enabled.com.liferay.portal.model.UserIdMapper"),
092                            true);
093            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
094                                    "value.object.finder.cache.enabled.com.liferay.portal.model.UserIdMapper"),
095                            true);
096            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
097                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.UserIdMapper"),
098                            true);
099            public static final long EXTERNALUSERID_COLUMN_BITMASK = 1L;
100            public static final long TYPE_COLUMN_BITMASK = 2L;
101            public static final long USERID_COLUMN_BITMASK = 4L;
102            public static final long USERIDMAPPERID_COLUMN_BITMASK = 8L;
103            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
104                                    "lock.expiration.time.com.liferay.portal.model.UserIdMapper"));
105    
106            public UserIdMapperModelImpl() {
107            }
108    
109            @Override
110            public long getPrimaryKey() {
111                    return _userIdMapperId;
112            }
113    
114            @Override
115            public void setPrimaryKey(long primaryKey) {
116                    setUserIdMapperId(primaryKey);
117            }
118    
119            @Override
120            public Serializable getPrimaryKeyObj() {
121                    return _userIdMapperId;
122            }
123    
124            @Override
125            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
126                    setPrimaryKey(((Long)primaryKeyObj).longValue());
127            }
128    
129            @Override
130            public Class<?> getModelClass() {
131                    return UserIdMapper.class;
132            }
133    
134            @Override
135            public String getModelClassName() {
136                    return UserIdMapper.class.getName();
137            }
138    
139            @Override
140            public Map<String, Object> getModelAttributes() {
141                    Map<String, Object> attributes = new HashMap<String, Object>();
142    
143                    attributes.put("mvccVersion", getMvccVersion());
144                    attributes.put("userIdMapperId", getUserIdMapperId());
145                    attributes.put("userId", getUserId());
146                    attributes.put("type", getType());
147                    attributes.put("description", getDescription());
148                    attributes.put("externalUserId", getExternalUserId());
149    
150                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
151                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
152    
153                    return attributes;
154            }
155    
156            @Override
157            public void setModelAttributes(Map<String, Object> attributes) {
158                    Long mvccVersion = (Long)attributes.get("mvccVersion");
159    
160                    if (mvccVersion != null) {
161                            setMvccVersion(mvccVersion);
162                    }
163    
164                    Long userIdMapperId = (Long)attributes.get("userIdMapperId");
165    
166                    if (userIdMapperId != null) {
167                            setUserIdMapperId(userIdMapperId);
168                    }
169    
170                    Long userId = (Long)attributes.get("userId");
171    
172                    if (userId != null) {
173                            setUserId(userId);
174                    }
175    
176                    String type = (String)attributes.get("type");
177    
178                    if (type != null) {
179                            setType(type);
180                    }
181    
182                    String description = (String)attributes.get("description");
183    
184                    if (description != null) {
185                            setDescription(description);
186                    }
187    
188                    String externalUserId = (String)attributes.get("externalUserId");
189    
190                    if (externalUserId != null) {
191                            setExternalUserId(externalUserId);
192                    }
193            }
194    
195            @Override
196            public long getMvccVersion() {
197                    return _mvccVersion;
198            }
199    
200            @Override
201            public void setMvccVersion(long mvccVersion) {
202                    _mvccVersion = mvccVersion;
203            }
204    
205            @Override
206            public long getUserIdMapperId() {
207                    return _userIdMapperId;
208            }
209    
210            @Override
211            public void setUserIdMapperId(long userIdMapperId) {
212                    _userIdMapperId = userIdMapperId;
213            }
214    
215            @Override
216            public long getUserId() {
217                    return _userId;
218            }
219    
220            @Override
221            public void setUserId(long userId) {
222                    _columnBitmask |= USERID_COLUMN_BITMASK;
223    
224                    if (!_setOriginalUserId) {
225                            _setOriginalUserId = true;
226    
227                            _originalUserId = _userId;
228                    }
229    
230                    _userId = userId;
231            }
232    
233            @Override
234            public String getUserUuid() {
235                    try {
236                            User user = UserLocalServiceUtil.getUserById(getUserId());
237    
238                            return user.getUuid();
239                    }
240                    catch (PortalException pe) {
241                            return StringPool.BLANK;
242                    }
243            }
244    
245            @Override
246            public void setUserUuid(String userUuid) {
247            }
248    
249            public long getOriginalUserId() {
250                    return _originalUserId;
251            }
252    
253            @Override
254            public String getType() {
255                    if (_type == null) {
256                            return StringPool.BLANK;
257                    }
258                    else {
259                            return _type;
260                    }
261            }
262    
263            @Override
264            public void setType(String type) {
265                    _columnBitmask |= TYPE_COLUMN_BITMASK;
266    
267                    if (_originalType == null) {
268                            _originalType = _type;
269                    }
270    
271                    _type = type;
272            }
273    
274            public String getOriginalType() {
275                    return GetterUtil.getString(_originalType);
276            }
277    
278            @Override
279            public String getDescription() {
280                    if (_description == null) {
281                            return StringPool.BLANK;
282                    }
283                    else {
284                            return _description;
285                    }
286            }
287    
288            @Override
289            public void setDescription(String description) {
290                    _description = description;
291            }
292    
293            @Override
294            public String getExternalUserId() {
295                    if (_externalUserId == null) {
296                            return StringPool.BLANK;
297                    }
298                    else {
299                            return _externalUserId;
300                    }
301            }
302    
303            @Override
304            public void setExternalUserId(String externalUserId) {
305                    _columnBitmask |= EXTERNALUSERID_COLUMN_BITMASK;
306    
307                    if (_originalExternalUserId == null) {
308                            _originalExternalUserId = _externalUserId;
309                    }
310    
311                    _externalUserId = externalUserId;
312            }
313    
314            public String getOriginalExternalUserId() {
315                    return GetterUtil.getString(_originalExternalUserId);
316            }
317    
318            public long getColumnBitmask() {
319                    return _columnBitmask;
320            }
321    
322            @Override
323            public ExpandoBridge getExpandoBridge() {
324                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
325                            UserIdMapper.class.getName(), getPrimaryKey());
326            }
327    
328            @Override
329            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
330                    ExpandoBridge expandoBridge = getExpandoBridge();
331    
332                    expandoBridge.setAttributes(serviceContext);
333            }
334    
335            @Override
336            public UserIdMapper toEscapedModel() {
337                    if (_escapedModel == null) {
338                            _escapedModel = (UserIdMapper)ProxyUtil.newProxyInstance(_classLoader,
339                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
340                    }
341    
342                    return _escapedModel;
343            }
344    
345            @Override
346            public Object clone() {
347                    UserIdMapperImpl userIdMapperImpl = new UserIdMapperImpl();
348    
349                    userIdMapperImpl.setMvccVersion(getMvccVersion());
350                    userIdMapperImpl.setUserIdMapperId(getUserIdMapperId());
351                    userIdMapperImpl.setUserId(getUserId());
352                    userIdMapperImpl.setType(getType());
353                    userIdMapperImpl.setDescription(getDescription());
354                    userIdMapperImpl.setExternalUserId(getExternalUserId());
355    
356                    userIdMapperImpl.resetOriginalValues();
357    
358                    return userIdMapperImpl;
359            }
360    
361            @Override
362            public int compareTo(UserIdMapper userIdMapper) {
363                    long primaryKey = userIdMapper.getPrimaryKey();
364    
365                    if (getPrimaryKey() < primaryKey) {
366                            return -1;
367                    }
368                    else if (getPrimaryKey() > primaryKey) {
369                            return 1;
370                    }
371                    else {
372                            return 0;
373                    }
374            }
375    
376            @Override
377            public boolean equals(Object obj) {
378                    if (this == obj) {
379                            return true;
380                    }
381    
382                    if (!(obj instanceof UserIdMapper)) {
383                            return false;
384                    }
385    
386                    UserIdMapper userIdMapper = (UserIdMapper)obj;
387    
388                    long primaryKey = userIdMapper.getPrimaryKey();
389    
390                    if (getPrimaryKey() == primaryKey) {
391                            return true;
392                    }
393                    else {
394                            return false;
395                    }
396            }
397    
398            @Override
399            public int hashCode() {
400                    return (int)getPrimaryKey();
401            }
402    
403            @Override
404            public boolean isEntityCacheEnabled() {
405                    return ENTITY_CACHE_ENABLED;
406            }
407    
408            @Override
409            public boolean isFinderCacheEnabled() {
410                    return FINDER_CACHE_ENABLED;
411            }
412    
413            @Override
414            public void resetOriginalValues() {
415                    UserIdMapperModelImpl userIdMapperModelImpl = this;
416    
417                    userIdMapperModelImpl._originalUserId = userIdMapperModelImpl._userId;
418    
419                    userIdMapperModelImpl._setOriginalUserId = false;
420    
421                    userIdMapperModelImpl._originalType = userIdMapperModelImpl._type;
422    
423                    userIdMapperModelImpl._originalExternalUserId = userIdMapperModelImpl._externalUserId;
424    
425                    userIdMapperModelImpl._columnBitmask = 0;
426            }
427    
428            @Override
429            public CacheModel<UserIdMapper> toCacheModel() {
430                    UserIdMapperCacheModel userIdMapperCacheModel = new UserIdMapperCacheModel();
431    
432                    userIdMapperCacheModel.mvccVersion = getMvccVersion();
433    
434                    userIdMapperCacheModel.userIdMapperId = getUserIdMapperId();
435    
436                    userIdMapperCacheModel.userId = getUserId();
437    
438                    userIdMapperCacheModel.type = getType();
439    
440                    String type = userIdMapperCacheModel.type;
441    
442                    if ((type != null) && (type.length() == 0)) {
443                            userIdMapperCacheModel.type = null;
444                    }
445    
446                    userIdMapperCacheModel.description = getDescription();
447    
448                    String description = userIdMapperCacheModel.description;
449    
450                    if ((description != null) && (description.length() == 0)) {
451                            userIdMapperCacheModel.description = null;
452                    }
453    
454                    userIdMapperCacheModel.externalUserId = getExternalUserId();
455    
456                    String externalUserId = userIdMapperCacheModel.externalUserId;
457    
458                    if ((externalUserId != null) && (externalUserId.length() == 0)) {
459                            userIdMapperCacheModel.externalUserId = null;
460                    }
461    
462                    return userIdMapperCacheModel;
463            }
464    
465            @Override
466            public String toString() {
467                    StringBundler sb = new StringBundler(13);
468    
469                    sb.append("{mvccVersion=");
470                    sb.append(getMvccVersion());
471                    sb.append(", userIdMapperId=");
472                    sb.append(getUserIdMapperId());
473                    sb.append(", userId=");
474                    sb.append(getUserId());
475                    sb.append(", type=");
476                    sb.append(getType());
477                    sb.append(", description=");
478                    sb.append(getDescription());
479                    sb.append(", externalUserId=");
480                    sb.append(getExternalUserId());
481                    sb.append("}");
482    
483                    return sb.toString();
484            }
485    
486            @Override
487            public String toXmlString() {
488                    StringBundler sb = new StringBundler(22);
489    
490                    sb.append("<model><model-name>");
491                    sb.append("com.liferay.portal.model.UserIdMapper");
492                    sb.append("</model-name>");
493    
494                    sb.append(
495                            "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
496                    sb.append(getMvccVersion());
497                    sb.append("]]></column-value></column>");
498                    sb.append(
499                            "<column><column-name>userIdMapperId</column-name><column-value><![CDATA[");
500                    sb.append(getUserIdMapperId());
501                    sb.append("]]></column-value></column>");
502                    sb.append(
503                            "<column><column-name>userId</column-name><column-value><![CDATA[");
504                    sb.append(getUserId());
505                    sb.append("]]></column-value></column>");
506                    sb.append(
507                            "<column><column-name>type</column-name><column-value><![CDATA[");
508                    sb.append(getType());
509                    sb.append("]]></column-value></column>");
510                    sb.append(
511                            "<column><column-name>description</column-name><column-value><![CDATA[");
512                    sb.append(getDescription());
513                    sb.append("]]></column-value></column>");
514                    sb.append(
515                            "<column><column-name>externalUserId</column-name><column-value><![CDATA[");
516                    sb.append(getExternalUserId());
517                    sb.append("]]></column-value></column>");
518    
519                    sb.append("</model>");
520    
521                    return sb.toString();
522            }
523    
524            private static final ClassLoader _classLoader = UserIdMapper.class.getClassLoader();
525            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
526                            UserIdMapper.class
527                    };
528            private long _mvccVersion;
529            private long _userIdMapperId;
530            private long _userId;
531            private long _originalUserId;
532            private boolean _setOriginalUserId;
533            private String _type;
534            private String _originalType;
535            private String _description;
536            private String _externalUserId;
537            private String _originalExternalUserId;
538            private long _columnBitmask;
539            private UserIdMapper _escapedModel;
540    }