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