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.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.tags.model.TagsEntry;
33  import com.liferay.portlet.tags.model.TagsEntrySoap;
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="TagsEntryModelImpl.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>TagsEntry</code> table
55   * in the database.
56   * </p>
57   *
58   * @author Brian Wing Shun Chan
59   *
60   * @see com.liferay.portlet.tags.model.TagsEntry
61   * @see com.liferay.portlet.tags.model.TagsEntryModel
62   * @see com.liferay.portlet.tags.model.impl.TagsEntryImpl
63   *
64   */
65  public class TagsEntryModelImpl extends BaseModelImpl<TagsEntry> {
66      public static final String TABLE_NAME = "TagsEntry";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "entryId", 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              { "name", new Integer(Types.VARCHAR) }
87          };
88      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)";
89      public static final String TABLE_SQL_DROP = "drop table TagsEntry";
90      public static final String DATA_SOURCE = "liferayDataSource";
91      public static final String SESSION_FACTORY = "liferaySessionFactory";
92      public static final String TX_MANAGER = "liferayTransactionManager";
93      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
94                  "value.object.entity.cache.enabled.com.liferay.portlet.tags.model.TagsEntry"),
95              true);
96      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
97                  "value.object.finder.cache.enabled.com.liferay.portlet.tags.model.TagsEntry"),
98              true);
99  
100     public static TagsEntry toModel(TagsEntrySoap soapModel) {
101         TagsEntry model = new TagsEntryImpl();
102 
103         model.setEntryId(soapModel.getEntryId());
104         model.setCompanyId(soapModel.getCompanyId());
105         model.setUserId(soapModel.getUserId());
106         model.setUserName(soapModel.getUserName());
107         model.setCreateDate(soapModel.getCreateDate());
108         model.setModifiedDate(soapModel.getModifiedDate());
109         model.setName(soapModel.getName());
110 
111         return model;
112     }
113 
114     public static List<TagsEntry> toModels(TagsEntrySoap[] soapModels) {
115         List<TagsEntry> models = new ArrayList<TagsEntry>(soapModels.length);
116 
117         for (TagsEntrySoap soapModel : soapModels) {
118             models.add(toModel(soapModel));
119         }
120 
121         return models;
122     }
123 
124     public static final boolean FINDER_CACHE_ENABLED_TAGSASSETS_TAGSENTRIES = com.liferay.portlet.tags.model.impl.TagsAssetModelImpl.FINDER_CACHE_ENABLED_TAGSASSETS_TAGSENTRIES;
125     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
126                 "lock.expiration.time.com.liferay.portlet.tags.model.TagsEntry"));
127 
128     public TagsEntryModelImpl() {
129     }
130 
131     public long getPrimaryKey() {
132         return _entryId;
133     }
134 
135     public void setPrimaryKey(long pk) {
136         setEntryId(pk);
137     }
138 
139     public Serializable getPrimaryKeyObj() {
140         return new Long(_entryId);
141     }
142 
143     public long getEntryId() {
144         return _entryId;
145     }
146 
147     public void setEntryId(long entryId) {
148         _entryId = entryId;
149     }
150 
151     public long getCompanyId() {
152         return _companyId;
153     }
154 
155     public void setCompanyId(long companyId) {
156         _companyId = companyId;
157 
158         if (!_setOriginalCompanyId) {
159             _setOriginalCompanyId = true;
160 
161             _originalCompanyId = companyId;
162         }
163     }
164 
165     public long getOriginalCompanyId() {
166         return _originalCompanyId;
167     }
168 
169     public long getUserId() {
170         return _userId;
171     }
172 
173     public void setUserId(long userId) {
174         _userId = userId;
175     }
176 
177     public String getUserUuid() throws SystemException {
178         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
179     }
180 
181     public void setUserUuid(String userUuid) {
182         _userUuid = userUuid;
183     }
184 
185     public String getUserName() {
186         return GetterUtil.getString(_userName);
187     }
188 
189     public void setUserName(String userName) {
190         _userName = userName;
191     }
192 
193     public Date getCreateDate() {
194         return _createDate;
195     }
196 
197     public void setCreateDate(Date createDate) {
198         _createDate = createDate;
199     }
200 
201     public Date getModifiedDate() {
202         return _modifiedDate;
203     }
204 
205     public void setModifiedDate(Date modifiedDate) {
206         _modifiedDate = modifiedDate;
207     }
208 
209     public String getName() {
210         return GetterUtil.getString(_name);
211     }
212 
213     public void setName(String name) {
214         _name = name;
215 
216         if (_originalName == null) {
217             _originalName = name;
218         }
219     }
220 
221     public String getOriginalName() {
222         return GetterUtil.getString(_originalName);
223     }
224 
225     public TagsEntry toEscapedModel() {
226         if (isEscapedModel()) {
227             return (TagsEntry)this;
228         }
229         else {
230             TagsEntry model = new TagsEntryImpl();
231 
232             model.setNew(isNew());
233             model.setEscapedModel(true);
234 
235             model.setEntryId(getEntryId());
236             model.setCompanyId(getCompanyId());
237             model.setUserId(getUserId());
238             model.setUserName(HtmlUtil.escape(getUserName()));
239             model.setCreateDate(getCreateDate());
240             model.setModifiedDate(getModifiedDate());
241             model.setName(HtmlUtil.escape(getName()));
242 
243             model = (TagsEntry)Proxy.newProxyInstance(TagsEntry.class.getClassLoader(),
244                     new Class[] { TagsEntry.class },
245                     new ReadOnlyBeanHandler(model));
246 
247             return model;
248         }
249     }
250 
251     public Object clone() {
252         TagsEntryImpl clone = new TagsEntryImpl();
253 
254         clone.setEntryId(getEntryId());
255         clone.setCompanyId(getCompanyId());
256         clone.setUserId(getUserId());
257         clone.setUserName(getUserName());
258         clone.setCreateDate(getCreateDate());
259         clone.setModifiedDate(getModifiedDate());
260         clone.setName(getName());
261 
262         return clone;
263     }
264 
265     public int compareTo(TagsEntry tagsEntry) {
266         int value = 0;
267 
268         value = getName().compareTo(tagsEntry.getName());
269 
270         if (value != 0) {
271             return value;
272         }
273 
274         return 0;
275     }
276 
277     public boolean equals(Object obj) {
278         if (obj == null) {
279             return false;
280         }
281 
282         TagsEntry tagsEntry = null;
283 
284         try {
285             tagsEntry = (TagsEntry)obj;
286         }
287         catch (ClassCastException cce) {
288             return false;
289         }
290 
291         long pk = tagsEntry.getPrimaryKey();
292 
293         if (getPrimaryKey() == pk) {
294             return true;
295         }
296         else {
297             return false;
298         }
299     }
300 
301     public int hashCode() {
302         return (int)getPrimaryKey();
303     }
304 
305     public String toString() {
306         StringBuilder sb = new StringBuilder();
307 
308         sb.append("{entryId=");
309         sb.append(getEntryId());
310         sb.append(", companyId=");
311         sb.append(getCompanyId());
312         sb.append(", userId=");
313         sb.append(getUserId());
314         sb.append(", userName=");
315         sb.append(getUserName());
316         sb.append(", createDate=");
317         sb.append(getCreateDate());
318         sb.append(", modifiedDate=");
319         sb.append(getModifiedDate());
320         sb.append(", name=");
321         sb.append(getName());
322         sb.append("}");
323 
324         return sb.toString();
325     }
326 
327     public String toXmlString() {
328         StringBuilder sb = new StringBuilder();
329 
330         sb.append("<model><model-name>");
331         sb.append("com.liferay.portlet.tags.model.TagsEntry");
332         sb.append("</model-name>");
333 
334         sb.append(
335             "<column><column-name>entryId</column-name><column-value><![CDATA[");
336         sb.append(getEntryId());
337         sb.append("]]></column-value></column>");
338         sb.append(
339             "<column><column-name>companyId</column-name><column-value><![CDATA[");
340         sb.append(getCompanyId());
341         sb.append("]]></column-value></column>");
342         sb.append(
343             "<column><column-name>userId</column-name><column-value><![CDATA[");
344         sb.append(getUserId());
345         sb.append("]]></column-value></column>");
346         sb.append(
347             "<column><column-name>userName</column-name><column-value><![CDATA[");
348         sb.append(getUserName());
349         sb.append("]]></column-value></column>");
350         sb.append(
351             "<column><column-name>createDate</column-name><column-value><![CDATA[");
352         sb.append(getCreateDate());
353         sb.append("]]></column-value></column>");
354         sb.append(
355             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
356         sb.append(getModifiedDate());
357         sb.append("]]></column-value></column>");
358         sb.append(
359             "<column><column-name>name</column-name><column-value><![CDATA[");
360         sb.append(getName());
361         sb.append("]]></column-value></column>");
362 
363         sb.append("</model>");
364 
365         return sb.toString();
366     }
367 
368     private long _entryId;
369     private long _companyId;
370     private long _originalCompanyId;
371     private boolean _setOriginalCompanyId;
372     private long _userId;
373     private String _userUuid;
374     private String _userName;
375     private Date _createDate;
376     private Date _modifiedDate;
377     private String _name;
378     private String _originalName;
379 }