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