1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.asset.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.language.LanguageUtil;
20  import com.liferay.portal.kernel.util.GetterUtil;
21  import com.liferay.portal.kernel.util.HtmlUtil;
22  import com.liferay.portal.kernel.util.LocaleUtil;
23  import com.liferay.portal.kernel.util.StringBundler;
24  import com.liferay.portal.kernel.util.Validator;
25  import com.liferay.portal.model.impl.BaseModelImpl;
26  import com.liferay.portal.service.ServiceContext;
27  import com.liferay.portal.util.PortalUtil;
28  
29  import com.liferay.portlet.asset.model.AssetVocabulary;
30  import com.liferay.portlet.asset.model.AssetVocabularySoap;
31  import com.liferay.portlet.expando.model.ExpandoBridge;
32  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
33  
34  import com.liferay.util.LocalizationUtil;
35  
36  import java.io.Serializable;
37  
38  import java.lang.reflect.Proxy;
39  
40  import java.sql.Types;
41  
42  import java.util.ArrayList;
43  import java.util.Date;
44  import java.util.List;
45  import java.util.Locale;
46  import java.util.Map;
47  
48  /**
49   * <a href="AssetVocabularyModelImpl.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 AssetVocabulary table in the
58   * database.
59   * </p>
60   *
61   * @author    Brian Wing Shun Chan
62   * @see       AssetVocabularyImpl
63   * @see       com.liferay.portlet.asset.model.AssetVocabulary
64   * @see       com.liferay.portlet.asset.model.AssetVocabularyModel
65   * @generated
66   */
67  public class AssetVocabularyModelImpl extends BaseModelImpl<AssetVocabulary> {
68      public static final String TABLE_NAME = "AssetVocabulary";
69      public static final Object[][] TABLE_COLUMNS = {
70              { "uuid_", new Integer(Types.VARCHAR) },
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              { "title", new Integer(Types.VARCHAR) },
80              { "description", new Integer(Types.VARCHAR) },
81              { "settings_", new Integer(Types.VARCHAR) }
82          };
83      public static final String TABLE_SQL_CREATE = "create table AssetVocabulary (uuid_ VARCHAR(75) null,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,title STRING null,description STRING null,settings_ STRING null)";
84      public static final String TABLE_SQL_DROP = "drop table AssetVocabulary";
85      public static final String ORDER_BY_JPQL = " ORDER BY assetVocabulary.name ASC";
86      public static final String ORDER_BY_SQL = " ORDER BY AssetVocabulary.name ASC";
87      public static final String DATA_SOURCE = "liferayDataSource";
88      public static final String SESSION_FACTORY = "liferaySessionFactory";
89      public static final String TX_MANAGER = "liferayTransactionManager";
90      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
91                  "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetVocabulary"),
92              true);
93      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
94                  "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetVocabulary"),
95              true);
96  
97      public static AssetVocabulary toModel(AssetVocabularySoap soapModel) {
98          AssetVocabulary model = new AssetVocabularyImpl();
99  
100         model.setUuid(soapModel.getUuid());
101         model.setVocabularyId(soapModel.getVocabularyId());
102         model.setGroupId(soapModel.getGroupId());
103         model.setCompanyId(soapModel.getCompanyId());
104         model.setUserId(soapModel.getUserId());
105         model.setUserName(soapModel.getUserName());
106         model.setCreateDate(soapModel.getCreateDate());
107         model.setModifiedDate(soapModel.getModifiedDate());
108         model.setName(soapModel.getName());
109         model.setTitle(soapModel.getTitle());
110         model.setDescription(soapModel.getDescription());
111         model.setSettings(soapModel.getSettings());
112 
113         return model;
114     }
115 
116     public static List<AssetVocabulary> toModels(
117         AssetVocabularySoap[] soapModels) {
118         List<AssetVocabulary> models = new ArrayList<AssetVocabulary>(soapModels.length);
119 
120         for (AssetVocabularySoap soapModel : soapModels) {
121             models.add(toModel(soapModel));
122         }
123 
124         return models;
125     }
126 
127     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
128                 "lock.expiration.time.com.liferay.portlet.asset.model.AssetVocabulary"));
129 
130     public AssetVocabularyModelImpl() {
131     }
132 
133     public long getPrimaryKey() {
134         return _vocabularyId;
135     }
136 
137     public void setPrimaryKey(long pk) {
138         setVocabularyId(pk);
139     }
140 
141     public Serializable getPrimaryKeyObj() {
142         return new Long(_vocabularyId);
143     }
144 
145     public String getUuid() {
146         return GetterUtil.getString(_uuid);
147     }
148 
149     public void setUuid(String uuid) {
150         _uuid = uuid;
151 
152         if (_originalUuid == null) {
153             _originalUuid = uuid;
154         }
155     }
156 
157     public String getOriginalUuid() {
158         return GetterUtil.getString(_originalUuid);
159     }
160 
161     public long getVocabularyId() {
162         return _vocabularyId;
163     }
164 
165     public void setVocabularyId(long vocabularyId) {
166         _vocabularyId = vocabularyId;
167     }
168 
169     public long getGroupId() {
170         return _groupId;
171     }
172 
173     public void setGroupId(long groupId) {
174         _groupId = groupId;
175 
176         if (!_setOriginalGroupId) {
177             _setOriginalGroupId = true;
178 
179             _originalGroupId = groupId;
180         }
181     }
182 
183     public long getOriginalGroupId() {
184         return _originalGroupId;
185     }
186 
187     public long getCompanyId() {
188         return _companyId;
189     }
190 
191     public void setCompanyId(long companyId) {
192         _companyId = companyId;
193     }
194 
195     public long getUserId() {
196         return _userId;
197     }
198 
199     public void setUserId(long userId) {
200         _userId = userId;
201     }
202 
203     public String getUserUuid() throws SystemException {
204         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
205     }
206 
207     public void setUserUuid(String userUuid) {
208         _userUuid = userUuid;
209     }
210 
211     public String getUserName() {
212         return GetterUtil.getString(_userName);
213     }
214 
215     public void setUserName(String userName) {
216         _userName = userName;
217     }
218 
219     public Date getCreateDate() {
220         return _createDate;
221     }
222 
223     public void setCreateDate(Date createDate) {
224         _createDate = createDate;
225     }
226 
227     public Date getModifiedDate() {
228         return _modifiedDate;
229     }
230 
231     public void setModifiedDate(Date modifiedDate) {
232         _modifiedDate = modifiedDate;
233     }
234 
235     public String getName() {
236         return GetterUtil.getString(_name);
237     }
238 
239     public void setName(String name) {
240         _name = name;
241 
242         if (_originalName == null) {
243             _originalName = name;
244         }
245     }
246 
247     public String getOriginalName() {
248         return GetterUtil.getString(_originalName);
249     }
250 
251     public String getTitle() {
252         return GetterUtil.getString(_title);
253     }
254 
255     public String getTitle(Locale locale) {
256         String languageId = LocaleUtil.toLanguageId(locale);
257 
258         return getTitle(languageId);
259     }
260 
261     public String getTitle(Locale locale, boolean useDefault) {
262         String languageId = LocaleUtil.toLanguageId(locale);
263 
264         return getTitle(languageId, useDefault);
265     }
266 
267     public String getTitle(String languageId) {
268         String value = LocalizationUtil.getLocalization(getTitle(), languageId);
269 
270         if (isEscapedModel()) {
271             return HtmlUtil.escape(value);
272         }
273         else {
274             return value;
275         }
276     }
277 
278     public String getTitle(String languageId, boolean useDefault) {
279         String value = LocalizationUtil.getLocalization(getTitle(), languageId,
280                 useDefault);
281 
282         if (isEscapedModel()) {
283             return HtmlUtil.escape(value);
284         }
285         else {
286             return value;
287         }
288     }
289 
290     public Map<Locale, String> getTitleMap() {
291         return LocalizationUtil.getLocalizationMap(getTitle());
292     }
293 
294     public void setTitle(String title) {
295         _title = title;
296     }
297 
298     public void setTitle(Locale locale, String title) {
299         String languageId = LocaleUtil.toLanguageId(locale);
300 
301         if (Validator.isNotNull(title)) {
302             setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
303                     title, languageId));
304         }
305         else {
306             setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
307                     languageId));
308         }
309     }
310 
311     public void setTitleMap(Map<Locale, String> titleMap) {
312         if (titleMap == null) {
313             return;
314         }
315 
316         Locale[] locales = LanguageUtil.getAvailableLocales();
317 
318         for (Locale locale : locales) {
319             String title = titleMap.get(locale);
320 
321             setTitle(locale, title);
322         }
323     }
324 
325     public String getDescription() {
326         return GetterUtil.getString(_description);
327     }
328 
329     public String getDescription(Locale locale) {
330         String languageId = LocaleUtil.toLanguageId(locale);
331 
332         return getDescription(languageId);
333     }
334 
335     public String getDescription(Locale locale, boolean useDefault) {
336         String languageId = LocaleUtil.toLanguageId(locale);
337 
338         return getDescription(languageId, useDefault);
339     }
340 
341     public String getDescription(String languageId) {
342         String value = LocalizationUtil.getLocalization(getDescription(),
343                 languageId);
344 
345         if (isEscapedModel()) {
346             return HtmlUtil.escape(value);
347         }
348         else {
349             return value;
350         }
351     }
352 
353     public String getDescription(String languageId, boolean useDefault) {
354         String value = LocalizationUtil.getLocalization(getDescription(),
355                 languageId, useDefault);
356 
357         if (isEscapedModel()) {
358             return HtmlUtil.escape(value);
359         }
360         else {
361             return value;
362         }
363     }
364 
365     public Map<Locale, String> getDescriptionMap() {
366         return LocalizationUtil.getLocalizationMap(getDescription());
367     }
368 
369     public void setDescription(String description) {
370         _description = description;
371     }
372 
373     public void setDescription(Locale locale, String description) {
374         String languageId = LocaleUtil.toLanguageId(locale);
375 
376         if (Validator.isNotNull(description)) {
377             setDescription(LocalizationUtil.updateLocalization(
378                     getDescription(), "Description", description, languageId));
379         }
380         else {
381             setDescription(LocalizationUtil.removeLocalization(
382                     getDescription(), "Description", languageId));
383         }
384     }
385 
386     public void setDescriptionMap(Map<Locale, String> descriptionMap) {
387         if (descriptionMap == null) {
388             return;
389         }
390 
391         Locale[] locales = LanguageUtil.getAvailableLocales();
392 
393         for (Locale locale : locales) {
394             String description = descriptionMap.get(locale);
395 
396             setDescription(locale, description);
397         }
398     }
399 
400     public String getSettings() {
401         return GetterUtil.getString(_settings);
402     }
403 
404     public void setSettings(String settings) {
405         _settings = settings;
406     }
407 
408     public AssetVocabulary toEscapedModel() {
409         if (isEscapedModel()) {
410             return (AssetVocabulary)this;
411         }
412         else {
413             AssetVocabulary model = new AssetVocabularyImpl();
414 
415             model.setNew(isNew());
416             model.setEscapedModel(true);
417 
418             model.setUuid(HtmlUtil.escape(getUuid()));
419             model.setVocabularyId(getVocabularyId());
420             model.setGroupId(getGroupId());
421             model.setCompanyId(getCompanyId());
422             model.setUserId(getUserId());
423             model.setUserName(HtmlUtil.escape(getUserName()));
424             model.setCreateDate(getCreateDate());
425             model.setModifiedDate(getModifiedDate());
426             model.setName(HtmlUtil.escape(getName()));
427             model.setTitle(getTitle());
428             model.setDescription(getDescription());
429             model.setSettings(HtmlUtil.escape(getSettings()));
430 
431             model = (AssetVocabulary)Proxy.newProxyInstance(AssetVocabulary.class.getClassLoader(),
432                     new Class[] { AssetVocabulary.class },
433                     new ReadOnlyBeanHandler(model));
434 
435             return model;
436         }
437     }
438 
439     public ExpandoBridge getExpandoBridge() {
440         if (_expandoBridge == null) {
441             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
442                     AssetVocabulary.class.getName(), getPrimaryKey());
443         }
444 
445         return _expandoBridge;
446     }
447 
448     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
449         getExpandoBridge().setAttributes(serviceContext);
450     }
451 
452     public Object clone() {
453         AssetVocabularyImpl clone = new AssetVocabularyImpl();
454 
455         clone.setUuid(getUuid());
456         clone.setVocabularyId(getVocabularyId());
457         clone.setGroupId(getGroupId());
458         clone.setCompanyId(getCompanyId());
459         clone.setUserId(getUserId());
460         clone.setUserName(getUserName());
461         clone.setCreateDate(getCreateDate());
462         clone.setModifiedDate(getModifiedDate());
463         clone.setName(getName());
464         clone.setTitle(getTitle());
465         clone.setDescription(getDescription());
466         clone.setSettings(getSettings());
467 
468         return clone;
469     }
470 
471     public int compareTo(AssetVocabulary assetVocabulary) {
472         int value = 0;
473 
474         value = getName().compareTo(assetVocabulary.getName());
475 
476         if (value != 0) {
477             return value;
478         }
479 
480         return 0;
481     }
482 
483     public boolean equals(Object obj) {
484         if (obj == null) {
485             return false;
486         }
487 
488         AssetVocabulary assetVocabulary = null;
489 
490         try {
491             assetVocabulary = (AssetVocabulary)obj;
492         }
493         catch (ClassCastException cce) {
494             return false;
495         }
496 
497         long pk = assetVocabulary.getPrimaryKey();
498 
499         if (getPrimaryKey() == pk) {
500             return true;
501         }
502         else {
503             return false;
504         }
505     }
506 
507     public int hashCode() {
508         return (int)getPrimaryKey();
509     }
510 
511     public String toString() {
512         StringBundler sb = new StringBundler(25);
513 
514         sb.append("{uuid=");
515         sb.append(getUuid());
516         sb.append(", vocabularyId=");
517         sb.append(getVocabularyId());
518         sb.append(", groupId=");
519         sb.append(getGroupId());
520         sb.append(", companyId=");
521         sb.append(getCompanyId());
522         sb.append(", userId=");
523         sb.append(getUserId());
524         sb.append(", userName=");
525         sb.append(getUserName());
526         sb.append(", createDate=");
527         sb.append(getCreateDate());
528         sb.append(", modifiedDate=");
529         sb.append(getModifiedDate());
530         sb.append(", name=");
531         sb.append(getName());
532         sb.append(", title=");
533         sb.append(getTitle());
534         sb.append(", description=");
535         sb.append(getDescription());
536         sb.append(", settings=");
537         sb.append(getSettings());
538         sb.append("}");
539 
540         return sb.toString();
541     }
542 
543     public String toXmlString() {
544         StringBundler sb = new StringBundler(40);
545 
546         sb.append("<model><model-name>");
547         sb.append("com.liferay.portlet.asset.model.AssetVocabulary");
548         sb.append("</model-name>");
549 
550         sb.append(
551             "<column><column-name>uuid</column-name><column-value><![CDATA[");
552         sb.append(getUuid());
553         sb.append("]]></column-value></column>");
554         sb.append(
555             "<column><column-name>vocabularyId</column-name><column-value><![CDATA[");
556         sb.append(getVocabularyId());
557         sb.append("]]></column-value></column>");
558         sb.append(
559             "<column><column-name>groupId</column-name><column-value><![CDATA[");
560         sb.append(getGroupId());
561         sb.append("]]></column-value></column>");
562         sb.append(
563             "<column><column-name>companyId</column-name><column-value><![CDATA[");
564         sb.append(getCompanyId());
565         sb.append("]]></column-value></column>");
566         sb.append(
567             "<column><column-name>userId</column-name><column-value><![CDATA[");
568         sb.append(getUserId());
569         sb.append("]]></column-value></column>");
570         sb.append(
571             "<column><column-name>userName</column-name><column-value><![CDATA[");
572         sb.append(getUserName());
573         sb.append("]]></column-value></column>");
574         sb.append(
575             "<column><column-name>createDate</column-name><column-value><![CDATA[");
576         sb.append(getCreateDate());
577         sb.append("]]></column-value></column>");
578         sb.append(
579             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
580         sb.append(getModifiedDate());
581         sb.append("]]></column-value></column>");
582         sb.append(
583             "<column><column-name>name</column-name><column-value><![CDATA[");
584         sb.append(getName());
585         sb.append("]]></column-value></column>");
586         sb.append(
587             "<column><column-name>title</column-name><column-value><![CDATA[");
588         sb.append(getTitle());
589         sb.append("]]></column-value></column>");
590         sb.append(
591             "<column><column-name>description</column-name><column-value><![CDATA[");
592         sb.append(getDescription());
593         sb.append("]]></column-value></column>");
594         sb.append(
595             "<column><column-name>settings</column-name><column-value><![CDATA[");
596         sb.append(getSettings());
597         sb.append("]]></column-value></column>");
598 
599         sb.append("</model>");
600 
601         return sb.toString();
602     }
603 
604     private String _uuid;
605     private String _originalUuid;
606     private long _vocabularyId;
607     private long _groupId;
608     private long _originalGroupId;
609     private boolean _setOriginalGroupId;
610     private long _companyId;
611     private long _userId;
612     private String _userUuid;
613     private String _userName;
614     private Date _createDate;
615     private Date _modifiedDate;
616     private String _name;
617     private String _originalName;
618     private String _title;
619     private String _description;
620     private String _settings;
621     private transient ExpandoBridge _expandoBridge;
622 }