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.StringPool;
29  import com.liferay.portal.model.WebDAVProps;
30  import com.liferay.portal.model.WebDAVPropsSoap;
31  import com.liferay.portal.util.PortalUtil;
32  
33  import com.liferay.portlet.expando.model.ExpandoBridge;
34  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
35  
36  import java.io.Serializable;
37  
38  import java.lang.reflect.Proxy;
39  
40  import java.sql.Types;
41  
42  import java.util.ArrayList;
43  import java.util.Date;
44  import java.util.List;
45  
46  /**
47   * <a href="WebDAVPropsModelImpl.java.html"><b><i>View Source</i></b></a>
48   *
49   * <p>
50   * ServiceBuilder generated this class. Modifications in this class will be
51   * overwritten the next time is generated.
52   * </p>
53   *
54   * <p>
55   * This class is a model that represents the <code>WebDAVProps</code> table
56   * in the database.
57   * </p>
58   *
59   * @author Brian Wing Shun Chan
60   *
61   * @see com.liferay.portal.model.WebDAVProps
62   * @see com.liferay.portal.model.WebDAVPropsModel
63   * @see com.liferay.portal.model.impl.WebDAVPropsImpl
64   *
65   */
66  public class WebDAVPropsModelImpl extends BaseModelImpl<WebDAVProps> {
67      public static final String TABLE_NAME = "WebDAVProps";
68      public static final Object[][] TABLE_COLUMNS = {
69              { "webDavPropsId", new Integer(Types.BIGINT) },
70              
71  
72              { "companyId", new Integer(Types.BIGINT) },
73              
74  
75              { "createDate", new Integer(Types.TIMESTAMP) },
76              
77  
78              { "modifiedDate", new Integer(Types.TIMESTAMP) },
79              
80  
81              { "classNameId", new Integer(Types.BIGINT) },
82              
83  
84              { "classPK", new Integer(Types.BIGINT) },
85              
86  
87              { "props", new Integer(Types.CLOB) }
88          };
89      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)";
90      public static final String TABLE_SQL_DROP = "drop table WebDAVProps";
91      public static final String DATA_SOURCE = "liferayDataSource";
92      public static final String SESSION_FACTORY = "liferaySessionFactory";
93      public static final String TX_MANAGER = "liferayTransactionManager";
94      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
95                  "value.object.entity.cache.enabled.com.liferay.portal.model.WebDAVProps"),
96              true);
97      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
98                  "value.object.finder.cache.enabled.com.liferay.portal.model.WebDAVProps"),
99              true);
100 
101     public static WebDAVProps toModel(WebDAVPropsSoap soapModel) {
102         WebDAVProps model = new WebDAVPropsImpl();
103 
104         model.setWebDavPropsId(soapModel.getWebDavPropsId());
105         model.setCompanyId(soapModel.getCompanyId());
106         model.setCreateDate(soapModel.getCreateDate());
107         model.setModifiedDate(soapModel.getModifiedDate());
108         model.setClassNameId(soapModel.getClassNameId());
109         model.setClassPK(soapModel.getClassPK());
110         model.setProps(soapModel.getProps());
111 
112         return model;
113     }
114 
115     public static List<WebDAVProps> toModels(WebDAVPropsSoap[] soapModels) {
116         List<WebDAVProps> models = new ArrayList<WebDAVProps>(soapModels.length);
117 
118         for (WebDAVPropsSoap soapModel : soapModels) {
119             models.add(toModel(soapModel));
120         }
121 
122         return models;
123     }
124 
125     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
126                 "lock.expiration.time.com.liferay.portal.model.WebDAVProps"));
127 
128     public WebDAVPropsModelImpl() {
129     }
130 
131     public long getPrimaryKey() {
132         return _webDavPropsId;
133     }
134 
135     public void setPrimaryKey(long pk) {
136         setWebDavPropsId(pk);
137     }
138 
139     public Serializable getPrimaryKeyObj() {
140         return new Long(_webDavPropsId);
141     }
142 
143     public long getWebDavPropsId() {
144         return _webDavPropsId;
145     }
146 
147     public void setWebDavPropsId(long webDavPropsId) {
148         _webDavPropsId = webDavPropsId;
149     }
150 
151     public long getCompanyId() {
152         return _companyId;
153     }
154 
155     public void setCompanyId(long companyId) {
156         _companyId = companyId;
157     }
158 
159     public Date getCreateDate() {
160         return _createDate;
161     }
162 
163     public void setCreateDate(Date createDate) {
164         _createDate = createDate;
165     }
166 
167     public Date getModifiedDate() {
168         return _modifiedDate;
169     }
170 
171     public void setModifiedDate(Date modifiedDate) {
172         _modifiedDate = modifiedDate;
173     }
174 
175     public String getClassName() {
176         if (getClassNameId() <= 0) {
177             return StringPool.BLANK;
178         }
179 
180         return PortalUtil.getClassName(getClassNameId());
181     }
182 
183     public long getClassNameId() {
184         return _classNameId;
185     }
186 
187     public void setClassNameId(long classNameId) {
188         _classNameId = classNameId;
189 
190         if (!_setOriginalClassNameId) {
191             _setOriginalClassNameId = true;
192 
193             _originalClassNameId = classNameId;
194         }
195     }
196 
197     public long getOriginalClassNameId() {
198         return _originalClassNameId;
199     }
200 
201     public long getClassPK() {
202         return _classPK;
203     }
204 
205     public void setClassPK(long classPK) {
206         _classPK = classPK;
207 
208         if (!_setOriginalClassPK) {
209             _setOriginalClassPK = true;
210 
211             _originalClassPK = classPK;
212         }
213     }
214 
215     public long getOriginalClassPK() {
216         return _originalClassPK;
217     }
218 
219     public String getProps() {
220         return GetterUtil.getString(_props);
221     }
222 
223     public void setProps(String props) {
224         _props = props;
225     }
226 
227     public WebDAVProps toEscapedModel() {
228         if (isEscapedModel()) {
229             return (WebDAVProps)this;
230         }
231         else {
232             WebDAVProps model = new WebDAVPropsImpl();
233 
234             model.setNew(isNew());
235             model.setEscapedModel(true);
236 
237             model.setWebDavPropsId(getWebDavPropsId());
238             model.setCompanyId(getCompanyId());
239             model.setCreateDate(getCreateDate());
240             model.setModifiedDate(getModifiedDate());
241             model.setClassNameId(getClassNameId());
242             model.setClassPK(getClassPK());
243             model.setProps(HtmlUtil.escape(getProps()));
244 
245             model = (WebDAVProps)Proxy.newProxyInstance(WebDAVProps.class.getClassLoader(),
246                     new Class[] { WebDAVProps.class },
247                     new ReadOnlyBeanHandler(model));
248 
249             return model;
250         }
251     }
252 
253     public ExpandoBridge getExpandoBridge() {
254         if (_expandoBridge == null) {
255             _expandoBridge = new ExpandoBridgeImpl(WebDAVProps.class.getName(),
256                     getPrimaryKey());
257         }
258 
259         return _expandoBridge;
260     }
261 
262     public Object clone() {
263         WebDAVPropsImpl clone = new WebDAVPropsImpl();
264 
265         clone.setWebDavPropsId(getWebDavPropsId());
266         clone.setCompanyId(getCompanyId());
267         clone.setCreateDate(getCreateDate());
268         clone.setModifiedDate(getModifiedDate());
269         clone.setClassNameId(getClassNameId());
270         clone.setClassPK(getClassPK());
271         clone.setProps(getProps());
272 
273         return clone;
274     }
275 
276     public int compareTo(WebDAVProps webDAVProps) {
277         long pk = webDAVProps.getPrimaryKey();
278 
279         if (getPrimaryKey() < pk) {
280             return -1;
281         }
282         else if (getPrimaryKey() > pk) {
283             return 1;
284         }
285         else {
286             return 0;
287         }
288     }
289 
290     public boolean equals(Object obj) {
291         if (obj == null) {
292             return false;
293         }
294 
295         WebDAVProps webDAVProps = null;
296 
297         try {
298             webDAVProps = (WebDAVProps)obj;
299         }
300         catch (ClassCastException cce) {
301             return false;
302         }
303 
304         long pk = webDAVProps.getPrimaryKey();
305 
306         if (getPrimaryKey() == pk) {
307             return true;
308         }
309         else {
310             return false;
311         }
312     }
313 
314     public int hashCode() {
315         return (int)getPrimaryKey();
316     }
317 
318     public String toString() {
319         StringBuilder sb = new StringBuilder();
320 
321         sb.append("{webDavPropsId=");
322         sb.append(getWebDavPropsId());
323         sb.append(", companyId=");
324         sb.append(getCompanyId());
325         sb.append(", createDate=");
326         sb.append(getCreateDate());
327         sb.append(", modifiedDate=");
328         sb.append(getModifiedDate());
329         sb.append(", classNameId=");
330         sb.append(getClassNameId());
331         sb.append(", classPK=");
332         sb.append(getClassPK());
333         sb.append(", props=");
334         sb.append(getProps());
335         sb.append("}");
336 
337         return sb.toString();
338     }
339 
340     public String toXmlString() {
341         StringBuilder sb = new StringBuilder();
342 
343         sb.append("<model><model-name>");
344         sb.append("com.liferay.portal.model.WebDAVProps");
345         sb.append("</model-name>");
346 
347         sb.append(
348             "<column><column-name>webDavPropsId</column-name><column-value><![CDATA[");
349         sb.append(getWebDavPropsId());
350         sb.append("]]></column-value></column>");
351         sb.append(
352             "<column><column-name>companyId</column-name><column-value><![CDATA[");
353         sb.append(getCompanyId());
354         sb.append("]]></column-value></column>");
355         sb.append(
356             "<column><column-name>createDate</column-name><column-value><![CDATA[");
357         sb.append(getCreateDate());
358         sb.append("]]></column-value></column>");
359         sb.append(
360             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
361         sb.append(getModifiedDate());
362         sb.append("]]></column-value></column>");
363         sb.append(
364             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
365         sb.append(getClassNameId());
366         sb.append("]]></column-value></column>");
367         sb.append(
368             "<column><column-name>classPK</column-name><column-value><![CDATA[");
369         sb.append(getClassPK());
370         sb.append("]]></column-value></column>");
371         sb.append(
372             "<column><column-name>props</column-name><column-value><![CDATA[");
373         sb.append(getProps());
374         sb.append("]]></column-value></column>");
375 
376         sb.append("</model>");
377 
378         return sb.toString();
379     }
380 
381     private long _webDavPropsId;
382     private long _companyId;
383     private Date _createDate;
384     private Date _modifiedDate;
385     private long _classNameId;
386     private long _originalClassNameId;
387     private boolean _setOriginalClassNameId;
388     private long _classPK;
389     private long _originalClassPK;
390     private boolean _setOriginalClassPK;
391     private String _props;
392     private transient ExpandoBridge _expandoBridge;
393 }