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