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