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.kernel.util.StringBundler;
30  import com.liferay.portal.model.impl.BaseModelImpl;
31  import com.liferay.portal.service.ServiceContext;
32  import com.liferay.portal.util.PortalUtil;
33  
34  import com.liferay.portlet.expando.model.ExpandoBridge;
35  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
36  import com.liferay.portlet.tags.model.TagsVocabulary;
37  import com.liferay.portlet.tags.model.TagsVocabularySoap;
38  
39  import java.io.Serializable;
40  
41  import java.lang.reflect.Proxy;
42  
43  import java.sql.Types;
44  
45  import java.util.ArrayList;
46  import java.util.Date;
47  import java.util.List;
48  
49  /**
50   * <a href="TagsVocabularyModelImpl.java.html"><b><i>View Source</i></b></a>
51   *
52   * <p>
53   * ServiceBuilder generated this class. Modifications in this class will be
54   * overwritten the next time is generated.
55   * </p>
56   *
57   * <p>
58   * This interface is a model that represents the TagsVocabulary table in the
59   * database.
60   * </p>
61   *
62   * @author    Brian Wing Shun Chan
63   * @see       TagsVocabularyImpl
64   * @see       com.liferay.portlet.tags.model.TagsVocabulary
65   * @see       com.liferay.portlet.tags.model.TagsVocabularyModel
66   * @generated
67   */
68  public class TagsVocabularyModelImpl extends BaseModelImpl<TagsVocabulary> {
69      public static final String TABLE_NAME = "TagsVocabulary";
70      public static final Object[][] TABLE_COLUMNS = {
71              { "vocabularyId", new Integer(Types.BIGINT) },
72              { "groupId", new Integer(Types.BIGINT) },
73              { "companyId", new Integer(Types.BIGINT) },
74              { "userId", new Integer(Types.BIGINT) },
75              { "userName", new Integer(Types.VARCHAR) },
76              { "createDate", new Integer(Types.TIMESTAMP) },
77              { "modifiedDate", new Integer(Types.TIMESTAMP) },
78              { "name", new Integer(Types.VARCHAR) },
79              { "description", new Integer(Types.VARCHAR) },
80              { "folksonomy", new Integer(Types.BOOLEAN) }
81          };
82      public static final String TABLE_SQL_CREATE = "create table TagsVocabulary (vocabularyId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,name VARCHAR(75) null,description VARCHAR(75) null,folksonomy BOOLEAN)";
83      public static final String TABLE_SQL_DROP = "drop table TagsVocabulary";
84      public static final String ORDER_BY_JPQL = " ORDER BY tagsVocabulary.name ASC";
85      public static final String ORDER_BY_SQL = " ORDER BY TagsVocabulary.name ASC";
86      public static final String DATA_SOURCE = "liferayDataSource";
87      public static final String SESSION_FACTORY = "liferaySessionFactory";
88      public static final String TX_MANAGER = "liferayTransactionManager";
89      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
90                  "value.object.entity.cache.enabled.com.liferay.portlet.tags.model.TagsVocabulary"),
91              true);
92      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
93                  "value.object.finder.cache.enabled.com.liferay.portlet.tags.model.TagsVocabulary"),
94              true);
95  
96      public static TagsVocabulary toModel(TagsVocabularySoap soapModel) {
97          TagsVocabulary model = new TagsVocabularyImpl();
98  
99          model.setVocabularyId(soapModel.getVocabularyId());
100         model.setGroupId(soapModel.getGroupId());
101         model.setCompanyId(soapModel.getCompanyId());
102         model.setUserId(soapModel.getUserId());
103         model.setUserName(soapModel.getUserName());
104         model.setCreateDate(soapModel.getCreateDate());
105         model.setModifiedDate(soapModel.getModifiedDate());
106         model.setName(soapModel.getName());
107         model.setDescription(soapModel.getDescription());
108         model.setFolksonomy(soapModel.getFolksonomy());
109 
110         return model;
111     }
112 
113     public static List<TagsVocabulary> toModels(TagsVocabularySoap[] soapModels) {
114         List<TagsVocabulary> models = new ArrayList<TagsVocabulary>(soapModels.length);
115 
116         for (TagsVocabularySoap soapModel : soapModels) {
117             models.add(toModel(soapModel));
118         }
119 
120         return models;
121     }
122 
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.TagsVocabulary"));
125 
126     public TagsVocabularyModelImpl() {
127     }
128 
129     public long getPrimaryKey() {
130         return _vocabularyId;
131     }
132 
133     public void setPrimaryKey(long pk) {
134         setVocabularyId(pk);
135     }
136 
137     public Serializable getPrimaryKeyObj() {
138         return new Long(_vocabularyId);
139     }
140 
141     public long getVocabularyId() {
142         return _vocabularyId;
143     }
144 
145     public void setVocabularyId(long vocabularyId) {
146         _vocabularyId = vocabularyId;
147     }
148 
149     public long getGroupId() {
150         return _groupId;
151     }
152 
153     public void setGroupId(long groupId) {
154         _groupId = groupId;
155 
156         if (!_setOriginalGroupId) {
157             _setOriginalGroupId = true;
158 
159             _originalGroupId = groupId;
160         }
161     }
162 
163     public long getOriginalGroupId() {
164         return _originalGroupId;
165     }
166 
167     public long getCompanyId() {
168         return _companyId;
169     }
170 
171     public void setCompanyId(long companyId) {
172         _companyId = companyId;
173     }
174 
175     public long getUserId() {
176         return _userId;
177     }
178 
179     public void setUserId(long userId) {
180         _userId = userId;
181     }
182 
183     public String getUserUuid() throws SystemException {
184         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
185     }
186 
187     public void setUserUuid(String userUuid) {
188         _userUuid = userUuid;
189     }
190 
191     public String getUserName() {
192         return GetterUtil.getString(_userName);
193     }
194 
195     public void setUserName(String userName) {
196         _userName = userName;
197     }
198 
199     public Date getCreateDate() {
200         return _createDate;
201     }
202 
203     public void setCreateDate(Date createDate) {
204         _createDate = createDate;
205     }
206 
207     public Date getModifiedDate() {
208         return _modifiedDate;
209     }
210 
211     public void setModifiedDate(Date modifiedDate) {
212         _modifiedDate = modifiedDate;
213     }
214 
215     public String getName() {
216         return GetterUtil.getString(_name);
217     }
218 
219     public void setName(String name) {
220         _name = name;
221 
222         if (_originalName == null) {
223             _originalName = name;
224         }
225     }
226 
227     public String getOriginalName() {
228         return GetterUtil.getString(_originalName);
229     }
230 
231     public String getDescription() {
232         return GetterUtil.getString(_description);
233     }
234 
235     public void setDescription(String description) {
236         _description = description;
237     }
238 
239     public boolean getFolksonomy() {
240         return _folksonomy;
241     }
242 
243     public boolean isFolksonomy() {
244         return _folksonomy;
245     }
246 
247     public void setFolksonomy(boolean folksonomy) {
248         _folksonomy = folksonomy;
249     }
250 
251     public TagsVocabulary toEscapedModel() {
252         if (isEscapedModel()) {
253             return (TagsVocabulary)this;
254         }
255         else {
256             TagsVocabulary model = new TagsVocabularyImpl();
257 
258             model.setNew(isNew());
259             model.setEscapedModel(true);
260 
261             model.setVocabularyId(getVocabularyId());
262             model.setGroupId(getGroupId());
263             model.setCompanyId(getCompanyId());
264             model.setUserId(getUserId());
265             model.setUserName(HtmlUtil.escape(getUserName()));
266             model.setCreateDate(getCreateDate());
267             model.setModifiedDate(getModifiedDate());
268             model.setName(HtmlUtil.escape(getName()));
269             model.setDescription(HtmlUtil.escape(getDescription()));
270             model.setFolksonomy(getFolksonomy());
271 
272             model = (TagsVocabulary)Proxy.newProxyInstance(TagsVocabulary.class.getClassLoader(),
273                     new Class[] { TagsVocabulary.class },
274                     new ReadOnlyBeanHandler(model));
275 
276             return model;
277         }
278     }
279 
280     public ExpandoBridge getExpandoBridge() {
281         if (_expandoBridge == null) {
282             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(TagsVocabulary.class.getName(),
283                     getPrimaryKey());
284         }
285 
286         return _expandoBridge;
287     }
288 
289     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
290         getExpandoBridge().setAttributes(serviceContext);
291     }
292 
293     public Object clone() {
294         TagsVocabularyImpl clone = new TagsVocabularyImpl();
295 
296         clone.setVocabularyId(getVocabularyId());
297         clone.setGroupId(getGroupId());
298         clone.setCompanyId(getCompanyId());
299         clone.setUserId(getUserId());
300         clone.setUserName(getUserName());
301         clone.setCreateDate(getCreateDate());
302         clone.setModifiedDate(getModifiedDate());
303         clone.setName(getName());
304         clone.setDescription(getDescription());
305         clone.setFolksonomy(getFolksonomy());
306 
307         return clone;
308     }
309 
310     public int compareTo(TagsVocabulary tagsVocabulary) {
311         int value = 0;
312 
313         value = getName().compareTo(tagsVocabulary.getName());
314 
315         if (value != 0) {
316             return value;
317         }
318 
319         return 0;
320     }
321 
322     public boolean equals(Object obj) {
323         if (obj == null) {
324             return false;
325         }
326 
327         TagsVocabulary tagsVocabulary = null;
328 
329         try {
330             tagsVocabulary = (TagsVocabulary)obj;
331         }
332         catch (ClassCastException cce) {
333             return false;
334         }
335 
336         long pk = tagsVocabulary.getPrimaryKey();
337 
338         if (getPrimaryKey() == pk) {
339             return true;
340         }
341         else {
342             return false;
343         }
344     }
345 
346     public int hashCode() {
347         return (int)getPrimaryKey();
348     }
349 
350     public String toString() {
351         StringBundler sb = new StringBundler(21);
352 
353         sb.append("{vocabularyId=");
354         sb.append(getVocabularyId());
355         sb.append(", groupId=");
356         sb.append(getGroupId());
357         sb.append(", companyId=");
358         sb.append(getCompanyId());
359         sb.append(", userId=");
360         sb.append(getUserId());
361         sb.append(", userName=");
362         sb.append(getUserName());
363         sb.append(", createDate=");
364         sb.append(getCreateDate());
365         sb.append(", modifiedDate=");
366         sb.append(getModifiedDate());
367         sb.append(", name=");
368         sb.append(getName());
369         sb.append(", description=");
370         sb.append(getDescription());
371         sb.append(", folksonomy=");
372         sb.append(getFolksonomy());
373         sb.append("}");
374 
375         return sb.toString();
376     }
377 
378     public String toXmlString() {
379         StringBundler sb = new StringBundler(34);
380 
381         sb.append("<model><model-name>");
382         sb.append("com.liferay.portlet.tags.model.TagsVocabulary");
383         sb.append("</model-name>");
384 
385         sb.append(
386             "<column><column-name>vocabularyId</column-name><column-value><![CDATA[");
387         sb.append(getVocabularyId());
388         sb.append("]]></column-value></column>");
389         sb.append(
390             "<column><column-name>groupId</column-name><column-value><![CDATA[");
391         sb.append(getGroupId());
392         sb.append("]]></column-value></column>");
393         sb.append(
394             "<column><column-name>companyId</column-name><column-value><![CDATA[");
395         sb.append(getCompanyId());
396         sb.append("]]></column-value></column>");
397         sb.append(
398             "<column><column-name>userId</column-name><column-value><![CDATA[");
399         sb.append(getUserId());
400         sb.append("]]></column-value></column>");
401         sb.append(
402             "<column><column-name>userName</column-name><column-value><![CDATA[");
403         sb.append(getUserName());
404         sb.append("]]></column-value></column>");
405         sb.append(
406             "<column><column-name>createDate</column-name><column-value><![CDATA[");
407         sb.append(getCreateDate());
408         sb.append("]]></column-value></column>");
409         sb.append(
410             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
411         sb.append(getModifiedDate());
412         sb.append("]]></column-value></column>");
413         sb.append(
414             "<column><column-name>name</column-name><column-value><![CDATA[");
415         sb.append(getName());
416         sb.append("]]></column-value></column>");
417         sb.append(
418             "<column><column-name>description</column-name><column-value><![CDATA[");
419         sb.append(getDescription());
420         sb.append("]]></column-value></column>");
421         sb.append(
422             "<column><column-name>folksonomy</column-name><column-value><![CDATA[");
423         sb.append(getFolksonomy());
424         sb.append("]]></column-value></column>");
425 
426         sb.append("</model>");
427 
428         return sb.toString();
429     }
430 
431     private long _vocabularyId;
432     private long _groupId;
433     private long _originalGroupId;
434     private boolean _setOriginalGroupId;
435     private long _companyId;
436     private long _userId;
437     private String _userUuid;
438     private String _userName;
439     private Date _createDate;
440     private Date _modifiedDate;
441     private String _name;
442     private String _originalName;
443     private String _description;
444     private boolean _folksonomy;
445     private transient ExpandoBridge _expandoBridge;
446 }