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