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