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