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