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