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