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