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