001    /**
002     * Copyright (c) 2000-2011 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.LayoutPrototype;
027    import com.liferay.portal.model.LayoutPrototypeModel;
028    import com.liferay.portal.model.LayoutPrototypeSoap;
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 LayoutPrototype service. Represents a row in the "LayoutPrototype" 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.LayoutPrototypeModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link LayoutPrototypeImpl}.
050     * </p>
051     *
052     * <p>
053     * Never modify or reference this class directly. All methods that expect a layout prototype model instance should use the {@link com.liferay.portal.model.LayoutPrototype} interface instead.
054     * </p>
055     *
056     * @author Brian Wing Shun Chan
057     * @see LayoutPrototypeImpl
058     * @see com.liferay.portal.model.LayoutPrototype
059     * @see com.liferay.portal.model.LayoutPrototypeModel
060     * @generated
061     */
062    public class LayoutPrototypeModelImpl extends BaseModelImpl<LayoutPrototype>
063            implements LayoutPrototypeModel {
064            public static final String TABLE_NAME = "LayoutPrototype";
065            public static final Object[][] TABLE_COLUMNS = {
066                            { "layoutPrototypeId", 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 LayoutPrototype (layoutPrototypeId 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 LayoutPrototype";
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.LayoutPrototype"),
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.LayoutPrototype"),
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 LayoutPrototype toModel(LayoutPrototypeSoap soapModel) {
092                    LayoutPrototype model = new LayoutPrototypeImpl();
093    
094                    model.setLayoutPrototypeId(soapModel.getLayoutPrototypeId());
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<LayoutPrototype> toModels(
111                    LayoutPrototypeSoap[] soapModels) {
112                    List<LayoutPrototype> models = new ArrayList<LayoutPrototype>(soapModels.length);
113    
114                    for (LayoutPrototypeSoap 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.LayoutPrototype"));
123    
124            public LayoutPrototypeModelImpl() {
125            }
126    
127            public long getPrimaryKey() {
128                    return _layoutPrototypeId;
129            }
130    
131            public void setPrimaryKey(long pk) {
132                    setLayoutPrototypeId(pk);
133            }
134    
135            public Serializable getPrimaryKeyObj() {
136                    return new Long(_layoutPrototypeId);
137            }
138    
139            public long getLayoutPrototypeId() {
140                    return _layoutPrototypeId;
141            }
142    
143            public void setLayoutPrototypeId(long layoutPrototypeId) {
144                    _layoutPrototypeId = layoutPrototypeId;
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 LayoutPrototype toEscapedModel() {
273                    if (isEscapedModel()) {
274                            return (LayoutPrototype)this;
275                    }
276                    else {
277                            return (LayoutPrototype)Proxy.newProxyInstance(LayoutPrototype.class.getClassLoader(),
278                                    new Class[] { LayoutPrototype.class },
279                                    new AutoEscapeBeanHandler(this));
280                    }
281            }
282    
283            public ExpandoBridge getExpandoBridge() {
284                    if (_expandoBridge == null) {
285                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
286                                            LayoutPrototype.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                    LayoutPrototypeImpl layoutPrototypeImpl = new LayoutPrototypeImpl();
298    
299                    layoutPrototypeImpl.setLayoutPrototypeId(getLayoutPrototypeId());
300    
301                    layoutPrototypeImpl.setCompanyId(getCompanyId());
302    
303                    layoutPrototypeImpl.setName(getName());
304    
305                    layoutPrototypeImpl.setDescription(getDescription());
306    
307                    layoutPrototypeImpl.setSettings(getSettings());
308    
309                    layoutPrototypeImpl.setActive(getActive());
310    
311                    return layoutPrototypeImpl;
312            }
313    
314            public int compareTo(LayoutPrototype layoutPrototype) {
315                    long pk = layoutPrototype.getPrimaryKey();
316    
317                    if (getPrimaryKey() < pk) {
318                            return -1;
319                    }
320                    else if (getPrimaryKey() > pk) {
321                            return 1;
322                    }
323                    else {
324                            return 0;
325                    }
326            }
327    
328            public boolean equals(Object obj) {
329                    if (obj == null) {
330                            return false;
331                    }
332    
333                    LayoutPrototype layoutPrototype = null;
334    
335                    try {
336                            layoutPrototype = (LayoutPrototype)obj;
337                    }
338                    catch (ClassCastException cce) {
339                            return false;
340                    }
341    
342                    long pk = layoutPrototype.getPrimaryKey();
343    
344                    if (getPrimaryKey() == pk) {
345                            return true;
346                    }
347                    else {
348                            return false;
349                    }
350            }
351    
352            public int hashCode() {
353                    return (int)getPrimaryKey();
354            }
355    
356            public String toString() {
357                    StringBundler sb = new StringBundler(13);
358    
359                    sb.append("{layoutPrototypeId=");
360                    sb.append(getLayoutPrototypeId());
361                    sb.append(", companyId=");
362                    sb.append(getCompanyId());
363                    sb.append(", name=");
364                    sb.append(getName());
365                    sb.append(", description=");
366                    sb.append(getDescription());
367                    sb.append(", settings=");
368                    sb.append(getSettings());
369                    sb.append(", active=");
370                    sb.append(getActive());
371                    sb.append("}");
372    
373                    return sb.toString();
374            }
375    
376            public String toXmlString() {
377                    StringBundler sb = new StringBundler(22);
378    
379                    sb.append("<model><model-name>");
380                    sb.append("com.liferay.portal.model.LayoutPrototype");
381                    sb.append("</model-name>");
382    
383                    sb.append(
384                            "<column><column-name>layoutPrototypeId</column-name><column-value><![CDATA[");
385                    sb.append(getLayoutPrototypeId());
386                    sb.append("]]></column-value></column>");
387                    sb.append(
388                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
389                    sb.append(getCompanyId());
390                    sb.append("]]></column-value></column>");
391                    sb.append(
392                            "<column><column-name>name</column-name><column-value><![CDATA[");
393                    sb.append(getName());
394                    sb.append("]]></column-value></column>");
395                    sb.append(
396                            "<column><column-name>description</column-name><column-value><![CDATA[");
397                    sb.append(getDescription());
398                    sb.append("]]></column-value></column>");
399                    sb.append(
400                            "<column><column-name>settings</column-name><column-value><![CDATA[");
401                    sb.append(getSettings());
402                    sb.append("]]></column-value></column>");
403                    sb.append(
404                            "<column><column-name>active</column-name><column-value><![CDATA[");
405                    sb.append(getActive());
406                    sb.append("]]></column-value></column>");
407    
408                    sb.append("</model>");
409    
410                    return sb.toString();
411            }
412    
413            private long _layoutPrototypeId;
414            private long _companyId;
415            private String _name;
416            private String _description;
417            private String _settings;
418            private boolean _active;
419            private transient ExpandoBridge _expandoBridge;
420    }