1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.kernel.util.StringBundler;
29  import com.liferay.portal.kernel.util.StringPool;
30  import com.liferay.portal.model.WebDAVProps;
31  import com.liferay.portal.model.WebDAVPropsSoap;
32  import com.liferay.portal.service.ServiceContext;
33  import com.liferay.portal.util.PortalUtil;
34  
35  import com.liferay.portlet.expando.model.ExpandoBridge;
36  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
37  
38  import java.io.Serializable;
39  
40  import java.lang.reflect.Proxy;
41  
42  import java.sql.Types;
43  
44  import java.util.ArrayList;
45  import java.util.Date;
46  import java.util.List;
47  
48  /**
49   * <a href="WebDAVPropsModelImpl.java.html"><b><i>View Source</i></b></a>
50   *
51   * <p>
52   * ServiceBuilder generated this class. Modifications in this class will be
53   * overwritten the next time is generated.
54   * </p>
55   *
56   * <p>
57   * This interface is a model that represents the WebDAVProps table in the
58   * database.
59   * </p>
60   *
61   * @author    Brian Wing Shun Chan
62   * @see       WebDAVPropsImpl
63   * @see       com.liferay.portal.model.WebDAVProps
64   * @see       com.liferay.portal.model.WebDAVPropsModel
65   * @generated
66   */
67  public class WebDAVPropsModelImpl extends BaseModelImpl<WebDAVProps> {
68      public static final String TABLE_NAME = "WebDAVProps";
69      public static final Object[][] TABLE_COLUMNS = {
70              { "webDavPropsId", new Integer(Types.BIGINT) },
71              { "companyId", new Integer(Types.BIGINT) },
72              { "createDate", new Integer(Types.TIMESTAMP) },
73              { "modifiedDate", new Integer(Types.TIMESTAMP) },
74              { "classNameId", new Integer(Types.BIGINT) },
75              { "classPK", new Integer(Types.BIGINT) },
76              { "props", new Integer(Types.CLOB) }
77          };
78      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)";
79      public static final String TABLE_SQL_DROP = "drop table WebDAVProps";
80      public static final String DATA_SOURCE = "liferayDataSource";
81      public static final String SESSION_FACTORY = "liferaySessionFactory";
82      public static final String TX_MANAGER = "liferayTransactionManager";
83      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
84                  "value.object.entity.cache.enabled.com.liferay.portal.model.WebDAVProps"),
85              true);
86      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
87                  "value.object.finder.cache.enabled.com.liferay.portal.model.WebDAVProps"),
88              true);
89  
90      public static WebDAVProps toModel(WebDAVPropsSoap soapModel) {
91          WebDAVProps model = new WebDAVPropsImpl();
92  
93          model.setWebDavPropsId(soapModel.getWebDavPropsId());
94          model.setCompanyId(soapModel.getCompanyId());
95          model.setCreateDate(soapModel.getCreateDate());
96          model.setModifiedDate(soapModel.getModifiedDate());
97          model.setClassNameId(soapModel.getClassNameId());
98          model.setClassPK(soapModel.getClassPK());
99          model.setProps(soapModel.getProps());
100 
101         return model;
102     }
103 
104     public static List<WebDAVProps> toModels(WebDAVPropsSoap[] soapModels) {
105         List<WebDAVProps> models = new ArrayList<WebDAVProps>(soapModels.length);
106 
107         for (WebDAVPropsSoap soapModel : soapModels) {
108             models.add(toModel(soapModel));
109         }
110 
111         return models;
112     }
113 
114     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
115                 "lock.expiration.time.com.liferay.portal.model.WebDAVProps"));
116 
117     public WebDAVPropsModelImpl() {
118     }
119 
120     public long getPrimaryKey() {
121         return _webDavPropsId;
122     }
123 
124     public void setPrimaryKey(long pk) {
125         setWebDavPropsId(pk);
126     }
127 
128     public Serializable getPrimaryKeyObj() {
129         return new Long(_webDavPropsId);
130     }
131 
132     public long getWebDavPropsId() {
133         return _webDavPropsId;
134     }
135 
136     public void setWebDavPropsId(long webDavPropsId) {
137         _webDavPropsId = webDavPropsId;
138     }
139 
140     public long getCompanyId() {
141         return _companyId;
142     }
143 
144     public void setCompanyId(long companyId) {
145         _companyId = companyId;
146     }
147 
148     public Date getCreateDate() {
149         return _createDate;
150     }
151 
152     public void setCreateDate(Date createDate) {
153         _createDate = createDate;
154     }
155 
156     public Date getModifiedDate() {
157         return _modifiedDate;
158     }
159 
160     public void setModifiedDate(Date modifiedDate) {
161         _modifiedDate = modifiedDate;
162     }
163 
164     public String getClassName() {
165         if (getClassNameId() <= 0) {
166             return StringPool.BLANK;
167         }
168 
169         return PortalUtil.getClassName(getClassNameId());
170     }
171 
172     public long getClassNameId() {
173         return _classNameId;
174     }
175 
176     public void setClassNameId(long classNameId) {
177         _classNameId = classNameId;
178 
179         if (!_setOriginalClassNameId) {
180             _setOriginalClassNameId = true;
181 
182             _originalClassNameId = classNameId;
183         }
184     }
185 
186     public long getOriginalClassNameId() {
187         return _originalClassNameId;
188     }
189 
190     public long getClassPK() {
191         return _classPK;
192     }
193 
194     public void setClassPK(long classPK) {
195         _classPK = classPK;
196 
197         if (!_setOriginalClassPK) {
198             _setOriginalClassPK = true;
199 
200             _originalClassPK = classPK;
201         }
202     }
203 
204     public long getOriginalClassPK() {
205         return _originalClassPK;
206     }
207 
208     public String getProps() {
209         return GetterUtil.getString(_props);
210     }
211 
212     public void setProps(String props) {
213         _props = props;
214     }
215 
216     public WebDAVProps toEscapedModel() {
217         if (isEscapedModel()) {
218             return (WebDAVProps)this;
219         }
220         else {
221             WebDAVProps model = new WebDAVPropsImpl();
222 
223             model.setNew(isNew());
224             model.setEscapedModel(true);
225 
226             model.setWebDavPropsId(getWebDavPropsId());
227             model.setCompanyId(getCompanyId());
228             model.setCreateDate(getCreateDate());
229             model.setModifiedDate(getModifiedDate());
230             model.setClassNameId(getClassNameId());
231             model.setClassPK(getClassPK());
232             model.setProps(HtmlUtil.escape(getProps()));
233 
234             model = (WebDAVProps)Proxy.newProxyInstance(WebDAVProps.class.getClassLoader(),
235                     new Class[] { WebDAVProps.class },
236                     new ReadOnlyBeanHandler(model));
237 
238             return model;
239         }
240     }
241 
242     public ExpandoBridge getExpandoBridge() {
243         if (_expandoBridge == null) {
244             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(WebDAVProps.class.getName(),
245                     getPrimaryKey());
246         }
247 
248         return _expandoBridge;
249     }
250 
251     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
252         getExpandoBridge().setAttributes(serviceContext);
253     }
254 
255     public Object clone() {
256         WebDAVPropsImpl clone = new WebDAVPropsImpl();
257 
258         clone.setWebDavPropsId(getWebDavPropsId());
259         clone.setCompanyId(getCompanyId());
260         clone.setCreateDate(getCreateDate());
261         clone.setModifiedDate(getModifiedDate());
262         clone.setClassNameId(getClassNameId());
263         clone.setClassPK(getClassPK());
264         clone.setProps(getProps());
265 
266         return clone;
267     }
268 
269     public int compareTo(WebDAVProps webDAVProps) {
270         long pk = webDAVProps.getPrimaryKey();
271 
272         if (getPrimaryKey() < pk) {
273             return -1;
274         }
275         else if (getPrimaryKey() > pk) {
276             return 1;
277         }
278         else {
279             return 0;
280         }
281     }
282 
283     public boolean equals(Object obj) {
284         if (obj == null) {
285             return false;
286         }
287 
288         WebDAVProps webDAVProps = null;
289 
290         try {
291             webDAVProps = (WebDAVProps)obj;
292         }
293         catch (ClassCastException cce) {
294             return false;
295         }
296 
297         long pk = webDAVProps.getPrimaryKey();
298 
299         if (getPrimaryKey() == pk) {
300             return true;
301         }
302         else {
303             return false;
304         }
305     }
306 
307     public int hashCode() {
308         return (int)getPrimaryKey();
309     }
310 
311     public String toString() {
312         StringBundler sb = new StringBundler(15);
313 
314         sb.append("{webDavPropsId=");
315         sb.append(getWebDavPropsId());
316         sb.append(", companyId=");
317         sb.append(getCompanyId());
318         sb.append(", createDate=");
319         sb.append(getCreateDate());
320         sb.append(", modifiedDate=");
321         sb.append(getModifiedDate());
322         sb.append(", classNameId=");
323         sb.append(getClassNameId());
324         sb.append(", classPK=");
325         sb.append(getClassPK());
326         sb.append(", props=");
327         sb.append(getProps());
328         sb.append("}");
329 
330         return sb.toString();
331     }
332 
333     public String toXmlString() {
334         StringBundler sb = new StringBundler(25);
335 
336         sb.append("<model><model-name>");
337         sb.append("com.liferay.portal.model.WebDAVProps");
338         sb.append("</model-name>");
339 
340         sb.append(
341             "<column><column-name>webDavPropsId</column-name><column-value><![CDATA[");
342         sb.append(getWebDavPropsId());
343         sb.append("]]></column-value></column>");
344         sb.append(
345             "<column><column-name>companyId</column-name><column-value><![CDATA[");
346         sb.append(getCompanyId());
347         sb.append("]]></column-value></column>");
348         sb.append(
349             "<column><column-name>createDate</column-name><column-value><![CDATA[");
350         sb.append(getCreateDate());
351         sb.append("]]></column-value></column>");
352         sb.append(
353             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
354         sb.append(getModifiedDate());
355         sb.append("]]></column-value></column>");
356         sb.append(
357             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
358         sb.append(getClassNameId());
359         sb.append("]]></column-value></column>");
360         sb.append(
361             "<column><column-name>classPK</column-name><column-value><![CDATA[");
362         sb.append(getClassPK());
363         sb.append("]]></column-value></column>");
364         sb.append(
365             "<column><column-name>props</column-name><column-value><![CDATA[");
366         sb.append(getProps());
367         sb.append("]]></column-value></column>");
368 
369         sb.append("</model>");
370 
371         return sb.toString();
372     }
373 
374     private long _webDavPropsId;
375     private long _companyId;
376     private Date _createDate;
377     private Date _modifiedDate;
378     private long _classNameId;
379     private long _originalClassNameId;
380     private boolean _setOriginalClassNameId;
381     private long _classPK;
382     private long _originalClassPK;
383     private boolean _setOriginalClassPK;
384     private String _props;
385     private transient ExpandoBridge _expandoBridge;
386 }