1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.tags.model.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.HtmlUtil;
21  import com.liferay.portal.kernel.util.StringBundler;
22  import com.liferay.portal.model.impl.BaseModelImpl;
23  import com.liferay.portal.util.PortalUtil;
24  
25  import com.liferay.portlet.tags.model.TagsEntry;
26  import com.liferay.portlet.tags.model.TagsEntrySoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.Date;
36  import java.util.List;
37  
38  /**
39   * <a href="TagsEntryModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This interface is a model that represents the TagsEntry table in the
48   * database.
49   * </p>
50   *
51   * @author    Brian Wing Shun Chan
52   * @see       TagsEntryImpl
53   * @see       com.liferay.portlet.tags.model.TagsEntry
54   * @see       com.liferay.portlet.tags.model.TagsEntryModel
55   * @generated
56   */
57  public class TagsEntryModelImpl extends BaseModelImpl<TagsEntry> {
58      public static final String TABLE_NAME = "TagsEntry";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "entryId", new Integer(Types.BIGINT) },
61              { "companyId", new Integer(Types.BIGINT) },
62              { "userId", new Integer(Types.BIGINT) },
63              { "userName", new Integer(Types.VARCHAR) },
64              { "createDate", new Integer(Types.TIMESTAMP) },
65              { "modifiedDate", new Integer(Types.TIMESTAMP) },
66              { "name", new Integer(Types.VARCHAR) }
67          };
68      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)";
69      public static final String TABLE_SQL_DROP = "drop table TagsEntry";
70      public static final String ORDER_BY_JPQL = " ORDER BY tagsEntry.name ASC";
71      public static final String ORDER_BY_SQL = " ORDER BY TagsEntry.name ASC";
72      public static final String DATA_SOURCE = "liferayDataSource";
73      public static final String SESSION_FACTORY = "liferaySessionFactory";
74      public static final String TX_MANAGER = "liferayTransactionManager";
75      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
76                  "value.object.entity.cache.enabled.com.liferay.portlet.tags.model.TagsEntry"),
77              true);
78      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.finder.cache.enabled.com.liferay.portlet.tags.model.TagsEntry"),
80              true);
81  
82      public static TagsEntry toModel(TagsEntrySoap soapModel) {
83          TagsEntry model = new TagsEntryImpl();
84  
85          model.setEntryId(soapModel.getEntryId());
86          model.setCompanyId(soapModel.getCompanyId());
87          model.setUserId(soapModel.getUserId());
88          model.setUserName(soapModel.getUserName());
89          model.setCreateDate(soapModel.getCreateDate());
90          model.setModifiedDate(soapModel.getModifiedDate());
91          model.setName(soapModel.getName());
92  
93          return model;
94      }
95  
96      public static List<TagsEntry> toModels(TagsEntrySoap[] soapModels) {
97          List<TagsEntry> models = new ArrayList<TagsEntry>(soapModels.length);
98  
99          for (TagsEntrySoap soapModel : soapModels) {
100             models.add(toModel(soapModel));
101         }
102 
103         return models;
104     }
105 
106     public static final String MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME = com.liferay.portlet.tags.model.impl.TagsAssetModelImpl.MAPPING_TABLE_TAGSASSETS_TAGSENTRIES_NAME;
107     public static final boolean FINDER_CACHE_ENABLED_TAGSASSETS_TAGSENTRIES = com.liferay.portlet.tags.model.impl.TagsAssetModelImpl.FINDER_CACHE_ENABLED_TAGSASSETS_TAGSENTRIES;
108     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
109                 "lock.expiration.time.com.liferay.portlet.tags.model.TagsEntry"));
110 
111     public TagsEntryModelImpl() {
112     }
113 
114     public long getPrimaryKey() {
115         return _entryId;
116     }
117 
118     public void setPrimaryKey(long pk) {
119         setEntryId(pk);
120     }
121 
122     public Serializable getPrimaryKeyObj() {
123         return new Long(_entryId);
124     }
125 
126     public long getEntryId() {
127         return _entryId;
128     }
129 
130     public void setEntryId(long entryId) {
131         _entryId = entryId;
132     }
133 
134     public long getCompanyId() {
135         return _companyId;
136     }
137 
138     public void setCompanyId(long companyId) {
139         _companyId = companyId;
140 
141         if (!_setOriginalCompanyId) {
142             _setOriginalCompanyId = true;
143 
144             _originalCompanyId = companyId;
145         }
146     }
147 
148     public long getOriginalCompanyId() {
149         return _originalCompanyId;
150     }
151 
152     public long getUserId() {
153         return _userId;
154     }
155 
156     public void setUserId(long userId) {
157         _userId = userId;
158     }
159 
160     public String getUserUuid() throws SystemException {
161         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
162     }
163 
164     public void setUserUuid(String userUuid) {
165         _userUuid = userUuid;
166     }
167 
168     public String getUserName() {
169         return GetterUtil.getString(_userName);
170     }
171 
172     public void setUserName(String userName) {
173         _userName = userName;
174     }
175 
176     public Date getCreateDate() {
177         return _createDate;
178     }
179 
180     public void setCreateDate(Date createDate) {
181         _createDate = createDate;
182     }
183 
184     public Date getModifiedDate() {
185         return _modifiedDate;
186     }
187 
188     public void setModifiedDate(Date modifiedDate) {
189         _modifiedDate = modifiedDate;
190     }
191 
192     public String getName() {
193         return GetterUtil.getString(_name);
194     }
195 
196     public void setName(String name) {
197         _name = name;
198 
199         if (_originalName == null) {
200             _originalName = name;
201         }
202     }
203 
204     public String getOriginalName() {
205         return GetterUtil.getString(_originalName);
206     }
207 
208     public TagsEntry toEscapedModel() {
209         if (isEscapedModel()) {
210             return (TagsEntry)this;
211         }
212         else {
213             TagsEntry model = new TagsEntryImpl();
214 
215             model.setNew(isNew());
216             model.setEscapedModel(true);
217 
218             model.setEntryId(getEntryId());
219             model.setCompanyId(getCompanyId());
220             model.setUserId(getUserId());
221             model.setUserName(HtmlUtil.escape(getUserName()));
222             model.setCreateDate(getCreateDate());
223             model.setModifiedDate(getModifiedDate());
224             model.setName(HtmlUtil.escape(getName()));
225 
226             model = (TagsEntry)Proxy.newProxyInstance(TagsEntry.class.getClassLoader(),
227                     new Class[] { TagsEntry.class },
228                     new ReadOnlyBeanHandler(model));
229 
230             return model;
231         }
232     }
233 
234     public Object clone() {
235         TagsEntryImpl clone = new TagsEntryImpl();
236 
237         clone.setEntryId(getEntryId());
238         clone.setCompanyId(getCompanyId());
239         clone.setUserId(getUserId());
240         clone.setUserName(getUserName());
241         clone.setCreateDate(getCreateDate());
242         clone.setModifiedDate(getModifiedDate());
243         clone.setName(getName());
244 
245         return clone;
246     }
247 
248     public int compareTo(TagsEntry tagsEntry) {
249         int value = 0;
250 
251         value = getName().compareTo(tagsEntry.getName());
252 
253         if (value != 0) {
254             return value;
255         }
256 
257         return 0;
258     }
259 
260     public boolean equals(Object obj) {
261         if (obj == null) {
262             return false;
263         }
264 
265         TagsEntry tagsEntry = null;
266 
267         try {
268             tagsEntry = (TagsEntry)obj;
269         }
270         catch (ClassCastException cce) {
271             return false;
272         }
273 
274         long pk = tagsEntry.getPrimaryKey();
275 
276         if (getPrimaryKey() == pk) {
277             return true;
278         }
279         else {
280             return false;
281         }
282     }
283 
284     public int hashCode() {
285         return (int)getPrimaryKey();
286     }
287 
288     public String toString() {
289         StringBundler sb = new StringBundler(15);
290 
291         sb.append("{entryId=");
292         sb.append(getEntryId());
293         sb.append(", companyId=");
294         sb.append(getCompanyId());
295         sb.append(", userId=");
296         sb.append(getUserId());
297         sb.append(", userName=");
298         sb.append(getUserName());
299         sb.append(", createDate=");
300         sb.append(getCreateDate());
301         sb.append(", modifiedDate=");
302         sb.append(getModifiedDate());
303         sb.append(", name=");
304         sb.append(getName());
305         sb.append("}");
306 
307         return sb.toString();
308     }
309 
310     public String toXmlString() {
311         StringBundler sb = new StringBundler(25);
312 
313         sb.append("<model><model-name>");
314         sb.append("com.liferay.portlet.tags.model.TagsEntry");
315         sb.append("</model-name>");
316 
317         sb.append(
318             "<column><column-name>entryId</column-name><column-value><![CDATA[");
319         sb.append(getEntryId());
320         sb.append("]]></column-value></column>");
321         sb.append(
322             "<column><column-name>companyId</column-name><column-value><![CDATA[");
323         sb.append(getCompanyId());
324         sb.append("]]></column-value></column>");
325         sb.append(
326             "<column><column-name>userId</column-name><column-value><![CDATA[");
327         sb.append(getUserId());
328         sb.append("]]></column-value></column>");
329         sb.append(
330             "<column><column-name>userName</column-name><column-value><![CDATA[");
331         sb.append(getUserName());
332         sb.append("]]></column-value></column>");
333         sb.append(
334             "<column><column-name>createDate</column-name><column-value><![CDATA[");
335         sb.append(getCreateDate());
336         sb.append("]]></column-value></column>");
337         sb.append(
338             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
339         sb.append(getModifiedDate());
340         sb.append("]]></column-value></column>");
341         sb.append(
342             "<column><column-name>name</column-name><column-value><![CDATA[");
343         sb.append(getName());
344         sb.append("]]></column-value></column>");
345 
346         sb.append("</model>");
347 
348         return sb.toString();
349     }
350 
351     private long _entryId;
352     private long _companyId;
353     private long _originalCompanyId;
354     private boolean _setOriginalCompanyId;
355     private long _userId;
356     private String _userUuid;
357     private String _userName;
358     private Date _createDate;
359     private Date _modifiedDate;
360     private String _name;
361     private String _originalName;
362 }