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.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 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.model.WebDAVProps
59   * @see com.liferay.portal.model.WebDAVPropsModel
60   * @see com.liferay.portal.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 String DATA_SOURCE = "liferayDataSource";
89      public static final String SESSION_FACTORY = "liferaySessionFactory";
90      public static final String TX_MANAGER = "liferayTransactionManager";
91      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
92                  "value.object.finder.cache.enabled.com.liferay.portal.model.WebDAVProps"),
93              true);
94  
95      public static WebDAVProps toModel(WebDAVPropsSoap soapModel) {
96          WebDAVProps model = new WebDAVPropsImpl();
97  
98          model.setWebDavPropsId(soapModel.getWebDavPropsId());
99          model.setCompanyId(soapModel.getCompanyId());
100         model.setCreateDate(soapModel.getCreateDate());
101         model.setModifiedDate(soapModel.getModifiedDate());
102         model.setClassNameId(soapModel.getClassNameId());
103         model.setClassPK(soapModel.getClassPK());
104         model.setProps(soapModel.getProps());
105 
106         return model;
107     }
108 
109     public static List<WebDAVProps> toModels(WebDAVPropsSoap[] soapModels) {
110         List<WebDAVProps> models = new ArrayList<WebDAVProps>(soapModels.length);
111 
112         for (WebDAVPropsSoap soapModel : soapModels) {
113             models.add(toModel(soapModel));
114         }
115 
116         return models;
117     }
118 
119     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
120                 "lock.expiration.time.com.liferay.portal.model.WebDAVProps"));
121 
122     public WebDAVPropsModelImpl() {
123     }
124 
125     public long getPrimaryKey() {
126         return _webDavPropsId;
127     }
128 
129     public void setPrimaryKey(long pk) {
130         setWebDavPropsId(pk);
131     }
132 
133     public Serializable getPrimaryKeyObj() {
134         return new Long(_webDavPropsId);
135     }
136 
137     public long getWebDavPropsId() {
138         return _webDavPropsId;
139     }
140 
141     public void setWebDavPropsId(long webDavPropsId) {
142         if (webDavPropsId != _webDavPropsId) {
143             _webDavPropsId = webDavPropsId;
144         }
145     }
146 
147     public long getCompanyId() {
148         return _companyId;
149     }
150 
151     public void setCompanyId(long companyId) {
152         if (companyId != _companyId) {
153             _companyId = companyId;
154         }
155     }
156 
157     public Date getCreateDate() {
158         return _createDate;
159     }
160 
161     public void setCreateDate(Date createDate) {
162         if (((createDate == null) && (_createDate != null)) ||
163                 ((createDate != null) && (_createDate == null)) ||
164                 ((createDate != null) && (_createDate != null) &&
165                 !createDate.equals(_createDate))) {
166             _createDate = createDate;
167         }
168     }
169 
170     public Date getModifiedDate() {
171         return _modifiedDate;
172     }
173 
174     public void setModifiedDate(Date modifiedDate) {
175         if (((modifiedDate == null) && (_modifiedDate != null)) ||
176                 ((modifiedDate != null) && (_modifiedDate == null)) ||
177                 ((modifiedDate != null) && (_modifiedDate != null) &&
178                 !modifiedDate.equals(_modifiedDate))) {
179             _modifiedDate = modifiedDate;
180         }
181     }
182 
183     public String getClassName() {
184         if (getClassNameId() <= 0) {
185             return StringPool.BLANK;
186         }
187 
188         return PortalUtil.getClassName(getClassNameId());
189     }
190 
191     public long getClassNameId() {
192         return _classNameId;
193     }
194 
195     public void setClassNameId(long classNameId) {
196         if (classNameId != _classNameId) {
197             _classNameId = classNameId;
198         }
199     }
200 
201     public long getClassPK() {
202         return _classPK;
203     }
204 
205     public void setClassPK(long classPK) {
206         if (classPK != _classPK) {
207             _classPK = classPK;
208         }
209     }
210 
211     public String getProps() {
212         return GetterUtil.getString(_props);
213     }
214 
215     public void setProps(String props) {
216         if (((props == null) && (_props != null)) ||
217                 ((props != null) && (_props == null)) ||
218                 ((props != null) && (_props != null) && !props.equals(_props))) {
219             _props = props;
220         }
221     }
222 
223     public WebDAVProps toEscapedModel() {
224         if (isEscapedModel()) {
225             return (WebDAVProps)this;
226         }
227         else {
228             WebDAVProps model = new WebDAVPropsImpl();
229 
230             model.setNew(isNew());
231             model.setEscapedModel(true);
232 
233             model.setWebDavPropsId(getWebDavPropsId());
234             model.setCompanyId(getCompanyId());
235             model.setCreateDate(getCreateDate());
236             model.setModifiedDate(getModifiedDate());
237             model.setClassNameId(getClassNameId());
238             model.setClassPK(getClassPK());
239             model.setProps(HtmlUtil.escape(getProps()));
240 
241             model = (WebDAVProps)Proxy.newProxyInstance(WebDAVProps.class.getClassLoader(),
242                     new Class[] { WebDAVProps.class },
243                     new ReadOnlyBeanHandler(model));
244 
245             return model;
246         }
247     }
248 
249     public Object clone() {
250         WebDAVPropsImpl clone = new WebDAVPropsImpl();
251 
252         clone.setWebDavPropsId(getWebDavPropsId());
253         clone.setCompanyId(getCompanyId());
254         clone.setCreateDate(getCreateDate());
255         clone.setModifiedDate(getModifiedDate());
256         clone.setClassNameId(getClassNameId());
257         clone.setClassPK(getClassPK());
258         clone.setProps(getProps());
259 
260         return clone;
261     }
262 
263     public int compareTo(Object obj) {
264         if (obj == null) {
265             return -1;
266         }
267 
268         WebDAVPropsImpl webDAVProps = (WebDAVPropsImpl)obj;
269 
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         WebDAVPropsImpl webDAVProps = null;
289 
290         try {
291             webDAVProps = (WebDAVPropsImpl)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     private long _webDavPropsId;
312     private long _companyId;
313     private Date _createDate;
314     private Date _modifiedDate;
315     private long _classNameId;
316     private long _classPK;
317     private String _props;
318 }