1   /**
2    * Copyright (c) 2000-2008 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.model.WebDAVProps;
29  import com.liferay.portal.model.WebDAVPropsSoap;
30  import com.liferay.portal.util.PortalUtil;
31  import com.liferay.portal.util.PropsUtil;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.Date;
41  import java.util.List;
42  
43  /**
44   * <a href="WebDAVPropsModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>WebDAVProps</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portal.service.model.WebDAVProps
59   * @see com.liferay.portal.service.model.WebDAVPropsModel
60   * @see com.liferay.portal.service.model.impl.WebDAVPropsImpl
61   *
62   */
63  public class WebDAVPropsModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "WebDAVProps";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "webDavPropsId", new Integer(Types.BIGINT) },
67              
68  
69              { "companyId", new Integer(Types.BIGINT) },
70              
71  
72              { "createDate", new Integer(Types.TIMESTAMP) },
73              
74  
75              { "modifiedDate", new Integer(Types.TIMESTAMP) },
76              
77  
78              { "classNameId", new Integer(Types.BIGINT) },
79              
80  
81              { "classPK", new Integer(Types.BIGINT) },
82              
83  
84              { "props", new Integer(Types.CLOB) }
85          };
86      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)";
87      public static final String TABLE_SQL_DROP = "drop table WebDAVProps";
88      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
89                  "value.object.finder.cache.enabled.com.liferay.portal.model.WebDAVProps"),
90              true);
91  
92      public static WebDAVProps toModel(WebDAVPropsSoap soapModel) {
93          WebDAVProps model = new WebDAVPropsImpl();
94  
95          model.setWebDavPropsId(soapModel.getWebDavPropsId());
96          model.setCompanyId(soapModel.getCompanyId());
97          model.setCreateDate(soapModel.getCreateDate());
98          model.setModifiedDate(soapModel.getModifiedDate());
99          model.setClassNameId(soapModel.getClassNameId());
100         model.setClassPK(soapModel.getClassPK());
101         model.setProps(soapModel.getProps());
102 
103         return model;
104     }
105 
106     public static List<WebDAVProps> toModels(WebDAVPropsSoap[] soapModels) {
107         List<WebDAVProps> models = new ArrayList<WebDAVProps>(soapModels.length);
108 
109         for (WebDAVPropsSoap soapModel : soapModels) {
110             models.add(toModel(soapModel));
111         }
112 
113         return models;
114     }
115 
116     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
117                 "lock.expiration.time.com.liferay.portal.model.WebDAVProps"));
118 
119     public WebDAVPropsModelImpl() {
120     }
121 
122     public long getPrimaryKey() {
123         return _webDavPropsId;
124     }
125 
126     public void setPrimaryKey(long pk) {
127         setWebDavPropsId(pk);
128     }
129 
130     public Serializable getPrimaryKeyObj() {
131         return new Long(_webDavPropsId);
132     }
133 
134     public long getWebDavPropsId() {
135         return _webDavPropsId;
136     }
137 
138     public void setWebDavPropsId(long webDavPropsId) {
139         if (webDavPropsId != _webDavPropsId) {
140             _webDavPropsId = webDavPropsId;
141         }
142     }
143 
144     public long getCompanyId() {
145         return _companyId;
146     }
147 
148     public void setCompanyId(long companyId) {
149         if (companyId != _companyId) {
150             _companyId = companyId;
151         }
152     }
153 
154     public Date getCreateDate() {
155         return _createDate;
156     }
157 
158     public void setCreateDate(Date createDate) {
159         if (((createDate == null) && (_createDate != null)) ||
160                 ((createDate != null) && (_createDate == null)) ||
161                 ((createDate != null) && (_createDate != null) &&
162                 !createDate.equals(_createDate))) {
163             _createDate = createDate;
164         }
165     }
166 
167     public Date getModifiedDate() {
168         return _modifiedDate;
169     }
170 
171     public void setModifiedDate(Date modifiedDate) {
172         if (((modifiedDate == null) && (_modifiedDate != null)) ||
173                 ((modifiedDate != null) && (_modifiedDate == null)) ||
174                 ((modifiedDate != null) && (_modifiedDate != null) &&
175                 !modifiedDate.equals(_modifiedDate))) {
176             _modifiedDate = modifiedDate;
177         }
178     }
179 
180     public String getClassName() {
181         return PortalUtil.getClassName(getClassNameId());
182     }
183 
184     public long getClassNameId() {
185         return _classNameId;
186     }
187 
188     public void setClassNameId(long classNameId) {
189         if (classNameId != _classNameId) {
190             _classNameId = classNameId;
191         }
192     }
193 
194     public long getClassPK() {
195         return _classPK;
196     }
197 
198     public void setClassPK(long classPK) {
199         if (classPK != _classPK) {
200             _classPK = classPK;
201         }
202     }
203 
204     public String getProps() {
205         return GetterUtil.getString(_props);
206     }
207 
208     public void setProps(String props) {
209         if (((props == null) && (_props != null)) ||
210                 ((props != null) && (_props == null)) ||
211                 ((props != null) && (_props != null) && !props.equals(_props))) {
212             _props = props;
213         }
214     }
215 
216     public WebDAVProps toEscapedModel() {
217         if (isEscapedModel()) {
218             return (WebDAVProps)this;
219         }
220         else {
221             WebDAVProps model = new WebDAVPropsImpl();
222 
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 Object clone() {
242         WebDAVPropsImpl clone = new WebDAVPropsImpl();
243 
244         clone.setWebDavPropsId(getWebDavPropsId());
245         clone.setCompanyId(getCompanyId());
246         clone.setCreateDate(getCreateDate());
247         clone.setModifiedDate(getModifiedDate());
248         clone.setClassNameId(getClassNameId());
249         clone.setClassPK(getClassPK());
250         clone.setProps(getProps());
251 
252         return clone;
253     }
254 
255     public int compareTo(Object obj) {
256         if (obj == null) {
257             return -1;
258         }
259 
260         WebDAVPropsImpl webDAVProps = (WebDAVPropsImpl)obj;
261 
262         long pk = webDAVProps.getPrimaryKey();
263 
264         if (getPrimaryKey() < pk) {
265             return -1;
266         }
267         else if (getPrimaryKey() > pk) {
268             return 1;
269         }
270         else {
271             return 0;
272         }
273     }
274 
275     public boolean equals(Object obj) {
276         if (obj == null) {
277             return false;
278         }
279 
280         WebDAVPropsImpl webDAVProps = null;
281 
282         try {
283             webDAVProps = (WebDAVPropsImpl)obj;
284         }
285         catch (ClassCastException cce) {
286             return false;
287         }
288 
289         long pk = webDAVProps.getPrimaryKey();
290 
291         if (getPrimaryKey() == pk) {
292             return true;
293         }
294         else {
295             return false;
296         }
297     }
298 
299     public int hashCode() {
300         return (int)getPrimaryKey();
301     }
302 
303     private long _webDavPropsId;
304     private long _companyId;
305     private Date _createDate;
306     private Date _modifiedDate;
307     private long _classNameId;
308     private long _classPK;
309     private String _props;
310 }