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