001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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                    _companyId = companyId;
143    
144                    if (!_setOriginalCompanyId) {
145                            _setOriginalCompanyId = true;
146    
147                            _originalCompanyId = companyId;
148                    }
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                    _portletId = portletId;
166    
167                    if (_originalPortletId == null) {
168                            _originalPortletId = portletId;
169                    }
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 clone = new PortletImpl();
226    
227                    clone.setId(getId());
228                    clone.setCompanyId(getCompanyId());
229                    clone.setPortletId(getPortletId());
230                    clone.setRoles(getRoles());
231                    clone.setActive(getActive());
232    
233                    return clone;
234            }
235    
236            public int compareTo(Portlet portlet) {
237                    long pk = portlet.getPrimaryKey();
238    
239                    if (getPrimaryKey() < pk) {
240                            return -1;
241                    }
242                    else if (getPrimaryKey() > pk) {
243                            return 1;
244                    }
245                    else {
246                            return 0;
247                    }
248            }
249    
250            public boolean equals(Object obj) {
251                    if (obj == null) {
252                            return false;
253                    }
254    
255                    Portlet portlet = null;
256    
257                    try {
258                            portlet = (Portlet)obj;
259                    }
260                    catch (ClassCastException cce) {
261                            return false;
262                    }
263    
264                    long pk = portlet.getPrimaryKey();
265    
266                    if (getPrimaryKey() == pk) {
267                            return true;
268                    }
269                    else {
270                            return false;
271                    }
272            }
273    
274            public int hashCode() {
275                    return (int)getPrimaryKey();
276            }
277    
278            public String toString() {
279                    StringBundler sb = new StringBundler(11);
280    
281                    sb.append("{id=");
282                    sb.append(getId());
283                    sb.append(", companyId=");
284                    sb.append(getCompanyId());
285                    sb.append(", portletId=");
286                    sb.append(getPortletId());
287                    sb.append(", roles=");
288                    sb.append(getRoles());
289                    sb.append(", active=");
290                    sb.append(getActive());
291                    sb.append("}");
292    
293                    return sb.toString();
294            }
295    
296            public String toXmlString() {
297                    StringBundler sb = new StringBundler(19);
298    
299                    sb.append("<model><model-name>");
300                    sb.append("com.liferay.portal.model.Portlet");
301                    sb.append("</model-name>");
302    
303                    sb.append(
304                            "<column><column-name>id</column-name><column-value><![CDATA[");
305                    sb.append(getId());
306                    sb.append("]]></column-value></column>");
307                    sb.append(
308                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
309                    sb.append(getCompanyId());
310                    sb.append("]]></column-value></column>");
311                    sb.append(
312                            "<column><column-name>portletId</column-name><column-value><![CDATA[");
313                    sb.append(getPortletId());
314                    sb.append("]]></column-value></column>");
315                    sb.append(
316                            "<column><column-name>roles</column-name><column-value><![CDATA[");
317                    sb.append(getRoles());
318                    sb.append("]]></column-value></column>");
319                    sb.append(
320                            "<column><column-name>active</column-name><column-value><![CDATA[");
321                    sb.append(getActive());
322                    sb.append("]]></column-value></column>");
323    
324                    sb.append("</model>");
325    
326                    return sb.toString();
327            }
328    
329            private long _id;
330            private long _companyId;
331            private long _originalCompanyId;
332            private boolean _setOriginalCompanyId;
333            private String _portletId;
334            private String _originalPortletId;
335            private String _roles;
336            private boolean _active;
337            private transient ExpandoBridge _expandoBridge;
338    }