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.WebDAVProps;
025    import com.liferay.portal.model.WebDAVPropsModel;
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.Date;
037    import java.util.HashMap;
038    import java.util.Map;
039    
040    /**
041     * The base model implementation for the WebDAVProps service. Represents a row in the "WebDAVProps" database table, with each column mapped to a property of this class.
042     *
043     * <p>
044     * This implementation and its corresponding interface {@link com.liferay.portal.model.WebDAVPropsModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link WebDAVPropsImpl}.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see WebDAVPropsImpl
049     * @see com.liferay.portal.model.WebDAVProps
050     * @see com.liferay.portal.model.WebDAVPropsModel
051     * @generated
052     */
053    public class WebDAVPropsModelImpl extends BaseModelImpl<WebDAVProps>
054            implements WebDAVPropsModel {
055            /*
056             * NOTE FOR DEVELOPERS:
057             *
058             * Never modify or reference this class directly. All methods that expect a web d a v props model instance should use the {@link com.liferay.portal.model.WebDAVProps} interface instead.
059             */
060            public static final String TABLE_NAME = "WebDAVProps";
061            public static final Object[][] TABLE_COLUMNS = {
062                            { "webDavPropsId", Types.BIGINT },
063                            { "companyId", Types.BIGINT },
064                            { "createDate", Types.TIMESTAMP },
065                            { "modifiedDate", Types.TIMESTAMP },
066                            { "classNameId", Types.BIGINT },
067                            { "classPK", Types.BIGINT },
068                            { "props", Types.CLOB }
069                    };
070            public static final String TABLE_SQL_CREATE = "create table WebDAVProps (webDavPropsId LONG not null primary key,companyId LONG,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,props TEXT null)";
071            public static final String TABLE_SQL_DROP = "drop table WebDAVProps";
072            public static final String ORDER_BY_JPQL = " ORDER BY webDAVProps.webDavPropsId ASC";
073            public static final String ORDER_BY_SQL = " ORDER BY WebDAVProps.webDavPropsId ASC";
074            public static final String DATA_SOURCE = "liferayDataSource";
075            public static final String SESSION_FACTORY = "liferaySessionFactory";
076            public static final String TX_MANAGER = "liferayTransactionManager";
077            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
078                                    "value.object.entity.cache.enabled.com.liferay.portal.model.WebDAVProps"),
079                            true);
080            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081                                    "value.object.finder.cache.enabled.com.liferay.portal.model.WebDAVProps"),
082                            true);
083            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.WebDAVProps"),
085                            true);
086            public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
087            public static long CLASSPK_COLUMN_BITMASK = 2L;
088            public static long WEBDAVPROPSID_COLUMN_BITMASK = 4L;
089            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
090                                    "lock.expiration.time.com.liferay.portal.model.WebDAVProps"));
091    
092            public WebDAVPropsModelImpl() {
093            }
094    
095            @Override
096            public long getPrimaryKey() {
097                    return _webDavPropsId;
098            }
099    
100            @Override
101            public void setPrimaryKey(long primaryKey) {
102                    setWebDavPropsId(primaryKey);
103            }
104    
105            @Override
106            public Serializable getPrimaryKeyObj() {
107                    return _webDavPropsId;
108            }
109    
110            @Override
111            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
112                    setPrimaryKey(((Long)primaryKeyObj).longValue());
113            }
114    
115            @Override
116            public Class<?> getModelClass() {
117                    return WebDAVProps.class;
118            }
119    
120            @Override
121            public String getModelClassName() {
122                    return WebDAVProps.class.getName();
123            }
124    
125            @Override
126            public Map<String, Object> getModelAttributes() {
127                    Map<String, Object> attributes = new HashMap<String, Object>();
128    
129                    attributes.put("webDavPropsId", getWebDavPropsId());
130                    attributes.put("companyId", getCompanyId());
131                    attributes.put("createDate", getCreateDate());
132                    attributes.put("modifiedDate", getModifiedDate());
133                    attributes.put("classNameId", getClassNameId());
134                    attributes.put("classPK", getClassPK());
135                    attributes.put("props", getProps());
136    
137                    return attributes;
138            }
139    
140            @Override
141            public void setModelAttributes(Map<String, Object> attributes) {
142                    Long webDavPropsId = (Long)attributes.get("webDavPropsId");
143    
144                    if (webDavPropsId != null) {
145                            setWebDavPropsId(webDavPropsId);
146                    }
147    
148                    Long companyId = (Long)attributes.get("companyId");
149    
150                    if (companyId != null) {
151                            setCompanyId(companyId);
152                    }
153    
154                    Date createDate = (Date)attributes.get("createDate");
155    
156                    if (createDate != null) {
157                            setCreateDate(createDate);
158                    }
159    
160                    Date modifiedDate = (Date)attributes.get("modifiedDate");
161    
162                    if (modifiedDate != null) {
163                            setModifiedDate(modifiedDate);
164                    }
165    
166                    Long classNameId = (Long)attributes.get("classNameId");
167    
168                    if (classNameId != null) {
169                            setClassNameId(classNameId);
170                    }
171    
172                    Long classPK = (Long)attributes.get("classPK");
173    
174                    if (classPK != null) {
175                            setClassPK(classPK);
176                    }
177    
178                    String props = (String)attributes.get("props");
179    
180                    if (props != null) {
181                            setProps(props);
182                    }
183            }
184    
185            @Override
186            public long getWebDavPropsId() {
187                    return _webDavPropsId;
188            }
189    
190            @Override
191            public void setWebDavPropsId(long webDavPropsId) {
192                    _webDavPropsId = webDavPropsId;
193            }
194    
195            @Override
196            public long getCompanyId() {
197                    return _companyId;
198            }
199    
200            @Override
201            public void setCompanyId(long companyId) {
202                    _companyId = companyId;
203            }
204    
205            @Override
206            public Date getCreateDate() {
207                    return _createDate;
208            }
209    
210            @Override
211            public void setCreateDate(Date createDate) {
212                    _createDate = createDate;
213            }
214    
215            @Override
216            public Date getModifiedDate() {
217                    return _modifiedDate;
218            }
219    
220            @Override
221            public void setModifiedDate(Date modifiedDate) {
222                    _modifiedDate = modifiedDate;
223            }
224    
225            @Override
226            public String getClassName() {
227                    if (getClassNameId() <= 0) {
228                            return StringPool.BLANK;
229                    }
230    
231                    return PortalUtil.getClassName(getClassNameId());
232            }
233    
234            @Override
235            public void setClassName(String className) {
236                    long classNameId = 0;
237    
238                    if (Validator.isNotNull(className)) {
239                            classNameId = PortalUtil.getClassNameId(className);
240                    }
241    
242                    setClassNameId(classNameId);
243            }
244    
245            @Override
246            public long getClassNameId() {
247                    return _classNameId;
248            }
249    
250            @Override
251            public void setClassNameId(long classNameId) {
252                    _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
253    
254                    if (!_setOriginalClassNameId) {
255                            _setOriginalClassNameId = true;
256    
257                            _originalClassNameId = _classNameId;
258                    }
259    
260                    _classNameId = classNameId;
261            }
262    
263            public long getOriginalClassNameId() {
264                    return _originalClassNameId;
265            }
266    
267            @Override
268            public long getClassPK() {
269                    return _classPK;
270            }
271    
272            @Override
273            public void setClassPK(long classPK) {
274                    _columnBitmask |= CLASSPK_COLUMN_BITMASK;
275    
276                    if (!_setOriginalClassPK) {
277                            _setOriginalClassPK = true;
278    
279                            _originalClassPK = _classPK;
280                    }
281    
282                    _classPK = classPK;
283            }
284    
285            public long getOriginalClassPK() {
286                    return _originalClassPK;
287            }
288    
289            @Override
290            public String getProps() {
291                    if (_props == null) {
292                            return StringPool.BLANK;
293                    }
294                    else {
295                            return _props;
296                    }
297            }
298    
299            @Override
300            public void setProps(String props) {
301                    _props = props;
302            }
303    
304            public long getColumnBitmask() {
305                    return _columnBitmask;
306            }
307    
308            @Override
309            public ExpandoBridge getExpandoBridge() {
310                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
311                            WebDAVProps.class.getName(), getPrimaryKey());
312            }
313    
314            @Override
315            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
316                    ExpandoBridge expandoBridge = getExpandoBridge();
317    
318                    expandoBridge.setAttributes(serviceContext);
319            }
320    
321            @Override
322            public WebDAVProps toEscapedModel() {
323                    if (_escapedModel == null) {
324                            _escapedModel = (WebDAVProps)ProxyUtil.newProxyInstance(_classLoader,
325                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
326                    }
327    
328                    return _escapedModel;
329            }
330    
331            @Override
332            public Object clone() {
333                    WebDAVPropsImpl webDAVPropsImpl = new WebDAVPropsImpl();
334    
335                    webDAVPropsImpl.setWebDavPropsId(getWebDavPropsId());
336                    webDAVPropsImpl.setCompanyId(getCompanyId());
337                    webDAVPropsImpl.setCreateDate(getCreateDate());
338                    webDAVPropsImpl.setModifiedDate(getModifiedDate());
339                    webDAVPropsImpl.setClassNameId(getClassNameId());
340                    webDAVPropsImpl.setClassPK(getClassPK());
341                    webDAVPropsImpl.setProps(getProps());
342    
343                    webDAVPropsImpl.resetOriginalValues();
344    
345                    return webDAVPropsImpl;
346            }
347    
348            @Override
349            public int compareTo(WebDAVProps webDAVProps) {
350                    long primaryKey = webDAVProps.getPrimaryKey();
351    
352                    if (getPrimaryKey() < primaryKey) {
353                            return -1;
354                    }
355                    else if (getPrimaryKey() > primaryKey) {
356                            return 1;
357                    }
358                    else {
359                            return 0;
360                    }
361            }
362    
363            @Override
364            public boolean equals(Object obj) {
365                    if (this == obj) {
366                            return true;
367                    }
368    
369                    if (!(obj instanceof WebDAVProps)) {
370                            return false;
371                    }
372    
373                    WebDAVProps webDAVProps = (WebDAVProps)obj;
374    
375                    long primaryKey = webDAVProps.getPrimaryKey();
376    
377                    if (getPrimaryKey() == primaryKey) {
378                            return true;
379                    }
380                    else {
381                            return false;
382                    }
383            }
384    
385            @Override
386            public int hashCode() {
387                    return (int)getPrimaryKey();
388            }
389    
390            @Override
391            public void resetOriginalValues() {
392                    WebDAVPropsModelImpl webDAVPropsModelImpl = this;
393    
394                    webDAVPropsModelImpl._originalClassNameId = webDAVPropsModelImpl._classNameId;
395    
396                    webDAVPropsModelImpl._setOriginalClassNameId = false;
397    
398                    webDAVPropsModelImpl._originalClassPK = webDAVPropsModelImpl._classPK;
399    
400                    webDAVPropsModelImpl._setOriginalClassPK = false;
401    
402                    webDAVPropsModelImpl._columnBitmask = 0;
403            }
404    
405            @Override
406            public CacheModel<WebDAVProps> toCacheModel() {
407                    WebDAVPropsCacheModel webDAVPropsCacheModel = new WebDAVPropsCacheModel();
408    
409                    webDAVPropsCacheModel.webDavPropsId = getWebDavPropsId();
410    
411                    webDAVPropsCacheModel.companyId = getCompanyId();
412    
413                    Date createDate = getCreateDate();
414    
415                    if (createDate != null) {
416                            webDAVPropsCacheModel.createDate = createDate.getTime();
417                    }
418                    else {
419                            webDAVPropsCacheModel.createDate = Long.MIN_VALUE;
420                    }
421    
422                    Date modifiedDate = getModifiedDate();
423    
424                    if (modifiedDate != null) {
425                            webDAVPropsCacheModel.modifiedDate = modifiedDate.getTime();
426                    }
427                    else {
428                            webDAVPropsCacheModel.modifiedDate = Long.MIN_VALUE;
429                    }
430    
431                    webDAVPropsCacheModel.classNameId = getClassNameId();
432    
433                    webDAVPropsCacheModel.classPK = getClassPK();
434    
435                    webDAVPropsCacheModel.props = getProps();
436    
437                    String props = webDAVPropsCacheModel.props;
438    
439                    if ((props != null) && (props.length() == 0)) {
440                            webDAVPropsCacheModel.props = null;
441                    }
442    
443                    return webDAVPropsCacheModel;
444            }
445    
446            @Override
447            public String toString() {
448                    StringBundler sb = new StringBundler(15);
449    
450                    sb.append("{webDavPropsId=");
451                    sb.append(getWebDavPropsId());
452                    sb.append(", companyId=");
453                    sb.append(getCompanyId());
454                    sb.append(", createDate=");
455                    sb.append(getCreateDate());
456                    sb.append(", modifiedDate=");
457                    sb.append(getModifiedDate());
458                    sb.append(", classNameId=");
459                    sb.append(getClassNameId());
460                    sb.append(", classPK=");
461                    sb.append(getClassPK());
462                    sb.append(", props=");
463                    sb.append(getProps());
464                    sb.append("}");
465    
466                    return sb.toString();
467            }
468    
469            @Override
470            public String toXmlString() {
471                    StringBundler sb = new StringBundler(25);
472    
473                    sb.append("<model><model-name>");
474                    sb.append("com.liferay.portal.model.WebDAVProps");
475                    sb.append("</model-name>");
476    
477                    sb.append(
478                            "<column><column-name>webDavPropsId</column-name><column-value><![CDATA[");
479                    sb.append(getWebDavPropsId());
480                    sb.append("]]></column-value></column>");
481                    sb.append(
482                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
483                    sb.append(getCompanyId());
484                    sb.append("]]></column-value></column>");
485                    sb.append(
486                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
487                    sb.append(getCreateDate());
488                    sb.append("]]></column-value></column>");
489                    sb.append(
490                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
491                    sb.append(getModifiedDate());
492                    sb.append("]]></column-value></column>");
493                    sb.append(
494                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
495                    sb.append(getClassNameId());
496                    sb.append("]]></column-value></column>");
497                    sb.append(
498                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
499                    sb.append(getClassPK());
500                    sb.append("]]></column-value></column>");
501                    sb.append(
502                            "<column><column-name>props</column-name><column-value><![CDATA[");
503                    sb.append(getProps());
504                    sb.append("]]></column-value></column>");
505    
506                    sb.append("</model>");
507    
508                    return sb.toString();
509            }
510    
511            private static ClassLoader _classLoader = WebDAVProps.class.getClassLoader();
512            private static Class<?>[] _escapedModelInterfaces = new Class[] {
513                            WebDAVProps.class
514                    };
515            private long _webDavPropsId;
516            private long _companyId;
517            private Date _createDate;
518            private Date _modifiedDate;
519            private long _classNameId;
520            private long _originalClassNameId;
521            private boolean _setOriginalClassNameId;
522            private long _classPK;
523            private long _originalClassPK;
524            private boolean _setOriginalClassPK;
525            private String _props;
526            private long _columnBitmask;
527            private WebDAVProps _escapedModel;
528    }