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