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.portlet.tags.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.impl.BaseModelImpl;
29  import com.liferay.portal.util.PropsUtil;
30  
31  import com.liferay.portlet.tags.model.TagsProperty;
32  import com.liferay.portlet.tags.model.TagsPropertySoap;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.Date;
42  import java.util.List;
43  
44  /**
45   * <a href="TagsPropertyModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>TagsProperty</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portlet.tags.service.model.TagsProperty
60   * @see com.liferay.portlet.tags.service.model.TagsPropertyModel
61   * @see com.liferay.portlet.tags.service.model.impl.TagsPropertyImpl
62   *
63   */
64  public class TagsPropertyModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "TagsProperty";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "propertyId", new Integer(Types.BIGINT) },
68              
69  
70              { "companyId", new Integer(Types.BIGINT) },
71              
72  
73              { "userId", new Integer(Types.BIGINT) },
74              
75  
76              { "userName", new Integer(Types.VARCHAR) },
77              
78  
79              { "createDate", new Integer(Types.TIMESTAMP) },
80              
81  
82              { "modifiedDate", new Integer(Types.TIMESTAMP) },
83              
84  
85              { "entryId", new Integer(Types.BIGINT) },
86              
87  
88              { "key_", new Integer(Types.VARCHAR) },
89              
90  
91              { "value", new Integer(Types.VARCHAR) }
92          };
93      public static final String TABLE_SQL_CREATE = "create table TagsProperty (propertyId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,entryId LONG,key_ VARCHAR(75) null,value VARCHAR(300) null)";
94      public static final String TABLE_SQL_DROP = "drop table TagsProperty";
95      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
96                  "value.object.finder.cache.enabled.com.liferay.portlet.tags.model.TagsProperty"),
97              true);
98  
99      public static TagsProperty toModel(TagsPropertySoap soapModel) {
100         TagsProperty model = new TagsPropertyImpl();
101 
102         model.setPropertyId(soapModel.getPropertyId());
103         model.setCompanyId(soapModel.getCompanyId());
104         model.setUserId(soapModel.getUserId());
105         model.setUserName(soapModel.getUserName());
106         model.setCreateDate(soapModel.getCreateDate());
107         model.setModifiedDate(soapModel.getModifiedDate());
108         model.setEntryId(soapModel.getEntryId());
109         model.setKey(soapModel.getKey());
110         model.setValue(soapModel.getValue());
111 
112         return model;
113     }
114 
115     public static List<TagsProperty> toModels(TagsPropertySoap[] soapModels) {
116         List<TagsProperty> models = new ArrayList<TagsProperty>(soapModels.length);
117 
118         for (TagsPropertySoap soapModel : soapModels) {
119             models.add(toModel(soapModel));
120         }
121 
122         return models;
123     }
124 
125     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
126                 "lock.expiration.time.com.liferay.portlet.tags.model.TagsProperty"));
127 
128     public TagsPropertyModelImpl() {
129     }
130 
131     public long getPrimaryKey() {
132         return _propertyId;
133     }
134 
135     public void setPrimaryKey(long pk) {
136         setPropertyId(pk);
137     }
138 
139     public Serializable getPrimaryKeyObj() {
140         return new Long(_propertyId);
141     }
142 
143     public long getPropertyId() {
144         return _propertyId;
145     }
146 
147     public void setPropertyId(long propertyId) {
148         if (propertyId != _propertyId) {
149             _propertyId = propertyId;
150         }
151     }
152 
153     public long getCompanyId() {
154         return _companyId;
155     }
156 
157     public void setCompanyId(long companyId) {
158         if (companyId != _companyId) {
159             _companyId = companyId;
160         }
161     }
162 
163     public long getUserId() {
164         return _userId;
165     }
166 
167     public void setUserId(long userId) {
168         if (userId != _userId) {
169             _userId = userId;
170         }
171     }
172 
173     public String getUserName() {
174         return GetterUtil.getString(_userName);
175     }
176 
177     public void setUserName(String userName) {
178         if (((userName == null) && (_userName != null)) ||
179                 ((userName != null) && (_userName == null)) ||
180                 ((userName != null) && (_userName != null) &&
181                 !userName.equals(_userName))) {
182             _userName = userName;
183         }
184     }
185 
186     public Date getCreateDate() {
187         return _createDate;
188     }
189 
190     public void setCreateDate(Date createDate) {
191         if (((createDate == null) && (_createDate != null)) ||
192                 ((createDate != null) && (_createDate == null)) ||
193                 ((createDate != null) && (_createDate != null) &&
194                 !createDate.equals(_createDate))) {
195             _createDate = createDate;
196         }
197     }
198 
199     public Date getModifiedDate() {
200         return _modifiedDate;
201     }
202 
203     public void setModifiedDate(Date modifiedDate) {
204         if (((modifiedDate == null) && (_modifiedDate != null)) ||
205                 ((modifiedDate != null) && (_modifiedDate == null)) ||
206                 ((modifiedDate != null) && (_modifiedDate != null) &&
207                 !modifiedDate.equals(_modifiedDate))) {
208             _modifiedDate = modifiedDate;
209         }
210     }
211 
212     public long getEntryId() {
213         return _entryId;
214     }
215 
216     public void setEntryId(long entryId) {
217         if (entryId != _entryId) {
218             _entryId = entryId;
219         }
220     }
221 
222     public String getKey() {
223         return GetterUtil.getString(_key);
224     }
225 
226     public void setKey(String key) {
227         if (((key == null) && (_key != null)) ||
228                 ((key != null) && (_key == null)) ||
229                 ((key != null) && (_key != null) && !key.equals(_key))) {
230             _key = key;
231         }
232     }
233 
234     public String getValue() {
235         return GetterUtil.getString(_value);
236     }
237 
238     public void setValue(String value) {
239         if (((value == null) && (_value != null)) ||
240                 ((value != null) && (_value == null)) ||
241                 ((value != null) && (_value != null) && !value.equals(_value))) {
242             _value = value;
243         }
244     }
245 
246     public TagsProperty toEscapedModel() {
247         if (isEscapedModel()) {
248             return (TagsProperty)this;
249         }
250         else {
251             TagsProperty model = new TagsPropertyImpl();
252 
253             model.setEscapedModel(true);
254 
255             model.setPropertyId(getPropertyId());
256             model.setCompanyId(getCompanyId());
257             model.setUserId(getUserId());
258             model.setUserName(HtmlUtil.escape(getUserName()));
259             model.setCreateDate(getCreateDate());
260             model.setModifiedDate(getModifiedDate());
261             model.setEntryId(getEntryId());
262             model.setKey(HtmlUtil.escape(getKey()));
263             model.setValue(HtmlUtil.escape(getValue()));
264 
265             model = (TagsProperty)Proxy.newProxyInstance(TagsProperty.class.getClassLoader(),
266                     new Class[] { TagsProperty.class },
267                     new ReadOnlyBeanHandler(model));
268 
269             return model;
270         }
271     }
272 
273     public Object clone() {
274         TagsPropertyImpl clone = new TagsPropertyImpl();
275 
276         clone.setPropertyId(getPropertyId());
277         clone.setCompanyId(getCompanyId());
278         clone.setUserId(getUserId());
279         clone.setUserName(getUserName());
280         clone.setCreateDate(getCreateDate());
281         clone.setModifiedDate(getModifiedDate());
282         clone.setEntryId(getEntryId());
283         clone.setKey(getKey());
284         clone.setValue(getValue());
285 
286         return clone;
287     }
288 
289     public int compareTo(Object obj) {
290         if (obj == null) {
291             return -1;
292         }
293 
294         TagsPropertyImpl tagsProperty = (TagsPropertyImpl)obj;
295 
296         int value = 0;
297 
298         value = getKey().compareTo(tagsProperty.getKey());
299 
300         if (value != 0) {
301             return value;
302         }
303 
304         return 0;
305     }
306 
307     public boolean equals(Object obj) {
308         if (obj == null) {
309             return false;
310         }
311 
312         TagsPropertyImpl tagsProperty = null;
313 
314         try {
315             tagsProperty = (TagsPropertyImpl)obj;
316         }
317         catch (ClassCastException cce) {
318             return false;
319         }
320 
321         long pk = tagsProperty.getPrimaryKey();
322 
323         if (getPrimaryKey() == pk) {
324             return true;
325         }
326         else {
327             return false;
328         }
329     }
330 
331     public int hashCode() {
332         return (int)getPrimaryKey();
333     }
334 
335     private long _propertyId;
336     private long _companyId;
337     private long _userId;
338     private String _userName;
339     private Date _createDate;
340     private Date _modifiedDate;
341     private long _entryId;
342     private String _key;
343     private String _value;
344 }