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.portal.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.language.LanguageUtil;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.HtmlUtil;
021    import com.liferay.portal.kernel.util.LocaleUtil;
022    import com.liferay.portal.kernel.util.LocalizationUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
025    import com.liferay.portal.kernel.util.Validator;
026    import com.liferay.portal.model.LayoutSetPrototype;
027    import com.liferay.portal.model.LayoutSetPrototypeModel;
028    import com.liferay.portal.model.LayoutSetPrototypeSoap;
029    import com.liferay.portal.service.ServiceContext;
030    
031    import com.liferay.portlet.expando.model.ExpandoBridge;
032    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033    
034    import java.io.Serializable;
035    
036    import java.lang.reflect.Proxy;
037    
038    import java.sql.Types;
039    
040    import java.util.ArrayList;
041    import java.util.List;
042    import java.util.Locale;
043    import java.util.Map;
044    
045    /**
046     * <p>
047     * This interface is a model that represents the LayoutSetPrototype table in the
048     * database.
049     * </p>
050     *
051     * @author    Brian Wing Shun Chan
052     * @see       LayoutSetPrototypeImpl
053     * @see       com.liferay.portal.model.LayoutSetPrototype
054     * @see       com.liferay.portal.model.LayoutSetPrototypeModel
055     * @generated
056     */
057    public class LayoutSetPrototypeModelImpl extends BaseModelImpl<LayoutSetPrototype>
058            implements LayoutSetPrototypeModel {
059            public static final String TABLE_NAME = "LayoutSetPrototype";
060            public static final Object[][] TABLE_COLUMNS = {
061                            { "layoutSetPrototypeId", new Integer(Types.BIGINT) },
062                            { "companyId", new Integer(Types.BIGINT) },
063                            { "name", new Integer(Types.VARCHAR) },
064                            { "description", new Integer(Types.VARCHAR) },
065                            { "settings_", new Integer(Types.VARCHAR) },
066                            { "active_", new Integer(Types.BOOLEAN) }
067                    };
068            public static final String TABLE_SQL_CREATE = "create table LayoutSetPrototype (layoutSetPrototypeId LONG not null primary key,companyId LONG,name STRING null,description STRING null,settings_ STRING null,active_ BOOLEAN)";
069            public static final String TABLE_SQL_DROP = "drop table LayoutSetPrototype";
070            public static final String DATA_SOURCE = "liferayDataSource";
071            public static final String SESSION_FACTORY = "liferaySessionFactory";
072            public static final String TX_MANAGER = "liferayTransactionManager";
073            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.entity.cache.enabled.com.liferay.portal.model.LayoutSetPrototype"),
075                            true);
076            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.finder.cache.enabled.com.liferay.portal.model.LayoutSetPrototype"),
078                            true);
079    
080            public static LayoutSetPrototype toModel(LayoutSetPrototypeSoap soapModel) {
081                    LayoutSetPrototype model = new LayoutSetPrototypeImpl();
082    
083                    model.setLayoutSetPrototypeId(soapModel.getLayoutSetPrototypeId());
084                    model.setCompanyId(soapModel.getCompanyId());
085                    model.setName(soapModel.getName());
086                    model.setDescription(soapModel.getDescription());
087                    model.setSettings(soapModel.getSettings());
088                    model.setActive(soapModel.getActive());
089    
090                    return model;
091            }
092    
093            public static List<LayoutSetPrototype> toModels(
094                    LayoutSetPrototypeSoap[] soapModels) {
095                    List<LayoutSetPrototype> models = new ArrayList<LayoutSetPrototype>(soapModels.length);
096    
097                    for (LayoutSetPrototypeSoap soapModel : soapModels) {
098                            models.add(toModel(soapModel));
099                    }
100    
101                    return models;
102            }
103    
104            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
105                                    "lock.expiration.time.com.liferay.portal.model.LayoutSetPrototype"));
106    
107            public LayoutSetPrototypeModelImpl() {
108            }
109    
110            public long getPrimaryKey() {
111                    return _layoutSetPrototypeId;
112            }
113    
114            public void setPrimaryKey(long pk) {
115                    setLayoutSetPrototypeId(pk);
116            }
117    
118            public Serializable getPrimaryKeyObj() {
119                    return new Long(_layoutSetPrototypeId);
120            }
121    
122            public long getLayoutSetPrototypeId() {
123                    return _layoutSetPrototypeId;
124            }
125    
126            public void setLayoutSetPrototypeId(long layoutSetPrototypeId) {
127                    _layoutSetPrototypeId = layoutSetPrototypeId;
128            }
129    
130            public long getCompanyId() {
131                    return _companyId;
132            }
133    
134            public void setCompanyId(long companyId) {
135                    _companyId = companyId;
136            }
137    
138            public String getName() {
139                    if (_name == null) {
140                            return StringPool.BLANK;
141                    }
142                    else {
143                            return _name;
144                    }
145            }
146    
147            public String getName(Locale locale) {
148                    String languageId = LocaleUtil.toLanguageId(locale);
149    
150                    return getName(languageId);
151            }
152    
153            public String getName(Locale locale, boolean useDefault) {
154                    String languageId = LocaleUtil.toLanguageId(locale);
155    
156                    return getName(languageId, useDefault);
157            }
158    
159            public String getName(String languageId) {
160                    String value = LocalizationUtil.getLocalization(getName(), languageId);
161    
162                    if (isEscapedModel()) {
163                            return HtmlUtil.escape(value);
164                    }
165                    else {
166                            return value;
167                    }
168            }
169    
170            public String getName(String languageId, boolean useDefault) {
171                    String value = LocalizationUtil.getLocalization(getName(), languageId,
172                                    useDefault);
173    
174                    if (isEscapedModel()) {
175                            return HtmlUtil.escape(value);
176                    }
177                    else {
178                            return value;
179                    }
180            }
181    
182            public Map<Locale, String> getNameMap() {
183                    return LocalizationUtil.getLocalizationMap(getName());
184            }
185    
186            public void setName(String name) {
187                    _name = name;
188            }
189    
190            public void setName(Locale locale, String name) {
191                    String languageId = LocaleUtil.toLanguageId(locale);
192    
193                    if (Validator.isNotNull(name)) {
194                            setName(LocalizationUtil.updateLocalization(getName(), "Name",
195                                            name, languageId));
196                    }
197                    else {
198                            setName(LocalizationUtil.removeLocalization(getName(), "Name",
199                                            languageId));
200                    }
201            }
202    
203            public void setNameMap(Map<Locale, String> nameMap) {
204                    if (nameMap == null) {
205                            return;
206                    }
207    
208                    Locale[] locales = LanguageUtil.getAvailableLocales();
209    
210                    for (Locale locale : locales) {
211                            String name = nameMap.get(locale);
212    
213                            setName(locale, name);
214                    }
215            }
216    
217            public String getDescription() {
218                    if (_description == null) {
219                            return StringPool.BLANK;
220                    }
221                    else {
222                            return _description;
223                    }
224            }
225    
226            public void setDescription(String description) {
227                    _description = description;
228            }
229    
230            public String getSettings() {
231                    if (_settings == null) {
232                            return StringPool.BLANK;
233                    }
234                    else {
235                            return _settings;
236                    }
237            }
238    
239            public void setSettings(String settings) {
240                    _settings = settings;
241            }
242    
243            public boolean getActive() {
244                    return _active;
245            }
246    
247            public boolean isActive() {
248                    return _active;
249            }
250    
251            public void setActive(boolean active) {
252                    _active = active;
253            }
254    
255            public LayoutSetPrototype toEscapedModel() {
256                    if (isEscapedModel()) {
257                            return (LayoutSetPrototype)this;
258                    }
259                    else {
260                            return (LayoutSetPrototype)Proxy.newProxyInstance(LayoutSetPrototype.class.getClassLoader(),
261                                    new Class[] { LayoutSetPrototype.class },
262                                    new AutoEscapeBeanHandler(this));
263                    }
264            }
265    
266            public ExpandoBridge getExpandoBridge() {
267                    if (_expandoBridge == null) {
268                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
269                                            LayoutSetPrototype.class.getName(), getPrimaryKey());
270                    }
271    
272                    return _expandoBridge;
273            }
274    
275            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
276                    getExpandoBridge().setAttributes(serviceContext);
277            }
278    
279            public Object clone() {
280                    LayoutSetPrototypeImpl clone = new LayoutSetPrototypeImpl();
281    
282                    clone.setLayoutSetPrototypeId(getLayoutSetPrototypeId());
283                    clone.setCompanyId(getCompanyId());
284                    clone.setName(getName());
285                    clone.setDescription(getDescription());
286                    clone.setSettings(getSettings());
287                    clone.setActive(getActive());
288    
289                    return clone;
290            }
291    
292            public int compareTo(LayoutSetPrototype layoutSetPrototype) {
293                    long pk = layoutSetPrototype.getPrimaryKey();
294    
295                    if (getPrimaryKey() < pk) {
296                            return -1;
297                    }
298                    else if (getPrimaryKey() > pk) {
299                            return 1;
300                    }
301                    else {
302                            return 0;
303                    }
304            }
305    
306            public boolean equals(Object obj) {
307                    if (obj == null) {
308                            return false;
309                    }
310    
311                    LayoutSetPrototype layoutSetPrototype = null;
312    
313                    try {
314                            layoutSetPrototype = (LayoutSetPrototype)obj;
315                    }
316                    catch (ClassCastException cce) {
317                            return false;
318                    }
319    
320                    long pk = layoutSetPrototype.getPrimaryKey();
321    
322                    if (getPrimaryKey() == pk) {
323                            return true;
324                    }
325                    else {
326                            return false;
327                    }
328            }
329    
330            public int hashCode() {
331                    return (int)getPrimaryKey();
332            }
333    
334            public String toString() {
335                    StringBundler sb = new StringBundler(13);
336    
337                    sb.append("{layoutSetPrototypeId=");
338                    sb.append(getLayoutSetPrototypeId());
339                    sb.append(", companyId=");
340                    sb.append(getCompanyId());
341                    sb.append(", name=");
342                    sb.append(getName());
343                    sb.append(", description=");
344                    sb.append(getDescription());
345                    sb.append(", settings=");
346                    sb.append(getSettings());
347                    sb.append(", active=");
348                    sb.append(getActive());
349                    sb.append("}");
350    
351                    return sb.toString();
352            }
353    
354            public String toXmlString() {
355                    StringBundler sb = new StringBundler(22);
356    
357                    sb.append("<model><model-name>");
358                    sb.append("com.liferay.portal.model.LayoutSetPrototype");
359                    sb.append("</model-name>");
360    
361                    sb.append(
362                            "<column><column-name>layoutSetPrototypeId</column-name><column-value><![CDATA[");
363                    sb.append(getLayoutSetPrototypeId());
364                    sb.append("]]></column-value></column>");
365                    sb.append(
366                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
367                    sb.append(getCompanyId());
368                    sb.append("]]></column-value></column>");
369                    sb.append(
370                            "<column><column-name>name</column-name><column-value><![CDATA[");
371                    sb.append(getName());
372                    sb.append("]]></column-value></column>");
373                    sb.append(
374                            "<column><column-name>description</column-name><column-value><![CDATA[");
375                    sb.append(getDescription());
376                    sb.append("]]></column-value></column>");
377                    sb.append(
378                            "<column><column-name>settings</column-name><column-value><![CDATA[");
379                    sb.append(getSettings());
380                    sb.append("]]></column-value></column>");
381                    sb.append(
382                            "<column><column-name>active</column-name><column-value><![CDATA[");
383                    sb.append(getActive());
384                    sb.append("]]></column-value></column>");
385    
386                    sb.append("</model>");
387    
388                    return sb.toString();
389            }
390    
391            private long _layoutSetPrototypeId;
392            private long _companyId;
393            private String _name;
394            private String _description;
395            private String _settings;
396            private boolean _active;
397            private transient ExpandoBridge _expandoBridge;
398    }