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