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