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.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.Portlet;
022    import com.liferay.portal.model.PortletModel;
023    import com.liferay.portal.model.PortletSoap;
024    import com.liferay.portal.service.ServiceContext;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    
029    import java.io.Serializable;
030    
031    import java.lang.reflect.Proxy;
032    
033    import java.sql.Types;
034    
035    import java.util.ArrayList;
036    import java.util.List;
037    
038    /**
039     * The base model implementation for the Portlet service. Represents a row in the "Portlet" database table, with each column mapped to a property of this class.
040     *
041     * <p>
042     * This implementation and its corresponding interface {@link com.liferay.portal.model.PortletModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PortletImpl}.
043     * </p>
044     *
045     * <p>
046     * Never modify or reference this class directly. All methods that expect a portlet model instance should use the {@link com.liferay.portal.model.Portlet} interface instead.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see PortletImpl
051     * @see com.liferay.portal.model.Portlet
052     * @see com.liferay.portal.model.PortletModel
053     * @generated
054     */
055    public class PortletModelImpl extends BaseModelImpl<Portlet>
056            implements PortletModel {
057            public static final String TABLE_NAME = "Portlet";
058            public static final Object[][] TABLE_COLUMNS = {
059                            { "id_", new Integer(Types.BIGINT) },
060                            { "companyId", new Integer(Types.BIGINT) },
061                            { "portletId", new Integer(Types.VARCHAR) },
062                            { "roles", new Integer(Types.VARCHAR) },
063                            { "active_", new Integer(Types.BOOLEAN) }
064                    };
065            public static final String TABLE_SQL_CREATE = "create table Portlet (id_ LONG not null primary key,companyId LONG,portletId VARCHAR(200) null,roles STRING null,active_ BOOLEAN)";
066            public static final String TABLE_SQL_DROP = "drop table Portlet";
067            public static final String DATA_SOURCE = "liferayDataSource";
068            public static final String SESSION_FACTORY = "liferaySessionFactory";
069            public static final String TX_MANAGER = "liferayTransactionManager";
070            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
071                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Portlet"),
072                            true);
073            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Portlet"),
075                            true);
076    
077            /**
078             * Converts the soap model instance into a normal model instance.
079             *
080             * @param soapModel the soap model instance to convert
081             * @return the normal model instance
082             */
083            public static Portlet toModel(PortletSoap soapModel) {
084                    Portlet model = new PortletImpl();
085    
086                    model.setId(soapModel.getId());
087                    model.setCompanyId(soapModel.getCompanyId());
088                    model.setPortletId(soapModel.getPortletId());
089                    model.setRoles(soapModel.getRoles());
090                    model.setActive(soapModel.getActive());
091    
092                    return model;
093            }
094    
095            /**
096             * Converts the soap model instances into normal model instances.
097             *
098             * @param soapModels the soap model instances to convert
099             * @return the normal model instances
100             */
101            public static List<Portlet> toModels(PortletSoap[] soapModels) {
102                    List<Portlet> models = new ArrayList<Portlet>(soapModels.length);
103    
104                    for (PortletSoap soapModel : soapModels) {
105                            models.add(toModel(soapModel));
106                    }
107    
108                    return models;
109            }
110    
111            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
112                                    "lock.expiration.time.com.liferay.portal.model.Portlet"));
113    
114            public PortletModelImpl() {
115            }
116    
117            public long getPrimaryKey() {
118                    return _id;
119            }
120    
121            public void setPrimaryKey(long pk) {
122                    setId(pk);
123            }
124    
125            public Serializable getPrimaryKeyObj() {
126                    return new Long(_id);
127            }
128    
129            public long getId() {
130                    return _id;
131            }
132    
133            public void setId(long id) {
134                    _id = id;
135            }
136    
137            public long getCompanyId() {
138                    return _companyId;
139            }
140    
141            public void setCompanyId(long companyId) {
142                    if (!_setOriginalCompanyId) {
143                            _setOriginalCompanyId = true;
144    
145                            _originalCompanyId = _companyId;
146                    }
147    
148                    _companyId = companyId;
149            }
150    
151            public long getOriginalCompanyId() {
152                    return _originalCompanyId;
153            }
154    
155            public String getPortletId() {
156                    if (_portletId == null) {
157                            return StringPool.BLANK;
158                    }
159                    else {
160                            return _portletId;
161                    }
162            }
163    
164            public void setPortletId(String portletId) {
165                    if (_originalPortletId == null) {
166                            _originalPortletId = _portletId;
167                    }
168    
169                    _portletId = portletId;
170            }
171    
172            public String getOriginalPortletId() {
173                    return GetterUtil.getString(_originalPortletId);
174            }
175    
176            public String getRoles() {
177                    if (_roles == null) {
178                            return StringPool.BLANK;
179                    }
180                    else {
181                            return _roles;
182                    }
183            }
184    
185            public void setRoles(String roles) {
186                    _roles = roles;
187            }
188    
189            public boolean getActive() {
190                    return _active;
191            }
192    
193            public boolean isActive() {
194                    return _active;
195            }
196    
197            public void setActive(boolean active) {
198                    _active = active;
199            }
200    
201            public Portlet toEscapedModel() {
202                    if (isEscapedModel()) {
203                            return (Portlet)this;
204                    }
205                    else {
206                            return (Portlet)Proxy.newProxyInstance(Portlet.class.getClassLoader(),
207                                    new Class[] { Portlet.class }, new AutoEscapeBeanHandler(this));
208                    }
209            }
210    
211            public ExpandoBridge getExpandoBridge() {
212                    if (_expandoBridge == null) {
213                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
214                                            Portlet.class.getName(), getPrimaryKey());
215                    }
216    
217                    return _expandoBridge;
218            }
219    
220            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
221                    getExpandoBridge().setAttributes(serviceContext);
222            }
223    
224            public Object clone() {
225                    PortletImpl portletImpl = new PortletImpl();
226    
227                    portletImpl.setId(getId());
228    
229                    portletImpl.setCompanyId(getCompanyId());
230    
231                    PortletModelImpl portletModelImpl = portletImpl;
232    
233                    portletModelImpl._originalCompanyId = portletModelImpl._companyId;
234    
235                    portletModelImpl._setOriginalCompanyId = false;
236                    portletImpl.setPortletId(getPortletId());
237    
238                    portletModelImpl._originalPortletId = portletModelImpl._portletId;
239    
240                    portletImpl.setRoles(getRoles());
241    
242                    portletImpl.setActive(getActive());
243    
244                    return portletImpl;
245            }
246    
247            public int compareTo(Portlet portlet) {
248                    long pk = portlet.getPrimaryKey();
249    
250                    if (getPrimaryKey() < pk) {
251                            return -1;
252                    }
253                    else if (getPrimaryKey() > pk) {
254                            return 1;
255                    }
256                    else {
257                            return 0;
258                    }
259            }
260    
261            public boolean equals(Object obj) {
262                    if (obj == null) {
263                            return false;
264                    }
265    
266                    Portlet portlet = null;
267    
268                    try {
269                            portlet = (Portlet)obj;
270                    }
271                    catch (ClassCastException cce) {
272                            return false;
273                    }
274    
275                    long pk = portlet.getPrimaryKey();
276    
277                    if (getPrimaryKey() == pk) {
278                            return true;
279                    }
280                    else {
281                            return false;
282                    }
283            }
284    
285            public int hashCode() {
286                    return (int)getPrimaryKey();
287            }
288    
289            public String toString() {
290                    StringBundler sb = new StringBundler(11);
291    
292                    sb.append("{id=");
293                    sb.append(getId());
294                    sb.append(", companyId=");
295                    sb.append(getCompanyId());
296                    sb.append(", portletId=");
297                    sb.append(getPortletId());
298                    sb.append(", roles=");
299                    sb.append(getRoles());
300                    sb.append(", active=");
301                    sb.append(getActive());
302                    sb.append("}");
303    
304                    return sb.toString();
305            }
306    
307            public String toXmlString() {
308                    StringBundler sb = new StringBundler(19);
309    
310                    sb.append("<model><model-name>");
311                    sb.append("com.liferay.portal.model.Portlet");
312                    sb.append("</model-name>");
313    
314                    sb.append(
315                            "<column><column-name>id</column-name><column-value><![CDATA[");
316                    sb.append(getId());
317                    sb.append("]]></column-value></column>");
318                    sb.append(
319                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
320                    sb.append(getCompanyId());
321                    sb.append("]]></column-value></column>");
322                    sb.append(
323                            "<column><column-name>portletId</column-name><column-value><![CDATA[");
324                    sb.append(getPortletId());
325                    sb.append("]]></column-value></column>");
326                    sb.append(
327                            "<column><column-name>roles</column-name><column-value><![CDATA[");
328                    sb.append(getRoles());
329                    sb.append("]]></column-value></column>");
330                    sb.append(
331                            "<column><column-name>active</column-name><column-value><![CDATA[");
332                    sb.append(getActive());
333                    sb.append("]]></column-value></column>");
334    
335                    sb.append("</model>");
336    
337                    return sb.toString();
338            }
339    
340            private long _id;
341            private long _companyId;
342            private long _originalCompanyId;
343            private boolean _setOriginalCompanyId;
344            private String _portletId;
345            private String _originalPortletId;
346            private String _roles;
347            private boolean _active;
348            private transient ExpandoBridge _expandoBridge;
349    }