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 DATA_SOURCE = "liferayDataSource";
073            public static final String SESSION_FACTORY = "liferaySessionFactory";
074            public static final String TX_MANAGER = "liferayTransactionManager";
075            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.entity.cache.enabled.com.liferay.portal.model.WebDAVProps"),
077                            true);
078            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.finder.cache.enabled.com.liferay.portal.model.WebDAVProps"),
080                            true);
081            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.WebDAVProps"),
083                            true);
084            public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
085            public static long CLASSPK_COLUMN_BITMASK = 2L;
086            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
087                                    "lock.expiration.time.com.liferay.portal.model.WebDAVProps"));
088    
089            public WebDAVPropsModelImpl() {
090            }
091    
092            public long getPrimaryKey() {
093                    return _webDavPropsId;
094            }
095    
096            public void setPrimaryKey(long primaryKey) {
097                    setWebDavPropsId(primaryKey);
098            }
099    
100            public Serializable getPrimaryKeyObj() {
101                    return new Long(_webDavPropsId);
102            }
103    
104            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
105                    setPrimaryKey(((Long)primaryKeyObj).longValue());
106            }
107    
108            public Class<?> getModelClass() {
109                    return WebDAVProps.class;
110            }
111    
112            public String getModelClassName() {
113                    return WebDAVProps.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("webDavPropsId", getWebDavPropsId());
121                    attributes.put("companyId", getCompanyId());
122                    attributes.put("createDate", getCreateDate());
123                    attributes.put("modifiedDate", getModifiedDate());
124                    attributes.put("classNameId", getClassNameId());
125                    attributes.put("classPK", getClassPK());
126                    attributes.put("props", getProps());
127    
128                    return attributes;
129            }
130    
131            @Override
132            public void setModelAttributes(Map<String, Object> attributes) {
133                    Long webDavPropsId = (Long)attributes.get("webDavPropsId");
134    
135                    if (webDavPropsId != null) {
136                            setWebDavPropsId(webDavPropsId);
137                    }
138    
139                    Long companyId = (Long)attributes.get("companyId");
140    
141                    if (companyId != null) {
142                            setCompanyId(companyId);
143                    }
144    
145                    Date createDate = (Date)attributes.get("createDate");
146    
147                    if (createDate != null) {
148                            setCreateDate(createDate);
149                    }
150    
151                    Date modifiedDate = (Date)attributes.get("modifiedDate");
152    
153                    if (modifiedDate != null) {
154                            setModifiedDate(modifiedDate);
155                    }
156    
157                    Long classNameId = (Long)attributes.get("classNameId");
158    
159                    if (classNameId != null) {
160                            setClassNameId(classNameId);
161                    }
162    
163                    Long classPK = (Long)attributes.get("classPK");
164    
165                    if (classPK != null) {
166                            setClassPK(classPK);
167                    }
168    
169                    String props = (String)attributes.get("props");
170    
171                    if (props != null) {
172                            setProps(props);
173                    }
174            }
175    
176            public long getWebDavPropsId() {
177                    return _webDavPropsId;
178            }
179    
180            public void setWebDavPropsId(long webDavPropsId) {
181                    _webDavPropsId = webDavPropsId;
182            }
183    
184            public long getCompanyId() {
185                    return _companyId;
186            }
187    
188            public void setCompanyId(long companyId) {
189                    _companyId = companyId;
190            }
191    
192            public Date getCreateDate() {
193                    return _createDate;
194            }
195    
196            public void setCreateDate(Date createDate) {
197                    _createDate = createDate;
198            }
199    
200            public Date getModifiedDate() {
201                    return _modifiedDate;
202            }
203    
204            public void setModifiedDate(Date modifiedDate) {
205                    _modifiedDate = modifiedDate;
206            }
207    
208            public String getClassName() {
209                    if (getClassNameId() <= 0) {
210                            return StringPool.BLANK;
211                    }
212    
213                    return PortalUtil.getClassName(getClassNameId());
214            }
215    
216            public void setClassName(String className) {
217                    long classNameId = 0;
218    
219                    if (Validator.isNotNull(className)) {
220                            classNameId = PortalUtil.getClassNameId(className);
221                    }
222    
223                    setClassNameId(classNameId);
224            }
225    
226            public long getClassNameId() {
227                    return _classNameId;
228            }
229    
230            public void setClassNameId(long classNameId) {
231                    _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
232    
233                    if (!_setOriginalClassNameId) {
234                            _setOriginalClassNameId = true;
235    
236                            _originalClassNameId = _classNameId;
237                    }
238    
239                    _classNameId = classNameId;
240            }
241    
242            public long getOriginalClassNameId() {
243                    return _originalClassNameId;
244            }
245    
246            public long getClassPK() {
247                    return _classPK;
248            }
249    
250            public void setClassPK(long classPK) {
251                    _columnBitmask |= CLASSPK_COLUMN_BITMASK;
252    
253                    if (!_setOriginalClassPK) {
254                            _setOriginalClassPK = true;
255    
256                            _originalClassPK = _classPK;
257                    }
258    
259                    _classPK = classPK;
260            }
261    
262            public long getOriginalClassPK() {
263                    return _originalClassPK;
264            }
265    
266            public String getProps() {
267                    if (_props == null) {
268                            return StringPool.BLANK;
269                    }
270                    else {
271                            return _props;
272                    }
273            }
274    
275            public void setProps(String props) {
276                    _props = props;
277            }
278    
279            public long getColumnBitmask() {
280                    return _columnBitmask;
281            }
282    
283            @Override
284            public ExpandoBridge getExpandoBridge() {
285                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
286                            WebDAVProps.class.getName(), getPrimaryKey());
287            }
288    
289            @Override
290            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
291                    ExpandoBridge expandoBridge = getExpandoBridge();
292    
293                    expandoBridge.setAttributes(serviceContext);
294            }
295    
296            @Override
297            public WebDAVProps toEscapedModel() {
298                    if (_escapedModel == null) {
299                            _escapedModel = (WebDAVProps)ProxyUtil.newProxyInstance(_classLoader,
300                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
301                    }
302    
303                    return _escapedModel;
304            }
305    
306            public WebDAVProps toUnescapedModel() {
307                    return (WebDAVProps)this;
308            }
309    
310            @Override
311            public Object clone() {
312                    WebDAVPropsImpl webDAVPropsImpl = new WebDAVPropsImpl();
313    
314                    webDAVPropsImpl.setWebDavPropsId(getWebDavPropsId());
315                    webDAVPropsImpl.setCompanyId(getCompanyId());
316                    webDAVPropsImpl.setCreateDate(getCreateDate());
317                    webDAVPropsImpl.setModifiedDate(getModifiedDate());
318                    webDAVPropsImpl.setClassNameId(getClassNameId());
319                    webDAVPropsImpl.setClassPK(getClassPK());
320                    webDAVPropsImpl.setProps(getProps());
321    
322                    webDAVPropsImpl.resetOriginalValues();
323    
324                    return webDAVPropsImpl;
325            }
326    
327            public int compareTo(WebDAVProps webDAVProps) {
328                    long primaryKey = webDAVProps.getPrimaryKey();
329    
330                    if (getPrimaryKey() < primaryKey) {
331                            return -1;
332                    }
333                    else if (getPrimaryKey() > primaryKey) {
334                            return 1;
335                    }
336                    else {
337                            return 0;
338                    }
339            }
340    
341            @Override
342            public boolean equals(Object obj) {
343                    if (this == obj) {
344                            return true;
345                    }
346    
347                    if (!(obj instanceof WebDAVProps)) {
348                            return false;
349                    }
350    
351                    WebDAVProps webDAVProps = (WebDAVProps)obj;
352    
353                    long primaryKey = webDAVProps.getPrimaryKey();
354    
355                    if (getPrimaryKey() == primaryKey) {
356                            return true;
357                    }
358                    else {
359                            return false;
360                    }
361            }
362    
363            @Override
364            public int hashCode() {
365                    return (int)getPrimaryKey();
366            }
367    
368            @Override
369            public void resetOriginalValues() {
370                    WebDAVPropsModelImpl webDAVPropsModelImpl = this;
371    
372                    webDAVPropsModelImpl._originalClassNameId = webDAVPropsModelImpl._classNameId;
373    
374                    webDAVPropsModelImpl._setOriginalClassNameId = false;
375    
376                    webDAVPropsModelImpl._originalClassPK = webDAVPropsModelImpl._classPK;
377    
378                    webDAVPropsModelImpl._setOriginalClassPK = false;
379    
380                    webDAVPropsModelImpl._columnBitmask = 0;
381            }
382    
383            @Override
384            public CacheModel<WebDAVProps> toCacheModel() {
385                    WebDAVPropsCacheModel webDAVPropsCacheModel = new WebDAVPropsCacheModel();
386    
387                    webDAVPropsCacheModel.webDavPropsId = getWebDavPropsId();
388    
389                    webDAVPropsCacheModel.companyId = getCompanyId();
390    
391                    Date createDate = getCreateDate();
392    
393                    if (createDate != null) {
394                            webDAVPropsCacheModel.createDate = createDate.getTime();
395                    }
396                    else {
397                            webDAVPropsCacheModel.createDate = Long.MIN_VALUE;
398                    }
399    
400                    Date modifiedDate = getModifiedDate();
401    
402                    if (modifiedDate != null) {
403                            webDAVPropsCacheModel.modifiedDate = modifiedDate.getTime();
404                    }
405                    else {
406                            webDAVPropsCacheModel.modifiedDate = Long.MIN_VALUE;
407                    }
408    
409                    webDAVPropsCacheModel.classNameId = getClassNameId();
410    
411                    webDAVPropsCacheModel.classPK = getClassPK();
412    
413                    webDAVPropsCacheModel.props = getProps();
414    
415                    String props = webDAVPropsCacheModel.props;
416    
417                    if ((props != null) && (props.length() == 0)) {
418                            webDAVPropsCacheModel.props = null;
419                    }
420    
421                    return webDAVPropsCacheModel;
422            }
423    
424            @Override
425            public String toString() {
426                    StringBundler sb = new StringBundler(15);
427    
428                    sb.append("{webDavPropsId=");
429                    sb.append(getWebDavPropsId());
430                    sb.append(", companyId=");
431                    sb.append(getCompanyId());
432                    sb.append(", createDate=");
433                    sb.append(getCreateDate());
434                    sb.append(", modifiedDate=");
435                    sb.append(getModifiedDate());
436                    sb.append(", classNameId=");
437                    sb.append(getClassNameId());
438                    sb.append(", classPK=");
439                    sb.append(getClassPK());
440                    sb.append(", props=");
441                    sb.append(getProps());
442                    sb.append("}");
443    
444                    return sb.toString();
445            }
446    
447            public String toXmlString() {
448                    StringBundler sb = new StringBundler(25);
449    
450                    sb.append("<model><model-name>");
451                    sb.append("com.liferay.portal.model.WebDAVProps");
452                    sb.append("</model-name>");
453    
454                    sb.append(
455                            "<column><column-name>webDavPropsId</column-name><column-value><![CDATA[");
456                    sb.append(getWebDavPropsId());
457                    sb.append("]]></column-value></column>");
458                    sb.append(
459                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
460                    sb.append(getCompanyId());
461                    sb.append("]]></column-value></column>");
462                    sb.append(
463                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
464                    sb.append(getCreateDate());
465                    sb.append("]]></column-value></column>");
466                    sb.append(
467                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
468                    sb.append(getModifiedDate());
469                    sb.append("]]></column-value></column>");
470                    sb.append(
471                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
472                    sb.append(getClassNameId());
473                    sb.append("]]></column-value></column>");
474                    sb.append(
475                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
476                    sb.append(getClassPK());
477                    sb.append("]]></column-value></column>");
478                    sb.append(
479                            "<column><column-name>props</column-name><column-value><![CDATA[");
480                    sb.append(getProps());
481                    sb.append("]]></column-value></column>");
482    
483                    sb.append("</model>");
484    
485                    return sb.toString();
486            }
487    
488            private static ClassLoader _classLoader = WebDAVProps.class.getClassLoader();
489            private static Class<?>[] _escapedModelInterfaces = new Class[] {
490                            WebDAVProps.class
491                    };
492            private long _webDavPropsId;
493            private long _companyId;
494            private Date _createDate;
495            private Date _modifiedDate;
496            private long _classNameId;
497            private long _originalClassNameId;
498            private boolean _setOriginalClassNameId;
499            private long _classPK;
500            private long _originalClassPK;
501            private boolean _setOriginalClassPK;
502            private String _props;
503            private long _columnBitmask;
504            private WebDAVProps _escapedModel;
505    }