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 {
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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
95                  "value.object.finder.cache.enabled.com.liferay.portal.model.WebDAVProps"),
96              true);
97  
98      public static WebDAVProps toModel(WebDAVPropsSoap soapModel) {
99          WebDAVProps model = new WebDAVPropsImpl();
100 
101         model.setWebDavPropsId(soapModel.getWebDavPropsId());
102         model.setCompanyId(soapModel.getCompanyId());
103         model.setCreateDate(soapModel.getCreateDate());
104         model.setModifiedDate(soapModel.getModifiedDate());
105         model.setClassNameId(soapModel.getClassNameId());
106         model.setClassPK(soapModel.getClassPK());
107         model.setProps(soapModel.getProps());
108 
109         return model;
110     }
111 
112     public static List<WebDAVProps> toModels(WebDAVPropsSoap[] soapModels) {
113         List<WebDAVProps> models = new ArrayList<WebDAVProps>(soapModels.length);
114 
115         for (WebDAVPropsSoap soapModel : soapModels) {
116             models.add(toModel(soapModel));
117         }
118 
119         return models;
120     }
121 
122     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
123                 "lock.expiration.time.com.liferay.portal.model.WebDAVProps"));
124 
125     public WebDAVPropsModelImpl() {
126     }
127 
128     public long getPrimaryKey() {
129         return _webDavPropsId;
130     }
131 
132     public void setPrimaryKey(long pk) {
133         setWebDavPropsId(pk);
134     }
135 
136     public Serializable getPrimaryKeyObj() {
137         return new Long(_webDavPropsId);
138     }
139 
140     public long getWebDavPropsId() {
141         return _webDavPropsId;
142     }
143 
144     public void setWebDavPropsId(long webDavPropsId) {
145         if (webDavPropsId != _webDavPropsId) {
146             _webDavPropsId = webDavPropsId;
147         }
148     }
149 
150     public long getCompanyId() {
151         return _companyId;
152     }
153 
154     public void setCompanyId(long companyId) {
155         if (companyId != _companyId) {
156             _companyId = companyId;
157         }
158     }
159 
160     public Date getCreateDate() {
161         return _createDate;
162     }
163 
164     public void setCreateDate(Date createDate) {
165         if (((createDate == null) && (_createDate != null)) ||
166                 ((createDate != null) && (_createDate == null)) ||
167                 ((createDate != null) && (_createDate != null) &&
168                 !createDate.equals(_createDate))) {
169             _createDate = createDate;
170         }
171     }
172 
173     public Date getModifiedDate() {
174         return _modifiedDate;
175     }
176 
177     public void setModifiedDate(Date modifiedDate) {
178         if (((modifiedDate == null) && (_modifiedDate != null)) ||
179                 ((modifiedDate != null) && (_modifiedDate == null)) ||
180                 ((modifiedDate != null) && (_modifiedDate != null) &&
181                 !modifiedDate.equals(_modifiedDate))) {
182             _modifiedDate = modifiedDate;
183         }
184     }
185 
186     public String getClassName() {
187         if (getClassNameId() <= 0) {
188             return StringPool.BLANK;
189         }
190 
191         return PortalUtil.getClassName(getClassNameId());
192     }
193 
194     public long getClassNameId() {
195         return _classNameId;
196     }
197 
198     public void setClassNameId(long classNameId) {
199         if (classNameId != _classNameId) {
200             _classNameId = classNameId;
201         }
202     }
203 
204     public long getClassPK() {
205         return _classPK;
206     }
207 
208     public void setClassPK(long classPK) {
209         if (classPK != _classPK) {
210             _classPK = classPK;
211         }
212     }
213 
214     public String getProps() {
215         return GetterUtil.getString(_props);
216     }
217 
218     public void setProps(String props) {
219         if (((props == null) && (_props != null)) ||
220                 ((props != null) && (_props == null)) ||
221                 ((props != null) && (_props != null) && !props.equals(_props))) {
222             _props = props;
223         }
224     }
225 
226     public WebDAVProps toEscapedModel() {
227         if (isEscapedModel()) {
228             return (WebDAVProps)this;
229         }
230         else {
231             WebDAVProps model = new WebDAVPropsImpl();
232 
233             model.setNew(isNew());
234             model.setEscapedModel(true);
235 
236             model.setWebDavPropsId(getWebDavPropsId());
237             model.setCompanyId(getCompanyId());
238             model.setCreateDate(getCreateDate());
239             model.setModifiedDate(getModifiedDate());
240             model.setClassNameId(getClassNameId());
241             model.setClassPK(getClassPK());
242             model.setProps(HtmlUtil.escape(getProps()));
243 
244             model = (WebDAVProps)Proxy.newProxyInstance(WebDAVProps.class.getClassLoader(),
245                     new Class[] { WebDAVProps.class },
246                     new ReadOnlyBeanHandler(model));
247 
248             return model;
249         }
250     }
251 
252     public ExpandoBridge getExpandoBridge() {
253         if (_expandoBridge == null) {
254             _expandoBridge = new ExpandoBridgeImpl(WebDAVProps.class.getName(),
255                     getPrimaryKey());
256         }
257 
258         return _expandoBridge;
259     }
260 
261     public Object clone() {
262         WebDAVPropsImpl clone = new WebDAVPropsImpl();
263 
264         clone.setWebDavPropsId(getWebDavPropsId());
265         clone.setCompanyId(getCompanyId());
266         clone.setCreateDate(getCreateDate());
267         clone.setModifiedDate(getModifiedDate());
268         clone.setClassNameId(getClassNameId());
269         clone.setClassPK(getClassPK());
270         clone.setProps(getProps());
271 
272         return clone;
273     }
274 
275     public int compareTo(Object obj) {
276         if (obj == null) {
277             return -1;
278         }
279 
280         WebDAVPropsImpl webDAVProps = (WebDAVPropsImpl)obj;
281 
282         long pk = webDAVProps.getPrimaryKey();
283 
284         if (getPrimaryKey() < pk) {
285             return -1;
286         }
287         else if (getPrimaryKey() > pk) {
288             return 1;
289         }
290         else {
291             return 0;
292         }
293     }
294 
295     public boolean equals(Object obj) {
296         if (obj == null) {
297             return false;
298         }
299 
300         WebDAVPropsImpl webDAVProps = null;
301 
302         try {
303             webDAVProps = (WebDAVPropsImpl)obj;
304         }
305         catch (ClassCastException cce) {
306             return false;
307         }
308 
309         long pk = webDAVProps.getPrimaryKey();
310 
311         if (getPrimaryKey() == pk) {
312             return true;
313         }
314         else {
315             return false;
316         }
317     }
318 
319     public int hashCode() {
320         return (int)getPrimaryKey();
321     }
322 
323     private long _webDavPropsId;
324     private long _companyId;
325     private Date _createDate;
326     private Date _modifiedDate;
327     private long _classNameId;
328     private long _classPK;
329     private String _props;
330     private transient ExpandoBridge _expandoBridge;
331 }