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     * The base model implementation for the AssetVocabulary service. Represents a row in the "AssetVocabulary" database table, with each column mapped to a property of this class.
051     *
052     * <p>
053     * This implementation and its corresponding interface {@link com.liferay.portlet.asset.model.AssetVocabularyModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AssetVocabularyImpl}.
054     * </p>
055     *
056     * <p>
057     * Never modify or reference this class directly. All methods that expect a asset vocabulary model instance should use the {@link com.liferay.portlet.asset.model.AssetVocabulary} interface instead.
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see AssetVocabularyImpl
062     * @see com.liferay.portlet.asset.model.AssetVocabulary
063     * @see com.liferay.portlet.asset.model.AssetVocabularyModel
064     * @generated
065     */
066    public class AssetVocabularyModelImpl extends BaseModelImpl<AssetVocabulary>
067            implements AssetVocabularyModel {
068            public static final String TABLE_NAME = "AssetVocabulary";
069            public static final Object[][] TABLE_COLUMNS = {
070                            { "uuid_", new Integer(Types.VARCHAR) },
071                            { "vocabularyId", new Integer(Types.BIGINT) },
072                            { "groupId", new Integer(Types.BIGINT) },
073                            { "companyId", new Integer(Types.BIGINT) },
074                            { "userId", new Integer(Types.BIGINT) },
075                            { "userName", new Integer(Types.VARCHAR) },
076                            { "createDate", new Integer(Types.TIMESTAMP) },
077                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
078                            { "name", new Integer(Types.VARCHAR) },
079                            { "title", new Integer(Types.VARCHAR) },
080                            { "description", new Integer(Types.VARCHAR) },
081                            { "settings_", new Integer(Types.VARCHAR) }
082                    };
083            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)";
084            public static final String TABLE_SQL_DROP = "drop table AssetVocabulary";
085            public static final String ORDER_BY_JPQL = " ORDER BY assetVocabulary.name ASC";
086            public static final String ORDER_BY_SQL = " ORDER BY AssetVocabulary.name ASC";
087            public static final String DATA_SOURCE = "liferayDataSource";
088            public static final String SESSION_FACTORY = "liferaySessionFactory";
089            public static final String TX_MANAGER = "liferayTransactionManager";
090            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
091                                    "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetVocabulary"),
092                            true);
093            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
094                                    "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetVocabulary"),
095                            true);
096    
097            /**
098             * Converts the soap model instance into a normal model instance.
099             *
100             * @param soapModel the soap model instance to convert
101             * @return the normal model instance
102             */
103            public static AssetVocabulary toModel(AssetVocabularySoap soapModel) {
104                    AssetVocabulary model = new AssetVocabularyImpl();
105    
106                    model.setUuid(soapModel.getUuid());
107                    model.setVocabularyId(soapModel.getVocabularyId());
108                    model.setGroupId(soapModel.getGroupId());
109                    model.setCompanyId(soapModel.getCompanyId());
110                    model.setUserId(soapModel.getUserId());
111                    model.setUserName(soapModel.getUserName());
112                    model.setCreateDate(soapModel.getCreateDate());
113                    model.setModifiedDate(soapModel.getModifiedDate());
114                    model.setName(soapModel.getName());
115                    model.setTitle(soapModel.getTitle());
116                    model.setDescription(soapModel.getDescription());
117                    model.setSettings(soapModel.getSettings());
118    
119                    return model;
120            }
121    
122            /**
123             * Converts the soap model instances into normal model instances.
124             *
125             * @param soapModels the soap model instances to convert
126             * @return the normal model instances
127             */
128            public static List<AssetVocabulary> toModels(
129                    AssetVocabularySoap[] soapModels) {
130                    List<AssetVocabulary> models = new ArrayList<AssetVocabulary>(soapModels.length);
131    
132                    for (AssetVocabularySoap soapModel : soapModels) {
133                            models.add(toModel(soapModel));
134                    }
135    
136                    return models;
137            }
138    
139            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
140                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetVocabulary"));
141    
142            public AssetVocabularyModelImpl() {
143            }
144    
145            public long getPrimaryKey() {
146                    return _vocabularyId;
147            }
148    
149            public void setPrimaryKey(long pk) {
150                    setVocabularyId(pk);
151            }
152    
153            public Serializable getPrimaryKeyObj() {
154                    return new Long(_vocabularyId);
155            }
156    
157            public String getUuid() {
158                    if (_uuid == null) {
159                            return StringPool.BLANK;
160                    }
161                    else {
162                            return _uuid;
163                    }
164            }
165    
166            public void setUuid(String uuid) {
167                    _uuid = uuid;
168    
169                    if (_originalUuid == null) {
170                            _originalUuid = uuid;
171                    }
172            }
173    
174            public String getOriginalUuid() {
175                    return GetterUtil.getString(_originalUuid);
176            }
177    
178            public long getVocabularyId() {
179                    return _vocabularyId;
180            }
181    
182            public void setVocabularyId(long vocabularyId) {
183                    _vocabularyId = vocabularyId;
184            }
185    
186            public long getGroupId() {
187                    return _groupId;
188            }
189    
190            public void setGroupId(long groupId) {
191                    _groupId = groupId;
192    
193                    if (!_setOriginalGroupId) {
194                            _setOriginalGroupId = true;
195    
196                            _originalGroupId = groupId;
197                    }
198            }
199    
200            public long getOriginalGroupId() {
201                    return _originalGroupId;
202            }
203    
204            public long getCompanyId() {
205                    return _companyId;
206            }
207    
208            public void setCompanyId(long companyId) {
209                    _companyId = companyId;
210            }
211    
212            public long getUserId() {
213                    return _userId;
214            }
215    
216            public void setUserId(long userId) {
217                    _userId = userId;
218            }
219    
220            public String getUserUuid() throws SystemException {
221                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
222            }
223    
224            public void setUserUuid(String userUuid) {
225                    _userUuid = userUuid;
226            }
227    
228            public String getUserName() {
229                    if (_userName == null) {
230                            return StringPool.BLANK;
231                    }
232                    else {
233                            return _userName;
234                    }
235            }
236    
237            public void setUserName(String userName) {
238                    _userName = userName;
239            }
240    
241            public Date getCreateDate() {
242                    return _createDate;
243            }
244    
245            public void setCreateDate(Date createDate) {
246                    _createDate = createDate;
247            }
248    
249            public Date getModifiedDate() {
250                    return _modifiedDate;
251            }
252    
253            public void setModifiedDate(Date modifiedDate) {
254                    _modifiedDate = modifiedDate;
255            }
256    
257            public String getName() {
258                    if (_name == null) {
259                            return StringPool.BLANK;
260                    }
261                    else {
262                            return _name;
263                    }
264            }
265    
266            public void setName(String name) {
267                    _name = name;
268    
269                    if (_originalName == null) {
270                            _originalName = name;
271                    }
272            }
273    
274            public String getOriginalName() {
275                    return GetterUtil.getString(_originalName);
276            }
277    
278            public String getTitle() {
279                    if (_title == null) {
280                            return StringPool.BLANK;
281                    }
282                    else {
283                            return _title;
284                    }
285            }
286    
287            public String getTitle(Locale locale) {
288                    String languageId = LocaleUtil.toLanguageId(locale);
289    
290                    return getTitle(languageId);
291            }
292    
293            public String getTitle(Locale locale, boolean useDefault) {
294                    String languageId = LocaleUtil.toLanguageId(locale);
295    
296                    return getTitle(languageId, useDefault);
297            }
298    
299            public String getTitle(String languageId) {
300                    String value = LocalizationUtil.getLocalization(getTitle(), languageId);
301    
302                    if (isEscapedModel()) {
303                            return HtmlUtil.escape(value);
304                    }
305                    else {
306                            return value;
307                    }
308            }
309    
310            public String getTitle(String languageId, boolean useDefault) {
311                    String value = LocalizationUtil.getLocalization(getTitle(), languageId,
312                                    useDefault);
313    
314                    if (isEscapedModel()) {
315                            return HtmlUtil.escape(value);
316                    }
317                    else {
318                            return value;
319                    }
320            }
321    
322            public Map<Locale, String> getTitleMap() {
323                    return LocalizationUtil.getLocalizationMap(getTitle());
324            }
325    
326            public void setTitle(String title) {
327                    _title = title;
328            }
329    
330            public void setTitle(Locale locale, String title) {
331                    String languageId = LocaleUtil.toLanguageId(locale);
332    
333                    if (Validator.isNotNull(title)) {
334                            setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
335                                            title, languageId));
336                    }
337                    else {
338                            setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
339                                            languageId));
340                    }
341            }
342    
343            public void setTitleMap(Map<Locale, String> titleMap) {
344                    if (titleMap == null) {
345                            return;
346                    }
347    
348                    Locale[] locales = LanguageUtil.getAvailableLocales();
349    
350                    for (Locale locale : locales) {
351                            String title = titleMap.get(locale);
352    
353                            setTitle(locale, title);
354                    }
355            }
356    
357            public String getDescription() {
358                    if (_description == null) {
359                            return StringPool.BLANK;
360                    }
361                    else {
362                            return _description;
363                    }
364            }
365    
366            public String getDescription(Locale locale) {
367                    String languageId = LocaleUtil.toLanguageId(locale);
368    
369                    return getDescription(languageId);
370            }
371    
372            public String getDescription(Locale locale, boolean useDefault) {
373                    String languageId = LocaleUtil.toLanguageId(locale);
374    
375                    return getDescription(languageId, useDefault);
376            }
377    
378            public String getDescription(String languageId) {
379                    String value = LocalizationUtil.getLocalization(getDescription(),
380                                    languageId);
381    
382                    if (isEscapedModel()) {
383                            return HtmlUtil.escape(value);
384                    }
385                    else {
386                            return value;
387                    }
388            }
389    
390            public String getDescription(String languageId, boolean useDefault) {
391                    String value = LocalizationUtil.getLocalization(getDescription(),
392                                    languageId, useDefault);
393    
394                    if (isEscapedModel()) {
395                            return HtmlUtil.escape(value);
396                    }
397                    else {
398                            return value;
399                    }
400            }
401    
402            public Map<Locale, String> getDescriptionMap() {
403                    return LocalizationUtil.getLocalizationMap(getDescription());
404            }
405    
406            public void setDescription(String description) {
407                    _description = description;
408            }
409    
410            public void setDescription(Locale locale, String description) {
411                    String languageId = LocaleUtil.toLanguageId(locale);
412    
413                    if (Validator.isNotNull(description)) {
414                            setDescription(LocalizationUtil.updateLocalization(
415                                            getDescription(), "Description", description, languageId));
416                    }
417                    else {
418                            setDescription(LocalizationUtil.removeLocalization(
419                                            getDescription(), "Description", languageId));
420                    }
421            }
422    
423            public void setDescriptionMap(Map<Locale, String> descriptionMap) {
424                    if (descriptionMap == null) {
425                            return;
426                    }
427    
428                    Locale[] locales = LanguageUtil.getAvailableLocales();
429    
430                    for (Locale locale : locales) {
431                            String description = descriptionMap.get(locale);
432    
433                            setDescription(locale, description);
434                    }
435            }
436    
437            public String getSettings() {
438                    if (_settings == null) {
439                            return StringPool.BLANK;
440                    }
441                    else {
442                            return _settings;
443                    }
444            }
445    
446            public void setSettings(String settings) {
447                    _settings = settings;
448            }
449    
450            public AssetVocabulary toEscapedModel() {
451                    if (isEscapedModel()) {
452                            return (AssetVocabulary)this;
453                    }
454                    else {
455                            return (AssetVocabulary)Proxy.newProxyInstance(AssetVocabulary.class.getClassLoader(),
456                                    new Class[] { AssetVocabulary.class },
457                                    new AutoEscapeBeanHandler(this));
458                    }
459            }
460    
461            public ExpandoBridge getExpandoBridge() {
462                    if (_expandoBridge == null) {
463                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
464                                            AssetVocabulary.class.getName(), getPrimaryKey());
465                    }
466    
467                    return _expandoBridge;
468            }
469    
470            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
471                    getExpandoBridge().setAttributes(serviceContext);
472            }
473    
474            public Object clone() {
475                    AssetVocabularyImpl clone = new AssetVocabularyImpl();
476    
477                    clone.setUuid(getUuid());
478                    clone.setVocabularyId(getVocabularyId());
479                    clone.setGroupId(getGroupId());
480                    clone.setCompanyId(getCompanyId());
481                    clone.setUserId(getUserId());
482                    clone.setUserName(getUserName());
483                    clone.setCreateDate(getCreateDate());
484                    clone.setModifiedDate(getModifiedDate());
485                    clone.setName(getName());
486                    clone.setTitle(getTitle());
487                    clone.setDescription(getDescription());
488                    clone.setSettings(getSettings());
489    
490                    return clone;
491            }
492    
493            public int compareTo(AssetVocabulary assetVocabulary) {
494                    int value = 0;
495    
496                    value = getName().compareTo(assetVocabulary.getName());
497    
498                    if (value != 0) {
499                            return value;
500                    }
501    
502                    return 0;
503            }
504    
505            public boolean equals(Object obj) {
506                    if (obj == null) {
507                            return false;
508                    }
509    
510                    AssetVocabulary assetVocabulary = null;
511    
512                    try {
513                            assetVocabulary = (AssetVocabulary)obj;
514                    }
515                    catch (ClassCastException cce) {
516                            return false;
517                    }
518    
519                    long pk = assetVocabulary.getPrimaryKey();
520    
521                    if (getPrimaryKey() == pk) {
522                            return true;
523                    }
524                    else {
525                            return false;
526                    }
527            }
528    
529            public int hashCode() {
530                    return (int)getPrimaryKey();
531            }
532    
533            public String toString() {
534                    StringBundler sb = new StringBundler(25);
535    
536                    sb.append("{uuid=");
537                    sb.append(getUuid());
538                    sb.append(", vocabularyId=");
539                    sb.append(getVocabularyId());
540                    sb.append(", groupId=");
541                    sb.append(getGroupId());
542                    sb.append(", companyId=");
543                    sb.append(getCompanyId());
544                    sb.append(", userId=");
545                    sb.append(getUserId());
546                    sb.append(", userName=");
547                    sb.append(getUserName());
548                    sb.append(", createDate=");
549                    sb.append(getCreateDate());
550                    sb.append(", modifiedDate=");
551                    sb.append(getModifiedDate());
552                    sb.append(", name=");
553                    sb.append(getName());
554                    sb.append(", title=");
555                    sb.append(getTitle());
556                    sb.append(", description=");
557                    sb.append(getDescription());
558                    sb.append(", settings=");
559                    sb.append(getSettings());
560                    sb.append("}");
561    
562                    return sb.toString();
563            }
564    
565            public String toXmlString() {
566                    StringBundler sb = new StringBundler(40);
567    
568                    sb.append("<model><model-name>");
569                    sb.append("com.liferay.portlet.asset.model.AssetVocabulary");
570                    sb.append("</model-name>");
571    
572                    sb.append(
573                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
574                    sb.append(getUuid());
575                    sb.append("]]></column-value></column>");
576                    sb.append(
577                            "<column><column-name>vocabularyId</column-name><column-value><![CDATA[");
578                    sb.append(getVocabularyId());
579                    sb.append("]]></column-value></column>");
580                    sb.append(
581                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
582                    sb.append(getGroupId());
583                    sb.append("]]></column-value></column>");
584                    sb.append(
585                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
586                    sb.append(getCompanyId());
587                    sb.append("]]></column-value></column>");
588                    sb.append(
589                            "<column><column-name>userId</column-name><column-value><![CDATA[");
590                    sb.append(getUserId());
591                    sb.append("]]></column-value></column>");
592                    sb.append(
593                            "<column><column-name>userName</column-name><column-value><![CDATA[");
594                    sb.append(getUserName());
595                    sb.append("]]></column-value></column>");
596                    sb.append(
597                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
598                    sb.append(getCreateDate());
599                    sb.append("]]></column-value></column>");
600                    sb.append(
601                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
602                    sb.append(getModifiedDate());
603                    sb.append("]]></column-value></column>");
604                    sb.append(
605                            "<column><column-name>name</column-name><column-value><![CDATA[");
606                    sb.append(getName());
607                    sb.append("]]></column-value></column>");
608                    sb.append(
609                            "<column><column-name>title</column-name><column-value><![CDATA[");
610                    sb.append(getTitle());
611                    sb.append("]]></column-value></column>");
612                    sb.append(
613                            "<column><column-name>description</column-name><column-value><![CDATA[");
614                    sb.append(getDescription());
615                    sb.append("]]></column-value></column>");
616                    sb.append(
617                            "<column><column-name>settings</column-name><column-value><![CDATA[");
618                    sb.append(getSettings());
619                    sb.append("]]></column-value></column>");
620    
621                    sb.append("</model>");
622    
623                    return sb.toString();
624            }
625    
626            private String _uuid;
627            private String _originalUuid;
628            private long _vocabularyId;
629            private long _groupId;
630            private long _originalGroupId;
631            private boolean _setOriginalGroupId;
632            private long _companyId;
633            private long _userId;
634            private String _userUuid;
635            private String _userName;
636            private Date _createDate;
637            private Date _modifiedDate;
638            private String _name;
639            private String _originalName;
640            private String _title;
641            private String _description;
642            private String _settings;
643            private transient ExpandoBridge _expandoBridge;
644    }