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.TagsEntry;
31  import com.liferay.portlet.tags.model.TagsEntrySoap;
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="TagsEntryModelImpl.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>TagsEntry</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.tags.service.model.TagsEntry
59   * @see com.liferay.portlet.tags.service.model.TagsEntryModel
60   * @see com.liferay.portlet.tags.service.model.impl.TagsEntryImpl
61   *
62   */
63  public class TagsEntryModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "TagsEntry";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "entryId", 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              { "name", new Integer(Types.VARCHAR) }
85          };
86      public static final String TABLE_SQL_CREATE = "create table TagsEntry (entryId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,name VARCHAR(75) null)";
87      public static final String TABLE_SQL_DROP = "drop table TagsEntry";
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.portlet.tags.model.TagsEntry"),
93              true);
94  
95      public static TagsEntry toModel(TagsEntrySoap soapModel) {
96          TagsEntry model = new TagsEntryImpl();
97  
98          model.setEntryId(soapModel.getEntryId());
99          model.setCompanyId(soapModel.getCompanyId());
100         model.setUserId(soapModel.getUserId());
101         model.setUserName(soapModel.getUserName());
102         model.setCreateDate(soapModel.getCreateDate());
103         model.setModifiedDate(soapModel.getModifiedDate());
104         model.setName(soapModel.getName());
105 
106         return model;
107     }
108 
109     public static List<TagsEntry> toModels(TagsEntrySoap[] soapModels) {
110         List<TagsEntry> models = new ArrayList<TagsEntry>(soapModels.length);
111 
112         for (TagsEntrySoap soapModel : soapModels) {
113             models.add(toModel(soapModel));
114         }
115 
116         return models;
117     }
118 
119     public static final boolean CACHE_ENABLED_TAGSASSETS_TAGSENTRIES = com.liferay.portlet.tags.model.impl.TagsAssetModelImpl.CACHE_ENABLED_TAGSASSETS_TAGSENTRIES;
120     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
121                 "lock.expiration.time.com.liferay.portlet.tags.model.TagsEntry"));
122 
123     public TagsEntryModelImpl() {
124     }
125 
126     public long getPrimaryKey() {
127         return _entryId;
128     }
129 
130     public void setPrimaryKey(long pk) {
131         setEntryId(pk);
132     }
133 
134     public Serializable getPrimaryKeyObj() {
135         return new Long(_entryId);
136     }
137 
138     public long getEntryId() {
139         return _entryId;
140     }
141 
142     public void setEntryId(long entryId) {
143         if (entryId != _entryId) {
144             _entryId = entryId;
145         }
146     }
147 
148     public long getCompanyId() {
149         return _companyId;
150     }
151 
152     public void setCompanyId(long companyId) {
153         if (companyId != _companyId) {
154             _companyId = companyId;
155         }
156     }
157 
158     public long getUserId() {
159         return _userId;
160     }
161 
162     public void setUserId(long userId) {
163         if (userId != _userId) {
164             _userId = userId;
165         }
166     }
167 
168     public String getUserName() {
169         return GetterUtil.getString(_userName);
170     }
171 
172     public void setUserName(String userName) {
173         if (((userName == null) && (_userName != null)) ||
174                 ((userName != null) && (_userName == null)) ||
175                 ((userName != null) && (_userName != null) &&
176                 !userName.equals(_userName))) {
177             _userName = userName;
178         }
179     }
180 
181     public Date getCreateDate() {
182         return _createDate;
183     }
184 
185     public void setCreateDate(Date createDate) {
186         if (((createDate == null) && (_createDate != null)) ||
187                 ((createDate != null) && (_createDate == null)) ||
188                 ((createDate != null) && (_createDate != null) &&
189                 !createDate.equals(_createDate))) {
190             _createDate = createDate;
191         }
192     }
193 
194     public Date getModifiedDate() {
195         return _modifiedDate;
196     }
197 
198     public void setModifiedDate(Date modifiedDate) {
199         if (((modifiedDate == null) && (_modifiedDate != null)) ||
200                 ((modifiedDate != null) && (_modifiedDate == null)) ||
201                 ((modifiedDate != null) && (_modifiedDate != null) &&
202                 !modifiedDate.equals(_modifiedDate))) {
203             _modifiedDate = modifiedDate;
204         }
205     }
206 
207     public String getName() {
208         return GetterUtil.getString(_name);
209     }
210 
211     public void setName(String name) {
212         if (((name == null) && (_name != null)) ||
213                 ((name != null) && (_name == null)) ||
214                 ((name != null) && (_name != null) && !name.equals(_name))) {
215             _name = name;
216         }
217     }
218 
219     public TagsEntry toEscapedModel() {
220         if (isEscapedModel()) {
221             return (TagsEntry)this;
222         }
223         else {
224             TagsEntry model = new TagsEntryImpl();
225 
226             model.setEscapedModel(true);
227 
228             model.setEntryId(getEntryId());
229             model.setCompanyId(getCompanyId());
230             model.setUserId(getUserId());
231             model.setUserName(HtmlUtil.escape(getUserName()));
232             model.setCreateDate(getCreateDate());
233             model.setModifiedDate(getModifiedDate());
234             model.setName(HtmlUtil.escape(getName()));
235 
236             model = (TagsEntry)Proxy.newProxyInstance(TagsEntry.class.getClassLoader(),
237                     new Class[] { TagsEntry.class },
238                     new ReadOnlyBeanHandler(model));
239 
240             return model;
241         }
242     }
243 
244     public Object clone() {
245         TagsEntryImpl clone = new TagsEntryImpl();
246 
247         clone.setEntryId(getEntryId());
248         clone.setCompanyId(getCompanyId());
249         clone.setUserId(getUserId());
250         clone.setUserName(getUserName());
251         clone.setCreateDate(getCreateDate());
252         clone.setModifiedDate(getModifiedDate());
253         clone.setName(getName());
254 
255         return clone;
256     }
257 
258     public int compareTo(Object obj) {
259         if (obj == null) {
260             return -1;
261         }
262 
263         TagsEntryImpl tagsEntry = (TagsEntryImpl)obj;
264 
265         int value = 0;
266 
267         value = getName().compareTo(tagsEntry.getName());
268 
269         if (value != 0) {
270             return value;
271         }
272 
273         return 0;
274     }
275 
276     public boolean equals(Object obj) {
277         if (obj == null) {
278             return false;
279         }
280 
281         TagsEntryImpl tagsEntry = null;
282 
283         try {
284             tagsEntry = (TagsEntryImpl)obj;
285         }
286         catch (ClassCastException cce) {
287             return false;
288         }
289 
290         long pk = tagsEntry.getPrimaryKey();
291 
292         if (getPrimaryKey() == pk) {
293             return true;
294         }
295         else {
296             return false;
297         }
298     }
299 
300     public int hashCode() {
301         return (int)getPrimaryKey();
302     }
303 
304     private long _entryId;
305     private long _companyId;
306     private long _userId;
307     private String _userName;
308     private Date _createDate;
309     private Date _modifiedDate;
310     private String _name;
311 }