001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.asset.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.language.LanguageUtil;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.HtmlUtil;
022    import com.liferay.portal.kernel.util.LocaleUtil;
023    import com.liferay.portal.kernel.util.LocalizationUtil;
024    import com.liferay.portal.kernel.util.StringBundler;
025    import com.liferay.portal.kernel.util.StringPool;
026    import com.liferay.portal.kernel.util.Validator;
027    import com.liferay.portal.model.impl.BaseModelImpl;
028    import com.liferay.portal.service.ServiceContext;
029    import com.liferay.portal.util.PortalUtil;
030    
031    import com.liferay.portlet.asset.model.AssetVocabulary;
032    import com.liferay.portlet.asset.model.AssetVocabularyModel;
033    import com.liferay.portlet.asset.model.AssetVocabularySoap;
034    import com.liferay.portlet.expando.model.ExpandoBridge;
035    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
036    
037    import java.io.Serializable;
038    
039    import java.lang.reflect.Proxy;
040    
041    import java.sql.Types;
042    
043    import java.util.ArrayList;
044    import java.util.Date;
045    import java.util.List;
046    import java.util.Locale;
047    import java.util.Map;
048    
049    /**
050     * <p>
051     * This interface is a model that represents the AssetVocabulary table in the
052     * database.
053     * </p>
054     *
055     * @author    Brian Wing Shun Chan
056     * @see       AssetVocabularyImpl
057     * @see       com.liferay.portlet.asset.model.AssetVocabulary
058     * @see       com.liferay.portlet.asset.model.AssetVocabularyModel
059     * @generated
060     */
061    public class AssetVocabularyModelImpl extends BaseModelImpl<AssetVocabulary>
062            implements AssetVocabularyModel {
063            public static final String TABLE_NAME = "AssetVocabulary";
064            public static final Object[][] TABLE_COLUMNS = {
065                            { "uuid_", new Integer(Types.VARCHAR) },
066                            { "vocabularyId", new Integer(Types.BIGINT) },
067                            { "groupId", new Integer(Types.BIGINT) },
068                            { "companyId", new Integer(Types.BIGINT) },
069                            { "userId", new Integer(Types.BIGINT) },
070                            { "userName", new Integer(Types.VARCHAR) },
071                            { "createDate", new Integer(Types.TIMESTAMP) },
072                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
073                            { "name", new Integer(Types.VARCHAR) },
074                            { "title", new Integer(Types.VARCHAR) },
075                            { "description", new Integer(Types.VARCHAR) },
076                            { "settings_", new Integer(Types.VARCHAR) }
077                    };
078            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)";
079            public static final String TABLE_SQL_DROP = "drop table AssetVocabulary";
080            public static final String ORDER_BY_JPQL = " ORDER BY assetVocabulary.name ASC";
081            public static final String ORDER_BY_SQL = " ORDER BY AssetVocabulary.name ASC";
082            public static final String DATA_SOURCE = "liferayDataSource";
083            public static final String SESSION_FACTORY = "liferaySessionFactory";
084            public static final String TX_MANAGER = "liferayTransactionManager";
085            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetVocabulary"),
087                            true);
088            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
089                                    "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetVocabulary"),
090                            true);
091    
092            public static AssetVocabulary toModel(AssetVocabularySoap soapModel) {
093                    AssetVocabulary model = new AssetVocabularyImpl();
094    
095                    model.setUuid(soapModel.getUuid());
096                    model.setVocabularyId(soapModel.getVocabularyId());
097                    model.setGroupId(soapModel.getGroupId());
098                    model.setCompanyId(soapModel.getCompanyId());
099                    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.setTitle(soapModel.getTitle());
105                    model.setDescription(soapModel.getDescription());
106                    model.setSettings(soapModel.getSettings());
107    
108                    return model;
109            }
110    
111            public static List<AssetVocabulary> toModels(
112                    AssetVocabularySoap[] soapModels) {
113                    List<AssetVocabulary> models = new ArrayList<AssetVocabulary>(soapModels.length);
114    
115                    for (AssetVocabularySoap soapModel : soapModels) {
116                            models.add(toModel(soapModel));
117                    }
118    
119                    return models;
120            }
121    
122            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
123                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetVocabulary"));
124    
125            public AssetVocabularyModelImpl() {
126            }
127    
128            public long getPrimaryKey() {
129                    return _vocabularyId;
130            }
131    
132            public void setPrimaryKey(long pk) {
133                    setVocabularyId(pk);
134            }
135    
136            public Serializable getPrimaryKeyObj() {
137                    return new Long(_vocabularyId);
138            }
139    
140            public String getUuid() {
141                    if (_uuid == null) {
142                            return StringPool.BLANK;
143                    }
144                    else {
145                            return _uuid;
146                    }
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                    if (_userName == null) {
213                            return StringPool.BLANK;
214                    }
215                    else {
216                            return _userName;
217                    }
218            }
219    
220            public void setUserName(String userName) {
221                    _userName = userName;
222            }
223    
224            public Date getCreateDate() {
225                    return _createDate;
226            }
227    
228            public void setCreateDate(Date createDate) {
229                    _createDate = createDate;
230            }
231    
232            public Date getModifiedDate() {
233                    return _modifiedDate;
234            }
235    
236            public void setModifiedDate(Date modifiedDate) {
237                    _modifiedDate = modifiedDate;
238            }
239    
240            public String getName() {
241                    if (_name == null) {
242                            return StringPool.BLANK;
243                    }
244                    else {
245                            return _name;
246                    }
247            }
248    
249            public void setName(String name) {
250                    _name = name;
251    
252                    if (_originalName == null) {
253                            _originalName = name;
254                    }
255            }
256    
257            public String getOriginalName() {
258                    return GetterUtil.getString(_originalName);
259            }
260    
261            public String getTitle() {
262                    if (_title == null) {
263                            return StringPool.BLANK;
264                    }
265                    else {
266                            return _title;
267                    }
268            }
269    
270            public String getTitle(Locale locale) {
271                    String languageId = LocaleUtil.toLanguageId(locale);
272    
273                    return getTitle(languageId);
274            }
275    
276            public String getTitle(Locale locale, boolean useDefault) {
277                    String languageId = LocaleUtil.toLanguageId(locale);
278    
279                    return getTitle(languageId, useDefault);
280            }
281    
282            public String getTitle(String languageId) {
283                    String value = LocalizationUtil.getLocalization(getTitle(), languageId);
284    
285                    if (isEscapedModel()) {
286                            return HtmlUtil.escape(value);
287                    }
288                    else {
289                            return value;
290                    }
291            }
292    
293            public String getTitle(String languageId, boolean useDefault) {
294                    String value = LocalizationUtil.getLocalization(getTitle(), languageId,
295                                    useDefault);
296    
297                    if (isEscapedModel()) {
298                            return HtmlUtil.escape(value);
299                    }
300                    else {
301                            return value;
302                    }
303            }
304    
305            public Map<Locale, String> getTitleMap() {
306                    return LocalizationUtil.getLocalizationMap(getTitle());
307            }
308    
309            public void setTitle(String title) {
310                    _title = title;
311            }
312    
313            public void setTitle(Locale locale, String title) {
314                    String languageId = LocaleUtil.toLanguageId(locale);
315    
316                    if (Validator.isNotNull(title)) {
317                            setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
318                                            title, languageId));
319                    }
320                    else {
321                            setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
322                                            languageId));
323                    }
324            }
325    
326            public void setTitleMap(Map<Locale, String> titleMap) {
327                    if (titleMap == null) {
328                            return;
329                    }
330    
331                    Locale[] locales = LanguageUtil.getAvailableLocales();
332    
333                    for (Locale locale : locales) {
334                            String title = titleMap.get(locale);
335    
336                            setTitle(locale, title);
337                    }
338            }
339    
340            public String getDescription() {
341                    if (_description == null) {
342                            return StringPool.BLANK;
343                    }
344                    else {
345                            return _description;
346                    }
347            }
348    
349            public String getDescription(Locale locale) {
350                    String languageId = LocaleUtil.toLanguageId(locale);
351    
352                    return getDescription(languageId);
353            }
354    
355            public String getDescription(Locale locale, boolean useDefault) {
356                    String languageId = LocaleUtil.toLanguageId(locale);
357    
358                    return getDescription(languageId, useDefault);
359            }
360    
361            public String getDescription(String languageId) {
362                    String value = LocalizationUtil.getLocalization(getDescription(),
363                                    languageId);
364    
365                    if (isEscapedModel()) {
366                            return HtmlUtil.escape(value);
367                    }
368                    else {
369                            return value;
370                    }
371            }
372    
373            public String getDescription(String languageId, boolean useDefault) {
374                    String value = LocalizationUtil.getLocalization(getDescription(),
375                                    languageId, useDefault);
376    
377                    if (isEscapedModel()) {
378                            return HtmlUtil.escape(value);
379                    }
380                    else {
381                            return value;
382                    }
383            }
384    
385            public Map<Locale, String> getDescriptionMap() {
386                    return LocalizationUtil.getLocalizationMap(getDescription());
387            }
388    
389            public void setDescription(String description) {
390                    _description = description;
391            }
392    
393            public void setDescription(Locale locale, String description) {
394                    String languageId = LocaleUtil.toLanguageId(locale);
395    
396                    if (Validator.isNotNull(description)) {
397                            setDescription(LocalizationUtil.updateLocalization(
398                                            getDescription(), "Description", description, languageId));
399                    }
400                    else {
401                            setDescription(LocalizationUtil.removeLocalization(
402                                            getDescription(), "Description", languageId));
403                    }
404            }
405    
406            public void setDescriptionMap(Map<Locale, String> descriptionMap) {
407                    if (descriptionMap == null) {
408                            return;
409                    }
410    
411                    Locale[] locales = LanguageUtil.getAvailableLocales();
412    
413                    for (Locale locale : locales) {
414                            String description = descriptionMap.get(locale);
415    
416                            setDescription(locale, description);
417                    }
418            }
419    
420            public String getSettings() {
421                    if (_settings == null) {
422                            return StringPool.BLANK;
423                    }
424                    else {
425                            return _settings;
426                    }
427            }
428    
429            public void setSettings(String settings) {
430                    _settings = settings;
431            }
432    
433            public AssetVocabulary toEscapedModel() {
434                    if (isEscapedModel()) {
435                            return (AssetVocabulary)this;
436                    }
437                    else {
438                            return (AssetVocabulary)Proxy.newProxyInstance(AssetVocabulary.class.getClassLoader(),
439                                    new Class[] { AssetVocabulary.class },
440                                    new AutoEscapeBeanHandler(this));
441                    }
442            }
443    
444            public ExpandoBridge getExpandoBridge() {
445                    if (_expandoBridge == null) {
446                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
447                                            AssetVocabulary.class.getName(), getPrimaryKey());
448                    }
449    
450                    return _expandoBridge;
451            }
452    
453            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
454                    getExpandoBridge().setAttributes(serviceContext);
455            }
456    
457            public Object clone() {
458                    AssetVocabularyImpl clone = new AssetVocabularyImpl();
459    
460                    clone.setUuid(getUuid());
461                    clone.setVocabularyId(getVocabularyId());
462                    clone.setGroupId(getGroupId());
463                    clone.setCompanyId(getCompanyId());
464                    clone.setUserId(getUserId());
465                    clone.setUserName(getUserName());
466                    clone.setCreateDate(getCreateDate());
467                    clone.setModifiedDate(getModifiedDate());
468                    clone.setName(getName());
469                    clone.setTitle(getTitle());
470                    clone.setDescription(getDescription());
471                    clone.setSettings(getSettings());
472    
473                    return clone;
474            }
475    
476            public int compareTo(AssetVocabulary assetVocabulary) {
477                    int value = 0;
478    
479                    value = getName().compareTo(assetVocabulary.getName());
480    
481                    if (value != 0) {
482                            return value;
483                    }
484    
485                    return 0;
486            }
487    
488            public boolean equals(Object obj) {
489                    if (obj == null) {
490                            return false;
491                    }
492    
493                    AssetVocabulary assetVocabulary = null;
494    
495                    try {
496                            assetVocabulary = (AssetVocabulary)obj;
497                    }
498                    catch (ClassCastException cce) {
499                            return false;
500                    }
501    
502                    long pk = assetVocabulary.getPrimaryKey();
503    
504                    if (getPrimaryKey() == pk) {
505                            return true;
506                    }
507                    else {
508                            return false;
509                    }
510            }
511    
512            public int hashCode() {
513                    return (int)getPrimaryKey();
514            }
515    
516            public String toString() {
517                    StringBundler sb = new StringBundler(25);
518    
519                    sb.append("{uuid=");
520                    sb.append(getUuid());
521                    sb.append(", vocabularyId=");
522                    sb.append(getVocabularyId());
523                    sb.append(", groupId=");
524                    sb.append(getGroupId());
525                    sb.append(", companyId=");
526                    sb.append(getCompanyId());
527                    sb.append(", userId=");
528                    sb.append(getUserId());
529                    sb.append(", userName=");
530                    sb.append(getUserName());
531                    sb.append(", createDate=");
532                    sb.append(getCreateDate());
533                    sb.append(", modifiedDate=");
534                    sb.append(getModifiedDate());
535                    sb.append(", name=");
536                    sb.append(getName());
537                    sb.append(", title=");
538                    sb.append(getTitle());
539                    sb.append(", description=");
540                    sb.append(getDescription());
541                    sb.append(", settings=");
542                    sb.append(getSettings());
543                    sb.append("}");
544    
545                    return sb.toString();
546            }
547    
548            public String toXmlString() {
549                    StringBundler sb = new StringBundler(40);
550    
551                    sb.append("<model><model-name>");
552                    sb.append("com.liferay.portlet.asset.model.AssetVocabulary");
553                    sb.append("</model-name>");
554    
555                    sb.append(
556                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
557                    sb.append(getUuid());
558                    sb.append("]]></column-value></column>");
559                    sb.append(
560                            "<column><column-name>vocabularyId</column-name><column-value><![CDATA[");
561                    sb.append(getVocabularyId());
562                    sb.append("]]></column-value></column>");
563                    sb.append(
564                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
565                    sb.append(getGroupId());
566                    sb.append("]]></column-value></column>");
567                    sb.append(
568                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
569                    sb.append(getCompanyId());
570                    sb.append("]]></column-value></column>");
571                    sb.append(
572                            "<column><column-name>userId</column-name><column-value><![CDATA[");
573                    sb.append(getUserId());
574                    sb.append("]]></column-value></column>");
575                    sb.append(
576                            "<column><column-name>userName</column-name><column-value><![CDATA[");
577                    sb.append(getUserName());
578                    sb.append("]]></column-value></column>");
579                    sb.append(
580                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
581                    sb.append(getCreateDate());
582                    sb.append("]]></column-value></column>");
583                    sb.append(
584                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
585                    sb.append(getModifiedDate());
586                    sb.append("]]></column-value></column>");
587                    sb.append(
588                            "<column><column-name>name</column-name><column-value><![CDATA[");
589                    sb.append(getName());
590                    sb.append("]]></column-value></column>");
591                    sb.append(
592                            "<column><column-name>title</column-name><column-value><![CDATA[");
593                    sb.append(getTitle());
594                    sb.append("]]></column-value></column>");
595                    sb.append(
596                            "<column><column-name>description</column-name><column-value><![CDATA[");
597                    sb.append(getDescription());
598                    sb.append("]]></column-value></column>");
599                    sb.append(
600                            "<column><column-name>settings</column-name><column-value><![CDATA[");
601                    sb.append(getSettings());
602                    sb.append("]]></column-value></column>");
603    
604                    sb.append("</model>");
605    
606                    return sb.toString();
607            }
608    
609            private String _uuid;
610            private String _originalUuid;
611            private long _vocabularyId;
612            private long _groupId;
613            private long _originalGroupId;
614            private boolean _setOriginalGroupId;
615            private long _companyId;
616            private long _userId;
617            private String _userUuid;
618            private String _userName;
619            private Date _createDate;
620            private Date _modifiedDate;
621            private String _name;
622            private String _originalName;
623            private String _title;
624            private String _description;
625            private String _settings;
626            private transient ExpandoBridge _expandoBridge;
627    }