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.util.GetterUtil;
019    import com.liferay.portal.kernel.util.ProxyUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.kernel.util.Validator;
023    import com.liferay.portal.model.CacheModel;
024    import com.liferay.portal.model.PasswordPolicyRel;
025    import com.liferay.portal.model.PasswordPolicyRelModel;
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 PasswordPolicyRel service. Represents a row in the "PasswordPolicyRel" 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.PasswordPolicyRelModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PasswordPolicyRelImpl}.
044     * </p>
045     *
046     * @author Brian Wing Shun Chan
047     * @see PasswordPolicyRelImpl
048     * @see com.liferay.portal.model.PasswordPolicyRel
049     * @see com.liferay.portal.model.PasswordPolicyRelModel
050     * @generated
051     */
052    public class PasswordPolicyRelModelImpl extends BaseModelImpl<PasswordPolicyRel>
053            implements PasswordPolicyRelModel {
054            /*
055             * NOTE FOR DEVELOPERS:
056             *
057             * Never modify or reference this class directly. All methods that expect a password policy rel model instance should use the {@link com.liferay.portal.model.PasswordPolicyRel} interface instead.
058             */
059            public static final String TABLE_NAME = "PasswordPolicyRel";
060            public static final Object[][] TABLE_COLUMNS = {
061                            { "passwordPolicyRelId", Types.BIGINT },
062                            { "passwordPolicyId", Types.BIGINT },
063                            { "classNameId", Types.BIGINT },
064                            { "classPK", Types.BIGINT }
065                    };
066            public static final String TABLE_SQL_CREATE = "create table PasswordPolicyRel (passwordPolicyRelId LONG not null primary key,passwordPolicyId LONG,classNameId LONG,classPK LONG)";
067            public static final String TABLE_SQL_DROP = "drop table PasswordPolicyRel";
068            public static final String ORDER_BY_JPQL = " ORDER BY passwordPolicyRel.passwordPolicyRelId ASC";
069            public static final String ORDER_BY_SQL = " ORDER BY PasswordPolicyRel.passwordPolicyRelId ASC";
070            public static final String DATA_SOURCE = "liferayDataSource";
071            public static final String SESSION_FACTORY = "liferaySessionFactory";
072            public static final String TX_MANAGER = "liferayTransactionManager";
073            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.entity.cache.enabled.com.liferay.portal.model.PasswordPolicyRel"),
075                            true);
076            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.finder.cache.enabled.com.liferay.portal.model.PasswordPolicyRel"),
078                            true);
079            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.PasswordPolicyRel"),
081                            true);
082            public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
083            public static long CLASSPK_COLUMN_BITMASK = 2L;
084            public static long PASSWORDPOLICYID_COLUMN_BITMASK = 4L;
085            public static long PASSWORDPOLICYRELID_COLUMN_BITMASK = 8L;
086            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
087                                    "lock.expiration.time.com.liferay.portal.model.PasswordPolicyRel"));
088    
089            public PasswordPolicyRelModelImpl() {
090            }
091    
092            public long getPrimaryKey() {
093                    return _passwordPolicyRelId;
094            }
095    
096            public void setPrimaryKey(long primaryKey) {
097                    setPasswordPolicyRelId(primaryKey);
098            }
099    
100            public Serializable getPrimaryKeyObj() {
101                    return _passwordPolicyRelId;
102            }
103    
104            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
105                    setPrimaryKey(((Long)primaryKeyObj).longValue());
106            }
107    
108            public Class<?> getModelClass() {
109                    return PasswordPolicyRel.class;
110            }
111    
112            public String getModelClassName() {
113                    return PasswordPolicyRel.class.getName();
114            }
115    
116            @Override
117            public Map<String, Object> getModelAttributes() {
118                    Map<String, Object> attributes = new HashMap<String, Object>();
119    
120                    attributes.put("passwordPolicyRelId", getPasswordPolicyRelId());
121                    attributes.put("passwordPolicyId", getPasswordPolicyId());
122                    attributes.put("classNameId", getClassNameId());
123                    attributes.put("classPK", getClassPK());
124    
125                    return attributes;
126            }
127    
128            @Override
129            public void setModelAttributes(Map<String, Object> attributes) {
130                    Long passwordPolicyRelId = (Long)attributes.get("passwordPolicyRelId");
131    
132                    if (passwordPolicyRelId != null) {
133                            setPasswordPolicyRelId(passwordPolicyRelId);
134                    }
135    
136                    Long passwordPolicyId = (Long)attributes.get("passwordPolicyId");
137    
138                    if (passwordPolicyId != null) {
139                            setPasswordPolicyId(passwordPolicyId);
140                    }
141    
142                    Long classNameId = (Long)attributes.get("classNameId");
143    
144                    if (classNameId != null) {
145                            setClassNameId(classNameId);
146                    }
147    
148                    Long classPK = (Long)attributes.get("classPK");
149    
150                    if (classPK != null) {
151                            setClassPK(classPK);
152                    }
153            }
154    
155            public long getPasswordPolicyRelId() {
156                    return _passwordPolicyRelId;
157            }
158    
159            public void setPasswordPolicyRelId(long passwordPolicyRelId) {
160                    _passwordPolicyRelId = passwordPolicyRelId;
161            }
162    
163            public long getPasswordPolicyId() {
164                    return _passwordPolicyId;
165            }
166    
167            public void setPasswordPolicyId(long passwordPolicyId) {
168                    _columnBitmask |= PASSWORDPOLICYID_COLUMN_BITMASK;
169    
170                    if (!_setOriginalPasswordPolicyId) {
171                            _setOriginalPasswordPolicyId = true;
172    
173                            _originalPasswordPolicyId = _passwordPolicyId;
174                    }
175    
176                    _passwordPolicyId = passwordPolicyId;
177            }
178    
179            public long getOriginalPasswordPolicyId() {
180                    return _originalPasswordPolicyId;
181            }
182    
183            public String getClassName() {
184                    if (getClassNameId() <= 0) {
185                            return StringPool.BLANK;
186                    }
187    
188                    return PortalUtil.getClassName(getClassNameId());
189            }
190    
191            public void setClassName(String className) {
192                    long classNameId = 0;
193    
194                    if (Validator.isNotNull(className)) {
195                            classNameId = PortalUtil.getClassNameId(className);
196                    }
197    
198                    setClassNameId(classNameId);
199            }
200    
201            public long getClassNameId() {
202                    return _classNameId;
203            }
204    
205            public void setClassNameId(long classNameId) {
206                    _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
207    
208                    if (!_setOriginalClassNameId) {
209                            _setOriginalClassNameId = true;
210    
211                            _originalClassNameId = _classNameId;
212                    }
213    
214                    _classNameId = classNameId;
215            }
216    
217            public long getOriginalClassNameId() {
218                    return _originalClassNameId;
219            }
220    
221            public long getClassPK() {
222                    return _classPK;
223            }
224    
225            public void setClassPK(long classPK) {
226                    _columnBitmask |= CLASSPK_COLUMN_BITMASK;
227    
228                    if (!_setOriginalClassPK) {
229                            _setOriginalClassPK = true;
230    
231                            _originalClassPK = _classPK;
232                    }
233    
234                    _classPK = classPK;
235            }
236    
237            public long getOriginalClassPK() {
238                    return _originalClassPK;
239            }
240    
241            public long getColumnBitmask() {
242                    return _columnBitmask;
243            }
244    
245            @Override
246            public ExpandoBridge getExpandoBridge() {
247                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
248                            PasswordPolicyRel.class.getName(), getPrimaryKey());
249            }
250    
251            @Override
252            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
253                    ExpandoBridge expandoBridge = getExpandoBridge();
254    
255                    expandoBridge.setAttributes(serviceContext);
256            }
257    
258            @Override
259            public PasswordPolicyRel toEscapedModel() {
260                    if (_escapedModel == null) {
261                            _escapedModel = (PasswordPolicyRel)ProxyUtil.newProxyInstance(_classLoader,
262                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
263                    }
264    
265                    return _escapedModel;
266            }
267    
268            @Override
269            public Object clone() {
270                    PasswordPolicyRelImpl passwordPolicyRelImpl = new PasswordPolicyRelImpl();
271    
272                    passwordPolicyRelImpl.setPasswordPolicyRelId(getPasswordPolicyRelId());
273                    passwordPolicyRelImpl.setPasswordPolicyId(getPasswordPolicyId());
274                    passwordPolicyRelImpl.setClassNameId(getClassNameId());
275                    passwordPolicyRelImpl.setClassPK(getClassPK());
276    
277                    passwordPolicyRelImpl.resetOriginalValues();
278    
279                    return passwordPolicyRelImpl;
280            }
281    
282            public int compareTo(PasswordPolicyRel passwordPolicyRel) {
283                    long primaryKey = passwordPolicyRel.getPrimaryKey();
284    
285                    if (getPrimaryKey() < primaryKey) {
286                            return -1;
287                    }
288                    else if (getPrimaryKey() > primaryKey) {
289                            return 1;
290                    }
291                    else {
292                            return 0;
293                    }
294            }
295    
296            @Override
297            public boolean equals(Object obj) {
298                    if (obj == null) {
299                            return false;
300                    }
301    
302                    PasswordPolicyRel passwordPolicyRel = null;
303    
304                    try {
305                            passwordPolicyRel = (PasswordPolicyRel)obj;
306                    }
307                    catch (ClassCastException cce) {
308                            return false;
309                    }
310    
311                    long primaryKey = passwordPolicyRel.getPrimaryKey();
312    
313                    if (getPrimaryKey() == primaryKey) {
314                            return true;
315                    }
316                    else {
317                            return false;
318                    }
319            }
320    
321            @Override
322            public int hashCode() {
323                    return (int)getPrimaryKey();
324            }
325    
326            @Override
327            public void resetOriginalValues() {
328                    PasswordPolicyRelModelImpl passwordPolicyRelModelImpl = this;
329    
330                    passwordPolicyRelModelImpl._originalPasswordPolicyId = passwordPolicyRelModelImpl._passwordPolicyId;
331    
332                    passwordPolicyRelModelImpl._setOriginalPasswordPolicyId = false;
333    
334                    passwordPolicyRelModelImpl._originalClassNameId = passwordPolicyRelModelImpl._classNameId;
335    
336                    passwordPolicyRelModelImpl._setOriginalClassNameId = false;
337    
338                    passwordPolicyRelModelImpl._originalClassPK = passwordPolicyRelModelImpl._classPK;
339    
340                    passwordPolicyRelModelImpl._setOriginalClassPK = false;
341    
342                    passwordPolicyRelModelImpl._columnBitmask = 0;
343            }
344    
345            @Override
346            public CacheModel<PasswordPolicyRel> toCacheModel() {
347                    PasswordPolicyRelCacheModel passwordPolicyRelCacheModel = new PasswordPolicyRelCacheModel();
348    
349                    passwordPolicyRelCacheModel.passwordPolicyRelId = getPasswordPolicyRelId();
350    
351                    passwordPolicyRelCacheModel.passwordPolicyId = getPasswordPolicyId();
352    
353                    passwordPolicyRelCacheModel.classNameId = getClassNameId();
354    
355                    passwordPolicyRelCacheModel.classPK = getClassPK();
356    
357                    return passwordPolicyRelCacheModel;
358            }
359    
360            @Override
361            public String toString() {
362                    StringBundler sb = new StringBundler(9);
363    
364                    sb.append("{passwordPolicyRelId=");
365                    sb.append(getPasswordPolicyRelId());
366                    sb.append(", passwordPolicyId=");
367                    sb.append(getPasswordPolicyId());
368                    sb.append(", classNameId=");
369                    sb.append(getClassNameId());
370                    sb.append(", classPK=");
371                    sb.append(getClassPK());
372                    sb.append("}");
373    
374                    return sb.toString();
375            }
376    
377            public String toXmlString() {
378                    StringBundler sb = new StringBundler(16);
379    
380                    sb.append("<model><model-name>");
381                    sb.append("com.liferay.portal.model.PasswordPolicyRel");
382                    sb.append("</model-name>");
383    
384                    sb.append(
385                            "<column><column-name>passwordPolicyRelId</column-name><column-value><![CDATA[");
386                    sb.append(getPasswordPolicyRelId());
387                    sb.append("]]></column-value></column>");
388                    sb.append(
389                            "<column><column-name>passwordPolicyId</column-name><column-value><![CDATA[");
390                    sb.append(getPasswordPolicyId());
391                    sb.append("]]></column-value></column>");
392                    sb.append(
393                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
394                    sb.append(getClassNameId());
395                    sb.append("]]></column-value></column>");
396                    sb.append(
397                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
398                    sb.append(getClassPK());
399                    sb.append("]]></column-value></column>");
400    
401                    sb.append("</model>");
402    
403                    return sb.toString();
404            }
405    
406            private static ClassLoader _classLoader = PasswordPolicyRel.class.getClassLoader();
407            private static Class<?>[] _escapedModelInterfaces = new Class[] {
408                            PasswordPolicyRel.class
409                    };
410            private long _passwordPolicyRelId;
411            private long _passwordPolicyId;
412            private long _originalPasswordPolicyId;
413            private boolean _setOriginalPasswordPolicyId;
414            private long _classNameId;
415            private long _originalClassNameId;
416            private boolean _setOriginalClassNameId;
417            private long _classPK;
418            private long _originalClassPK;
419            private boolean _setOriginalClassPK;
420            private long _columnBitmask;
421            private PasswordPolicyRel _escapedModel;
422    }