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